/// <summary>
 /// 页面控件赋值
 /// </summary>
 /// <param name="deparcode">部门账号</param>
 /// <param name="CompanyCode">公司账号</param>
 protected void Storage(string deparcode, string CompanyCode)
 {
     depar = _deparService.FindDepartmentByDepCodeAndCompanyCode(deparcode, CompanyCode);
     if (depar != null)
     {
         Txt_CompanyCode.Text = depar.CompanyCode;
         Txt_DepCode.Text = depar.DepCode;
         Txt_DepName.Text = depar.DepName;
         ddl_FeeDiscountType.SelectedValue = depar.FeeDiscountType.ToString();
         Txt_FeeDiscountRate.Text = depar.FeeDiscountRate.ToString();
         ddl_WeightDiscountType.SelectedValue = depar.WeightDiscountType.ToString();
         Txt_WeightDiscountRate.Text = depar.WeightDiscountRate.ToString();
         ddl_SettleType.SelectedValue = depar.SettleType.ToString();
         ddl_WeightCalType.SelectedValue = depar.WeightCalType.ToString();
         Session["Department"] = depar;
     }
 }
        private void DepCode()
        {
            if (Txt_CompanyCode.Text.Trim() != "")
            {
                if (Txt_Code.Text.Trim() != "")
                {
                    depar = _departmentservice.FindDepartmentByDepCodeAndCompanyCode(Txt_Code.Text.Trim(), Txt_CompanyCode.Text.Trim());
                    if (depar == null)
                    {
                        ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('没有该部门账号,请重新输入!')", true);
                        //Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('没有该部门账号,请重新输入!')</script>");
                        Txt_Code.Focus();
                        Txt_Code.Text = "";
                    }
                    else
                    {
                        Txt_LoginName.Focus();
                        Session["Depar"] = depar.DID;
                    }
                }
                else
                {
                    //Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请重新输入部门账号!')</script>");
                    ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('请重新输入部门账号!')", true);
                    Txt_Code.Focus();
                }

            }
            else
            {
                //Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请重新输入公司账号!')</script>");
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('请重新输入公司账号!')", true);
                Txt_CompanyCode.Focus();
            }
        }
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btn_UpCompany_Click(object sender, EventArgs e)
 {
     if (depar == null)
     {
         if (Session["Department"] != null)
         {
             depar = (Department)Session["Department"];
         }
         else
         {
             depar = _deparService.FindDepartmentByDepCodeAndCompanyCode(Txt_DepCode.Text, Txt_CompanyCode.Text);
         }
     }
     if (Txt_CompanyCode.Text.Trim() == "")
     {
         Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('公司账号不能为空!')</script>");
         Txt_CompanyCode.Focus();
     }
     else if (Txt_DepCode.Text.Trim() == "")
     {
         Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('部门账号不能为空!')</script>");
         Txt_DepCode.Focus();
     }
     else if (Txt_FeeDiscountRate.Text.Trim() == "")
     {
         Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('费用折扣率不能为空!')</script>");
         Txt_FeeDiscountRate.Focus();
     }
     else if (Txt_WeightDiscountRate.Text.Trim() == "")
     {
         Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('重量折扣率不能为空!')</script>");
         Txt_WeightDiscountRate.Focus();
     }
     else
     {
         if (!Rnubel.IsMatch(Txt_FeeDiscountRate.Text.Trim()))
         {
             Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('只能输入0.01-1的数字!')</script>");
             Txt_FeeDiscountRate.Focus();
         }
         else if (!Rnubel.IsMatch(Txt_WeightDiscountRate.Text.Trim()))
         {
             Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('只能输入0.01-1的数字!')</script>");
             Txt_WeightDiscountRate.Focus();
         }
         else
         {
             depar.DepName = Txt_DepName.Text.Trim().ToUpper();
             depar.FeeDiscountType = int.Parse(ddl_FeeDiscountType.SelectedValue);
             depar.FeeDiscountRate = decimal.Parse(Txt_FeeDiscountRate.Text.Trim());
             depar.WeightDiscountType = int.Parse(ddl_WeightDiscountType.SelectedValue);
             depar.WeightDiscountRate = decimal.Parse(Txt_WeightDiscountRate.Text.Trim());
             depar.WeightCalType = int.Parse(ddl_WeightCalType.SelectedValue);
             depar.SettleType = int.Parse(ddl_SettleType.SelectedValue);
             _deparService.ModifyDepartment(depar);
             Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "show", "<script>alert('修改成功!');location='DepartmentManagemnet.aspx'</script>");
         }
     }
 }
Example #4
0
     private void FixupDepartment(Department previousValue, bool skipKeys = false)
     {
         if (IsDeserializing)
         {
             return;
         }
 
         if (previousValue != null && previousValue.HAWBs.Contains(this))
         {
             previousValue.HAWBs.Remove(this);
         }
 
         if (Department != null)
         {
             if (!Department.HAWBs.Contains(this))
             {
                 Department.HAWBs.Add(this);
             }
 
             DID = Department.DID;
         }
         else if (!skipKeys)
         {
             DID = null;
         }
 
         if (ChangeTracker.ChangeTrackingEnabled)
         {
             if (ChangeTracker.OriginalValues.ContainsKey("Department")
                 && (ChangeTracker.OriginalValues["Department"] == Department))
             {
                 ChangeTracker.OriginalValues.Remove("Department");
             }
             else
             {
                 ChangeTracker.RecordOriginalValue("Department", previousValue);
             }
             if (Department != null && !Department.ChangeTracker.ChangeTrackingEnabled)
             {
                 Department.StartTracking();
             }
         }
     }