Пример #1
0
 public string GetStrParent(string pkpath)
 {
     string str;
     try
     {
         string str2 = "";
         this.dbo = new DB_OPT();
         this.dbo.Open();
         BranchModel[] parents = new BranchDal { PKPath = pkpath }.GetParents(false, this.dbo);
         for (int i = 0; i < parents.Length; i++)
         {
             str2 = parents[i].BranchPK + "~" + str2;
         }
         str = str2.Substring(0, str2.Length - 1);
     }
     catch (Exception)
     {
         str = "";
     }
     finally
     {
         if (this.dbo != null)
         {
             this.dbo.Close();
         }
     }
     return str;
 }
Пример #2
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);
     }
 }
Пример #3
0
 private void BindDrop(DB_OPT dbo)
 {
     BranchModel[] modelArray = new BranchDal().GetModels("", false, false, false, false, dbo);
     this.ddlbranch.DataSource = modelArray;
     this.ddlbranch.DataTextField = "Name";
     this.ddlbranch.DataValueField = "BranchPK";
     this.ddlbranch.DataBind();
 }
Пример #4
0
 private void BindList(DB_OPT dbo)
 {
     CompanyModel[] modelArray = new CompanyDal().GetModels("", false, false, false, dbo);
     this.ddlcompany.DataSource = modelArray;
     this.ddlcompany.DataTextField = "Name";
     this.ddlcompany.DataValueField = "pk_corp";
     this.ddlcompany.DataBind();
     BranchModel[] modelArray2 = new BranchDal().GetModels("", false, false, false, false, dbo);
     this.ddlbranch.DataSource = modelArray2;
     this.ddlbranch.DataTextField = "Name";
     this.ddlbranch.DataValueField = "BranchPK";
     this.ddlbranch.DataBind();
 }
