private void txtTerminalNo_TextChanged(object sender, EventArgs e) { try { Int32 iTerminalNo = Int32.Parse(txtTerminalNo.Text); if (iTerminalNo > 0) { Data.Terminal clsTerminal = new Data.Terminal(); TerminalDetails = clsTerminal.Details(txtTerminalNo.Text); BranchDetails = TerminalDetails.BranchDetails; Int32 iBranchCount = clsTerminal.BranchCount(txtTerminalNo.Text); cboBranch.Items.Clear(); Data.Branch clsBranch = new Data.Branch(clsTerminal.Connection, clsTerminal.Transaction); foreach (System.Data.DataRow dr in clsBranch.ListAsDataTable(TerminalNo: txtTerminalNo.Text).Rows) { cboBranch.Items.Add(dr["BranchCode"]); } clsTerminal.CommitAndDispose(); if (iBranchCount == 0) { cboBranch.Items.Add("No Applicable Branch"); } else if (iBranchCount == 1) { cboBranch.SelectedIndex = cboBranch.Items.IndexOf(BranchDetails.BranchCode); cboBranch.Enabled = false; } else { cboBranch.SelectedIndex = cboBranch.Items.IndexOf(BranchDetails.BranchCode); cboBranch.Enabled = true; } txtTerminalName.Text = TerminalDetails.TerminalName; } } catch { } }
private void txtTerminalNo_TextChanged(object sender, EventArgs e) { try { Int32 iTerminalNo = Int32.Parse(txtTerminalNo.Text); if (iTerminalNo > 0) { Data.Terminal clsTerminal = new Data.Terminal(); TerminalDetails = clsTerminal.Details(txtTerminalNo.Text); BranchDetails = TerminalDetails.BranchDetails; Int32 iBranchCount = clsTerminal.BranchCount(txtTerminalNo.Text); cboBranch.Items.Clear(); Data.Branch clsBranch = new Data.Branch(clsTerminal.Connection, clsTerminal.Transaction); foreach (System.Data.DataRow dr in clsBranch.ListAsDataTable(TerminalNo: txtTerminalNo.Text).Rows) { cboBranch.Items.Add(dr["BranchCode"]); } clsTerminal.CommitAndDispose(); if (iBranchCount == 0) cboBranch.Items.Add("No Applicable Branch"); else if (iBranchCount == 1) { cboBranch.SelectedIndex = cboBranch.Items.IndexOf(BranchDetails.BranchCode); cboBranch.Enabled = false; } else { cboBranch.SelectedIndex = cboBranch.Items.IndexOf(BranchDetails.BranchCode); cboBranch.Enabled = true; } txtTerminalName.Text = TerminalDetails.TerminalName; } } catch { } }
private static bool IsTerminalExist(out string ErrorMessage) { ErrorMessage = ""; Event clsEvent = new Event(); try { clsEvent.AddEvent("Checking terminal if exist in the database. [" + CompanyDetails.TerminalNo + "]"); Data.Terminal clsTerminal = new Data.Terminal(); Data.TerminalDetails clsDetails = new Data.TerminalDetails(); Int32 iBranchCount = clsTerminal.BranchCount(CompanyDetails.TerminalNo); bool boIsTerminalExist = false; if (iBranchCount == 1) { clsDetails = clsTerminal.Details(CompanyDetails.TerminalNo); boIsTerminalExist = true; CONFIG.SaveConfig(clsDetails); } else { boIsTerminalExist = clsTerminal.IsExist(Constants.TerminalBranchID, CompanyDetails.TerminalNo, out clsDetails); } clsTerminal.CommitAndDispose(); if (!boIsTerminalExist) { ErrorMessage = "FATAL ERROR Level 1.!!! " + Environment.NewLine + "Terminal No:[" + CompanyDetails.TerminalNo + "] @ BranchID:[" + Constants.TerminalBranchID.ToString() + "] does not exist in the database." + Environment.NewLine + "Please consult your system administrator immediately..."; clsEvent.AddEventLn("FATAL ERROR!!! " + Environment.NewLine + "Terminal No:[" + CompanyDetails.TerminalNo + "] @ BranchID:[" + Constants.TerminalBranchID.ToString() + "] does not exist in the database. TRACE: Procedure IsTerminalExist returns false."); } else { clsEvent.AddEventLn("Done!"); clsEvent.AddEvent("Product Version suited for DB Version [" + clsDetails.DBVersion + "] =? Product Version[" + Application.ProductVersion + "]"); if (clsDetails.DBVersion != Application.ProductVersion) { ErrorMessage = "FATAL ERROR Level 1.!!! The Product Version [" + Application.ProductVersion + "] is not compatible with Database Version [" + clsDetails.DBVersion + "]." + Environment.NewLine + "Please consult your system administrator immediately..."; clsEvent.AddEventLn("FATAL ERROR!!! The Product Version is not compatible with database version. TRACE: Product Version returns false."); return(false); } clsEvent.AddEventLn("Done!"); clsEvent.AddEvent("Checking Machine Serial No. [" + CONFIG.MachineSerialNo + "]"); if (clsDetails.MachineSerialNo != CONFIG.MachineSerialNo) { //bypass this //ErrorMessage = "FATAL ERROR Level 1.!!! The Machine Serial No. in the database and configuration file does not match." + Environment.NewLine + "Please consult your system administrator immediately..."; //clsEvent.AddEventLn("FATAL ERROR!!! The Machine Serial No. in the database and configuration file does not match. TRACE: Procedure IsTerminalExist returns false."); //return false; clsEvent.AddEventLn("BYPASS-FATAL ERROR!!! The Machine Serial No. in the database and configuration file does not match. TRACE: Procedure IsTerminalExist returns false."); } clsEvent.AddEventLn("Done!"); clsEvent.AddEvent("Checking accreditation no. [" + CONFIG.AccreditationNo + "]"); if (clsDetails.AccreditationNo != CONFIG.AccreditationNo) { //ErrorMessage = "FATAL ERROR Level 1.!!! The Accreditation No. in the database and configuration file does not match." + Environment.NewLine + "Please consult your system administrator immediately..."; //clsEvent.AddEventLn("FATAL ERROR!!! The Accreditation No. in the database and configuration file does not match. TRACE: Procedure IsTerminalExist returns false."); //return false; clsEvent.AddEventLn("BY-PASS FATAL ERROR!!! The Accreditation No. in the database and configuration file does not match. TRACE: Procedure IsTerminalExist returns false."); } clsEvent.AddEventLn("Done!"); } return(boIsTerminalExist); } catch (Exception ex) { ErrorMessage = "FATAL ERROR!!! TRACE: " + ex.Message; clsEvent.AddEventLn("FATAL ERROR!!! TRACE:" + ex.Message); return(false); } }
private static bool IsTerminalExist(out string ErrorMessage) { ErrorMessage = ""; Event clsEvent = new Event(); try { clsEvent.AddEvent("Checking terminal if exist in the database. [" + CompanyDetails.TerminalNo + "]"); Data.Terminal clsTerminal = new Data.Terminal(); Data.TerminalDetails clsDetails = new Data.TerminalDetails(); Int32 iBranchCount = clsTerminal.BranchCount(CompanyDetails.TerminalNo); bool boIsTerminalExist = false; if (iBranchCount == 1) { clsDetails = clsTerminal.Details(CompanyDetails.TerminalNo); boIsTerminalExist = true; CONFIG.SaveConfig(clsDetails); } else { boIsTerminalExist = clsTerminal.IsExist(Constants.TerminalBranchID, CompanyDetails.TerminalNo, out clsDetails); } clsTerminal.CommitAndDispose(); if (!boIsTerminalExist) { ErrorMessage = "FATAL ERROR Level 1.!!! " + Environment.NewLine + "Terminal No:[" + CompanyDetails.TerminalNo + "] @ BranchID:[" + Constants.TerminalBranchID.ToString() + "] does not exist in the database." + Environment.NewLine + "Please consult your system administrator immediately..."; clsEvent.AddEventLn("FATAL ERROR!!! " + Environment.NewLine + "Terminal No:[" + CompanyDetails.TerminalNo + "] @ BranchID:[" + Constants.TerminalBranchID.ToString() + "] does not exist in the database. TRACE: Procedure IsTerminalExist returns false."); } else { clsEvent.AddEventLn("Done!"); clsEvent.AddEvent("Product Version suited for DB Version [" + clsDetails.DBVersion + "] =? Product Version[" + Application.ProductVersion + "]"); if (clsDetails.DBVersion != Application.ProductVersion) { ErrorMessage = "FATAL ERROR Level 1.!!! The Product Version [" + Application.ProductVersion + "] is not compatible with Database Version [" + clsDetails.DBVersion + "]." + Environment.NewLine + "Please consult your system administrator immediately..."; clsEvent.AddEventLn("FATAL ERROR!!! The Product Version is not compatible with database version. TRACE: Product Version returns false."); return false; } clsEvent.AddEventLn("Done!"); clsEvent.AddEvent("Checking Machine Serial No. [" + CONFIG.MachineSerialNo + "]"); if (clsDetails.MachineSerialNo != CONFIG.MachineSerialNo) { //bypass this //ErrorMessage = "FATAL ERROR Level 1.!!! The Machine Serial No. in the database and configuration file does not match." + Environment.NewLine + "Please consult your system administrator immediately..."; //clsEvent.AddEventLn("FATAL ERROR!!! The Machine Serial No. in the database and configuration file does not match. TRACE: Procedure IsTerminalExist returns false."); //return false; clsEvent.AddEventLn("BYPASS-FATAL ERROR!!! The Machine Serial No. in the database and configuration file does not match. TRACE: Procedure IsTerminalExist returns false."); } clsEvent.AddEventLn("Done!"); clsEvent.AddEvent("Checking accreditation no. [" + CONFIG.AccreditationNo + "]"); if (clsDetails.AccreditationNo != CONFIG.AccreditationNo) { //ErrorMessage = "FATAL ERROR Level 1.!!! The Accreditation No. in the database and configuration file does not match." + Environment.NewLine + "Please consult your system administrator immediately..."; //clsEvent.AddEventLn("FATAL ERROR!!! The Accreditation No. in the database and configuration file does not match. TRACE: Procedure IsTerminalExist returns false."); //return false; clsEvent.AddEventLn("BY-PASS FATAL ERROR!!! The Accreditation No. in the database and configuration file does not match. TRACE: Procedure IsTerminalExist returns false."); } clsEvent.AddEventLn("Done!"); } return boIsTerminalExist; } catch (Exception ex) { ErrorMessage = "FATAL ERROR!!! TRACE: " + ex.Message; clsEvent.AddEventLn("FATAL ERROR!!! TRACE:" + ex.Message); return false; } }