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 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 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; } }