//Delete statement public Boolean Delete(ModelAuthenCode model) { try { string query = "DELETE FROM tb_authen_code WHERE id=" + model.id; //if (this.OpenConnection() == true) //{ using (MySqlConnection connection = new MySqlConnection(Configurations.MysqlStr)) { connection.Open(); MySqlCommand cmd = new MySqlCommand(query, connection); cmd.ExecuteNonQuery(); } // this.CloseConnection(); //} //else //{ // System.Windows.Forms.MessageBox.Show("Not Allow Insert,Delete,Update On OffLine Mode!!"); //} } catch (Exception ex) { logger.Error(ex.InnerException); logger.Error(ex.InnerException); //System.Windows.Forms.MessageBox.Show(ex.Message); return(false); } return(true); }
//Update statement public Boolean Update(ModelAuthenCode model) { try { string query = "UPDATE tb_authen_code SET ath_user ='******' ,ath_pass ='******',ath_use ='" + model.ath_use + "',ath_code='" + model.ath_code + "' WHERE id =" + model.id + " And station_id=" + model.station_id; using (MySqlConnection connection = new MySqlConnection(Configurations.MysqlStr)) { connection.Open(); //create mysql command MySqlCommand cmd = new MySqlCommand(); //Assign the query using CommandText cmd.CommandText = query; //Assign the connection using Connection cmd.Connection = connection; //Execute query cmd.ExecuteNonQuery(); } //Also update used access code to offince UpdateOffine(model); } catch (Exception ex) { logger.Error(ex.InnerException); //System.Windows.Forms.MessageBox.Show(ex.Message); return(false); } return(true); }
private void CMD_REGEN_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; 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) { accessCode = lists[0]; B_ACCESS_CODE.Text = accessCode.ath_code; model.ath_id = accessCode.ath_code; model.update_by = (onlineStatus) ? this.main.staffModel.id : staffId; model.update_date = DateTime.Now; if ((onlineStatus) ? tranDao.Update(model, StationID) : tranDao.UpdateOffline(model, StationID)) { accessCode.ath_use = "1"; result = (onlineStatus) ? authenDao.Update(accessCode) : authenDao.UpdateOffine(accessCode); } MessageBox.Show("เปลี่ยนแปลง Access Code เรียบร้อยแล้ว"); main.refreshData(); } else { MessageBox.Show("Access Code ไม่เพียงพอ"); } Cursor = Cursors.Default; }
private void B_PREVIEW_Click(object sender, EventArgs e) { try { if (!TXT_FILENAME.Text.Equals("")) { using (CsvFileReader reader = new CsvFileReader(TXT_FILENAME.Text)) { authenCodes = new List <ModelAuthenCode>(); CsvRow row = new CsvRow(); while (reader.ReadRow(row)) { //Login,Password,Uptime Limit,Used Uptime,Used Download,Used Upload ModelAuthenCode model = new ModelAuthenCode(); model.ath_code = row[1]; model.ath_user = row[0]; model.ath_pass = row[1]; model.ath_use = "0"; model.station_id = Convert.ToInt32(lounge_site.SelectedValue); model.createDate = DateTime.Now; authenCodes.Add(model); } dataGridView1.DataSource = authenCodes; if (authenCodes.Count > 0) { B_LOAD.Enabled = true; } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public List <ModelAuthenCode> SelectAutehnPage(String cri, int station_id) { string query = "SELECT * FROM tb_authen_code " + ((cri.Equals("")) ? " Where station_id=" + station_id : cri + " And station_id=" + station_id); //Create a list to store the result List <ModelAuthenCode> lists = new List <ModelAuthenCode>(); using (MySqlConnection connection = new MySqlConnection(Configurations.MysqlStr)) { connection.Open(); //Create Command MySqlCommand cmd = new MySqlCommand(query, connection); //Create a data reader and Execute the command MySqlDataReader dr = cmd.ExecuteReader(); //Read the data and store them in the list while (dr.Read()) { ModelAuthenCode model = new ModelAuthenCode(); model.id = (DBNull.Value == dr["id"]) ? -1 : Convert.ToInt32(dr["id"]); model.ath_code = (DBNull.Value == dr["ath_code"]) ? "" : Convert.ToString(dr["ath_code"]); model.ath_user = (DBNull.Value == dr["ath_user"]) ? "" : Convert.ToString(dr["ath_user"]); model.ath_pass = (DBNull.Value == dr["ath_pass"]) ? "" : Convert.ToString(dr["ath_pass"]); model.ath_use = (DBNull.Value == dr["ath_use"]) ? "" : Convert.ToString(dr["ath_use"]); model.station_id = (DBNull.Value == dr["station_id"]) ? -1 : Convert.ToInt32(dr["station_id"]); model.createDate = (DBNull.Value == dr["createDate"]) ? DateTime.Now : Convert.ToDateTime(dr["createDate"]); lists.Add(model); } //close Data Reader dr.Close(); } //return list to be displayed //validate out of accesscode if (cri.StartsWith("where ath_use = 0")) { if (lists.Count == 0) { List <ModelAuthenCode> tmpList = Select(" Where station_id=" + station_id, station_id); if (tmpList.Count > 0) { resetAuthenCode(station_id); return(Select(cri, station_id)); } } } return(lists); }
private void B_DELETE_Click(object sender, EventArgs e) { if (MessageBox.Show("Really delete?", "Confirm delete", MessageBoxButtons.YesNo) == DialogResult.Yes) { ModelAuthenCode model = new ModelAuthenCode(); model.id = this.id; model.ath_code = ath_code.Text; model.ath_use = (ath_use.Checked) ? "1" : "0"; Boolean result = authenCodeDao.Delete(model); if (result) { MessageBox.Show("ลบข้อมูลเรียบร้อยแล้ว"); refresh(); } } }
private void FrmDetail_Load(object sender, EventArgs e) { //check offine mode #region Initial variable StationID = Convert.ToInt32(ManageLOG.getValueFromRegistry(Configurations.AppRegName, "StationID")); if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "userInfo") != null) { String[] userInfo = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "userInfo").Split(','); staffId = Convert.ToInt32(userInfo[0]); lounge = Convert.ToInt32(userInfo[1]); area = Convert.ToInt32(userInfo[2]); } if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "OnlineStatus") != null) { onlineStatus = (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "OnlineStatus").Equals("1")) ? true : false; } #endregion if (model != null) { remakr2.Text = model.remakr2; remark.Text = model.remark; B_ACCESS_CODE.Text = model.ath_id + ""; } List <ModelAuthenCode> codes = (onlineStatus) ? authenDao.Select(" where ath_code='" + model.ath_id + "'", StationID) : authenDao.SelectOffine(" where ath_code='" + model.ath_id + "'", StationID); if (codes.Count > 0) { accessCode = codes[0]; B_ACCESS_CODE.Text = codes[0].ath_code; } // if (onlineStatus) { label3.Text = String.Format(label3.Text, main.staffModel.user_name); } else { label3.Text = String.Format(label3.Text, staffId); } }
public Boolean UpdateOffine(ModelAuthenCode model) { try { string query = "UPDATE tb_authen_code SET ath_user ='******' ,ath_pass ='******',ath_use ='" + model.ath_use + "',ath_code='" + model.ath_code + "' WHERE id =" + model.id + " And station_id=" + model.station_id; using (SQLiteConnection conn = new SQLiteConnection(Configurations.SqLiteStr)) { conn.Open(); //Create Command SQLiteCommand cmd = new SQLiteCommand(query, conn); //Create a data reader and Execute the command cmd.ExecuteNonQuery(); } } catch (Exception ex) { logger.Error(ex.InnerException); return(false); } return(true); }
public Boolean InsertOffline(ModelAuthenCode model) { try { string query = "INSERT INTO tb_authen_code(ath_user,ath_pass,ath_code,createdate,ath_use,station_id) VALUES('" + model.ath_user + "','" + model.ath_pass + "','" + model.ath_code + "','" + DateTime.Now + "',0,'" + model.station_id + "')"; using (SQLiteConnection connection = new SQLiteConnection(Configurations.SqLiteStr)) { connection.Open(); //create command and assign the query and connection from the constructor SQLiteCommand cmd = new SQLiteCommand(query, connection); //Execute command cmd.ExecuteNonQuery(); } } catch (Exception ex) { logger.Error(ex.InnerException); return(false); } return(true); }
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(); }