Example #1
0
        private void simpleButtonOK_Click(object sender, EventArgs e)
        {
            int    deptid = 0;
            string cname = "", attendance = "", attendance3rd = "", attendance4th = "";

            DeptMapQuery.GetInfo(ref deptid, ref cname, ref attendance, ref attendance3rd, ref attendance4th);
            ConnDB conn = new ConnDB();
            string sql  = "update cost_dept_map set DEPT2 = '" + textEdit2nd.Text.ToString().Trim() + "',dept_id =" + comboBoxDept.SelectedValue.ToString() + ",DEPT3 = '" + textEdit3rd.Text.ToString().Trim() + "',DEPT4 = '" + textEdit4th.Text.ToString().Trim() + "'";

            sql = sql + " where dept_id = " + deptid + " and isnull(DEPT2,'') = '" + attendance + "' and isnull(DEPT3,'') = '" + attendance3rd + "' and isnull(DEPT4,'') = '" + attendance4th + "'";
            string sql2 = "select * from cost_dept_map where isnull(DEPT2,'') = '" + textEdit2nd.Text.ToString().Trim() + "' and dept_id = " + comboBoxDept.SelectedValue.ToString() + " and isnull(DEPT3,'') = '" + textEdit3rd.Text.ToString().Trim() + "' and isnull(DEPT4,'') = '" + textEdit4th.Text.ToString().Trim() + "'";

            if (textEdit4th.Text.ToString().Trim() != "" && comboBoxDept.SelectedValue.ToString() != "0")
            {
                int rows = conn.ReturnRecordCount(sql2);
                if (rows > 0)
                {
                    MessageBox.Show("该记录已经存在!");
                }
                else
                {
                    bool isok = conn.EditDatabase(sql);
                    if (isok)
                    {
                        MessageBox.Show("修改成功!");
                        DeptMapQuery.RefreshEX();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("失败!");
                    }
                }
            }
            else
            {
                MessageBox.Show("不能为空值!");
            }
            conn.Close();
        }
Example #2
0
        private void simpleButtonOK_Click(object sender, EventArgs e)
        {
            ConnDB conn = new ConnDB();
            string strsql, strsql2;
            int    rows;

            strsql  = "insert into cost_dept_map(dept_id,DEPT1,DEPT2,DEPT3,DEPT4) values(" + comboBoxDept.SelectedValue.ToString() + ",'制造中心','" + textEdit2nd.Text.ToString().Trim() + "','" + textEdit3rd.Text.ToString().Trim() + "','" + textEdit4th.Text.ToString().Trim() + "')";
            strsql2 = "select * from cost_dept_map where isnull(DEPT2,'') = '" + textEdit2nd.Text.ToString().Trim() + "' and isnull(DEPT3,'') = '" + textEdit3rd.Text.ToString().Trim() + "' and isnull(DEPT4,'') = '" + textEdit4th.Text.ToString().Trim() + "'";
            if (textEdit4th.Text.ToString().Trim() != "" && comboBoxDept.SelectedValue.ToString() != "0")
            {
                rows = conn.ReturnRecordCount(strsql2);
                if (rows > 0)
                {
                    MessageBox.Show("该考勤部门已经存在!");
                }
                else
                {
                    bool isok = conn.EditDatabase(strsql);
                    if (isok)
                    {
                        MessageBox.Show("添加成功!");
                        DeptMapQuery.RefreshEX();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("失败!");
                    }
                }
            }
            else
            {
                MessageBox.Show("不能为空!");
            }
            conn.Close();
        }
Example #3
0
 private void barButtonItem删除_ItemClick(object sender, ItemClickEventArgs e)
 {
     DeptMapQuery.Delete();
     DeptMapQuery.RefreshEX();
 }