private void Cmb_Running_EditValueChanged(object sender, EventArgs e) { GridLookUpEdit G_Run = sender as GridLookUpEdit; if (G_Run.EditValue == null) { return; } _RunningID = G_Run.EditValue.ToString(); using (var db = new DocumentRunningService(Utility.ConnSDB)) { if (_RunningID == "" || _Menu_ID == "") { return; } DEntRun = db.GetFind(Convert.ToInt32(_RunningID), _Menu_ID);//db.GetRunning(Convert.ToInt32(_RunningID), _Menu_ID); } if (DEntRun == null) { return; } txt_DocNoTran.Text = Db_Run.GetRunningDisplay(DEntRun); if (txt_DocNoTran.Text != "") { btn_Select.Enabled = true; } }
private void Click_LoadData() { if (_DataRunning != null) { using (var db = new DocumentRunningService(Utility.ConnSDB)) { Stock_DocumentRunning Item = db.GetFind(_DataRunning.Format_Id, _DataRunning.Menu_ID); if (Item != null) { txt_docGroup.Text = Item.Prefix; txt_description.Text = Item.Description; txt_Format.Text = Item.FormatDisplay; txt_Month.Text = string.Format("{0:00}", Item.DocMonth == null ? 0 : Item.DocMonth); txt_Year.Text = Convert.ToString(Item.DocYear == null ? 0 : Item.DocYear); txt_Day.Text = Convert.ToString(Item.DocDay == null ? 0 : Item.DocDay); num_Running.Value = Convert.ToDecimal(Item.LastRunningID); } } } }
private bool Fn_CheckRunningChange(int RunID, string _Menu_ID)//True : มีการเปลี่ยน Running พร้อม Reset เป็น 0 { using (var srv = new DocumentRunningService(Utility.ConnSDB)) { if (srv.ResetRunning(RunID, _Menu_ID)) { Utility.MessageInformation("มีการ Reset เลขที่เอกสารใหม่...กรุณาตรวจสอบเลขที่เอกสารใหม่อีกครั้งครับ"); DEntRun = srv.GetFind(Convert.ToInt32(_RunningID), _Menu_ID);//srv.GetRunning(Convert.ToInt32(_RunningID), _Menu_ID); if (DEntRun == null) { Utility.MessageError("ไม่พบข้อมูลการ Running กรุณาลองใหม่อีกครั้งครับ"); return(false); } txt_DocNoTran.Text = srv.GetRunningDisplay(DEntRun); return(false); } else { return(true); } } }
private void MenuClick_Delete_Click(object sender, EventArgs e) { Stock_DocumentFormat GData = (Stock_DocumentFormat)grd_FormatS.GetRow(Row_Format); if (GData == null) { return; } using (var Db = new DocumentRunningService(Utility.ConnSDB)) { Stock_DocumentRunning ICheck = Db.GetFind(GData.Format_Id, GData.Menu_ID); if (ICheck != null) { if (ICheck.LastRunningID > 0) { MessageBox.Show("Running ถูกใช้งานแล้ว [ทั้งหมด : " + ICheck.LastRunningID + "] แล้ว...ไม่สามารถลบได้ครับ", "Error!!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } if (MessageBox.Show("คุณต้องการที่จะลบข้อมูลของ [ " + GData.Prefix + "-" + GData.Description + " ] หรือไม่ครับ?", "ยืนยันการลบ", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { try { db_Format.Delete(GData.Format_Id, GData.Menu_ID); //using (var db_Log = new ContractLogService()) // db_Log.InsertLog("", Utility._UserDB, DateTime.Now, this.Text, GData.Format_Id.ToString(), "Delete", "", "Success!!-ข้อมูล Format", "DocumentFormat"); Click_loadFormat(GData.Menu_ID); } catch (Exception ex) { //using (var db_Log = new ContractLogService()) // db_Log.InsertLog("", Utility._UserDB, DateTime.Now, this.Text, GData.Format_Id.ToString(), "Delete", "", "Error!!-ข้อมูล Format", "DocumentFormat"); MessageBox.Show("Error : " + ex.Message, "Error...!!"); } } }
private void btn_Update_Click(object sender, EventArgs e) { if (dxValidationProvider1.Validate() == false) { return; } DateTime DateCurrent = db_Run.GetDate(); Stock_DocumentMenu GData = (Stock_DocumentMenu)gridView1.GetRow(Row_Menu); Stock_DocumentFormat GDataFM = (Stock_DocumentFormat)grd_FormatS.GetRow(Row_Format); if (MessageBox.Show("คุณยืนยันที่จะทำการ [แก้ไข] รูปแบบเอกสาร [" + string.Format("{0}-{1}", GDataFM.Menu_ID, GDataFM.Description) + "] นี้หรือไม่ครับ?", "ยืนยันการแก้ไข", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Stock_DocumentFormat item = new Stock_DocumentFormat(); item.Format_Id = GDataFM.Format_Id; item.Menu_ID = GDataFM.Menu_ID; item.Running_Len = Convert.ToInt32(num_Running.Value); item.Prefix_Enable = true;//swith_DocGroup.IsOn; item.Prefix = txt_DocGroup.Text.Trim(); item.Year_Enable = swith_Year.IsOn; item.Day_Enable = swith_Day.IsOn; if (swith_Year.IsOn) { item.Year_Len = Convert.ToInt32(rdo_YearLen.EditValue); } item.Month_Enable = swith_Month.IsOn; item.Description = txt_Description.Text.Trim(); Stock_DocumentRunning itemR = db_Run.GetFind(item.Format_Id, item.Menu_ID);// new DocumentRunning(); bool _ResetRunning = false; itemR.Prefix = txt_DocGroup.Text.Trim(); if (swith_Year.IsOn) { int YearR = Convert.ToInt32(rdo_YearLen.EditValue); string SYear = DateCurrent.Year > 2400 ? DateCurrent.Year.ToString() : (DateCurrent.Year + 543).ToString(); if (YearR == 4) { if (itemR.DocYear != null) { if (itemR.DocYear.Value.ToString().Length == 4) { if (Convert.ToInt32(SYear.Substring(0, YearR)) > itemR.DocYear)//เทียบปีปัจจุบันว่าเปลี่ยนไปหรือป่าว { itemR.DocYear = Convert.ToInt32(SYear.Substring(0, YearR)); _ResetRunning = true; } } else//ไม่เคยมี Setting นี้ { if (itemR.DocYear.Value.ToString().Length == 2)//เช็คว่าอันเดิมเป็น 2 ตำแหน่งหรือไม่ แล้วทำการเปรียบเทียบว่า ปีเท่ากันมั้ย { if (Convert.ToInt32(SYear.Substring(2, 2)) > itemR.DocYear)//เทียบปีปัจจุบันว่าเปลี่ยนไปหรือป่าว { itemR.DocYear = Convert.ToInt32(SYear.Substring(0, YearR)); _ResetRunning = true; } else { itemR.DocYear = Convert.ToInt32(SYear.Substring(0, YearR)); } } else { itemR.DocYear = Convert.ToInt32(SYear.Substring(0, YearR)); _ResetRunning = true; } } } else//ไม่เคยมี Setting นี้ { itemR.DocYear = Convert.ToInt32(SYear.Substring(0, YearR)); _ResetRunning = true; } } else { if (itemR.DocYear != null) { if (itemR.DocYear.Value.ToString().Length == 2) { if (Convert.ToInt32(SYear.Substring(2, YearR)) > itemR.DocYear)//เทียบปีปัจจุบันว่าเปลี่ยนไปหรือป่าว { itemR.DocYear = Convert.ToInt32(SYear.Substring(2, YearR)); _ResetRunning = true; } } else//ไม่เคยมี Setting นี้ { if (itemR.DocYear.Value.ToString().Length == 4)//เช็คว่าอันเดิมเป็น 4 ตำแหน่งหรือไม่ แล้วทำการเปรียบเทียบว่า ปีเท่ากันมั้ย { if (Convert.ToInt32(SYear.Substring(0, 4)) > itemR.DocYear)//เทียบปีปัจจุบันว่าเปลี่ยนไปหรือป่าว { itemR.DocYear = Convert.ToInt32(SYear.Substring(2, YearR)); _ResetRunning = true; } else { itemR.DocYear = Convert.ToInt32(SYear.Substring(2, YearR)); } } else { itemR.DocYear = Convert.ToInt32(SYear.Substring(2, YearR)); _ResetRunning = true; } } } else//ไม่เคยมี Setting นี้ { itemR.DocYear = Convert.ToInt32(SYear.Substring(2, YearR)); _ResetRunning = true; } } } else { itemR.DocYear = null; } if (swith_Month.IsOn) { if (itemR.DocMonth != null) { if (DateCurrent.Month > itemR.DocMonth) { itemR.DocMonth = DateCurrent.Month; _ResetRunning = true; } } else//ไม่เคยปี Setting นี้ { itemR.DocMonth = DateCurrent.Month; _ResetRunning = true; } } else { itemR.DocMonth = null; } if (swith_Day.IsOn) { if (itemR.DocDay != null) { if (DateCurrent.Day > itemR.DocDay) { itemR.DocDay = DateCurrent.Day;; _ResetRunning = true; } } else//ไม่เคยปี Setting นี้ { itemR.DocDay = DateCurrent.Day; _ResetRunning = true; } } else { itemR.DocDay = null; } if (_ResetRunning)// Reset Running is 0 { itemR.LastRunningID = 0; } itemR.FormatString = txt_FormatString.Text.Trim(); itemR.FormatDisplay = txt_FormatDisplay.Text.Trim(); itemR.Description = txt_Description.Text.Trim(); itemR.Active = 1; db_Format.Update(item, itemR); //using (var db_Log = new ContractLogService()) // db_Log.InsertLog("", Utility._UserDB, DateTime.Now, this.Text, item.Format_Id.ToString(), "Update", "", "Success!!-ข้อมูล Format Running", "DocumentFormat,DocumentRunning"); Click_loadFormat(GData.Menu_ID); Click_Clear(); } }