public List <BusinessObjects.Models.Screen> selectScreensByBankId(BusinessObjects.Models.Bank pBank) { try { List <BusinessObjects.Models.Screen> lstScreens = new List <BusinessObjects.Models.Screen>(); string pquery = "SELECT id,name,isActive,bankId FROM tblScreens where bankId = @bankId"; List <SqlParameter> screenParams = new List <SqlParameter>(); screenParams.Add(new SqlParameter("@bankId", pBank.id)); DALDBHelper.DALDBHelper dBHelper = new DALDBHelper.DALDBHelper(); DataSet dataSet = dBHelper.executeAdapter(pquery, screenParams); if (dataSet != null) { foreach (DataRow dataRow in dataSet.Tables[0].Rows) { lstScreens.Add(new BusinessObjects.Models.Screen(Convert.ToInt32(dataRow["id"]), Convert.ToString(dataRow["name"]), Convert.ToBoolean(dataRow["isActive"]), Convert.ToInt32(dataRow["bankId"]))); } return(lstScreens); } else { return(null); } } catch (Exception ex) { ExceptionsWriter.saveExceptionToLogFile(ex); return(null); } }
public BusinessObjects.Models.User UserCheck(string userName, string password, string bankName) { try { string pquery = "select tblBanks.id,tblUsers.userName from tblUsers inner join tblBanks on tblUsers.bankId = tblBanks.id where tblUsers.userName = @userName and tblUsers.password = @password and tblBanks.name = @bankName"; List <SqlParameter> UserParams = new List <SqlParameter>(); UserParams.Add(new SqlParameter("@userName", userName)); UserParams.Add(new SqlParameter("@password", password)); UserParams.Add(new SqlParameter("@bankName", bankName)); DALDBHelper.DALDBHelper dBHelper = new DALDBHelper.DALDBHelper(); DataSet dataSet = dBHelper.executeAdapter(pquery, UserParams); BusinessObjects.Models.User user = new BusinessObjects.Models.User(); if (dataSet != null && dataSet.Tables[0].Rows.Count > 0) { user.bankId = Convert.ToInt32(dataSet.Tables[0].Rows[0][0].ToString()); user.userName = dataSet.Tables[0].Rows[0][1].ToString(); return(user); } return(null); } catch (Exception ex) { ExceptionsWriter.saveEventsAndExceptions(ex, "Exceptions not handled", EventLogEntryType.Error); return(null); } }
public bool checkExist(string tableName, int id) { try { string pquery = "SELECT * FROM " + tableName + " WHERE id = @id"; List <SqlParameter> bankParams = new List <SqlParameter>(); bankParams.Add(new SqlParameter("@id", id)); DALDBHelper.DALDBHelper dBHelper = new DALDBHelper.DALDBHelper(); DataSet dataSet = dBHelper.executeAdapter(pquery, bankParams); if (dataSet != null) { if (dataSet.Tables[0].Rows.Count > 0) { return(true); } else { return(false); } } else { return(false); } } catch (Exception ex) { ExceptionsWriter.saveExceptionToLogFile(ex); return(false); } }
public BusinessObjects.Models.Screen selectActiveScreenByBankName(string bankName) { try { string pquery = "SELECT tblScreens.* FROM tblScreens inner join tblBanks on tblBanks.id = tblScreens.bankId where tblBanks.name = @bankName and isActive = 1"; List <SqlParameter> screenParams = new List <SqlParameter>(); screenParams.Add(new SqlParameter("@bankName", bankName)); DALDBHelper.DALDBHelper dBHelper = new DALDBHelper.DALDBHelper(); DataSet dataSet = dBHelper.executeAdapter(pquery, screenParams); if (dataSet == null) { return(null); } if (dataSet.Tables[0].Rows.Count == 0) { return(new BusinessObjects.Models.Screen()); } DataRow dataRow = dataSet.Tables[0].Rows[0]; BusinessObjects.Models.Screen screen = new BusinessObjects.Models.Screen(Convert.ToInt32(dataRow["id"]) , Convert.ToString(dataRow["name"]), Convert.ToBoolean(dataRow["isActive"]), Convert.ToInt32(dataRow["bankId"])); return(screen); } catch (Exception ex) { ExceptionsWriter.saveEventsAndExceptions(ex, "Exceptions not handled", EventLogEntryType.Error); return(null); } }
public List <T> selectButtonsbyScreenId <T>(int pScreenId, BusinessObjects.Models.btnType btnType) { try { List <T> lstButtons = new List <T>(); string pquery = "SELECT * FROM tbl" + btnType.ToString() + "Button where screenId = @screenId"; List <SqlParameter> screenParams = new List <SqlParameter>(); screenParams.Add(new SqlParameter("@screenId", pScreenId)); DALDBHelper.DALDBHelper dBHelper = new DALDBHelper.DALDBHelper(); DataSet dataSet = dBHelper.executeAdapter(pquery, screenParams); foreach (DataRow dataRow in dataSet.Tables[0].Rows) { if (btnType == BusinessObjects.Models.btnType.ShowMessage) { var btn = new BusinessObjects.Models.ShowMessageButton(Convert.ToInt32(dataRow["id"]), dataRow["enName"].ToString(), dataRow["arName"].ToString(), dataRow["messageAR"].ToString(), dataRow["messageEN"].ToString(), Convert.ToInt32(dataRow["screenId"])); lstButtons.Add((T)(object)btn); } else { var btn = new BusinessObjects.Models.IssueTicketButton(Convert.ToInt32(dataRow["id"]), dataRow["enName"].ToString(), dataRow["arName"].ToString(), Convert.ToInt32(dataRow["serviceId"]), Convert.ToInt32(dataRow["screenId"])); lstButtons.Add((T)(object)btn); } } return(lstButtons); } catch (Exception ex) { ExceptionsWriter.saveEventsAndExceptions(ex, "Exceptions not handled", EventLogEntryType.Error); return(null); } }
public BusinessObjects.Models.Bank checkBankExist(BusinessObjects.Models.Bank pBank) { try { string pquery = "SELECT id,name FROM tblBanks WHERE name = @name"; List <SqlParameter> bankParams = new List <SqlParameter>(); bankParams.Add(new SqlParameter("@name", pBank.name)); DALDBHelper.DALDBHelper dBHelper = new DALDBHelper.DALDBHelper(); DataSet dataSet = dBHelper.executeAdapter(pquery, bankParams); if (dataSet != null) { if (dataSet.Tables[0].Rows.Count > 0) { pBank.id = Convert.ToInt32(dataSet.Tables[0].Rows[0][0].ToString()); } else { pBank.id = 0; } } else { return(null); } return(pBank); } catch (Exception ex) { ExceptionsWriter.saveExceptionToLogFile(ex); return(null); } }
public BusinessObjects.Models.Bank getBankById(int id) { try { string pquery = "SELECT id,name FROM tblBanks WHERE id = @id"; List <SqlParameter> bankParams = new List <SqlParameter>(); bankParams.Add(new SqlParameter("@id", id)); DALDBHelper.DALDBHelper dBHelper = new DALDBHelper.DALDBHelper(); DataSet dataSet = dBHelper.executeAdapter(pquery, bankParams); BusinessObjects.Models.Bank pBank = new BusinessObjects.Models.Bank(); if (dataSet != null) { if (dataSet.Tables[0].Rows.Count > 0) { pBank.id = Convert.ToInt32(dataSet.Tables[0].Rows[0][0].ToString()); pBank.name = dataSet.Tables[0].Rows[0][1].ToString(); } else { pBank.id = 0; } } else { return(null); } return(pBank); } catch (Exception ex) { ExceptionsWriter.saveEventsAndExceptions(ex, "Exceptions not handled", EventLogEntryType.Error); return(null); } }
public Service selectServiceById(int serviceId, int bankId) { try { string pquery = "SELECT * FROM tblService where id = @serviceId and bankId = @bankId"; List <SqlParameter> serviceParams = new List <SqlParameter>(); serviceParams.Add(new SqlParameter("@serviceId", serviceId)); serviceParams.Add(new SqlParameter("@bankId", bankId)); DALDBHelper.DALDBHelper dBHelper = new DALDBHelper.DALDBHelper(); DataSet dataSet = dBHelper.executeAdapter(pquery, serviceParams); if (dataSet != null) { Service service = new Service(); if (dataSet.Tables[0].Rows.Count != 0) { DataRow dataRow = dataSet.Tables[0].Rows[0]; service.id = Convert.ToInt32(dataRow["id"]); service.enName = dataRow["enName"].ToString(); service.arName = dataRow["arName"].ToString(); service.active = Convert.ToBoolean(dataRow["active"]); service.maxNumOfTickets = Convert.ToInt32(dataRow["maxNumOfTickets"]); if (dataRow["minimumServiceTime"] != System.DBNull.Value) { service.minimumServiceTime = Convert.ToInt32(dataRow["minimumServiceTime"]); } if (dataRow["maximumServiceTime"] != System.DBNull.Value) { service.maximumServiceTime = Convert.ToInt32(dataRow["maximumServiceTime"]); } service.bankId = Convert.ToInt32(dataRow["bankId"]); return(service); } else { service.id = 0; return(service); } } else { return(null); } } catch (Exception ex) { ExceptionsWriter.saveEventsAndExceptions(ex, "Exceptions not handled", EventLogEntryType.Error); return(null); } }
public Counter selectCounterById(int counterId, int bankId) { try { string pquery = "SELECT * FROM tblCounters where id = @id and bankId = @bankId"; List <SqlParameter> counterParams = new List <SqlParameter>(); counterParams.Add(new SqlParameter("@id", counterId)); counterParams.Add(new SqlParameter("@bankId", bankId)); DALDBHelper.DALDBHelper dBHelper = new DALDBHelper.DALDBHelper(); DataSet dataSet = dBHelper.executeAdapter(pquery, counterParams); if (dataSet != null) { Counter counter = new Counter(); if (dataSet.Tables[0].Rows.Count != 0) { DataRow dataRow = dataSet.Tables[0].Rows[0]; counter.id = Convert.ToInt32(dataRow["id"]); counter.enName = dataRow["enName"].ToString(); counter.arName = dataRow["arName"].ToString(); counter.active = Convert.ToBoolean(dataRow["active"]); counter.type = dataRow["type"].ToString(); counter.branchId = Convert.ToInt32(dataRow["branchId"]); return(counter); } else { counter.id = 0; return(counter); } } else { return(null); } } catch (Exception ex) { ExceptionsWriter.saveExceptionToLogFile(ex); return(null); } }
public Branch selectBranchById(int branchId, int bankId) { try { string query = "SELECT * FROM tblBranches where id = @branchId and bankId = @bankId"; List <SqlParameter> branchParams = new List <SqlParameter>(); branchParams.Add(new SqlParameter("@branchId", branchId)); branchParams.Add(new SqlParameter("@bankId", bankId)); DALDBHelper.DALDBHelper dBHelper = new DALDBHelper.DALDBHelper(); DataSet dataSet = dBHelper.executeAdapter(query, branchParams); if (dataSet != null) { Branch branch = new Branch(); if (dataSet.Tables[0].Rows.Count != 0) { DataRow dataRow = dataSet.Tables[0].Rows[0]; branch.id = Convert.ToInt32(dataRow["id"]); branch.enName = dataRow["enName"].ToString(); branch.arName = dataRow["arName"].ToString(); branch.active = Convert.ToBoolean(dataRow["active"]); branch.bankId = Convert.ToInt32(dataRow["bankId"]); return(branch); } else { branch.id = 0; return(branch); } } else { return(null); } } catch (Exception ex) { ExceptionsWriter.saveEventsAndExceptions(ex, "Exceptions not handled", EventLogEntryType.Error); return(null); } }
public BusinessObjects.Models.User userLogin(BusinessObjects.Models.User pUser) { try { string pquery = "select tblUsers.*, tblBanks.name from tblUsers inner join tblBanks on tblUsers.bankId = tblBanks.id where tblBanks.name = @bankName and tblUsers.userName = @userName and tblUsers.password = @password"; List <SqlParameter> UserParams = new List <SqlParameter>(); UserParams.Add(new SqlParameter("@bankName", pUser.bankName)); UserParams.Add(new SqlParameter("@userName", pUser.userName)); UserParams.Add(new SqlParameter("@password", pUser.password)); DALDBHelper.DALDBHelper dBHelper = new DALDBHelper.DALDBHelper(); DataSet dataSet = dBHelper.executeAdapter(pquery, UserParams); if (dataSet != null) { if (dataSet.Tables[0].Rows.Count > 0) { pUser.id = Convert.ToInt32(dataSet.Tables[0].Rows[0][0].ToString()); pUser.bankId = Convert.ToInt32(dataSet.Tables[0].Rows[0][3].ToString()); pUser.bankName = dataSet.Tables[0].Rows[0][4].ToString(); } else { pUser.id = 0; } } else { return(null); } return(pUser); } catch (Exception ex) { ExceptionsWriter.saveExceptionToLogFile(ex); return(null); } }