private void btn_Alter_Click(object sender, EventArgs e) { try { int AbsenceNo; int.TryParse(this.absence_NoTextBox.Text, out AbsenceNo); FrmYesNo f = new FrmYesNo(); f.label1.Text = "確定修改資料?"; f.ShowDialog(); if (f.DialogResult == System.Windows.Forms.DialogResult.Yes) { //圖片轉換=========== byte[] bytes = null; if (this.certificate_DocPictureBox.Image != null) { MemoryStream ms = new MemoryStream(); certificate_DocPictureBox.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); bytes = ms.GetBuffer(); } //================================================== //修改 審核中+未通過審核 的資料============= //var alter_Absence = (from AT in db.Absence_Table // where AT.Absence_No == AbsenceNo // select AT).FirstOrDefault(); var alter_Absence = db.Absence_Table.Where(AT => AT.Absence_No == AbsenceNo).FirstOrDefault(); if (alter_Absence == null) { MessageBox.Show("假單不存在!"); return; } alter_Absence.Reason = reasonTextBox.Text; alter_Absence.Certificate_Doc = bytes; alter_Absence.ChechStatu.Check_ID = 1; db.SaveChanges(); } } catch { } //================================================== }
private void btn_delete_Click(object sender, EventArgs e) { try { int AbsenceNo; int.TryParse(this.absence_NoTextBox.Text, out AbsenceNo); FrmYesNo f = new FrmYesNo(); f.ShowDialog(); if (f.DialogResult == System.Windows.Forms.DialogResult.Yes) { //刪除 審核中+未通過審核 的資料============= //var delete_Absence = (from AT in db.Absence_Table // where AT.Absence_No == AbsenceNo // select AT).FirstOrDefault(); var delete_Absence = db.Absence_Table.Where(AT => AT.Absence_No == AbsenceNo).FirstOrDefault(); if (delete_Absence == null) { MessageBox.Show("假單不存在!"); return; } db.Absence_Table.Remove(delete_Absence); db.SaveChanges(); } } catch { } //================================================== }
private void btn_Reject_Click(object sender, EventArgs e) { try { int AbsenceNo; int.TryParse(this.absence_NoTextBox2.Text, out AbsenceNo); FrmYesNo f = new FrmYesNo(); f.label1.Text = "確定修改資料?"; f.ShowDialog(); if (f.DialogResult == System.Windows.Forms.DialogResult.Yes) { //修改 審核中+未通過審核 的資料============= //var accept_Absence = (from AT in db.Absence_Table // where AT.Absence_No == AbsenceNo // select AT).FirstOrDefault(); var accept_Absence = db.Absence_Table.Where(AT => AT.Absence_No == AbsenceNo).FirstOrDefault(); if (accept_Absence == null) { MessageBox.Show("假單不存在!"); return; } accept_Absence.Check_ID = 3; //db.SaveChanges(); //================================================== } } catch { } }