public bool InsertBASE_DEPARTMENT(MODELBASE_DEPARTMENT MODELBASE_DEPARTMENT) { StringBuilder str = new StringBuilder(); str.Append("INSERT INTO BASE_DEPARTMENT(DEPARTMENTID,DEPARTMENTNAME,DEPARTMENTTEL,DEPARTMENTMANAGER,PARENTID,MEMO,SIMPLECODE) "); str.Append("VALUES(@DEPARTMENTID,@DEPARTMENTNAME,@DEPARTMENTTEL,@DEPARTMENTMANAGER,@PARENTID,@MEMO,@SIMPLECODE)"); SqlParameter[] para = { new SqlParameter("@DEPARTMENTID", SqlDbType.VarChar, 50), new SqlParameter("@DEPARTMENTNAME", SqlDbType.VarChar, 50), new SqlParameter("@DEPARTMENTTEL", SqlDbType.VarChar, 50), new SqlParameter("@DEPARTMENTMANAGER", SqlDbType.VarChar, 30), new SqlParameter("@PARENTID", SqlDbType.VarChar, 30), new SqlParameter("@MEMO", SqlDbType.VarChar, 50), new SqlParameter("@SIMPLECODE", SqlDbType.VarChar, 50) }; para[0].Value = MODELBASE_DEPARTMENT.DEPARTMENTID; para[1].Value = MODELBASE_DEPARTMENT.DEPARTMENTNAME; para[2].Value = MODELBASE_DEPARTMENT.DEPARTMENTTEL; para[3].Value = MODELBASE_DEPARTMENT.DEPARTMENTMANAGER; para[4].Value = MODELBASE_DEPARTMENT.PARENTID; para[5].Value = MODELBASE_DEPARTMENT.MEMO; para[6].Value = MODELBASE_DEPARTMENT.SIMPLECODE; if (DBUtility.DbHelperSQL.ExecuteSql(str.ToString(), para) > 0) { return(true); } else { return(false); } }
private void btSetUp_Click(object sender, EventArgs e) { string strCompany = ""; if (rb01.Checked) { strCompany = "01"; } else if (rb010003.Checked) { strCompany = "010003"; } if (strCompany == "") { mes.Show("请选择公司后操作!"); return; } if (txtName.Text.Trim() == "") { mes.Show("公司名称不能为空!"); return; } MODELBASE_DEPARTMENT MODELBASE_DEPARTMENT = new MODELBASE_DEPARTMENT(); MODELBASE_DEPARTMENT.DEPARTMENTID = strCompany; MODELBASE_DEPARTMENT.DEPARTMENTNAME = txtName.Text.Trim(); MODELBASE_DEPARTMENT.PARENTID = "0"; MODELBASE_DEPARTMENT.SIMPLECODE = PinYinConvert.GetHeadOfChs(MODELBASE_DEPARTMENT.DEPARTMENTNAME); MODELBASE_DEPARTMENT.FPAddressAndTel = txtAddressAndTel.Text; MODELBASE_DEPARTMENT.FPBankNameAndAccountNO = txtBankNameAndAccountNO.Text; MODELBASE_DEPARTMENT.FPTaxNO = txtTaxNO.Text; MODELBASE_DEPARTMENT.Payee = txtPayee.Text; MODELBASE_DEPARTMENT.Checker = txtChecker.Text; if (!BLLBASE_DEPARTMENT.UpdateDEP(MODELBASE_DEPARTMENT)) { mes.Show("更新数据库失败,请重新打开窗体设置!"); return; } else { mes.Show("设置成功!"); } }
public bool UpdateDEP(MODELBASE_DEPARTMENT MODELBASE_DEPARTMENT) { StringBuilder str = new StringBuilder(); str.Append("UPDATE BASE_DEPARTMENT SET DEPARTMENTNAME=@DEPARTMENTNAME,DEPARTMENTTEL=@DEPARTMENTTEL,DEPARTMENTMANAGER=@DEPARTMENTMANAGER,PARENTID=@PARENTID,MEMO=@MEMO,SIMPLECODE=@SIMPLECODE, "); str.Append(" FPTaxNO=@FPTaxNO,FPAddressAndTel=@FPAddressAndTel,FPBankNameAndAccountNO=@FPBankNameAndAccountNO,"); str.Append(" Payee=@Payee,Checker=@Checker "); str.Append("WHERE DEPARTMENTID=@DEPARTMENTID"); SqlParameter[] para = { new SqlParameter("@DEPARTMENTNAME", SqlDbType.VarChar, 50), new SqlParameter("@DEPARTMENTTEL", SqlDbType.VarChar, 50), new SqlParameter("@DEPARTMENTMANAGER", SqlDbType.VarChar, 30), new SqlParameter("@PARENTID", SqlDbType.VarChar, 30), new SqlParameter("@MEMO", SqlDbType.VarChar, 50), new SqlParameter("@SIMPLECODE", SqlDbType.VarChar, 50), new SqlParameter("@FPTaxNO", SqlDbType.VarChar, 50), new SqlParameter("@FPAddressAndTel", SqlDbType.VarChar, 100), new SqlParameter("@FPBankNameAndAccountNO", SqlDbType.VarChar, 100), new SqlParameter("@Payee", SqlDbType.VarChar, 50), new SqlParameter("@Checker", SqlDbType.VarChar, 50), new SqlParameter("@DEPARTMENTID", SqlDbType.VarChar, 50) }; para[0].Value = MODELBASE_DEPARTMENT.DEPARTMENTNAME; para[1].Value = MODELBASE_DEPARTMENT.DEPARTMENTTEL; para[2].Value = MODELBASE_DEPARTMENT.DEPARTMENTMANAGER; para[3].Value = MODELBASE_DEPARTMENT.PARENTID; para[4].Value = MODELBASE_DEPARTMENT.MEMO; para[5].Value = MODELBASE_DEPARTMENT.SIMPLECODE; para[6].Value = MODELBASE_DEPARTMENT.FPTaxNO; para[7].Value = MODELBASE_DEPARTMENT.FPAddressAndTel; para[8].Value = MODELBASE_DEPARTMENT.FPBankNameAndAccountNO; para[9].Value = MODELBASE_DEPARTMENT.Payee; para[10].Value = MODELBASE_DEPARTMENT.Checker; para[11].Value = MODELBASE_DEPARTMENT.DEPARTMENTID; if (DBUtility.DbHelperSQL.ExecuteSql(str.ToString(), para) > 0) { return(true); } else { return(false); } }
private void tvDep_AfterSelect(object sender, TreeViewEventArgs e) { if (e.Node == null) { return; } string strDepID = e.Node.Tag.ToString(); MODELBASE_DEPARTMENT MODELBASE_DEPARTMENT = new MODELBASE_DEPARTMENT(); MODELBASE_DEPARTMENT = BLLBASE_DEPARTMENT.GetModelBASE_DEPARTMENT(strDepID); txtID.Text = strDepID; txtName.Text = MODELBASE_DEPARTMENT.DEPARTMENTNAME; cmbParentID.SelectedValue = MODELBASE_DEPARTMENT.PARENTID; cmbLeader.Text = MODELBASE_DEPARTMENT.DEPARTMENTMANAGER; txtTel.Text = MODELBASE_DEPARTMENT.DEPARTMENTTEL; txtMemo.Text = MODELBASE_DEPARTMENT.MEMO; txtCode.Text = MODELBASE_DEPARTMENT.SIMPLECODE; }
public MODELBASE_DEPARTMENT GetModelBASE_DEPARTMENT(string strDepID) { DataTable dt = new DataTable(); MODELBASE_DEPARTMENT MODELBASE_DEPARTMENT = new MODELBASE_DEPARTMENT(); StringBuilder str = new StringBuilder(); str.Append("SELECT * FROM BASE_DEPARTMENT WHERE DEPARTMENTID=@DEPARTMENTID"); SqlParameter[] para = { new SqlParameter("@DEPARTMENTID", SqlDbType.VarChar, 30) }; para[0].Value = strDepID; dt = DBUtility.DbHelperSQL.Query(str.ToString(), para).Tables[0]; if (dt.Rows.Count == 0) { return(null); } else { MODELBASE_DEPARTMENT.DEPARTMENTNAME = dt.Rows[0]["DEPARTMENTNAME"].ToString(); if (dt.Rows[0]["DEPARTMENTTEL"] != null) { MODELBASE_DEPARTMENT.DEPARTMENTTEL = dt.Rows[0]["DEPARTMENTTEL"].ToString(); } if (dt.Rows[0]["DEPARTMENTMANAGER"] != null) { MODELBASE_DEPARTMENT.DEPARTMENTMANAGER = dt.Rows[0]["DEPARTMENTMANAGER"].ToString(); } if (dt.Rows[0]["PARENTID"] != null) { MODELBASE_DEPARTMENT.PARENTID = dt.Rows[0]["PARENTID"].ToString(); } if (dt.Rows[0]["MEMO"] != null) { MODELBASE_DEPARTMENT.MEMO = dt.Rows[0]["MEMO"].ToString(); } if (dt.Rows[0]["SIMPLECODE"] != null) { MODELBASE_DEPARTMENT.SIMPLECODE = dt.Rows[0]["SIMPLECODE"].ToString(); } return(MODELBASE_DEPARTMENT); } }
private void toolSubmit_Click(object sender, EventArgs e) { if (!IsADD && tvDep.SelectedNode.Tag.ToString() == "01") { mes.Show("该部门无法删除或修改!"); return; } if (txtName.Text.Trim() == "") { mes.Show("请填写部门名称!"); txtName.Focus(); return; } if (txtCode.Text.Trim() == "") { mes.Show("请填写部门拼音简码!"); txtCode.Focus(); return; } //if (cmbParentID.SelectedValue == null && tvDep.SelectedNode.Tag.ToString()!="00010001") if (cmbParentID.SelectedValue == null) { mes.Show("请选择所属部门!"); cmbParentID.Focus(); return; } MODELBASE_DEPARTMENT MODELBASE_DEPARTMENT = new MODELBASE_DEPARTMENT(); MODELBASE_DEPARTMENT.DEPARTMENTNAME = txtName.Text; //if (tvDep.SelectedNode.Tag.ToString() != "00010001") //MODELBASE_DEPARTMENT.PARENTID = cmbParentID.SelectedValue.ToString(); //else // MODELBASE_DEPARTMENT.PARENTID = "0"; MODELBASE_DEPARTMENT.PARENTID = cmbParentID.SelectedValue.ToString(); MODELBASE_DEPARTMENT.DEPARTMENTMANAGER = cmbLeader.Text; MODELBASE_DEPARTMENT.DEPARTMENTTEL = txtTel.Text; MODELBASE_DEPARTMENT.MEMO = txtMemo.Text; MODELBASE_DEPARTMENT.SIMPLECODE = txtCode.Text.Trim(); if (IsADD) { MODELBASE_DEPARTMENT.DEPARTMENTID = GETTABLEID.GetTableID(MODELBASE_DEPARTMENT.PARENTID, "BASE_DEPARTMENT"); } else { MODELBASE_DEPARTMENT.DEPARTMENTID = txtID.Text; //if (MODELBASE_DEPARTMENT.DEPARTMENTIDOLD.Substring(0, MODELBASE_DEPARTMENT.PARENTID.Length) == MODELBASE_DEPARTMENT.PARENTID) // MODELBASE_DEPARTMENT.DEPARTMENTID = MODELBASE_DEPARTMENT.DEPARTMENTIDOLD; //else //MODELBASE_DEPARTMENT.DEPARTMENTID = GETTABLEID.GetTableID(MODELBASE_DEPARTMENT.PARENTID, "BASE_DEPARTMENT"); } try { if (IsADD) { if (BLLBASE_DEPARTMENT.InsertBASE_DEPARTMENT(MODELBASE_DEPARTMENT)) { tvDep.Enabled = true; tvDep.Nodes.Clear(); AddTreeNode("0", null); toolAdd.Enabled = true; GetSelectedNode(tvDep.Nodes[0], MODELBASE_DEPARTMENT.DEPARTMENTID); BindDEP(); } } else { if (BLLBASE_DEPARTMENT.UpdateDEP(MODELBASE_DEPARTMENT)) { tvDep.Enabled = true; tvDep.Nodes.Clear(); AddTreeNode("0", null); GetSelectedNode(tvDep.Nodes[0], MODELBASE_DEPARTMENT.DEPARTMENTID); BindDEP(); } } } catch (Exception ex) { lg.Write(ex.ToString(), MsgType.Error); mes.Show(ex.Message.ToString()); return; } IsADD = false; }