Пример #5
0
 private void AddUser()
 {
     try
     {
         this.dbo = new DB_OPT();
         this.dbo.Open();
         if (((this.txtUserName.Text.Trim() == "") || (this.txtssbmpk.Value.Trim() == "")) || ((this.txtssgspk.Value.Trim() == "") || (this.txtssjspk.Value.Trim() == "")))
         {
             Const.ShowMessage("带*的数据必须填写!", this.Page);
         }
         else
         {
             UserModel model = new UserDal
             {
                 UserName = this.txtUserName.Text.Trim(),
                 TrueName = this.txtTrueName.Text.Trim()
             };
             if (model.ExistsByUserName(this.dbo) > 0)
             {
                 Const.ShowMessage("用户名已经存在!", this.Page);
             }
             else
             {
                 RoleModel model2 = new RoleDal
                 {
                     RolePK = this.txtssjspk.Value.Trim()
                 };
                 model2 = model2.GetModel(false, false, this.dbo);
                 BranchModel model3 = new BranchDal
                 {
                     BranchPK = this.txtssbmpk.Value.Trim()
                 };
                 model3 = model3.GetModel(false, false, false, false, this.dbo);
                 string str = PowerClass.SubTwoPower(this.PowerMenu1.GetPower(), model2.Power, "|");
                 model.Power = str;
                 string str2 = PowerClass.SubTwoPower(this.PowerCompany1.GetPower(), model3.CompanyPower, "|");
                 model.CompanyPower = str2;
                 model.BranchPK = this.txtssbmpk.Value.Trim();
                 model.RolePK = this.txtssjspk.Value.Trim();
                 if (this.txtPwd.Text.Trim() == "")
                 {
                     model.Password = QxRoom.QxConst.QxConst.Encrypt("123456", "powerich").Trim();
                 }
                 else
                 {
                     model.Password = QxRoom.QxConst.QxConst.Encrypt(this.txtPwd.Text.Trim(), "powerich").Trim();
                 }
                 model.pk_corp = this.txtssgspk.Value.Trim();
                 int count = 0;
                 count = model.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.txtssbm.Text.Trim() + " 部门下新增用户名为:" + this.txtUserName.Text.Trim() + " 真实姓名为:" + this.txtTrueName.Text.Trim() + " 角色为:" + this.txtssjs.Text.Trim() + " 的用户,菜单权限为:" + this.PowerMenu1.GetPowerText() + " 管理范围为:" + 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 = "AddUser()";
         this.el.WriteExceptionLog(true);
         Const.OpenErrorPage("操作失败,请联系管理员!", this.Page);
     }
     finally
     {
         if (this.dbo != null)
         {
             this.dbo.Close();
         }
     }
 }
Пример #6
0
 public static string btn_tb()
 {
     string str = "";
     StringBuilder builder = new StringBuilder();
     builder.Append("select distinct gsdm as PK_CORP,gsmc as Name,case len(gsdm) when 2 then 1 else 0 end as ISHASBABY,case len(gsdm) when 2 then 0 else 1 end as  Grade,substring(gsdm,1,2) as FatherPK,substring(gsdm,1,2)+'|' as PKPath,'0' as ZXBJ from PubGszl where kjnd=(select max(kjnd) from PubGszl)");
     builder.Append(" and gsdm in ");
     builder.Append(strSelectDW);
     builder.Append(" ; ");
     builder.Append("select gsdm as PK_CORP,kjnd,bmdm as BH,bmmc as Name from PUBBMXX where kjnd=(select max(kjnd) from PUBBMXX );");
     builder.Append(" and gsdm in ");
     builder.Append(strSelectDW);
     builder.Append(" ; ");
     builder.Append("select gsdm,kjnd,zydm,zyxm,bmdm from PUBZYXX  where kjnd=(select max(kjnd) from PUBZYXX );");
     builder.Append(" and gsdm in ");
     builder.Append(strSelectDW);
     builder.Append(" ; ");
     builder.Append("select ID,name as UserName,password,gsdm as PK_CORP from gl_CZY;");
     builder.Append(" and gsdm in ");
     builder.Append(strSelectDW);
     builder.Append(" ; ");
     DataSet set = DbHelperSQL.Query(builder.ToString());
     DB_OPT dbo = new DB_OPT();
     dbo.Open();
     if ((set == null) || (set.Tables.Count != 4))
     {
         return str;
     }
     DataTable table = set.Tables[0];
     for (int i = 0; i < table.Rows.Count; i++)
     {
         DataRow row = table.Rows[i];
         CompanyModel model = new CompanyDal
         {
             pk_corp = row["PK_CORP"].ToString(),
             Name = row["Name"].ToString(),
             IsHasBaby = row["ISHASBABY"].ToString(),
             Grade = Convert.ToInt32(row["Grade"].ToString()),
             FatherPK = row["FatherPK"].ToString(),
             PKPath = row["PKPath"].ToString(),
             ZXBJ = row["ZXBJ"].ToString()
         };
         builder = new StringBuilder();
         builder.Append("select * from DB_Company where pk_corp='");
         builder.Append(model.pk_corp);
         builder.Append("'");
         if (DbHelperOra.Exists(builder.ToString()))
         {
             builder = new StringBuilder();
             builder.Append("update Db_Company set IsHasBaby='");
             builder.Append(model.IsHasBaby);
             builder.Append("',Grade=");
             builder.Append(model.Grade);
             builder.Append(",FatherPK='");
             builder.Append(model.FatherPK);
             builder.Append("',PKPath='");
             builder.Append(model.PKPath);
             builder.Append("',ZXBJ='");
             builder.Append(model.ZXBJ);
             builder.Append("' where PK_CORP='");
             builder.Append(model.pk_corp);
             builder.Append("' ");
             DbHelperOra.ExecuteSql(builder.ToString());
         }
         else
         {
             builder = new StringBuilder();
             builder.Append("insert into Db_Company(pk_corp,Name,Ishasbaby,Grade,FatherPK,PKPath,ZXBJ) values('");
             builder.Append(model.pk_corp);
             builder.Append("','");
             builder.Append(model.Name);
             builder.Append("','");
             builder.Append(model.IsHasBaby);
             builder.Append("',");
             builder.Append(model.Grade);
             builder.Append(",'");
             builder.Append(model.FatherPK);
             builder.Append("','");
             builder.Append(model.PKPath);
             builder.Append("','");
             builder.Append(model.ZXBJ);
             builder.Append("')");
             DbHelperOra.ExecuteSql(builder.ToString());
             builder = new StringBuilder();
             builder.Append("insert into db_branch(BranchPK,BH,Name,ISHasbaby,grade,PK_CORP,ISJGBM) values (sys_Guid(),'D");
             builder.Append(model.pk_corp);
             builder.Append("01','");
             builder.Append(model.Name);
             builder.Append("默认部门',0,0,'");
             builder.Append(model.pk_corp);
             builder.Append("',0)");
             DbHelperOra.ExecuteSql(builder.ToString());
             builder = new StringBuilder();
             builder.Append("insert into db_role(RolePK,BH,Name,Power,ServicesPower,ISUserPower,Grade,BranchPK,PK_CORP )");
             builder.Append("select sys_guid(),'R");
             builder.Append(model.pk_corp);
             builder.Append("01','");
             builder.Append(model.Name);
             builder.Append("默认角色',");
             builder.Append("Power,ServicesPower,ISUserPower,Grade,(select BranchPK from Db_Branch where BH='D");
             builder.Append(model.pk_corp);
             builder.Append("01' and Rownum=1),'");
             builder.Append(model.pk_corp);
             builder.Append("' from db_role t where BH='R000000' ");
             DbHelperOra.ExecuteSql(builder.ToString());
         }
     }
     table = set.Tables[1];
     for (int j = 0; j < table.Rows.Count; j++)
     {
         DataRow row2 = table.Rows[j];
         BranchModel model2 = new BranchDal
         {
             BH = row2["BH"].ToString(),
             Name = row2["Name"].ToString(),
             pk_corp = row2["PK_CORP"].ToString()
         };
         if (model2.Exists(model2.BH, dbo) > 0)
         {
             model2.Update(dbo);
         }
         else
         {
             model2.Add(dbo);
         }
     }
     table = set.Tables[3];
     for (int k = 0; k < table.Rows.Count; k++)
     {
         DataRow row3 = table.Rows[k];
         UserModel model3 = new UserDal
         {
             UserName = row3["UserName"].ToString().Trim(),
             TrueName = row3["UserName"].ToString(),
             Password = QxRoom.QxConst.QxConst.Encrypt(row3["password"].ToString(), "powerich")
         };
         if (string.IsNullOrEmpty(row3["PK_CORP"].ToString()))
         {
             model3.pk_corp = "01";
         }
         else
         {
             model3.pk_corp = row3["PK_CORP"].ToString();
         }
         if (model3.ExistsByUserName(dbo) > 0)
         {
             builder = new StringBuilder();
             builder.Append("update DB_Users set Password ='******' , PK_Corp='");
             builder.Append(model3.pk_corp);
             builder.Append("' , TrueName='");
             builder.Append(model3.UserName);
             builder.Append("' where UserName='******'");
             DbHelperOra.ExecuteSql(builder.ToString());
         }
         else
         {
             builder = new StringBuilder();
             builder.Append("insert into Db_Users(UserName,TrueName,Password,pk_corp,BranchPK,RolePK) values('");
             builder.Append(model3.UserName);
             builder.Append("','");
             builder.Append(model3.UserName);
             builder.Append("','");
             builder.Append(model3.Password);
             builder.Append("','");
             builder.Append(model3.pk_corp);
             builder.Append("',(select BranchPK from Db_Branch where BH='D");
             builder.Append(model3.pk_corp);
             builder.Append("01' and Rownum=1),(SELECT rolepk FROM db_role  WHERE BH='R");
             builder.Append(model3.pk_corp);
             builder.Append("01' and Rownum=1))");
             DbHelperOra.ExecuteSql(builder.ToString());
             builder = new StringBuilder();
             builder.Append("update db_users a set (a.Power, a.servicespower)= (select b.Power, b.servicespower from Db_Role b where a.RolePK=b.RolePK) where length(a.pk_corp)<=4");
             DbHelperOra.ExecuteSql(builder.ToString());
         }
     }
     dbo.Close();
     StringBuilder builder2 = new StringBuilder();
     builder2.Append("已成功同步乡财县管系统的基础数据! 本次共同步【单位数据】:");
     builder2.Append(set.Tables[0].Rows.Count);
     builder2.Append(" 条;【部门数据】:");
     builder2.Append(set.Tables[1].Rows.Count);
     builder2.Append(" 条;【人员数据】:");
     builder2.Append(set.Tables[3].Rows.Count);
     builder2.Append(" 条");
     return builder2.ToString();
 }
Пример #7
0
 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();
         }
     }
 }
