📄 deliverchargeui.aspx.cs
字号:
namespace PowerEasy.WebSite.Admin.Shop
{
using PowerEasy.Common;
using PowerEasy.ExtendedControls;
using PowerEasy.Model.Shop;
using PowerEasy.Shop;
using PowerEasy.Web.UI;
using System;
using System.Text;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class DeliverChargeUI : AdminPage
{
protected ExtendedButton BtnSave;
protected HtmlForm form1;
protected ListBox LstArrArea;
protected TextBox TxtChargeMax;
protected TextBox TxtChargeMin;
protected TextBox TxtChargePerUnit;
protected TextBox TxtWeightMin;
protected TextBox TxtWeightPerUnit;
protected void BtnSave_Click(object sender, EventArgs e)
{
bool flag;
if (!this.ValidateControls())
{
AdminPage.WriteErrMsg("输入的值格式有误!");
return;
}
if (this.LstArrArea.GetSelectedIndices().Length == 0)
{
AdminPage.WriteErrMsg("请指定省份!");
return;
}
DeliverChargeInfo deliverChargeInfo = this.CreateInfo();
string str2 = this.ViewState["action"].ToString();
if (str2 != null)
{
if (!(str2 == "Add"))
{
if (str2 == "Modify")
{
deliverChargeInfo.Id = Convert.ToInt32(this.ViewState["id"], null);
flag = DeliverCharge.Update(deliverChargeInfo);
goto Label_00B5;
}
}
else
{
deliverChargeInfo.DeliverTypeId = Convert.ToInt32(this.ViewState["deliverTypeId"], null);
flag = DeliverCharge.Add(deliverChargeInfo);
goto Label_00B5;
}
}
flag = false;
Label_00B5:
if (flag)
{
string s = "<script> window.opener.__doPostBack('DeliverCharge_PostBack',''); window.close(); </script>";
base.Response.Write(s);
}
else
{
AdminPage.WriteErrMsg("操作失败!");
}
}
private DeliverChargeInfo CreateInfo()
{
DeliverChargeInfo info = new DeliverChargeInfo();
info.ArrArea = this.GetArrArea();
info.AreaType = 4;
info.ChargeMin = Convert.ToDecimal(this.TxtChargeMin.Text, null);
info.WeightMin = float.Parse(this.TxtWeightMin.Text, (IFormatProvider) null);
info.ChargePerUnit = Convert.ToDecimal(this.TxtChargePerUnit.Text, null);
info.WeightPerUnit = float.Parse(this.TxtWeightPerUnit.Text, (IFormatProvider) null);
info.ChargeMax = Convert.ToDecimal(this.TxtChargeMax.Text, null);
return info;
}
private string GetArrArea()
{
StringBuilder builder = new StringBuilder();
int[] selectedIndices = this.LstArrArea.GetSelectedIndices();
for (int i = 0; i < selectedIndices.Length; i++)
{
builder.Append(this.LstArrArea.Items[selectedIndices[i]].Value + ",");
}
if (builder.Length != 0)
{
builder.Remove(builder.Length - 1, 1);
}
return builder.ToString();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!base.IsPostBack)
{
if (BasePage.RequestString("Action") == null)
{
this.BtnSave.Enabled = false;
}
else
{
string str2;
string str = BasePage.RequestString("Action");
this.ViewState["action"] = str;
if (!string.IsNullOrEmpty(str) && ((str2 = str) != null))
{
if (!(str2 == "Add"))
{
if (!(str2 == "Modify"))
{
return;
}
}
else
{
if (string.IsNullOrEmpty(BasePage.RequestString("DeliverTypeID")))
{
this.BtnSave.Enabled = false;
return;
}
int deliverTypeId = BasePage.RequestInt32("DeliverTypeID");
this.ViewState["deliverTypeId"] = deliverTypeId;
this.LstArrArea.DataSource = DeliverCharge.GetProvinceList(deliverTypeId);
this.LstArrArea.DataBind();
return;
}
if (BasePage.RequestString("Id") == null)
{
this.BtnSave.Enabled = false;
}
else
{
this.LstArrArea.DataSource = DeliverCharge.GetProvinceList();
this.LstArrArea.DataBind();
int id = BasePage.RequestInt32("Id");
this.ViewState["id"] = id;
DeliverChargeInfo deliverChargeById = DeliverCharge.GetDeliverChargeById(id);
this.ViewState["deliverTypeId"] = deliverChargeById.DeliverTypeId;
this.TxtChargeMin.Text = deliverChargeById.ChargeMin.ToString("N2");
this.TxtWeightMin.Text = deliverChargeById.WeightMin.ToString();
this.TxtChargePerUnit.Text = deliverChargeById.ChargePerUnit.ToString("N2");
this.TxtWeightPerUnit.Text = deliverChargeById.WeightPerUnit.ToString();
this.TxtChargeMax.Text = deliverChargeById.ChargeMax.ToString("N2");
this.SetArrArea(deliverChargeById.ArrArea);
}
}
}
}
}
private void SetArrArea(string arrArea)
{
string[] strArray = arrArea.Split(new char[] { ',' });
for (int i = 0; i < strArray.Length; i++)
{
if (this.LstArrArea.Items.FindByText(strArray[i]) != null)
{
this.LstArrArea.Items.FindByText(strArray[i]).Selected = true;
}
}
}
private bool ValidateControls()
{
foreach (Control control in this.Page.Form.Controls)
{
if (control.GetType() == typeof(TextBox))
{
string input = ((TextBox) control).Text.Replace(",", "");
if (!DataValidator.IsDecimal(input) && !DataValidator.IsNumber(input))
{
return false;
}
}
}
return true;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -