private void FrmStaff_Load(object sender, EventArgs e) { StationID = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "StationID"); if (!String.IsNullOrEmpty(StationID)) { String[] userInfo = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "userInfo").Split(','); if (!userInfo[6].Equals("9")) { staff_station.DataSource = stationDao.Select(" where id = " + StationID); staff_station.SelectedIndex = 0; staff_station.Enabled = false; } else { staff_station.DataSource = stationDao.Select(""); staff_station.SelectedIndex = 0; staff_station.Enabled = true; } } user_role.DataSource = roleDao.Select(" Where role_code <> 'SPECIAL'"); user_role.SelectedIndex = 0; //initial refresh(); }
private void FrmAutoGen_Load(object sender, EventArgs e) { #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]); stationName = userInfo[3]; loungeName = userInfo[4]; areaName = userInfo[5]; cbDisableVaridate.Visible = userInfo[7].ToUpper().Equals("ADMIN") || userInfo[7].ToUpper().Equals("SPECIAL"); } if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "OnlineStatus") != null) { onlineStatus = (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "OnlineStatus").Equals("1")) ? true : false; } #endregion lSupport.Text = String.Format(lSupport.Text, ManageLOG.getValueFromRegistry(Configurations.AppRegName, "SupportCATInternet"), ""); lounge_site.Enabled = false; lounge_site.Text = stationName; L_SITE_DESC.Text = loungeName + "-" + areaName; date_of_flight.DataSource = MyFunction.getYearDDL(1); group_id.DataSource = (onlineStatus) ? groupDao.Select("") : groupDao.SelectOffine(""); refreshData(); }
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { String expireDate = DateTime.Now.AddHours(3).ToString(); String ssidName = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "SSIDName"); String accessCode = B_ACCESS_CODE.Text; String template_p1 = "\t\tBangkok Airways\n" + "\t\tInternet Service\n\n" + "------------------------------------------------\n" + "Access Code: "; String template_p2 = "Expire Time: " + expireDate + "\n"; String template_p3 = "---------------------------------------------------------------\nInstructions for User\n" + "1. Select Wifi " + ((ssidName == null) ? "" : ssidName) + "\n (เลือก Wifi) \n" + "2. Run the Internet Browser and go to any website.\n(เปิดอินเตอร์เนตบราวเซอร์แล้วไปยังเวปไซต์ที่ต้องการ) \n" + "3. The system will automatically redirect to the \nLogin Page,(ระบบจะไปยังหน้าจอ Login อัตโนมัติ)\n" + "Please enter Access Code.\n (ป้อน Access Code ที่ได้รับ)" + "\n" + "\n"; Bitmap logo = new Bitmap(Configurations.PosLogoPath); Bitmap clone = new Bitmap(logo.Width, logo.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb); using (Graphics gr = Graphics.FromImage(clone)) { gr.DrawImage(logo, new Rectangle(0, 0, 110, 60)); } e.Graphics.DrawImage(clone, -5, -12); e.Graphics.DrawString(template_p1, new Font("Arial", 8), Brushes.Black, 0, 5); e.Graphics.DrawString(accessCode, new Font("Arial", 10), Brushes.Black, 80, 55); e.Graphics.DrawString(template_p2, new Font("Arial", 8), Brushes.Black, 0, 75); e.Graphics.DrawString(template_p3, new Font("Arial", 6), Brushes.Black, 0, 95); e.Graphics.DrawString("-", new Font("Arial", 6), Brushes.Black, 0, 225); }
private void FrmReport_Load(object sender, EventArgs e) { if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "userInfo") != null) { String[] userInfo = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "userInfo").Split(','); if (userInfo[6].Equals("9")) { lounge_site.DataSource = siteDao.Select(""); } else { String StationID = ManageLOG.getValueFromRegistry("WiFi Management", "StationID"); if (!String.IsNullOrEmpty(StationID)) { lounge_site.DataSource = siteDao.Select(" where id=" + StationID); } else { lounge_site.DataSource = siteDao.Select(""); } } } stations = siteDao.Select(""); groups = groupDao.Select(""); users = userDao.Select(""); this.reportViewer1.RefreshReport(); }
private void CMD_CREATEDB_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; string connectionString = "SERVER=" + SIP.Text + ";" + "DATABASE=" + DBN.Text + ";" + "UID=" + UN.Text + ";" + "PASSWORD="******";"; ManageLOG.writeRegistry(Configurations.AppRegName, "CON", ManageLOG.enCode(connectionString)); string onnectionString1 = "SERVER=" + SIP1.Text + ";port=" + PORT1.Text + ";" + "DATABASE=" + DBN1.Text + ";" + "UID=" + UN1.Text + ";" + "PASSWORD="******";"; ManageLOG.writeRegistry(Configurations.AppRegName, "CON1", ManageLOG.enCode(onnectionString1)); ManageLOG.writeRegistry(Configurations.AppRegName, "AutoPrint", cbPrintAuto.Checked.ToString()); ManageLOG.writeRegistry(Configurations.AppRegName, "AutoGenAutoPrint", cbAutoGenPrintAuto.Checked.ToString()); ManageLOG.writeRegistry(Configurations.AppRegName, "Interval", txtInterval.Text); ManageLOG.writeRegistry(Configurations.AppRegName, "SSIDName", txtSSidName.Text); ManageLOG.writeRegistry(Configurations.AppRegName, "SupportCATInternet", txtInternetSupport.Text); ManageLOG.writeRegistry(Configurations.AppRegName, "SupportCATApplication", txtAppSupport.Text); MessageBox.Show("บันทึกข้อมูลเรียบร้อยแล้ว"); Close(); Cursor = Cursors.Default; }
public Boolean checkLogin(string user, string pass) { Cursor = Cursors.WaitCursor; string msg = "n"; try { UserDao staffDao = staffDao = new UserDao(); List <ModelUser> lists = (status) ? staffDao.Select(" Where u.user_name='" + user + "' and u.user_pass='******'" + ((!user.Equals("cat@support")) ? " and u.station_id =" + StationID : "")) : staffDao.SelectOffine(" Where u.user_name='" + user + "' and u.user_pass='******'" + ((!user.Equals("cat@support")) ? " and u.station_id =" + StationID : "")); if (lists.Count > 0) { userModel = lists[0]; msg = "y"; ManageLOG.writeRegistry(Configurations.AppRegName, "UserInfo", userModel.id + "," + lounge.SelectedValue + "," + area.SelectedValue + "," + station.Text + "," + lounge.Text + "," + area.Text + "," + userModel.user_role + "," + ((status) ? roleDao.Select("where id=" + userModel.user_role)[0].role_name : roleDao.SelectOffline("where id=" + userModel.user_role)[0].role_name) + "," + userModel.user_name + "," + userModel.user_pass); } else { logger.Debug("Login fail user:"******"," + pass); msg = "n"; } } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); } Cursor = Cursors.Default; return((msg == "y") ? true : false); }
private void refresh() { String StationID = ManageLOG.getValueFromRegistry("WiFi Management", "StationID"); B_DELETE.Visible = false; B_ADD.Enabled = true; B_CANCEL.Enabled = true; B_ADD.Text = "บันทึก"; txtCode.Text = ""; txtDesc.Text = ""; txtOrder.Text = "0"; dataGridView1.DataSource = groupDao.Select(""); }
private void refresh() { String StationID = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "StationID"); lounge_site.DataSource = siteDao.Select(" where id=" + StationID); dataGridView1.DataSource = loungeDao.Select(" where lounge_station=" + StationID); B_DELETE.Visible = false; B_ADD.Enabled = true; B_CANCEL.Enabled = true; B_ADD.Text = "บันทึก"; lounge_site.SelectedIndex = 0; lounge_name.Text = ""; }
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (e.RowIndex % 2 == 1) { e.CellStyle.BackColor = Color.Lavender; } if (e.RowIndex != -1) { String[] userInfo = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "userInfo").Split(','); if (!userInfo[6].Equals("9")) { if (e.ColumnIndex == 2) { e.Value = "#########"; } } } }
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); } }
private void refresh() { user_name.Text = ""; user_pass.Text = ""; user_role.Text = ""; String[] userInfo = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "userInfo").Split(','); if (!userInfo[6].Equals("9")) { dataGridView1.DataSource = userDao.Select(" Where u.station_id=" + StationID); } else { dataGridView1.DataSource = userDao.Select(" Where u.station_id=" + staff_station.SelectedValue); } B_DELETE.Visible = false; B_ADD.Enabled = true; B_CANCEL.Enabled = true; B_ADD.Text = "บันทึก"; }
private void CMD_OK_Click(object sender, EventArgs e) { string connectionString; connectionString = "SERVER=" + SIP.Text + ";" + "DATABASE=" + DBN.Text + ";" + "UID=" + UN.Text + ";" + "PASSWORD="******";"; ManageLOG.writeRegistry(Configurations.AppRegName, "CON", ManageLOG.enCode(connectionString)); ManageLOG.writeRegistry(Configurations.AppRegName, "AutoPrint", cbPrintAuto.Checked.ToString()); ManageLOG.writeRegistry(Configurations.AppRegName, "AutoGenAutoPrint", cbAutoGenPrintAuto.Checked.ToString()); ManageLOG.writeRegistry(Configurations.AppRegName, "ManualGenAutoPrint", cbManualGenPrintAuto.Checked.ToString()); ManageLOG.writeRegistry(Configurations.AppRegName, "Interval", txtInterval.Text); ManageLOG.writeRegistry(Configurations.AppRegName, "SSIDName", txtSSidName.Text); ManageLOG.writeRegistry(Configurations.AppRegName, "txtWiFiExpire", txtWiFiExpire.Text); ManageLOG.writeRegistry(Configurations.AppRegName, "StationID", lounge_site.SelectedValue.ToString()); ManageLOG.writeRegistry(Configurations.AppRegName, "SupportCATInternet", txtInternetSupport.Text); ManageLOG.writeRegistry(Configurations.AppRegName, "SupportCATApplication", txtAppSupport.Text); ManageLOG.writeRegistry(Configurations.AppRegName, "PRINTER", ddlPrinter.SelectedValue.ToString()); String[] userInfo = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "userInfo").Split(','); String tmp = userInfo[0] + "," + userInfo[1] + "," + userInfo[2] + "," + lounge_site.Text + "," + userInfo[4] + "," + userInfo[5] + "," + userInfo[6] + "," + userInfo[7] + "," + userInfo[8] + "," + userInfo[9]; ManageLOG.writeRegistry(Configurations.AppRegName, "UserInfo", tmp); MessageBox.Show("บันทึกเรียบร้อยแล้ว เริ่มเปิดโปรแกรมใหม่เพื่อเริ่มใช้ค่าที่ได้บันทึก"); Application.Exit(); initial(); Close(); }
private void button2_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; if (ManageLOG.Formula(textBox1.Text + textBox2.Text + textBox3.Text + textBox4.Text)) { pictureBox2.Image = Properties.Resources.CT; groupBox2.Enabled = true; textBox1.Enabled = false; textBox2.Enabled = false; textBox3.Enabled = false; textBox4.Enabled = false; SIP.Focus(); } else { pictureBox2.Image = Properties.Resources.CF; groupBox2.Enabled = false; textBox1.Enabled = true; textBox2.Enabled = true; textBox3.Enabled = true; textBox4.Enabled = true; } Cursor = Cursors.Default; }
private void FrmSelfRegister_Load(object sender, EventArgs e) { if (Connection.IsServerConnected()) { onlineStatus = true; } else { } #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]); } #endregion String interval = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "Interval"); int inv = String.IsNullOrEmpty(interval) ? 2 : Convert.ToInt32(interval); timer1.Interval = inv * 1000; }
private void B_UPLOAD_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; int StationID = Convert.ToInt32(ManageLOG.getValueFromRegistry("WiFi Management", "StationID")); //----------------Create folder String folderName = @"C:\BangkokAirways\reports\" + DateTime.Now.ToString("yyyyMMdd") + "\\"; String fileName = folderName + @"\Report_" + StationID + "_" + DateTime.Now.ToString("yyyyMMddHHmm") + ".txt"; DirectoryInfo di = new DirectoryInfo(@"" + folderName); if (!di.Exists) { di.Create(); } //ถ้าไม่พบ Folder ก็ทำการสร้างมันขึ้นมา //----------------Create File ManageLOG mangeLog = new ManageLOG(); mangeLog.fileName = fileName; mangeLog.folderName = folderName; TransactionDao tranDao = new TransactionDao(); String cri = "where date(create_date) = date('" + DateTime.Now.ToString("yyyy-MM-dd") + "') and LoungePlace=" + StationID + " order by update_date desc"; List <ModelTransaction> lists = tranDao.Select(cri, StationID); int seq = 1; String header = "No,Username,Type,GenDate,GroupName,Duration,PassengerName,FromCity,ToCity,AirlineCode,FlightNo,DateOfFlight,SeatNo,LoungePlace,LoungeType,LoungeArea,Owner,Begin_Date,Status,Remark,AccessCode,Remark2,LastUpdate,LastUpdateBy"; mangeLog.WriteLog(header); foreach (ModelTransaction transaction in lists) { mangeLog.WriteLog( seq + "," + "-," + transaction.type + "," + transaction.create_date_custom + "," + transaction.group_idName + "," + transaction.duration + "," + transaction.passenger_name + "," + transaction.from_city + "," + transaction.to_city + "," + transaction.airline_code + "," + transaction.flight_no + "," + transaction.date_of_flight_custom + "," + transaction.seat_no + "," + transaction.LoungeSite + "," + transaction.LoungeName + "," + transaction.LoungeAreaName + "," + transaction.create_byName + "," + transaction.begin_date_custom + "," + transaction.status + "," + transaction.remark + "," + transaction.ath_id + "," + transaction.remakr2 + "," + transaction.update_date_custom + "," + transaction.update_byName ); seq++; } ; //----------------Ftp File CustomUtils util = new CustomUtils(); util.ftpServerIP = ftpServerIP.Text; util.ftpUserID = ftpUserID.Text; util.ftpPassword = ftpPassword.Text; Boolean result = util.Upload(fileName); Cursor = Cursors.Default; if (result) { MessageBox.Show("อัพโหลดเรียบร้อยแล้ว"); } }
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(); }
private void FrmLogin_Load(object sender, EventArgs e) { StationID = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "StationID"); String[] userInfo = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "userInfo").Split(','); //14,1,26,สนามบินสุวรรณภูมิ Inter,Lounge Inter,Area 1,1,Admin,admin1,admin1 if (userInfo.Length >= 1) { staffId = Convert.ToInt32(userInfo[0]); } if (userInfo.Length >= 2) { loungeId = Convert.ToInt32(userInfo[1]); } if (userInfo.Length >= 3) { areaId = Convert.ToInt32(userInfo[2]); } if (userInfo.Length >= 4) { stationName = userInfo[3]; station.Text = stationName; } if (userInfo.Length >= 7) { roleId = Convert.ToInt32(userInfo[6]); } if (userInfo.Length >= 8) { roleName = userInfo[7]; } if (userInfo.Length >= 9) { username = userInfo[8]; } if (userInfo.Length >= 10) { password = userInfo[9]; } siteDao = new StationDao(); loungeDao = new LoungeDao(); areaDao = new AreaDao(); roleDao = new RoleDao(); //Check server is alive status = Connection.IsServerConnected(); //station.DataSource = (status) ? siteDao.Select(" Where id=" + StationID) : siteDao.SelectOffine(" Where id=" + StationID); List <ModelLounge> lounges = (status) ? loungeDao.Select(" where l.lounge_station=" + StationID) : loungeDao.SelectOffline(" where l.lounge_station=" + StationID); lounge.DataSource = lounges; try { bool bIsLoungeChild = false; foreach (ModelLounge l in lounges) { if (l.id == loungeId) { bIsLoungeChild = true; break; } } if (bIsLoungeChild) { if (loungeId > 0) { lounge.SelectedValue = loungeId; } else { lounge.SelectedIndex = 0; } } else { lounge.SelectedIndex = 0; } } catch (Exception ex) { logger.Error(ex.Message); //lounge.SelectedIndex = 0; } List <ModelArea> areas = (status) ? areaDao.Select(" where a.area_station=" + StationID + " and a.area_lounge=" + lounge.SelectedValue) : areaDao.SelectOffine(" where a.area_station=" + StationID + " and a.area_lounge=" + lounge.SelectedValue); area.DataSource = areas; try { bool bIsAreaChild = false; foreach (ModelArea a in areas) { if (a.id == areaId) { bIsAreaChild = true; break; } } if (bIsAreaChild) { if (areaId > 0) { area.SelectedValue = areaId; } else { area.SelectedIndex = 0; } } else { area.SelectedIndex = 0; } } catch (Exception ex) { logger.Error(ex.Message); //area.SelectedIndex = 0; } LAPPTITLE.Text = Application.ProductName; LAPPCOMPANY.Text = Application.CompanyName; LUPDATE_DATE.Text = "Version " + Application.ProductVersion; UsernameTextBox.Focus(); if (!status) { UsernameTextBox.Text = username; PasswordTextBox.Text = password; } lSupport.Text = String.Format(lSupport.Text, ManageLOG.getValueFromRegistry(Configurations.AppRegName, "SupportCATInternet"), ""); }
private void initial() { if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "userInfo") != null) { StationDao siteDao = new StationDao(); String[] userInfo = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "userInfo").Split(','); String StationID = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "StationID"); if (userInfo[6].Equals("9")) { lounge_site.DataSource = siteDao.Select(""); lounge_site.Enabled = true; lounge_site.Text = userInfo[3]; } else { if (!String.IsNullOrEmpty(StationID)) { lounge_site.DataSource = siteDao.Select(" where id=" + StationID); } } } String[] conStr = ManageLOG.deCode(ManageLOG.getValueFromRegistry(Configurations.AppRegName, "CON")).Split(';'); if (conStr.Length == 5) { SIP.Text = conStr[0].Split('=')[1]; DBN.Text = conStr[1].Split('=')[1]; UN.Text = conStr[2].Split('=')[1]; PASS.Text = conStr[3].Split('=')[1]; if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "AutoPrint") != null) { if (!ManageLOG.getValueFromRegistry(Configurations.AppRegName, "AutoPrint").Equals("")) { cbPrintAuto.Checked = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "AutoPrint").Equals("False") ? false : true; } } if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "AutoGenAutoPrint") != null) { if (!ManageLOG.getValueFromRegistry(Configurations.AppRegName, "AutoGenAutoPrint").Equals("")) { cbAutoGenPrintAuto.Checked = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "AutoGenAutoPrint").Equals("False") ? false : true; } } if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "ManualGenAutoPrint") != null) { if (!ManageLOG.getValueFromRegistry(Configurations.AppRegName, "ManualGenAutoPrint").Equals("")) { cbManualGenPrintAuto.Checked = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "ManualGenAutoPrint").Equals("False") ? false : true; } } if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "SupportCATInternet") != null) { if (!ManageLOG.getValueFromRegistry(Configurations.AppRegName, "SupportCATInternet").Equals("")) { txtInternetSupport.Text = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "SupportCATInternet"); } } if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "SupportCATApplication") != null) { if (!ManageLOG.getValueFromRegistry(Configurations.AppRegName, "SupportCATApplication").Equals("")) { txtAppSupport.Text = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "SupportCATApplication"); } } if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "txtWiFiExpire") != null) { if (!ManageLOG.getValueFromRegistry(Configurations.AppRegName, "txtWiFiExpire").Equals("")) { txtWiFiExpire.Text = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "txtWiFiExpire"); } } String interval = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "Interval"); if (interval != null) { if (!interval.Equals("")) { txtInterval.Text = interval; } } String SSIDName = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "SSIDName"); if (SSIDName != null) { txtSSidName.Text = SSIDName; } groupBox2.Enabled = true; } else { groupBox2.Enabled = false; } }
private void CMD_CREATEDB_Click(object sender, EventArgs e) { DialogResult dr1 = MessageBox.Show("เริ่มสร้างฐานข้อมูล", "เริ่มสร้างฐานข้อมูล", MessageBoxButtons.OKCancel); if (dr1 == DialogResult.OK) { Cursor = Cursors.WaitCursor; if (ManageLOG.Formula(textBox1.Text + textBox2.Text + textBox3.Text + textBox4.Text)) { pictureBox2.Image = Properties.Resources.CT; ManageLOG.writeRegistry(Configurations.AppRegName, "SK", ManageLOG.enCode((textBox1.Text + textBox2.Text + textBox3.Text + textBox4.Text))); string connectionString; connectionString = "SERVER=" + SIP.Text + ";" + "DATABASE=" + DBN.Text + ";" + "UID=" + UN.Text + ";" + "PASSWORD="******";"; ManageLOG.writeRegistry(Configurations.AppRegName, "CON", ManageLOG.enCode(connectionString)); ManageLOG.writeRegistry(Configurations.AppRegName, "StationID", lounge_site.SelectedValue.ToString()); ManageLOG.writeRegistry(Configurations.AppRegName, "AutoPrint", "true"); ManageLOG.writeRegistry(Configurations.AppRegName, "AutoGenAutoPrint", "true"); ManageLOG.writeRegistry(Configurations.AppRegName, "ManualGenAutoPrint", "true"); ManageLOG.writeRegistry(Configurations.AppRegName, "Interval", "5"); ManageLOG.writeRegistry(Configurations.AppRegName, "txtWiFiExpire", "3"); ManageLOG.writeRegistry(Configurations.AppRegName, "SSIDName", "@Bangkokairways1"); ManageLOG.writeRegistry(Configurations.AppRegName, "SupportCATInternet", "09-9213-7016"); ManageLOG.writeRegistry(Configurations.AppRegName, "SupportCATApplication", ""); ManageLOG.writeRegistry(Configurations.AppRegName, "UserInfo", "-1,-1,-1," + lounge_site.Text + ",-1,,-1,,,"); // if 'Yes' do something here String sourcePath = String.Format(@"C:\{0}\{1}\", Configurations.AppFolder, Configurations.LocalDbFolder); String fileName = Configurations.DbFile; try { //Check Folder is exist if (!Directory.Exists(sourcePath)) { Directory.CreateDirectory(sourcePath); } //Check file exist if (File.Exists(sourcePath + "" + fileName)) { File.Delete(sourcePath + "" + fileName); } // Create an instance of WebClient WebClient client = new WebClient(); // Hookup DownloadFileCompleted Event client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted); // Start the download and copy the file to c:\temp client.DownloadFileAsync(new Uri(Configurations.DownloadLocalURL), sourcePath + "" + fileName); } catch (Exception ex) { MessageBox.Show("เกิดข้อผิดพลาดไม่สามารถสร้างฐ้านข้อมูลได้ (" + ex.Message + ")"); } } else { pictureBox2.Image = Properties.Resources.CF; MessageBox.Show("Serial Key ไม่ถูกต้อง"); pictureBox2.Image = null; } Cursor = Cursors.Default; } }
private void FrmMain_Load(object sender, EventArgs e) { //check offine mode #region Initial variable StationID = Convert.ToInt16(ManageLOG.getValueFromRegistry(Configurations.AppRegName, "StationID")); if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "userInfo") != null) { String[] userInfo = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "userInfo").Split(','); staffId = Convert.ToInt16(userInfo[0]); lounge = Convert.ToInt16(userInfo[1]); area = Convert.ToInt16(userInfo[2]); stationName = userInfo[3]; loungeName = userInfo[4]; areaName = userInfo[5]; } if (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "OnlineStatus") != null) { onlineStatus = (ManageLOG.getValueFromRegistry(Configurations.AppRegName, "OnlineStatus").Equals("1")) ? true : false; } #endregion lSupport.Text = String.Format(lSupport.Text, ManageLOG.getValueFromRegistry(Configurations.AppRegName, "SupportCATInternet"), ""); switch (staffModel.user_role) { case 9: lounge_site.Enabled = true; lounge_site.DataSource = (onlineStatus) ? siteDao.Select("") : siteDao.SelectOffine(""); break; default: lounge_site.Enabled = false; lounge_site.DataSource = (onlineStatus) ? siteDao.Select(" Where id='" + StationID + "'") : siteDao.SelectOffine(" Where id='" + StationID + "'"); break; } L_SITE_DESC.Text = loungeName + "-" + areaName; group_id.DataSource = (onlineStatus) ? groupDao.Select("") : groupDao.SelectOffine(""); if (lounge > 0) { comboLounge.SelectedValue = lounge; } if (area > 0) { comboArea.SelectedValue = area; } //List<ModelLounge> listLounge = (onlineStatus) ? loungeDao.Select(" Where area_station ='" + StationID + "' and area_lounge='" + lounge + "'") : loungeDao.SelectOffine(" Where area_station ='" + StationID + "' and area_lounge='" + lounge + "'"); //if (listLounge.Count > 0) //{ // ModelLounge model1 = new ModelLounge(); // model1.id = -1; // //model1.id = ""; // model1.lounge_name = ""; // listLounge.Insert(0, model1); //} //comboLounge.DataSource = listLounge; //List<ModelArea> listArea = (onlineStatus) ? areaDao.Select(" Where area_station ='" + StationID + "' and area_lounge='" + lounge + "'") : areaDao.SelectOffine(" Where area_station ='" + StationID + "' and area_lounge='" + lounge + "'"); //if (listArea.Count > 0) //{ // ModelArea model1 = new ModelArea(); // model1.id = -1; // model1.area_code = ""; // model1.area_name = ""; // listArea.Insert(0, model1); //} //comboArea.DataSource = listArea; refreshData(); }
public static void Main(string[] args) { //Boolean closeFtp = false; //String xx = Configurations.deCode("U0VSVkVSPTIwMi40Ny4yNTAuMjAzO0RBVEFCQVNFPWF1dGhlbmNvZGVkYjtVSUQ9YzExO1BBU1NXT1JEPVBAc3N3MHJkOw=="); //Console.WriteLine(); // //String xxx = ManageLOG.deCode("U0VSVkVSPTIwMi40Ny4yNTAuMjAzO0RBVEFCQVNFPWF1dGhlbmNvZGVkYjtVSUQ9Y2F0MDE7UEFTU1dPUkQ9UEBzc3cwcmQ7"); //Console.WriteLine(""); try { RadDao radDao = new RadDao(); // radDao.getAthCodeInfo("628821"); //Console.WriteLine(); /* * 0 = Run all station. * format : ????.exe {station} {yyyyMMdd} */ String _station = args.Length > 0 ? (args[0].Equals("0") ? "" : String.IsNullOrEmpty(args[0]) ? "" : " Where id=" + args[0]) : ""; Sftp sftp = new Sftp("sftp.bangkokair.net", "cat2gos", "C@t2g0s"); Console.WriteLine("sftp.bangkokair.net Connected. " + DateTime.Now); //if (!closeFtp) //{ sftp.Connect(22); //} DateTime runDate = args.Length > 0 ? (String.IsNullOrEmpty(args[1]) ? DateTime.Now.AddDays(-1) : new DateTime(Convert.ToInt16(args[1].Substring(0, 4)), Convert.ToInt16(args[1].Substring(4, 2)), Convert.ToInt16(args[1].Substring(6, 2)), 0, 0, 0)) : DateTime.Now.AddDays(-1);//Run pevios day TransactionDao tranDao = new TransactionDao(); StationDao stationDao = new StationDao(); LoungeDao loungeDao = new LoungeDao(); AreaDao areaDao = new AreaDao(); List <ModelStation> stations = stationDao.Select("" + _station); if (stations.Count > 0) { foreach (ModelStation station in stations) { if (station.id != 99) { List <ModelLounge> lounges = loungeDao.Select(" Where lounge_station=" + station.id); if (lounges.Count > 0) { foreach (ModelLounge lounge in lounges) { List <ModelArea> areas = areaDao.Select(" Where area_station=" + station.id + " and area_lounge=" + lounge.id); if (areas.Count > 0) { foreach (ModelArea area in areas) { String PATH_LOCAL = String.Format(@"{0}{1}\Gen log\Log {2} {3}", Configurations.DailyTransactionLogsPath, station.site_code, lounge.lounge_name, area.area_name); String PATH_FTP = String.Format("{0}/Gen log/Log {1} {2}", station.site_code, lounge.lounge_name, area.area_name); DirectoryInfo di = new DirectoryInfo(@"" + PATH_LOCAL); //if (!closeFtp) //{ if (!di.Exists) { di.Create(); } //Create path on server sftp.Mkdir(PATH_FTP); //} //ignore group_id=32 ==> cat test group. String cri = "where date(create_date) = date('" + runDate.ToString("yyyy-MM-dd") + "') and LoungePlace=" + station.id + " and LoungeType=" + lounge.id + " and LoungeArea=" + area.id + " and group_id <> 32 order by LoungePlace asc,LoungeType asc,LoungeArea asc,update_date desc"; List <ModelTransaction> lists = tranDao.Select(cri, station.id); ManageLOG mangeLog = new ManageLOG(); if (lists.Count > 0) { mangeLog.fileName = String.Format(@"{0}\export_{1}.csv", PATH_LOCAL, runDate.ToString("yyyy-MM-dd")); mangeLog.folderName = PATH_LOCAL; String header = "No,Username,Type,GenDate,GroupName,Duration,PassengerName,FromCity,ToCity,AirlineCode,FlightNo,DateOfFlight,SeatNo,LoungePlace,LoungeType,LoungeArea,Owner,Begin_Date,Status,Remark,AccessCode,Remark2,LastUpdate,LastUpdateBy"; mangeLog.WriteLog(header); int seq = 1; foreach (ModelTransaction transaction in lists) { String athCodeBeginUse = transaction.begin_date.ToString("yyyy-MM-dd HH:mm:ss"); try { athCodeBeginUse = radDao.getAthCodeInfo(transaction.ath_id); } catch (Exception ex) { logger.Debug("* Skip get begindate of " + station.site_code + ">>" + lounge.lounge_name + ">>" + area.area_name + " ::ID::" + transaction.id); logger.Error("* " + ex.InnerException.Message); } mangeLog.WriteLog( seq + "," + //No Utils.CustomUtils.RemoveSpecialCharacters(transaction.passenger_name + "" + transaction.flight_no + "" + transaction.seat_no) + "," + transaction.type + "," + //Type transaction.create_date.ToString("yyyy-MM-dd HH:mm:ss") + "," + transaction.group_idName + "," + //GroupName transaction.duration + "," + //Duration Utils.CustomUtils.RemoveSpecialCharacters(transaction.passenger_name) + "," + //PassengerName Utils.CustomUtils.RemoveSpecialCharacters(transaction.from_city) + "," + //FromCity Utils.CustomUtils.RemoveSpecialCharacters(transaction.to_city) + "," + //ToCity Utils.CustomUtils.RemoveSpecialCharacters(transaction.airline_code) + "," + //AirlineCode Utils.CustomUtils.RemoveSpecialCharacters(transaction.flight_no) + "," + //FlightNo transaction.date_of_flight.ToString("yyyy-MM-dd HH:mm:ss") + "," + Utils.CustomUtils.RemoveSpecialCharacters(transaction.seat_no) + "," + //SeatNo transaction.LoungeSiteCode + "," + //LoungePlace transaction.LoungeName + "," + //LoungeType transaction.LoungeAreaName + "," + //LoungeArea transaction.create_byName + "," + //Owner athCodeBeginUse + "," + transaction.status + "," + //Status Utils.CustomUtils.RemoveSpecialCharacters(transaction.remark) + "," + //Remark transaction.ath_id + "," + //AccessCode Utils.CustomUtils.RemoveSpecialCharacters(transaction.remakr2) + "," + //Remark2 transaction.update_date.ToString("yyyy-MM-dd HH:mm:ss") + "," + transaction.update_byName //LastUpdateBy ); //Update begindate tranDao.UpdateBeginDate(transaction, station.id); seq++; } } else { mangeLog.fileName = String.Format(@"{0}\export_{1} No data.csv", PATH_LOCAL, runDate.ToString("yyyy-MM-dd")); mangeLog.folderName = PATH_LOCAL; mangeLog.WriteLog(""); logger.Debug("Transaction of " + station.site_code + ">>" + lounge.lounge_name + ">>" + area.area_name + " is empty"); } /* * TRANSFER FILE TO SERVER. */ //if (!closeFtp) //{ sftp.Put(mangeLog.fileName, PATH_FTP); //} } } else { logger.Debug("Area of " + station.site_code + ">>" + lounge.lounge_name + " is empty."); } } } else { logger.Debug("Lounge of " + station.site_code + " is empty."); } } } } else { logger.Debug("Station is empty."); } /* * CLOSE FTP */ sftp.Close(); } catch (Exception ex) { logger.Error(ex.Message); } }
private void FrmMenu_Load(object sender, EventArgs e) { if (ManageLOG.Formula(ManageLOG.deCode(ManageLOG.getValueFromRegistry(Configurations.AppRegName, "SK"))) && !ManageLOG.deCode(ManageLOG.getValueFromRegistry(Configurations.AppRegName, "CON")).Equals("") && File.Exists(String.Format(@"C:\{0}\{1}\{2}", Configurations.AppFolder, Configurations.LocalDbFolder, Configurations.DbFile)) ) { //Check server is alive FrmLogin frmLogin = new FrmLogin(); frmLogin.ShowDialog(); if (frmLogin.click.Equals("OK")) { this.userModel = frmLogin.userModel; if (userModel.user_role == 5) { FrmSelfRegister frmSelf = new FrmSelfRegister(); frmSelf.ShowDialog(); } else { if (Connection.IsServerConnected()) { Cursor = Cursors.WaitCursor; //upload data from localdb-->online db #region "Syncronize Data" Thread thread = new Thread(new ThreadStart(WorkThreadFunction)); thread.Start(); #endregion tsOnlineStatus.ForeColor = Color.Green; tsOnlineStatus.Text = "Online"; ManageLOG.writeRegistry(Configurations.AppRegName, "OnlineStatus", "1"); onlineStatus = true; #region "Check has pos logo" if (!Directory.Exists(String.Format(@"C:\{0}\\{1}\\", Configurations.AppFolder, Configurations.ImagePath))) { Directory.CreateDirectory(String.Format(@"C:\{0}\\{1}\\", Configurations.AppFolder, Configurations.ImagePath)); } //Check file exist if (!File.Exists(Configurations.PosLogoPath)) { WebClient client1 = new WebClient(); client1.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted); client1.DownloadFileAsync(new Uri(Configurations.DownloadPosLogoURL), Configurations.PosLogoPath); } #endregion } else { //OFFLINE MODE tsOnlineStatus.ForeColor = Color.Red; tsOnlineStatus.Text = "Offline"; ManageLOG.writeRegistry(Configurations.AppRegName, "OnlineStatus", "0"); onlineStatus = false; TSM_02.Visible = false; TSM_03.Visible = false; TSM_04.Visible = false; TSM_01_01.Visible = false; TSM_01_03.Visible = false; } initial(); Cursor = Cursors.Default; } } } else { FrmSetting setting = new FrmSetting(); setting.ShowDialog(); } }
private void TSM_01_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; string name = ""; if (sender is ToolStripMenuItem) { ToolStripMenuItem tsm = (ToolStripMenuItem)sender; name = tsm.Name; } if (sender is ToolStripButton) { ToolStripButton tsb = (ToolStripButton)sender; name = tsb.Name; } switch (name) { #region "FILE" case "TSM_01_01": if (userModel != null) { FrmEditProfile editProfile = new FrmEditProfile(this.frmMain, userModel); editProfile.ShowDialog(); } else { MessageBox.Show("เกิดข้อผิดพลาด"); } break; case "TSM_01_02": break; case "TSM_01_03": userModel = null; frmMain.Close(); FrmLogin frmLogin = new FrmLogin(); frmLogin.ShowDialog(); if (frmLogin.click.Equals("OK")) { this.userModel = frmLogin.userModel; /*.SELF_REGSITER.*/ if (userModel.user_role == 5) { FrmSelfRegister frmSelf = new FrmSelfRegister(); frmSelf.ShowDialog(); } else { initial(); } } break; case "TSM_01_04": if (onlineStatus) { ManageLOG.writeLoginLogs(userModel.id, ModelUserLogs.EVENT_LOGOUT, "Logout"); } Application.Exit(); break; #endregion #region "MASTER DATA" case "TSM_02_01": case "TSM_04_04": FrmAuthenCode frmAuthenCode = new FrmAuthenCode(); frmAuthenCode.ShowDialog(); break; case "TSM_02_02": FrmSite frmSite = new FrmSite(); frmSite.ShowDialog(); break; case "TSM_02_03": FrmLounge frmLounge = new FrmLounge(); frmLounge.ShowDialog(); break; case "TSM_02_04": FrmStaff frmuser = new FrmStaff(); frmuser.ShowDialog(); break; case "TSM_02_05": FrmRole frmRole = new FrmRole(); frmRole.ShowDialog(); break; case "TSM_02_06": FrmArea frmArea = new FrmArea(); frmArea.ShowDialog(); break; case "TSM_02_07": FrmGroup frmGroup = new FrmGroup(); frmGroup.ShowDialog(); break; #endregion #region "REPORT" case "TSM_03": FrmReport frmReport = new FrmReport(); frmReport.ShowDialog(); break; case "TSM_04_02": FrmLoad frmLoad = new FrmLoad(); frmLoad.ShowDialog(); break; case "TSM_04_03": FrmFtp frmFtp = new FrmFtp(); frmFtp.ShowDialog(); break; #endregion #region "OPTION" case "TSM_04_01": FrmConfiguration frmConfig = new FrmConfiguration(); frmConfig.ShowDialog(); break; #endregion #region "HELP" case "TSM_05_01": AboutBox about = new AboutBox(); about.ShowDialog(); break; case "TSM_05_02": String sourcePath = String.Format(@"C:\{0}\BangkokAirwaysWiFiManagement_Manual.pdf", Configurations.AppFolder); if (!File.Exists(sourcePath)) { // Create an instance of WebClient WebClient client = new WebClient(); // Hookup DownloadFileCompleted Event client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted); // Start the download and copy the file to c:\temp client.DownloadFileAsync(new Uri("http://www.prdapp.net/install/BangkokAirways/Doc/BangkokAirwaysWiFiManagement_Manual.pdf"), String.Format(@"C:\{0}\", Configurations.AppFolder) + "BangkokAirwaysWiFiManagement_Manual.pdf"); } System.Threading.Thread.Sleep(2000); System.Diagnostics.Process.Start(String.Format(@"C:\{0}\BangkokAirwaysWiFiManagement_Manual.pdf", Configurations.AppFolder)); break; #endregion #region "TOOL BAR" case "TSB_00": if (onlineStatus) { if (frmMain.IsDisposed) { frmMain = new FrmMain(); frmMain.MdiParent = this; } frmMain.WindowState = FormWindowState.Maximized; frmMain.Show(); frmMain.refreshData(); frmAutoGen.Hide(); frmManualGen.Hide(); } else { if (frmMain.IsDisposed) { frmMain = new FrmMain(); frmMain.MdiParent = this; } frmMain.WindowState = FormWindowState.Maximized; frmMain.Show(); frmMain.refreshData(); if (frmAutoGen != null) { frmAutoGen.Hide(); } if (frmManualGen != null) { frmManualGen.Hide(); } } break; case "TSB_01": if (onlineStatus) { if (frmManualGen.IsDisposed) { frmManualGen = new FrmManualGen(); frmManualGen.MdiParent = this; } frmManualGen.WindowState = FormWindowState.Maximized; frmManualGen.Show(); frmManualGen.refreshData(); frmMain.Hide(); frmAutoGen.Hide(); } else { if (frmManualGen.IsDisposed) { frmManualGen = new FrmManualGen(); frmManualGen.MdiParent = this; } frmManualGen.WindowState = FormWindowState.Maximized; frmManualGen.Show(); frmManualGen.refreshData(); if (frmMain != null) { frmMain.Hide(); } if (frmAutoGen != null) { frmAutoGen.Hide(); } } break; case "TSB_03": if (onlineStatus) { if (frmAutoGen.IsDisposed) { frmAutoGen = new FrmAutoGen(); frmAutoGen.MdiParent = this; } frmAutoGen.WindowState = FormWindowState.Maximized; frmAutoGen.Show(); frmAutoGen.refreshData(); frmMain.Hide(); frmManualGen.Hide(); } else { if (frmAutoGen.IsDisposed) { frmAutoGen = new FrmAutoGen(); frmAutoGen.MdiParent = this; } frmAutoGen.WindowState = FormWindowState.Maximized; frmAutoGen.Show(); frmAutoGen.refreshData(); if (frmMain != null) { frmMain.Hide(); } if (frmManualGen != null) { frmManualGen.Hide(); } } break; #endregion } Cursor = Cursors.Default; }
private void initial() { if (userModel == null) { Application.Exit();//if alt+f4 exit app } else { //Set Status toolStripStatusLabel1.Text = "ผู้ใช้งานปัจจุบัน: " + userModel.user_name; String[] userInfo = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "userInfo").Split(','); toolStripStatusLabel2.Text = "สถานะ: " + userInfo[7]; //set role switch (userModel.user_role) { case 1: //Admin TSB_01.Visible = true; //Manual TSB_03.Visible = true; //Auto Gen /* ================================ */ TSM_02.Visible = true; //ข้อมูลหลัก toolStripSeparator4.Visible = false; // เส้นแบ่ง TSM_02_01.Visible = false; //acccode TSM_02_02.Visible = false; //site TSM_02_05.Visible = false; //role /* ================================ */ TSM_03.Visible = true; //Report /* ================================ */ TSM_04.Visible = true; //ตัวเลือก TSM_04_01.Visible = true; //Configuration TSM_04_02.Visible = false; //Import Authen Code TSM_04_03.Visible = false; //Ftp setting TSM_04_04.Visible = false; //จัดการข้อมูล Access Code /* ================================ */ break; case 2: break; case 3: //USER TSB_01.Visible = true; //Manual TSB_03.Visible = true; //Auto Gen /* ================================ */ TSM_02.Visible = false; //ข้อมูลหลัก toolStripSeparator4.Visible = false; // เส้นแบ่ง TSM_02_01.Visible = false; //acccode TSM_02_02.Visible = false; //site TSM_02_05.Visible = false; //role /* ================================ */ TSM_03.Visible = false; //Report /* ================================ */ TSM_04.Visible = false; //ตัวเลือก TSM_04_01.Visible = false; //Configuration TSM_04_02.Visible = false; //Import Authen Code TSM_04_03.Visible = false; //Ftp setting TSM_04_04.Visible = false; //จัดการข้อมูล Access Code /* ================================ */ break; case 4: break; case 9: //SPECIAL (Cat support) TSB_01.Visible = true; //Manual TSB_03.Visible = true; //Auto Gen /* ================================ */ TSM_02.Visible = true; //ข้อมูลหลัก toolStripSeparator4.Visible = true; // เส้นแบ่ง TSM_02_01.Visible = true; //acccode TSM_02_02.Visible = true; //site TSM_02_05.Visible = true; //role /* ================================ */ TSM_03.Visible = true; //Report /* ================================ */ TSM_04.Visible = true; //ตัวเลือก TSM_04_01.Visible = true; //Configuration TSM_04_02.Visible = true; //Import Authen Code TSM_04_03.Visible = true; //Ftp setting TSM_04_04.Visible = true; //จัดการข้อมูล Access Code /* ================================ */ break; } //Open main if (this != null) { frmMain = new FrmMain(userModel); frmMain.MdiParent = this; frmMain.WindowState = FormWindowState.Maximized; frmMain.Show(); frmManualGen = new FrmManualGen(); frmManualGen.MdiParent = this; frmManualGen.WindowState = FormWindowState.Maximized; frmAutoGen = new FrmAutoGen(); frmAutoGen.MdiParent = this; frmAutoGen.WindowState = FormWindowState.Maximized; } else { Application.Exit(); } } }
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; }