Пример #8
0
 private EmployeeModel Getem(DataRow dr, bool bj_child, bool bj_father, bool bj_company, bool bj_branch, bool bj_role, DB_OPT dbo)
 {
     EmployeeModel model = new EmployeeModel();
     if (bj_father)
     {
         model.BranchPK = dr["FatherPK"].ToString();
         model.FatherInfo = model.GetModel(false, false, false, false, true, dbo);
     }
     model.BranchPK = dr["BranchPK"].ToString().Trim();
     if (bj_branch)
     {
         BranchModel model2 = new BranchDal
         {
             BranchPK = dr["BranchPK"].ToString()
         };
         model2 = model2.GetModel(false, false, false, false, dbo);
         model.Branch = model2;
     }
     model.RolePK = dr["RolePK"].ToString().Trim();
     if (bj_role)
     {
         RoleModel model3 = new RoleDal
         {
             RolePK = dr["RolePK"].ToString()
         };
         model3 = model3.GetModel(false, false, dbo);
         model.Role = model3;
     }
     model.BH = dr["BH"].ToString();
     model.Name = dr["Name"].ToString();
     model.CardNum = dr["CardNum"].ToString();
     model.Sex = dr["Sex"].ToString();
     if (dr["Age"].ToString() != "")
     {
         model.Age = int.Parse(dr["Age"].ToString());
     }
     if (dr["WorkAge"].ToString() != "")
     {
         model.WorkAge = int.Parse(dr["WorkAge"].ToString());
     }
     if (dr["BirthDay"].ToString() != "")
     {
         model.BirthDay = DateTime.Parse(dr["BirthDay"].ToString());
     }
     model.MZ = dr["MZ"].ToString();
     model.Nationals = dr["Nationals"].ToString();
     model.Province = dr["Province"].ToString();
     model.Area = dr["Area"].ToString();
     model.City = dr["City"].ToString();
     model.Address = dr["Address"].ToString();
     model.PostalCode = dr["PostalCode"].ToString();
     model.OfficePhone = dr["OfficePhone"].ToString();
     model.Phone = dr["Phone"].ToString();
     model.Mobile1 = dr["Mobile1"].ToString();
     model.Mobile2 = dr["Mobile2"].ToString();
     model.Mobile3 = dr["Mobile3"].ToString();
     model.QQNum = dr["QQNum"].ToString();
     model.ICQNum = dr["ICQNum"].ToString();
     model.MSNNum = dr["MSNNum"].ToString();
     model.Email = dr["Email"].ToString();
     model.OtherLink = dr["OtherLink"].ToString();
     model.pk_corp = dr["pk_corp"].ToString();
     if (bj_company)
     {
         CompanyModel model4 = new CompanyDal
         {
             pk_corp = dr["pk_corp"].ToString()
         };
         model4 = model4.GetModel(false, false, false, dbo);
         model.Company = model4;
     }
     model.FatherPK = dr["FatherPK"].ToString().Trim();
     model.IsHasBaby = dr["IsHasBaby"].ToString();
     if (dr["Grade"].ToString() != "")
     {
         model.Grade = int.Parse(dr["Grade"].ToString());
     }
     model.PKPath = dr["PKPath"].ToString();
     if ((dr["IsHasBaby"].ToString() == "1") && bj_child)
     {
         this.GetChilds(model.EmployeePK, false, false, false, dbo);
     }
     return model;
 }
