Example #1
0
 public static void ChangeChildPkPath(string branchpk, string pkpath, int grade, DB_OPT dbo)
 {
     BranchModel model = new BranchDal();
     BranchModel[] modelArray = model.GetChilds(branchpk, false, dbo);
     if (modelArray != null)
     {
         for (int i = 0; i < modelArray.Length; i++)
         {
             model.BranchPK = modelArray[i].BranchPK;
             model.Grade = grade;
             model.PKPath = pkpath;
             if (modelArray[i].IsHasBaby == "1")
             {
                 ChangeChildPkPath(modelArray[i].BranchPK, pkpath + model.BranchPK + "|", grade + 1, dbo);
             }
         }
     }
     else
     {
         model.BranchPK = branchpk;
         model.IsHasBaby = "0";
         model.UpdateHasBaby(dbo);
     }
 }
 private void AddBranch()
 {
     try
     {
         this.dbo = new DB_OPT();
         this.dbo.Open();
         if (((this.txtssgspk.Value.Trim() == "") || (this.txtName.Text.Trim() == "")) || (this.txtbmbh.Text.Trim() == ""))
         {
             Const.ShowMessage("带*号的数据必须填写!", this.Page);
         }
         else
         {
             BranchModel model = new BranchDal();
             if (model.Exists(this.txtbmbh.Text.Trim(), this.dbo) > 0)
             {
                 Const.ShowMessage("部门编码已经存在!", this.Page);
             }
             else
             {
                 BranchModel model2 = new BranchDal();
                 model.FatherPK = this.txtsjbmpk.Value.Trim();
                 if (model.FatherPK != "")
                 {
                     model.BranchPK = model.FatherPK;
                     model = model.GetModel(false, false, false, false, this.dbo);
                     if (model.IsHasBaby == "0")
                     {
                         model2.BranchPK = model.BranchPK;
                         model2.UpdateHasBaby(this.dbo);
                     }
                     model2.PKPath = model.PKPath + model.BranchPK + "|";
                     model2.Grade++;
                 }
                 else
                 {
                     model2.Grade = 0;
                 }
                 model2.FatherPK = this.txtsjbmpk.Value.Trim();
                 model2.IsHasBaby = "0";
                 string power = "";
                 power = this.PowerCompany1.GetPower();
                 model2.CompanyPower = power;
                 model2.Name = this.txtName.Text.Trim();
                 model2.BH = this.txtbmbh.Text.Trim();
                 model2.Address = this.txtaddress.Text.Trim();
                 model2.Manager = this.txtfzrpk.Value.Trim();
                 model2.Email = this.txtemail.Text.Trim();
                 model2.Phone = this.txtphone.Text.Trim();
                 model2.Fax = this.txtfax.Text.Trim();
                 model2.pk_corp = this.txtssgspk.Value.Trim();
                 int count = model2.Add(this.dbo);
                 if (base.Request["reload"] != null)
                 {
                     Const.AddSuccess(count, base.Request["reload"].ToString(), this.Page);
                 }
                 else
                 {
                     Const.AddSuccess(count, "", this.Page);
                 }
                 OperationLogBll.insertOp("新增", "部门列表", "在 " + this.txtssgs.Text.Trim() + " 单位下新增编号为:" + this.txtbmbh.Text.Trim() + " 名称为:" + this.txtName.Text.Trim() + " 的部门,管理范围为:" + this.PowerCompany1.GetPowerText(), "Y", this.Page);
             }
         }
     }
     catch (Exception exception)
     {
         this.el = new ExceptionLog.ExceptionLog();
         this.el.ErrClassName = base.GetType().ToString();
         this.el.ErrMessage = exception.Message.ToString();
         this.el.ErrMethod = "AddBranch()";
         this.el.WriteExceptionLog(true);
         Const.OpenErrorPage("操作失败,请联系管理员!", this.Page);
     }
     finally
     {
         if (this.dbo != null)
         {
             this.dbo.Close();
         }
     }
 }