private void BtnShowCompany_Click(object sender, EventArgs e) { string company = txtBoxCompany.Text; if (string.IsNullOrWhiteSpace(txtBoxCompany.Text)) { try { dGVERP.DataSource = WebController.SelectAllCompany().Select(o => new { o.Name, o.Description }).ToList(); } catch (Exception x) { StatusLbl.ShowMessage(x.Message); } } else { try { dGVERP.DataSource = WebController.GetCompany(company).Select(o => new { o.Name, o.Description }).ToList(); } catch (Exception x) { StatusLbl.ShowMessage(x.Message); } } }
private void BtnUpdateCompany_Click(object sender, EventArgs e) { string name = txtBoxCompany.Text; string desc = txtBoxCompanyDescription.Text; if (string.IsNullOrWhiteSpace(txtBoxCompanyDescription.Text) || string.IsNullOrWhiteSpace(txtBoxCompany.Text)) { StatusLbl.ShowMessage("You need to fill both name and description"); } else { try { WebController.UpdateCompany(name, desc); dGVERP.DataSource = WebController.GetCompany(name).Select(o => new { o.Name, o.Description }).ToList(); txtBoxCompany.Text = ""; txtBoxCompanyDescription.Text = ""; StatusLbl.ShowStatus("Update success!"); } catch (Exception x) { StatusLbl.ShowMessage(x.Message); } } }
private void BtnDeleteCompany_Click(object sender, EventArgs e) { string companyName = txtBoxCompany.Text; if (companyName != null) { DialogResult dr = MessageBox.Show("You will permanently remove the company from the database", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.Yes) { try { WebController.RemoveCompany(companyName); dGVERP.DataSource = null; txtBoxCompany.Text = ""; txtBoxCompanyDescription.Text = ""; StatusLbl.ShowStatus("Company deleted!"); } catch (Exception x) { StatusLbl.ShowMessage(x.Message); } } else { StatusLbl.ShowMessage("Delete cancelled"); } } }
public void SetStatus(string statusText) { if (StatusLbl.InvokeRequired) { StatusLbl.Invoke(new Action(() => { StatusLbl.Text = statusText; })); return; } StatusLbl.Text = statusText; }
private void BtnShowPlayers_Click(object sender, EventArgs e) { dataGridGetAllPlayers.DataSource = null; try { dataGridGetAllPlayers.DataSource = WebController.GetAllPlayers(); } catch (Exception x) { StatusLbl.ShowMessage(x.Message); } }
public void UpdateStatusLbl(Color myColor) { if (StatusLbl.InvokeRequired) { StatusLbl.BeginInvoke(new Action(() => { StatusLbl.BackColor = myColor; })); } else { StatusLbl.BackColor = myColor; } }
private async void DownloadBtn_Click(object sender, EventArgs e) { try { IsDownloading = true; Cursor = Cursors.WaitCursor; DownloadBtn.Enabled = ReleasesTxt.Enabled = false; using (var webClient = new WebClient()) { webClient.Proxy = null; StatusLbl.SetDotAnimation("Downloading"); byte[] tanjiZip = await webClient.DownloadDataTaskAsync(DownloadUrl); BringToFront(); StatusLbl.StopDotAnimation("Extracting..."); if (TanjiDirectoryDlg.ShowDialog() != DialogResult.OK) { StatusLbl.StopDotAnimation("Standing By..."); return; } using (var tanjiStream = new MemoryStream(tanjiZip)) using (var tanjiArchive = new ZipArchive(tanjiStream)) { foreach (var tanjiFile in tanjiArchive.Entries) { StatusLbl.SetDotAnimation("Extracting {0}", tanjiFile.Name); string saveAs = Path.Combine(TanjiDirectoryDlg.SelectedPath, tanjiFile.Name); tanjiFile.ExtractToFile(saveAs, true); } } } } finally { IsDownloading = false; Cursor = Cursors.Default; DownloadBtn.Enabled = ReleasesTxt.Enabled = true; StatusLbl.StopDotAnimation("Standing By..."); } }
private void BtnAddCompany_Click(object sender, EventArgs e) { string text = txtBoxCompany.Text; string desc = txtBoxCompanyDescription.Text; try { if (string.IsNullOrWhiteSpace(txtBoxCompany.Text) || string.IsNullOrWhiteSpace(txtBoxCompanyDescription.Text)) { StatusLbl.ShowMessage("You need to fill both name and description"); } else { WebController.AddCompany(text, desc); txtBoxCompany.Text = ""; txtBoxCompanyDescription.Text = ""; } }catch (Exception p) { StatusLbl.ShowMessage(p.Message + text); } }
private void OpenFile_Click(object sender, EventArgs e) { OpenFileDialog openFile = new OpenFileDialog { Filter = "txt files (*.txt)|*.txt" }; if (openFile.ShowDialog() == System.Windows.Forms.DialogResult.OK) { txtBox.Text = ""; string strFilePath = openFile.InitialDirectory + openFile.FileName; try { string fileText = WebController.OpenFile(strFilePath); txtBox.Text = fileText; } catch (Exception x) { StatusLbl.ShowMessage(x.Message); } } }
private void BtnSelectERP_Click(object sender, EventArgs e) { dGVERP.DataSource = null; if (cBoxERP.SelectedIndex > -1) { try { switch (cBoxERP.SelectedIndex) { case 0: dGVERP.DataSource = WebController.getMetaKeys(); break; case 1: dGVERP.DataSource = WebController.getMetaIndexes(); break; case 2: dGVERP.DataSource = WebController.getMetaTablesConstraints(); break; case 3: dGVERP.DataSource = WebController.getMetaTables(); break; case 4: dGVERP.DataSource = WebController.getMetaTables2(); break; case 5: dGVERP.DataSource = WebController.GetMetaColumns(); break; case 6: dGVERP.DataSource = WebController.GetMetaColumns2(); break; case 7: dGVERP.DataSource = WebController.GetAllEmployees().Select(o => new { o.First_Name, o.Job_Title, o.City }).ToList(); break; case 8: dGVERP.DataSource = WebController.GetMetaColumns(); break; case 9: dGVERP.DataSource = WebController.GetEmployeeRelatives(); break; case 10: dGVERP.DataSource = WebController.GetEmployeeAbsence().Select(o => new { o.Employee_No_, o.Cause_of_Absence_Code, o.Description, From_Date = o.From_Date.ToString() }).ToList(); break; case 11: dGVERP.DataSource = WebController.GetMostSick(); break; case 12: dGVERP.DataSource = WebController.GetAllEmployeeAbsence().Select(o => new { o.Entry_No_, o.Employee_No_, o.Cause_of_Absence_Code }).ToList(); break; case 13: dGVERP.DataSource = WebController.GetAllPortalSetup().Select(o => new { o.Config_TP_Group_Capt_ID, o.Config_Tool_Pane_Caption, o.Search_Tool_Pane_Caption }).ToList(); break; case 14: dGVERP.DataSource = WebController.GetAllQualification().Select(o => new { o.Description, o.Qualification_Code, o.Institution_Company }).ToList(); break; } }catch (Exception x) { StatusLbl.ShowMessage(x.Message); } } }