//删除按钮 private void button_delete_Click(object sender, EventArgs e) { if (MessageBox.Show("您确定要删除本条记录?", "警告!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { if (dataGridView_application.CurrentRow == null) { MessageBox.Show("什么都没选中!"); return; } int selectedRowIndex = dataGridView_application.CurrentRow.Index; string appId = dataGridView_application.Rows[selectedRowIndex].Cells[0].Value.ToString(); string sqlStr = string.Format(Globalconst.SELECT_APPSTATUS, appId); DataSet ds = CADOConn.GetDataSet(sqlStr); string status = ds.Tables[0].Rows[0][0].ToString(); if (status.Equals(Globalconst.SUCCESS)) { MessageBox.Show("档案已借出,该条预约记录无法删除!"); return; } sqlStr = string.Format(Globalconst.DELETE_APPLICATION, appId); CADOConn.ExecuteSQL(sqlStr); loadDATA(); } }
//维护状态:确定档案是已经借出去了 private void button_lend_Click(object sender, EventArgs e) { if (dataGridView_admin.CurrentRow == null) { MessageBox.Show("什么都没选中!"); return; } int select_index = dataGridView_admin.CurrentRow.Index; string appid = dataGridView_admin.Rows[select_index].Cells[0].Value.ToString(); string objNameCode = dataGridView_admin.Rows[select_index].Cells[2].Value.ToString(); string[] temp = objNameCode.Split('('); string objCode = temp[1]; objCode = objCode.Substring(0, 10); //更新档案状态 string sqlStr = string.Format(Globalconst.UPDATE_DOCUMENT, Globalconst.NOT_ON_SHELF, objCode); CADOConn.ExecuteSQL(sqlStr); //更新预约状态 sqlStr = string.Format(Globalconst.UPDATE_APPLICATION, Globalconst.SUCCESS, appid); CADOConn.ExecuteSQL(sqlStr); //生成事件记录 string data = System.DateTime.Now.Date.ToString("yyyyMMdd"); sqlStr = string.Format(Globalconst.INSERT_EVENT, Globalconst.LEND, objCode, appid, Program.curUser.UserName, data); CADOConn.ExecuteSQL(sqlStr); MessageBox.Show("存档成功!"); loadData(); }
private void button1_Click(object sender, EventArgs e) { string objName = textBox_objName.Text; string objCode = textBox_ObjCode.Text; if (string.IsNullOrEmpty(objName)) { MessageBox.Show("请输入被借阅人姓名!"); return; } if (string.IsNullOrEmpty(objCode)) { MessageBox.Show("请输入被借阅人档案号!"); return; } //验证姓名和学号是否匹配 string sql = string.Format(Globalconst.SELECT_DOCUMENT, objCode); DataSet ds = CADOConn.GetDataSet(sql); //如果查询结果为空 if (ds.Tables[0].Rows.Count == 0) { MessageBox.Show("查无此人,请检查档案号是否正确!"); return; } if (!string.Equals(ds.Tables[0].Rows[0][0].ToString(), objName)) { MessageBox.Show("姓名和档案号不匹配,请重新输入!"); return; } //查询此人的档案是否在不在架 sql = string.Format(Globalconst.SELECT_DOCUMENT_STATUS, objCode); ds = CADOConn.GetDataSet(sql); string status = ds.Tables[0].Rows[0][0].ToString(); if (status == Globalconst.ON_SHELF) { MessageBox.Show("此人的档案在架,无需归还!"); return; } //如果所有条件都符合,就执行归还 //归还:生成事件,维护档案记录 //这里最后补充原子性操作 string data = System.DateTime.Now.Date.ToString("yyyyMMdd"); string sqlStr = string.Format(Globalconst.INSERT_EVENT, Globalconst.LEND, objCode, "", Program.curUser.UserName, data); CADOConn.ExecuteSQL(sqlStr); sqlStr = string.Format(Globalconst.UPDATE_DOCUMENT, Globalconst.ON_SHELF, objCode); CADOConn.ExecuteSQL(sqlStr); MessageBox.Show("归档成功!"); this.Close(); }
private void button_disagree_Click(object sender, EventArgs e) { if (dataGridView_authorize.CurrentRow == null) { MessageBox.Show("什么都没选中!"); return; } int selectedRowIndex = dataGridView_authorize.CurrentRow.Index; string appId = dataGridView_authorize.Rows[selectedRowIndex].Cells[0].Value.ToString(); string appStatus = dataGridView_authorize.Rows[selectedRowIndex].Cells[4].Value.ToString(); if (appStatus.Equals(Globalconst.PENDING)) { string sqlStr = string.Format(Globalconst.UPDATE_APPLICATION, Globalconst.DISAGREE, appId); CADOConn.ExecuteSQL(sqlStr); MessageBox.Show("不同意授权成功!"); loadDATA(); } else { MessageBox.Show("该条记录已经处理过!"); } }
private void button_OK_Click(object sender, EventArgs e) { string appCode = textBox_applicant.Text; string objName = textBox_objname.Text; string objCode = textBox_object.Text; if (string.IsNullOrEmpty(textBox_objname.Text)) { MessageBox.Show("请输入被借阅人姓名"); return; } if (string.IsNullOrEmpty(textBox_object.Text)) { MessageBox.Show("请输入被借阅人姓名"); return; } //验证姓名和学号是否匹配 string sql = string.Format(Globalconst.SELECT_DOCUMENT, textBox_object.Text); DataSet ds = CADOConn.GetDataSet(sql); //如果查询结果为空 if (ds.Tables[0].Rows.Count == 0) { MessageBox.Show("查无此人,请检查档案号是否正确!"); return; } if (!string.Equals(ds.Tables[0].Rows[0][0].ToString(), textBox_objname.Text)) { MessageBox.Show("姓名和档案号不匹配,请重新输入!"); return; } //不能自己借自己的档案 if (string.Equals(textBox_object.Text, textBox_applicant.Text)) { MessageBox.Show("您没有权限借阅自己的档案!"); return; } //如果当前档案不在架,则无法借阅 sql = string.Format(Globalconst.SELECT_STATUS, objCode); ds = CADOConn.GetDataSet(sql); string status = ds.Tables[0].Rows[0][0].ToString(); if (string.Equals(status, "1")) { MessageBox.Show("该档案不在架,暂时无法借阅!"); return; } //获取预约日期 string data = dateTimePicker_application.Value.ToString("yyyy-MM-dd"); //获取授权老师档案号 string authoCode = getAuthoCode(appCode); //获取预约号 string appId = getAppid(); // 申请编号 申请人 被借阅人 授权人 日期 sql = string.Format(Globalconst.INSERT_APPLICATION, appId, appCode, objCode, authoCode, data); CADOConn.ExecuteSQL(sql); MessageBox.Show("添加成功"); this.Close(); }