private void AddDept() { string strSQL = ""; DataLib.DataHelper myHelper = new DataLib.DataHelper(); CommonData.frmSelDept mySelDept = new CommonData.frmSelDept(); if (mySelDept.ShowDialog() == DialogResult.OK) { int[] intCnt = mySelDept.gvMain.GetSelectedRows(); for (int i = 0; i < intCnt.Length; i++) { DataRow dr = mySelDept.gvMain.GetDataRow(intCnt[i]); strSQL = "if not exists(select * from t_ArrangeDept where F_DeptID = '" + dr["F_ID"].ToString() + "') insert into t_ArrangeDept values(" + GetMaxID().ToString() + ",'" + dr["F_ID"].ToString() + "')"; myHelper.ExecuteSQL(strSQL); } BindData(); } mySelDept.Dispose(); }
private void sbSelDept_Click(object sender, EventArgs e) { string strID = "", strName = ""; CommonData.frmSelDept mySelDept = new CommonData.frmSelDept(); if (mySelDept.ShowDialog() == DialogResult.OK) { int[] intCnt = mySelDept.gvMain.GetSelectedRows(); for (int i = 0; i < intCnt.Length; i++) { DataRow dr = mySelDept.gvMain.GetDataRow(intCnt[i]); strID = strID + dr["F_ID"].ToString() + ","; strName = strName + dr["F_Name"].ToString() + ","; } strID = strID.Remove(strID.Length - 1); strName = strName.Remove(strName.Length - 1); editDept.SetValue(strID); lbDept.Text = strName; } mySelDept.Dispose(); }