private void textBoxContainButton2_Click(object sender, EventArgs e) { TextBoxContainButton _txt = (TextBoxContainButton)sender; Dictionary <string, object> _ht = new Dictionary <string, object>(); if (LoginInfo._ZT_Admin_Id == "Z") { string _columns = " ID=Role_ID,Desc_01=Desc_01 "; _ht = CommomHelper.GetQuery1("Role", _columns, ""); } else { string _columns = " ID=Role_ID,Desc_01=Role_ID "; string _where = "and UsrRole.Usr_id='" + LoginInfo._Usr_id + "'"; _ht = CommomHelper.GetQuery1("UsrRole", _columns, _where); } if (_ht != null) { if (_ht.ContainsKey("ID") && _ht.ContainsKey("DESC")) { _txt.ID = _ht["ID"].ToString(); _txt.Desc = _ht["DESC"].ToString(); _txt.Text = _ht["DESC"].ToString(); } } }
private void Login(DataTable _dtUsr) { if (_dtUsr.Rows[0]["Pwd_Web"].ToString() == CommomHelper.GetMD5(this.txtPwd.Text.Trim())) { LoginInfo._Usr_id = _dtUsr.Rows[0]["Usr_Id"].ToString(); LoginInfo._ZT_Admin_Id = _dtUsr.Rows[0]["ZT_Admin_Id"].ToString(); if (_dtUsr.Rows[0]["ZT_Admin_Id"].ToString() != "Z") //超级用户 { LoginInfo._Usr_Company = string.IsNullOrEmpty(this.textBoxContainButton1.ID) ? "" : this.textBoxContainButton1.ID; LoginInfo._Usr_Role = string.IsNullOrEmpty(this.textBoxContainButton2.ID) ? "" : this.textBoxContainButton2.ID; } else { string sqlStr = "Select Company_Id from SysCompany1 where isnull(Company_Up,'')=''"; object _dtCompany = SqlHelper.ExecuteScalar(sqlStr); LoginInfo._Usr_Company = _dtCompany.ToString(); LoginInfo._Usr_Role = string.IsNullOrEmpty(this.textBoxContainButton2.ID) ? "" : this.textBoxContainButton2.ID; } MainForm _main = new MainForm(); this.Hide(); _main.ShowDialog(); this.Close(); } else { MessageBox.Show("密码错误!"); } }
private void CreateTree() { StringBuilder sqlStr = new StringBuilder(); if (_SysPgm == "Employee") { sqlStr.Append("select PGM_Id=Department_Id, NAME=Desc_01, Level_Id, IS_LOWEST from Department where Company_Id='" + LoginInfo._Usr_Company + "' "); } else if (_SysPgm == "Item") { sqlStr.Append("select PGM_Id=ItemKind_Id, NAME=Desc_01, Level_Id, IS_LOWEST from ItemKind where Company_Id='" + LoginInfo._Usr_Company + "' "); } DataSet ds = SqlHelper.ExecuteDataSet(sqlStr.ToString()); DataTable dt = ds.Tables[0]; TreeNode treeNode; Dictionary <int, TreeNode> treeNodeDict = new Dictionary <int, TreeNode>(); if (dt != null && dt.Rows.Count > 0) { string pgm_Id, pgm_Name, is_Lowest; int level_Id, parent_Level_Id, itm; for (int i = 0; i < dt.Rows.Count; i++) { level_Id = CommomHelper.ToInt(dt.Rows[i]["Level_Id"].ToString()); if (level_Id == 0) { //Text = dt.Rows[i]["NAME"].ToString(); //continue; } level_Id = level_Id - 1; parent_Level_Id = level_Id - 1; pgm_Id = dt.Rows[i]["PGM_Id"].ToString(); pgm_Name = dt.Rows[i]["NAME"].ToString(); is_Lowest = dt.Rows[i]["IS_LOWEST"].ToString(); treeNode = new TreeNode(); treeNode.Name = pgm_Id; treeNode.Text = pgm_Name; if (!treeNodeDict.ContainsKey(parent_Level_Id)) { treeView1.Nodes.Add(treeNode); } else { treeNodeDict[parent_Level_Id].Nodes.Add(treeNode); } if (!treeNodeDict.ContainsKey(level_Id)) { treeNodeDict.Add(level_Id, treeNode); } else { treeNodeDict[level_Id] = treeNode; } } } }
private void textBoxContainButton1_Click(object sender, EventArgs e) { TextBoxContainButton _txt = (TextBoxContainButton)sender; string _columns = " ID=Usr_ID,Desc_01=Name "; Dictionary <string, object> _ht = new Dictionary <string, object>(); _ht = CommomHelper.GetQuery1("Usr1", _columns, ""); if (_ht != null) { if (_ht.ContainsKey("ID") && _ht.ContainsKey("DESC")) { _txt.ID = _ht["ID"].ToString(); _txt.Desc = _ht["DESC"].ToString(); _txt.Text = _ht["DESC"].ToString(); } } }
private void textBoxContainButton1_Click(object sender, EventArgs e) { TextBoxContainButton _txt = (TextBoxContainButton)sender; string _where = "and UsrCompany1.Usr_id='" + txtUsr.Text + "'"; string _columns = " ID=Usr_Id,Desc_01=Usr_Id "; Dictionary <string, object> _ht = new Dictionary <string, object>(); _ht = CommomHelper.GetQuery1("UsrCompany1", _columns, _where); if (_ht != null) { if (_ht.ContainsKey("ID") && _ht.ContainsKey("DESC")) { _txt.ID = _ht["ID"].ToString(); _txt.Desc = _ht["DESC"].ToString(); _txt.Text = _ht["DESC"].ToString(); } } }
private void textBoxContainButton2_Click(object sender, EventArgs e) { TextBoxContainButton _txt = (TextBoxContainButton)sender; string _company_id = string.IsNullOrEmpty(this.textBoxContainButton1.ID) ? "" : this.textBoxContainButton1.ID; string _where = "and UsrRole.Usr_id='" + txtUsr.Text + "' and UsrRole.Company_Id='" + _company_id + "' "; string _columns = " ID=Role_Id,Desc_01=Role_Id "; Dictionary <string, object> _ht = new Dictionary <string, object>(); _ht = CommomHelper.GetQuery1("UsrRole", _columns, _where); if (_ht != null) { if (_ht.ContainsKey("ID") && _ht.ContainsKey("DESC")) { _txt.ID = _ht["ID"].ToString(); _txt.Desc = _ht["DESC"].ToString(); _txt.Text = _ht["DESC"].ToString(); } } }
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { UsrManageModel pmgPowState = new UsrManageModel(); pmgPowState.Pgm_Id = (string)dataGridView1.Rows[e.RowIndex].Cells["Pgm_Id"].Value; pmgPowState.Name = (string)dataGridView1.Rows[e.RowIndex].Cells["Name_Body"].Value; pmgPowState.Query_Rights_Id = dataGridView1.Rows[e.RowIndex].Cells["Query_Rights_Id"].Value.ToString(); pmgPowState.Insert_Rights_Id = dataGridView1.Rows[e.RowIndex].Cells["Insert_Rights_Id"].Value.ToString(); pmgPowState.Update_Rights_Id = dataGridView1.Rows[e.RowIndex].Cells["Update_Rights_Id"].Value.ToString(); pmgPowState.Print_Rights_Id = dataGridView1.Rows[e.RowIndex].Cells["Print_Rights_Id"].Value.ToString(); pmgPowState.Export_Rights_Id = dataGridView1.Rows[e.RowIndex].Cells["Export_Rights_Id"].Value.ToString(); pmgPowState.Delete_Rights_Id = dataGridView1.Rows[e.RowIndex].Cells["Delete_Rights_Id"].Value.ToString(); pmgPowState.Itm = CommomHelper.ToInt(dataGridView1.Rows[e.RowIndex].Cells["Itm"].Value); if (PgmPowerStateList.ContainsKey(pmgPowState.Pgm_Id)) { PgmPowerStateList[pmgPowState.Pgm_Id] = pmgPowState; } else { PgmPowerStateList.Add(pmgPowState.Pgm_Id, pmgPowState); } } }
private void getTreeData(string PgmName, string _where) { StringBuilder _sql = new StringBuilder(); StringBuilder _Sqlwhere = new StringBuilder(); _Sqlwhere.Append("where 1=1 "); if (!string.IsNullOrEmpty(_where)) { _Sqlwhere.Append(_where); } switch (PgmName) { case "SysCompany": _sql.Append(string.Format("select ID=Company_Id,NAME=Company_Name,Level_Id,Is_Lowest from SysCompany1 {0} order by itm asc", _Sqlwhere)); break; case "UsrCompany1": _sql.Append(string.Format("select ID=UsrCompany1.Company_Id,NAME=s.Company_Name,s.Level_Id,s.Is_Lowest from UsrCompany1 " + "left join sysCompany1 s on UsrCompany1.Company_Id=S.Company_Id {0} order by s.itm asc", _Sqlwhere)); break; case "Role": _sql.Append(string.Format("select ID=Role_Id,NAME=Desc_01,Level_Id,Is_Lowest from Role order by Est_Itm asc", _Sqlwhere)); break; case "UsrRole": _sql.Append(string.Format("select ID=UsrRole.Role_Id,NAME=Desc_01,Level_Id,Is_Lowest from UsrRole " + " left join Role r on UsrRole.Company_Id=r.Company_Id and UsrRole.Role_Id=r.Role_Id " + " {0} order by Est_Itm asc", _Sqlwhere)); break; case "Usr1": _sql.Append(string.Format(" select ID=USR_ID,NAME=Name from Usr1", _Sqlwhere)); break; case "ItemUt": _sql.Append(string.Format(" Select ID=ItemUt_Id,NAME=Desc_01,Level_Id,Is_Lowest from ItemUt")); break; case "Department": _sql.Append(string.Format(" Select ID=Department_Id,NAME=Desc_01,Level_Id,Is_Lowest from Department")); break; case "Employee": _sql.Append(string.Format(" Select ID=Employee_Id,NAME=Desc_01,Level_Id,Is_Lowest from Employee")); break; case "Csv": _sql.Append(string.Format(" Select ID=Csv_Id,NAME=Desc_01,Level_Id,Is_Lowest from Csv")); break; case "Currency": _sql.Append(string.Format(" Select ID=Currency_Id,NAME=Desc_01,Level_Id,Is_Lowest from Currency")); break; case "SalesType": _sql.Append(string.Format(" Select ID=SalesType_Id,NAME=Desc_01,Level_Id,Is_Lowest from SalesType")); break; case "BusinessType": _sql.Append(string.Format(" Select ID=BusinessType_Id,NAME=Desc_01,Level_Id,Is_Lowest from BusinessType")); break; case "ItemKind": _sql.Append(string.Format(" Select ID=ItemKind_Id,NAME=Desc_01,Level_Id,Is_Lowest from ItemKind")); break; case "Item": _sql.Append(string.Format(" Select ID=Item_Id,NAME=Desc_01,Level_Id,Is_Lowest from Item")); break; case "ProductArea": _sql.Append(string.Format(" Select ID=ProductArea_Id,NAME=Desc_01,Level_Id,Is_Lowest from ProductArea")); break; case "Warehouse": _sql.Append(string.Format(" Select ID=Warehouse_Id,NAME=Desc_01,Level_Id,Is_Lowest from Warehouse")); break; case "PlanningOrderInfoInput": _sql.Append(string.Format(" Select ID=Warehouse_Id,NAME=Warehouse_Id from PlanningOrderInfoInput")); break; case "RequestCollectionOrder": _sql.Append(string.Format(" Select ID=Collection_Id,NAME=Collection_Id from RequestCollectionOrder")); break; case "TaskNotifyOrder": _sql.Append(string.Format(" Select ID=Notify_Id,NAME=Notify_Id from TaskNotifyOrder ")); break; case "ShippingInfoConfirmOrder": _sql.Append(string.Format(" Select ID=Shipping_Id,NAME=Shipping_Id from ShippingInfoConfirmOrder ")); break; case "PgmTransferWarningSetting": _sql.Append(string.Format(" Select ID=Pgm_Id,NAME=Pgm_Id from ShippingInfoConfirmOrder ")); break; case "Project": _sql.Append(string.Format(" Select ID=Project_Id,NAME=Desc_01 from Project ")); break; case "ProjectStage": _sql.Append(string.Format(" Select ID=ProjectStage_Id,NAME=Desc_01,Level_Id,Is_Lowest from ProjectStage ")); break; case "ReqType": _sql.Append(string.Format(" Select ID=ReqType_Id, NAME=Desc_01 From ReqType ")); break; case "PackageMethod": _sql.Append(string.Format(" Select ID=PackageMethod_Id, NAME=Desc_01,Level_Id,Is_Lowest From PackageMethod ")); break; case "ItemSrcKind": _sql.Append(string.Format(" Select ID=ItemSrcKind_Id, NAME=Desc_01,Level_Id,Is_Lowest From ItemSrcKind ")); break; case "ItemUnit": _sql.Append(string.Format(" Select ID=ItemUnit_Id,NAME=ItemUnit_Id from ItemUnit")); break; case "ShippingAddress": _sql.Append(string.Format(" Select ID=ShippingAddress_Id,NAME=Desc_01 from ShippingAddress ")); break; default: break; } DataSet ds = SqlHelper.ExecuteDataSet(_sql.ToString()); DataTable dt = ds.Tables[0]; TreeNode treeNode; Dictionary <int, TreeNode> treeNodeDict = new Dictionary <int, TreeNode>(); ToolStripMenuItem menuItem; Dictionary <int, ToolStripMenuItem> menuItemDict = new Dictionary <int, ToolStripMenuItem>(); if (dt != null && dt.Rows.Count > 0) { string Id, Name, is_Lowest; int level_Id = 1, parent_Level_Id = 1; for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Columns.Contains("Level_Id")) { level_Id = CommomHelper.ToInt(dt.Rows[i]["Level_Id"].ToString()); } level_Id = level_Id - 1; parent_Level_Id = level_Id - 1; Id = dt.Rows[i]["ID"].ToString(); Name = dt.Rows[i]["NAME"].ToString(); if (dt.Columns.Contains("IS_LOWEST")) { is_Lowest = dt.Rows[i]["IS_LOWEST"].ToString(); } treeNode = new TreeNode(); treeNode.Name = Id; treeNode.Text = Id + "/" + Name; menuItem = new ToolStripMenuItem(); menuItem.Name = Id;; menuItem.Text = Name; menuItem.Tag = treeNode; if (!treeNodeDict.ContainsKey(parent_Level_Id)) { treeView1.Nodes.Add(treeNode); treeView1.NodeMouseDoubleClick += treeView1_NodeMouseDoubleClick; } else { treeNodeDict[parent_Level_Id].Nodes.Add(treeNode); } if (!treeNodeDict.ContainsKey(level_Id)) { treeNodeDict.Add(level_Id, treeNode); } else { treeNodeDict[level_Id] = treeNode; } } } }
void LoadSysPgm(DataTable _dt) { // dataGridView1.Rows.Clear(); // dataGridView1.Columns.Clear(); // dataGridView1.Columns.AddRange(new DataGridViewColumn[] { // Pgm_Id, // Name_Body, // Query_Rights_Id, // Insert_Rights_Id, // Update_Rights_Id, // Delete_Rights_Id, // Print_Rights_Id, // Export_Rights_Id //}); dataGridView1.Rows.Clear(); foreach (DataRow row in _dt.Rows) { UsrManageModel pgmPowState = null; //try //{ // pgmPowState = PgmPowerStateList[row["Pgm_Id"].ToString()]; //} //catch //{ // pgmPowState = new UsrManageModel() // { // Pgm_Id = row["Pgm_Id"].ToString(), // Name = row["Name"].ToString(), // Insert_Rights_Id = "F", // Delete_Rights_Id = "F", // Update_Rights_Id = "F", // Print_Rights_Id = "F", // Query_Rights_Id = "F", // Export_Rights_Id = "F", // Itm = CommomHelper.ToInt(row["Itm"]) // }; //} if (PgmPowerStateList != null && PgmPowerStateList.Count > 0 && PgmPowerStateList.ContainsKey(row["Pgm_Id"].ToString())) { pgmPowState = PgmPowerStateList[row["Pgm_Id"].ToString()]; } else { pgmPowState = new UsrManageModel() { Pgm_Id = row["Pgm_Id"].ToString(), Name = row["Name"].ToString(), Insert_Rights_Id = row["Insert_Rights_Id"].ToString(), Delete_Rights_Id = row["Delete_Rights_Id"].ToString(), Update_Rights_Id = row["Update_Rights_Id"].ToString(), Print_Rights_Id = row["Print_Rights_Id"].ToString(), Query_Rights_Id = row["Query_Rights_Id"].ToString(), Export_Rights_Id = row["Export_Rights_Id"].ToString(), Itm = CommomHelper.ToInt(row["Itm"]) }; } DataGridViewRow r = new DataGridViewRow(); r.CreateCells(dataGridView1, new object[] { row["Pgm_Id"], row["Name"], pgmPowState.Query_Rights_Id, pgmPowState.Insert_Rights_Id, pgmPowState.Update_Rights_Id, pgmPowState.Delete_Rights_Id, pgmPowState.Print_Rights_Id, pgmPowState.Export_Rights_Id, pgmPowState.Itm }); dataGridView1.Rows.Add(r); } _dt.Dispose(); }
private bool UpdUsr() { StringBuilder UpdColmn = new StringBuilder(); UpdColmn.Append("Name=@Name,B_Date=@B_Date,E_Date=@E_Date,ZT_Admin_Id=@ZT_Admin_Id,Status_Id=@Status_Id,Usr__Id=@Usr__Id,Role__Id=@Role__Id,Create__Date=@Create__Date,Remark=@Remark"); if (!string.IsNullOrEmpty(this.txtPwd.Text)) { UpdColmn.Append(",Pwd_Web=@Pwd_Web "); } StringBuilder _sqlStr = new StringBuilder(); _sqlStr.Append(string.Format("Update Usr1 set {0} Where ZT_Id=@ZT_Id and Usr_Id=@Usr_Id ; ", UpdColmn)); StringBuilder _sqlCompany = new StringBuilder(); _sqlCompany.Append(" Delete from UsrCompany1 Where ZT_Id=@ZT_Id and Usr_Id=@Usr_Id ;"); StringBuilder _sqlRole = new StringBuilder(); BindingSource _bdSource = new BindingSource(); _bdSource = dataGridView1.DataSource as BindingSource; DataTable _dt = _bdSource.DataSource as DataTable; for (int i = 0; i < _dt.Rows.Count; i++) { if (!string.IsNullOrEmpty(_dt.Rows[i]["Company_Id"].ToString())) { _sqlCompany.Append("If ((select 1 from UsrCompany1 where ZT_Id=@ZT_Id and Usr_Id=@Usr_Id and Company_Id='" + _dt.Rows[i]["Company_Id"].ToString() + "') is null) " + "Insert Into UsrCompany1(ZT_Id,Usr_Id,Company_Id,Role__Id,Usr__Id,Create__Date)" + "VALUES(@ZT_Id,@Usr_Id,'" + _dt.Rows[i]["Company_Id"].ToString() + "',@Role__Id,@Usr__Id,@Create__Date) ;"); } if (!string.IsNullOrEmpty(_dt.Rows[i]["Company_Id"].ToString()) && !string.IsNullOrEmpty(_dt.Rows[i]["Role_Id"].ToString())) { _sqlRole.Append(" Delete from UsrRole Where Company_Id='" + _dt.Rows[i]["Company_Id"].ToString() + "' and Usr_Id=@Usr_Id;"); _sqlRole.Append("If ((select 1 from UsrRole where Usr_Id=@Usr_Id and Company_Id='" + _dt.Rows[i]["Company_Id"].ToString() + "'" + "and Role_Id='" + _dt.Rows[i]["Role_Id"].ToString() + "') is null)" + "Insert Into UsrRole(Usr_Id,Company_Id,Role_Id,Role__Id,Usr__Id,Create__Date)" + "VALUES(@Usr_Id,'" + _dt.Rows[i]["Company_Id"].ToString() + "','" + _dt.Rows[i]["Role_Id"].ToString() + "',@Role__Id,@Usr__Id,@Create__Date) ; "); } } SqlParameter[] paras = new SqlParameter[12]; paras[0] = new SqlParameter("@ZT_Id", SqlDbType.VarChar, 50); paras[0].Value = "CYGIA"; paras[1] = new SqlParameter("@Usr_Id", SqlDbType.VarChar, 50); paras[1].Value = this.txtUsrId.Text.Trim(); paras[2] = new SqlParameter("@Name", SqlDbType.VarChar, 100); paras[2].Value = this.txtName.Text.Trim(); paras[3] = new SqlParameter("@Pwd_Web", SqlDbType.VarChar, 100); paras[3].Value = CommomHelper.GetMD5(this.txtPwd.Text.Trim()); paras[4] = new SqlParameter("@B_Date", SqlDbType.DateTime); paras[4].Value = System.DateTime.Now; paras[5] = new SqlParameter("@E_Date", SqlDbType.DateTime); paras[5].Value = DBNull.Value; paras[6] = new SqlParameter("@ZT_Admin_Id", SqlDbType.VarChar, 1); if (LoginInfo._ZT_Admin_Id == "Z") { paras[6].Value = "Z"; } paras[7] = new SqlParameter("@Status_Id", SqlDbType.VarChar, 5); paras[7].Value = ""; paras[8] = new SqlParameter("@Usr__Id", SqlDbType.VarChar, 50); paras[8].Value = LoginInfo._Usr_id; paras[9] = new SqlParameter("@Role__Id", SqlDbType.VarChar, 50); paras[9].Value = ((LoginInfo._ZT_Admin_Id == "Z") ? "" : LoginInfo._Usr_Role); paras[10] = new SqlParameter("@Create__Date", SqlDbType.DateTime); paras[10].Value = System.DateTime.Now; paras[11] = new SqlParameter("@Remark", SqlDbType.Text); paras[11].Value = this.txtRemark.Text; if (SqlHelper.ExecuteQueryTrans(_sqlCompany.ToString() + _sqlRole.ToString() + _sqlStr.ToString(), paras)) { return(true); } else { return(false); } }