Пример #9
0
 private BranchModel Getmm(DataRow dr, bool bj_child, bool bj_father, bool bj_company, bool bj_employee, DB_OPT dbo)
 {
     BranchModel model = new BranchDal();
     if (bj_father)
     {
         model.BranchPK = dr["FatherPK"].ToString();
         model.FatherInfo = model.GetModel(false, false, false, true, dbo);
     }
     model.BranchPK = dr["BranchPK"].ToString().Trim();
     model.BH = dr["BH"].ToString();
     model.Name = dr["Name"].ToString();
     model.Power = dr["Power"].ToString();
     model.DataPower = dr["DataPower"].ToString();
     model.RowPower = dr["RowPower"].ToString();
     model.ServicesPower = dr["ServicesPower"].ToString();
     model.CompanyPower = dr["CompanyPower"].ToString();
     model.IsUserPower = dr["IsUserPower"].ToString();
     model.Discription = dr["Discription"].ToString();
     model.Manager = dr["Manager"].ToString();
     model.Phone = dr["Phone"].ToString();
     model.Fax = dr["Fax"].ToString();
     model.Email = dr["Email"].ToString();
     model.Address = dr["Address"].ToString();
     model.FatherPK = dr["FatherPK"].ToString().Trim();
     model.IsHasBaby = dr["IsHasBaby"].ToString();
     if (dr["Grade"].ToString() != "")
     {
         model.Grade = int.Parse(dr["Grade"].ToString());
     }
     model.PKPath = dr["PKPath"].ToString();
     model.pk_corp = dr["pk_corp"].ToString();
     if (bj_employee)
     {
         model.ManagerInfo = new EmployeeDal { EmployeePK = dr["Manager"].ToString() }.GetModel(true, false, false, false, true, dbo);
     }
     if (bj_company)
     {
         model.PK_Corp_Info = new CompanyDal { pk_corp = dr["pk_corp"].ToString() }.GetModel(false, false, false, dbo);
     }
     if ((dr["IsHasBaby"].ToString() == "1") && bj_child)
     {
         model.Childs = this.GetChilds(model.BranchPK, true, dbo);
     }
     model.IsJGBM = dr["IsJGBM"].ToString();
     return model;
 }
Пример #10
0
 public BranchModel[] GetBranch(string parentid)
 {
     BranchModel[] modelArray;
     try
     {
         this.dbo = new DB_OPT();
         this.dbo.Open();
         modelArray = new BranchDal().GetModels("FatherPK='" + parentid.Split(new char[] { '|' })[0] + "'", false, false, true, true, this.dbo);
     }
     catch (Exception)
     {
         modelArray = null;
     }
     finally
     {
         if (this.dbo != null)
         {
             this.dbo.Close();
         }
     }
     return modelArray;
 }