private void btnRefillPaper_Click(object sender, EventArgs e) { try { if (Convert.ToInt32(txtPaperCount.Text) > 25) { var MsgStat = new MessageAlerts(); MsgStat.ExceptionMessage("Maximum No of Paper : 25"); } else { var path = Properties.Settings.Default.AdminPath + "Admin.xml"; var xDoc = XDocument.Load(path); var node = xDoc.Descendants("Admin").FirstOrDefault(cd => cd.Element("paper").Value != ""); if (node.Name != null || node.Name != "") { node.SetElementValue("paper", txtPaperCount.Text); } xDoc.Save(path); lblStatPaper.Text = "Paper Count - Update"; lblStatPaper.ForeColor = Color.PaleGreen; LoadPaperCount(); } } catch (Exception ex) { var MsgAlert = new MessageAlerts(); MsgAlert.ExceptionMessage(ex.Message); } }
private bool ValidateAdmin() { bool UserStat = false; if (lblAdminStatus.Text == "Not Admin") { if (txtCode.Text == "12345") { groupBoxButtons.Enabled = true; lblAdminStatus.Text = "Admin"; lblAdminStatusPaper.Text = "Admin"; lblAdminStatusPaper.ForeColor = Color.PaleGreen; lblAdminStatus.ForeColor = Color.PaleGreen; panel1.Hide(); UserStat = true; } else { var MsgStat = new MessageAlerts(); MsgStat.ExceptionMessage("Incorrect Code"); } } return(UserStat); }
private void btnPrint_Click(object sender, EventArgs e) { if (CheckReaminingPaperInDispenser() && !withPaper) { var MsgStat = new MessageAlerts(); MsgStat.ExceptionMessage("No More paper left in the Dispenser"); serialPort1.WriteLine("b"); return; } ExecutePrint(); }
private void frmAdmin_Load(object sender, EventArgs e) { try { lblAdminStatus.Text = "Not Admin"; lblAdminStatus.ForeColor = Color.Red; lblStatus.ForeColor = Color.Red; groupBoxButtons.Enabled = false; LoadDocument(); } catch (Exception ex) { var MsgAlert = new MessageAlerts(); MsgAlert.ExceptionMessage(ex.Message); } }
private void btnUpdate_Click(object sender, EventArgs e) { try { var path = Properties.Settings.Default.AdminPath + "Admin.xml"; var xDoc = XDocument.Load(path); var node = xDoc.Descendants("Admin").FirstOrDefault(cd => cd.Element("multiplier").Value != ""); if (node.Name != null || node.Name != "") { node.SetElementValue("multiplier", txtMultiplier.Text); } xDoc.Save(path); lblStatus.Text = "File Has been updated"; lblStatus.ForeColor = Color.PaleGreen; } catch (Exception ex) { var MsgAlert = new MessageAlerts(); MsgAlert.ExceptionMessage(ex.Message); } }
private void ComputationSummary_Load(object sender, EventArgs e) { try { withPaper = false; InitializeSerialPort(); LoadDocument(); if (CheckReaminingPaperInDispenser()) { MessageBox.Show("Paper is less than the assigned value", "Transaction Information", MessageBoxButtons.OK, MessageBoxIcon.Warning); if (serialPort1.IsOpen) { serialPort1.WriteLine(Convert.ToString(1000)); } } } catch (Exception ex) { var MsgAlerts = new MessageAlerts(); MsgAlerts.ExceptionMessage(ex.Message); } }
private void btnPrintDocument_Click(object sender, EventArgs e) { PdfPrint.Status result = PdfPrint.Status.OK; if (printDialog.ShowDialog() == DialogResult.OK) { //Open ComputeSummary form var CompSum = new ComputationSummary(); //Returns a value of number of copies to be printed CompSum.txtNoOfCopies.Text = Convert.ToString(printDialog.PrinterSettings.Copies); CompSum.txtNoOfPages.Text = Convert.ToString(pdfViewer1.NumberOfPages); //Returns a boolean value if the item to be printed is colored or grayscale PrintColor = printDialog.PrinterSettings.DefaultPageSettings.Color; decimal costPerImage = 0; //Compute Cost var cal = new PrintCalculation(); if (!pdfPrinting.ExcelFormat) { costPerImage = cal.CalculateImageInFile(pdfPrinting.FileInDocFormat); } if (PrintColor == true) { //Return a value of cost per page and if colored CompSum.txtTotalAmount.Text = Convert.ToString(costPerImage + ((printDialog.PrinterSettings.Copies * 2) * pdfViewer1.NumberOfPages)); CompSum.txtColored.Text = "Yes"; } else { //Return a value of cost per page and if not colored CompSum.txtTotalAmount.Text = Convert.ToString(costPerImage + ((printDialog.PrinterSettings.Copies * 1) * pdfViewer1.NumberOfPages)); CompSum.txtColored.Text = "No"; } CompSum.FileLocFromMain = FileLoc; CompSum.ShowDialog(); if (CompSum.PrintSuccess) { pdfViewer1.CloseDocument(); btnPrintDocument.Enabled = false; } } else { pdfViewer1.CloseDocument(); result = PdfPrint.Status.PRINTING_CANCELLED; } if (result == PdfPrint.Status.OK) { /*MessageBox.Show("Done Successfully", "Printing Transaction Status", MessageBoxButtons.OK, MessageBoxIcon.Information);*/ } else if (result == PdfPrint.Status.PRINTING_CANCELLED) { var MsgAlerts = new MessageAlerts(); MsgAlerts.ExceptionMessage(pdfPrinting.DecodeStatusCode(result)); } else { var MsgAlerts = new MessageAlerts(); MsgAlerts.ExceptionMessage("Error." + pdfPrinting.DecodeStatusCode(result)); } }
private void SetText(string text) { try { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (this.textBox1.InvokeRequired) { StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(SetText); this.Invoke(d, new object[] { text }); } else { //var val = text.Split('\r'); var val = text; //Thread.Sleep(300); if (val == "1") { InsertedCoin = InsertedCoin + 1; this.txtCurrentBal.Text = Convert.ToString(InsertedCoin); this.textBox1.Text = text; var TAmount = Convert.ToInt32(txtTotalAmount.Text); var TCurBal = Convert.ToInt32(txtCurrentBal.Text); if (TAmount >= TCurBal) { ErrorCount = false; //InsertedCoin = TCurBal + Convert.ToInt32(textBox1.Text); //txtCurrentBal.Text = Convert.ToString(InsertedCoin); if (Convert.ToInt32(txtCurrentBal.Text) == TAmount) { if (CheckReaminingPaperInDispenser()) { btnDispense.Enabled = false; btnWithPaper.Enabled = true; } else { btnDispense.Enabled = true; btnWithPaper.Enabled = true; //btnPrint.Enabled = true; } } } else { //btnDispense.Enabled = true; if (!ErrorCount) { ErrorCount = true; MessageBox.Show("Balance is now sufficient", "Transaction Notice", MessageBoxButtons.OK, MessageBoxIcon.Information); } } //if (textBox1.Text != "") //{ // var TAmount = Convert.ToInt32(txtTotalAmount.Text); // var TCurBal = Convert.ToInt32(txtCurrentBal.Text); // if (TAmount > TCurBal ) // { // //InsertedCoin = TCurBal + Convert.ToInt32(textBox1.Text); // //txtCurrentBal.Text = Convert.ToString(InsertedCoin); // InsertedCoin = InsertedCoin + 1; // if(Convert.ToInt32(txtCurrentBal.Text) == TAmount) // { // btnDispense.Enabled = true; // } // }else // { // btnDispense.Enabled = true; // MessageBox.Show("Balance is now sufficient","Transaction Notice",MessageBoxButtons.OK,MessageBoxIcon.Information); // } //} //else //{ // if(InsertedCoin == 1) // txtCurrentBal.Text = "1"; //} } else if (val == "b") { btnPrint.Enabled = true; btnDispense.Enabled = false; btnWithPaper.Enabled = false; } } //for (int i = 1; i < val.Length; i++) //{ //} } catch (Exception ex) { var Alerts = new MessageAlerts(); Alerts.ExceptionMessage(ex.ToString()); } }