private void simpleButtonOK_Click(object sender, EventArgs e) { ConnDB conn = new ConnDB(); string sql = "update COST_EXPENSE set emp_no = '" + textEditEmpno.Text.ToString().Trim() + "',begin_date = '" + dateTimePickerDate.Text + "',expense='" + Common.IsNull(textEditPrice.Text.ToString().Trim()) + "'"; sql = sql + " where cid = '" + id + "'"; string sql2 = "select * from COST_EXPENSE where cid <> '" + id + "' and emp_no = '" + textEditEmpno.Text.ToString().Trim() + "' and begin_date = '" + dateTimePickerDate.Text.ToString() + "' and ctype =2"; int rows = conn.ReturnRecordCount(sql2); if (rows > 0) { MessageBox.Show("该员工这天的交通补贴信息已经存在!"); } else { bool isok = conn.EditDatabase(sql); if (isok) { MessageBox.Show("修改成功!"); TempEmpTravelExpenseQuery.RefreshEX(); this.Close(); } else { MessageBox.Show("失败!"); } } conn.Close(); }
private void simpleButtonOK_Click(object sender, EventArgs e) { ConnDB conn = new ConnDB(); string strsql, strsql2; int rows; strsql = "insert into COST_EXPENSE(CTYPE,TYPE_DES,BEGIN_DATE,EMP_NO,EXPENSE) values(2,'交通补贴','" + dateTimePickerBegin.Text.ToString() + "','" + textEditEmpno.Text.ToString().Trim() + "','" + textEditPrice.Text.ToString().Trim() + "')"; strsql2 = "select EXPENSE from COST_EXPENSE where ctype =2 and emp_no ='" + textEditEmpno.Text.ToString().Trim() + "' and begin_date = '" + dateTimePickerBegin.Text.ToString() + "'"; if (textEditEmpno.Text.ToString().Trim() != "") { rows = conn.ReturnRecordCount(strsql2); if (rows > 0) { MessageBox.Show("该员工此日期的交通补贴已经存在!"); } else { bool isok = conn.EditDatabase(strsql); if (isok) { MessageBox.Show("添加成功!"); TempEmpTravelExpenseQuery.RefreshEX(); this.Close(); } else { MessageBox.Show("失败!"); } } } else { MessageBox.Show("工号不能为空!"); } conn.Close(); }
private void barButtonItem刷新_ItemClick(object sender, ItemClickEventArgs e) { TempEmpTravelExpenseQuery.RefreshEX(); }