private void B_SAVE1_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; Boolean result = false; this.model.remakr2 = remakr2.Text; this.model.remark = remark.Text; this.model.ath_id = (accessCode == null) ? model.ath_id : accessCode.ath_code; this.model.update_by = (onlineStatus) ? this.main.staffModel.id : staffId; this.model.update_date = DateTime.Now; if ((onlineStatus) ? tranDao.Update(this.model, StationID) : tranDao.UpdateOffline(this.model, StationID)) { accessCode.ath_use = "1"; result = (onlineStatus) ? authenDao.Update(accessCode) : authenDao.UpdateOffine(accessCode); } MessageBox.Show("บันทึกข้อมูลเรียบร้อยแล้ว"); //Refresh Main accessCode = null; main.refreshData(); clear(); Cursor = Cursors.Default; Close(); }
private void B_ADD_Click(object sender, EventArgs e) { if (isValidInputData()) { int StationID = Convert.ToInt32(lounge_site.SelectedValue); ModelAuthenCode model = new ModelAuthenCode(); model.id = this.id; model.ath_code = ath_code.Text; model.ath_use = (ath_use.Checked) ? "1" : "0"; model.station_id = StationID; Boolean result = false; switch (B_ADD.Text) { case "บันทึก": result = authenCodeDao.Insert(model); if (result) { MessageBox.Show("บันทึกข้อมูลเรียบร้อยแล้ว"); } break; case "แก้ไข": result = authenCodeDao.Update(model); if (result) { MessageBox.Show("แก้ไขข้อมูลเรียบร้อยแล้ว"); } break; } if (result) { refresh(); } } }
private void txt_barcode_KeyUp(object sender, KeyEventArgs e) { if (e.KeyValue == (char)Keys.Return) { if (group_id.Text.Equals("")) { MessageBox.Show("ยังไม่ได้เลือกข้อมูล Group"); txt_barcode.Text = string.Empty; group_id.Select(); return; } try { txt_barcode.Text = txt_barcode.Text.Replace("\r\n", ""); string strCode = txt_barcode.Text; int dayOfYear = Convert.ToInt32(strCode.Substring(44, 3)); if (cbDisableVaridate.Checked || strCode.Substring(0, 2).Equals("M1") && (DateTime.Now.DayOfYear == dayOfYear || DateTime.Now.DayOfYear + 1 == dayOfYear)) { ModelTransaction tran = new ModelTransaction(); tran.id = 0; tran.boardingpass = txt_barcode.Text; tran.type = "A"; tran.group_id = Convert.ToInt32(group_id.SelectedValue); tran.passenger_name = strCode.Substring(2, 20); tran.from_city = strCode.Substring(30, 3); tran.to_city = strCode.Substring(33, 3); tran.airline_code = strCode.Substring(36, 2); tran.flight_no = strCode.Substring(39, 4); tran.date_of_flight = new DateTime(Convert.ToInt32(date_of_flight.SelectedValue), DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); tran.seat_no = strCode.Substring(48, 4); tran.remark = remark.Text; tran.remakr2 = remark2.Text; tran.LoungePlace = StationID; tran.LoungeType = lounge; tran.LoungeArea = area; tran.begin_date = DateTime.Now; tran.create_by = staffId; tran.create_date = DateTime.Now; tran.update_by = staffId; tran.update_date = DateTime.Now; logger.Debug("AUTO->INPUT :" + tran.passenger_name + "" + tran.flight_no + "" + tran.seat_no + "," + tran.type + "," + //Type tran.create_date.ToString("yyyy-MM-dd HH:MM:ss") + "," + tran.group_idName + "," + //GroupName tran.duration + "," + //Duration tran.passenger_name + "," + //PassengerName tran.from_city + "," + //FromCity tran.to_city + "," + //ToCity tran.airline_code + "," + //AirlineCode tran.flight_no + "," + //FlightNo tran.date_of_flight.ToString("yyyy-MM-dd HH:MM:ss") + "," + tran.seat_no + "," + //SeatNo tran.LoungeSiteCode + "," + //LoungePlace tran.LoungeName + "," + //LoungeType tran.LoungeAreaName + "," + //LoungeArea tran.create_byName + "," + //Owner tran.begin_date.ToString("yyyy-MM-dd HH:MM:ss") + "," + tran.status + "," + //Status tran.remark + "," + //Remark tran.ath_id + "," + //AccessCode tran.remakr2 + "," + //Remark2 tran.update_date.ToString("yyyy-MM-dd HH:MM:ss") + "," + tran.update_byName //LastUpdateBy ); /* * List<ModelTransaction> tmps = (onlineStatus) ? tranDao.Select(" Where boardingpass='******' order by t.create_date desc", StationID) : tranDao.SelectOffine(" Where boardingpass='******' order by t.create_date desc", StationID); * //Generate Access Code ใหม่ถ้ามีอายุการใช้งานเกิน 5 ชั่วโมง * if (tmps.Count > 0 && ((DateTime.Now.Hour - tmps[0].create_date.Hour) <= 5)) * { * * tran.ath_id = tmps[0].ath_id; * if ((onlineStatus) ? tranDao.Insert(tran, StationID) : tranDao.InsertOffine(tran, StationID)) * { * CMD_PRINT.Enabled = true; * lbMessage.Text = "บันทึกข้อมูลเรียบร้อยแล้ว"; * * lbAccessCode.Text = String.Format("{0}", tmps[0].ath_id); * lbAccessCode.ForeColor = Color.Green; * txt_barcode.Select(); * //Auto print * if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "AutoGenAutoPrint") != null) * { * if (!ManageLOG.getValueFromRegistry(Configurations.AppRegName, "AutoGenAutoPrint").Equals("")) * { * Boolean bPrint = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "AutoGenAutoPrint").Equals("False") ? false : true; * if (bPrint) * { * if (!lbAccessCode.Text.Equals("")) * { * printDocument1.Print(); * } * } * } * } * } * } * else * { */ String cri = "where ath_use = 0"; List <ModelAuthenCode> lists = (onlineStatus) ? authenDao.Select(cri, StationID) : authenDao.SelectOffine(cri, StationID); if (lists != null) { if (lists.Count > 0) { // ModelAuthenCode accessCode = lists[0]; // tran.ath_id = lists[0].ath_code; //auto save if ((onlineStatus) ? tranDao.Insert(tran, StationID) : tranDao.InsertOffine(tran, StationID)) { accessCode.ath_use = "1"; Boolean result = (onlineStatus) ? authenDao.Update(accessCode) : authenDao.UpdateOffine(accessCode); if (result) { CMD_PRINT.Enabled = true; lbMessage.Text = "บันทึกข้อมูลเรียบร้อยแล้ว"; lbAccessCode.Text = String.Format("{0}", accessCode.ath_code); lbAccessCode.ForeColor = Color.Green; txt_barcode.Select(); //Auto print if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "AutoGenAutoPrint") != null) { if (!ManageLOG.getValueFromRegistry(Configurations.AppRegName, "AutoGenAutoPrint").Equals("")) { Boolean bPrint = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "AutoGenAutoPrint").Equals("False") ? false : true; if (bPrint) { if (!lbAccessCode.Text.Equals("")) { printDocument1.Print(); } } } } } else { lbMessage.Text = "เกิดข้อผิดพลาดในการปรับปรุงค่า Access Code"; } } } else { logger.Error("Out of access code!"); lbMessage.Text = ""; lbAccessCode.Text = String.Format("Access Code is not enought!"); lbAccessCode.ForeColor = Color.Red; txt_barcode.Select(); } } else { logger.Error("Out of access code!"); } //} } else { lbMessage.Text = ""; lbAccessCode.Text = String.Format("BoardingPass is expired or incorrect data format."); lbAccessCode.ForeColor = Color.Red; txt_barcode.Select(); } //Clear Barcode Value clearData(); } catch (Exception ex) { logger.Error(ex.InnerException); e.Handled = false; ManageLOG.writeLoginLogs(-1, ModelUserLogs.EVENT_EXCEPTION, this.Name + "-passenger_name_KeyUp:" + ex.Message); txt_barcode.Text = ""; txt_barcode.Focus(); } } }
private void TXT_BARCODE_DATA_KeyUp(object sender, KeyEventArgs e) { Cursor = Cursors.WaitCursor; if (e.KeyValue == (char)Keys.Return) { e.Handled = true; if (!TXT_BARCODE_DATA.Text.Equals("")) { try { TXT_BARCODE_DATA.Text = TXT_BARCODE_DATA.Text.Replace("\r\n", ""); string strCode = TXT_BARCODE_DATA.Text; int dayOfYear = Convert.ToInt32(strCode.Substring(44, 3)); if (strCode.Substring(0, 2).Equals("M1") && (DateTime.Now.DayOfYear == dayOfYear || DateTime.Now.DayOfYear + 1 == dayOfYear)) { TXT_BARCODE_DATA.Enabled = false; logger.Debug("Boarding pass:"******"S";//Self tran.group_id = 16; tran.passenger_name = strCode.Substring(2, 20); tran.from_city = strCode.Substring(30, 3); tran.to_city = strCode.Substring(33, 3); tran.airline_code = strCode.Substring(36, 2); tran.flight_no = strCode.Substring(39, 4); tran.date_of_flight = DateTime.Now; tran.seat_no = strCode.Substring(48, 4); tran.remark = ""; tran.remakr2 = ""; tran.LoungePlace = Convert.ToInt32(StationID); tran.LoungeType = lounge; tran.LoungeArea = area; tran.begin_date = DateTime.Now; tran.create_by = staffId; tran.create_date = DateTime.Now; tran.update_date = DateTime.Now; tran.update_by = staffId; /* * List<ModelTransaction> tmps = (onlineStatus) ? tranDao.Select(" Where boardingpass='******' order by t.create_date desc", StationID) : tranDao.SelectOffine(" Where boardingpass='******' order by t.create_date desc", StationID); * * //Generate Access Code ใหม่ถ้ามีอายุการใช้งานเกิน 5 ชั่วโมง * if (tmps.Count > 0 && ((DateTime.Now.Hour - tmps[0].create_date.Hour) <= 5)) * { * * tran.ath_id = tmps[0].ath_id; * tran.create_date = DateTime.Now; * * if ((onlineStatus) ? tranDao.Insert(tran, StationID) : tranDao.InsertOffine(tran, StationID)) * { * Console.Beep(); * TXT_ACCESS_CODE.Text = tran.ath_id; * TXT_BARCODE_DATA.Enabled = false; * //Auto print * if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "AutoPrint") != null) * { * if (!ManageLOG.getValueFromRegistry(Configurations.AppRegName, "AutoPrint").Equals("")) * { * Boolean bPrint = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "AutoPrint").Equals("False") ? false : true; * if (bPrint) * { * if (!TXT_ACCESS_CODE.Text.Equals("")) * { * TXT_BARCODE_DATA.Enabled = false; * printDocument1.Print(); * } * } * } * } * success = true; * } * else * { * TXT_BARCODE_DATA.Enabled = true; * TXT_ACCESS_CODE.Text = "CAN'T CREATE PLEASE TRY AGAIN!"; * TXT_BARCODE_DATA.Text = ""; * TXT_BARCODE_DATA.Focus(); * Cursor = Cursors.Default; * } * } * else * { */ //get authen code String cri = "where ath_use = 0"; List <ModelAuthenCode> lists = (onlineStatus) ? authenCodeDao.Select(cri, StationID) : authenCodeDao.SelectOffine(cri, StationID); if (lists != null) { if (lists.Count > 0) { ModelAuthenCode tmpAuthenModel = lists[0]; tran.ath_id = tmpAuthenModel.ath_code; tran.create_date = DateTime.Now; if ((onlineStatus) ? tranDao.Insert(tran, StationID) : tranDao.InsertOffine(tran, StationID)) { tmpAuthenModel.ath_use = "1"; Boolean result = (onlineStatus) ? authenCodeDao.Update(tmpAuthenModel) : authenCodeDao.UpdateOffine(tmpAuthenModel); if (result) { Console.Beep(); TXT_ACCESS_CODE.Text = tmpAuthenModel.ath_code; //Auto print if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "AutoPrint") != null) { if (!ManageLOG.getValueFromRegistry(Configurations.AppRegName, "AutoPrint").Equals("")) { Boolean bPrint = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "AutoPrint").Equals("False") ? false : true; if (bPrint) { if (!TXT_ACCESS_CODE.Text.Equals("")) { printDocument1.Print(); TXT_BARCODE_DATA.Enabled = false; TXT_BARCODE_DATA.Text = string.Empty; TXT_ACCESS_CODE.Text = string.Empty; success = true; } } } } } else { TXT_ACCESS_CODE.Text = "CAN'T CREATE PLEASE TRY AGAIN!"; TXT_BARCODE_DATA.Enabled = true; TXT_BARCODE_DATA.Text = ""; TXT_BARCODE_DATA.Focus(); Cursor = Cursors.Default; } } else { TXT_ACCESS_CODE.Text = "CAN'T CREATE PLEASE TRY AGAIN!"; TXT_BARCODE_DATA.Enabled = true; TXT_BARCODE_DATA.Text = ""; TXT_BARCODE_DATA.Focus(); Cursor = Cursors.Default; } } else { logger.Error("Out of access code!"); TXT_ACCESS_CODE.Text = "OUT OF ACCESS CODE!"; TXT_BARCODE_DATA.Enabled = true; TXT_BARCODE_DATA.Text = ""; TXT_BARCODE_DATA.Focus(); Cursor = Cursors.Default; } } else { logger.Error("Out of access code!"); } //} } else { TXT_ACCESS_CODE.Text = "BoardingPass is expired or incorrect data format."; TXT_BARCODE_DATA.Enabled = true; TXT_BARCODE_DATA.Text = ""; TXT_BARCODE_DATA.Focus(); Cursor = Cursors.Default; } Cursor = Cursors.Default; } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); TXT_ACCESS_CODE.Text = "INCORRECT DATA FORMAT!"; TXT_BARCODE_DATA.Enabled = true; TXT_BARCODE_DATA.Text = ""; TXT_BARCODE_DATA.Focus(); Cursor = Cursors.Default; } TXT_BARCODE_DATA.Enabled = false; if (success) { timer1.Enabled = true; timer1.Start(); } else { timer1.Enabled = false; timer1.Stop(); } } } TXT_BARCODE_DATA.Enabled = true; TXT_BARCODE_DATA.Focus(); Cursor = Cursors.Default; }
private void B_SAVE_Click(object sender, EventArgs e) { //Validate if (passenger_name.Text.Equals("")) { MessageBox.Show("ยังไม่ได้ป้อนข้อมูล Passenger Name"); passenger_name.Select(); return; } if (airlineCode.Text.Equals("")) { MessageBox.Show("ยังไม่ได้ป้อนข้อมูล Airline Code"); airlineCode.Select(); return; } if (flight_no.Text.Equals("")) { MessageBox.Show("ยังไม่ได้ป้อนข้อมูล Flight No"); flight_no.Select(); return; } if (date_of_flight.Value.Equals("")) { MessageBox.Show("ยังไม่ได้ป้อนข้อมูล Date Of flight"); date_of_flight.Select(); return; } if (seat_no.Text.Equals("")) { MessageBox.Show("ยังไม่ได้ป้อนข้อมูล Seat No"); seat_no.Select(); return; } //if (fromcity.Text.Equals("")) //{ // MessageBox.Show("ยังไม่ได้ป้อนข้อมูล From City"); // fromcity.Select(); // return; //} //if (tocity.Text.Equals("")) //{ // MessageBox.Show("ยังไม่ได้ป้อนข้อมูล To City"); // tocity.Select(); // return; //} if (group_id.Text.Equals("")) { MessageBox.Show("ยังไม่ได้เลือกข้อมูล Group"); group_id.Select(); return; } Boolean result = false; String cri = "where ath_use = 0"; List <ModelAuthenCode> lists = (onlineStatus) ? authenDao.Select(cri, StationID) : authenDao.SelectOffine(cri, StationID); if (lists.Count > 0) { ModelAuthenCode accessCode = lists[0]; ModelTransaction tran = new ModelTransaction(); tran.type = "M"; tran.group_id = (group_id.Text.Equals("")) ? -1 : Convert.ToInt32(group_id.SelectedValue); tran.passenger_name = passenger_name.Text; tran.from_city = fromcity.Text; tran.to_city = tocity.Text; tran.airline_code = airlineCode.Text; tran.flight_no = flight_no.Text; tran.date_of_flight = date_of_flight.Value; tran.seat_no = ((seat_no.Text.Length > 4) ? seat_no.Text.Substring(0, 4) : seat_no.Text); tran.remark = remark.Text; tran.remakr2 = remark2.Text; tran.LoungePlace = StationID; tran.LoungeType = lounge; tran.LoungeArea = area; tran.begin_date = DateTime.Now; tran.ath_id = accessCode.ath_code; tran.create_by = staffId; tran.create_date = DateTime.Now; tran.update_date = DateTime.Now; tran.update_by = staffId; //M1GILJIMENEZ/PILA9 MS EKWGVQS BKKTDXPG 0305 078Y045A0016 300 tran.boardingpass = MyFunction.getBoadingPass(tran);// passenger_name.Text + "" + fromcity.Text + tocity.Text + airlineCode.Text + date_of_flight.Value + seat_no.Text; logger.Debug("MANUAL->INPUT :" + tran.passenger_name + "" + tran.flight_no + "" + tran.seat_no + "," + tran.type + "," + //Type tran.create_date.ToString("yyyy-MM-dd HH:MM:ss") + "," + tran.group_idName + "," + //GroupName tran.duration + "," + //Duration tran.passenger_name + "," + //PassengerName tran.from_city + "," + //FromCity tran.to_city + "," + //ToCity tran.airline_code + "," + //AirlineCode tran.flight_no + "," + //FlightNo tran.date_of_flight.ToString("yyyy-MM-dd HH:MM:ss") + "," + tran.seat_no + "," + //SeatNo tran.LoungeSiteCode + "," + //LoungePlace tran.LoungeName + "," + //LoungeType tran.LoungeAreaName + "," + //LoungeArea tran.create_byName + "," + //Owner tran.begin_date.ToString("yyyy-MM-dd HH:MM:ss") + "," + tran.status + "," + //Status tran.remark + "," + //Remark tran.ath_id + "," + //AccessCode tran.remakr2 + "," + //Remark2 tran.update_date.ToString("yyyy-MM-dd HH:MM:ss") + "," + tran.update_byName //LastUpdateBy ); //auto save if ((onlineStatus) ? tranDao.Insert(tran, StationID) : tranDao.InsertOffine(tran, StationID)) { accessCode.ath_use = "1"; result = (onlineStatus) ? authenDao.Update(accessCode) : authenDao.UpdateOffine(accessCode); if (result) { lbMessage.Text = "บันทึกข้อมูลเรียบร้อยแล้ว"; CMD_PRINT.Enabled = true; lbAccessCode.Text = String.Format("{0}", accessCode.ath_code); lbAccessCode.ForeColor = Color.Green; //Auto print if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "ManualGenAutoPrint") != null) { if (!ManageLOG.getValueFromRegistry(Configurations.AppRegName, "ManualGenAutoPrint").Equals("")) { Boolean bPrint = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "ManualGenAutoPrint").Equals("False") ? false : true; if (bPrint) { if (!lbAccessCode.Text.Equals("")) { printDocument1.Print(); } } } } } else { lbMessage.Text = ""; lbMessage.Text = "เกิดข้อผิดพลาดในการปรับปรุงค่า Access Code"; } } } else { lbMessage.Text = ""; lbAccessCode.Text = String.Format("Access Code is not enought!"); lbAccessCode.ForeColor = Color.Red; } clearData(); }