public string addCustomerAccountInfo(Customer_Account_O2M customerAccount) { SqlConnection conn = null; SqlTransaction trans = null; string returnString = IdProConstants.FAIL; Customer_Account_O2MDAO customerAccounto2mDao = new Customer_Account_O2MDAO(); long AccountID = 0; ConnectionDao ConnectionDao = new ConnectionDao(); try { conn = ConnectionDao.getConnection(); trans = conn.BeginTransaction(); returnString = customerAccounto2mDao.addCustomerAccountO2MInfo(conn, trans, customerAccount); if (!AccountID.Equals(0)) { trans.Commit(); } else { trans.Rollback(); } } catch (Exception exception) { trans.Rollback(); System.Diagnostics.Trace.WriteLine("[EmployeeServices:addEmployee] Exception " + exception.StackTrace); } finally { ConnectionDao.closeConnection(conn); } return returnString ; }
public long addaccount(Account account) { SqlConnection conn = null; SqlTransaction trans = null; AccountDao accountDao = new AccountDao(); long AccountID = 0; ConnectionDao ConnectionDao = new ConnectionDao(); try { conn = ConnectionDao.getConnection(); trans = conn.BeginTransaction(); AccountID = accountDao.addAccountBasicInfo(conn, trans, account); if (!AccountID.Equals(0)) { trans.Commit(); } else { trans.Rollback(); } } catch (Exception exception) { trans.Rollback(); System.Diagnostics.Trace.WriteLine("[EmployeeServices:addEmployee] Exception " + exception.StackTrace); } finally { ConnectionDao.closeConnection(conn); } return AccountID; }
public int getNumberOfCustomerBySSN(string ssn) { ConnectionDao connectionDao = new ConnectionDao(); Account account = new Account(); SqlCommand cmd = null; SqlConnection conn = null; SqlDataReader rs = null; int count = 0; string query = "select count(*) as count from customer where ssn=@ssn"; try { conn = connectionDao.getConnection(); cmd = connectionDao.getSqlCommandWithoutTransaction(query, conn); SqlParameter param1 = new SqlParameter(); param1.ParameterName = "@ssn"; param1.Value = ssn; cmd.Parameters.Add(param1); rs = cmd.ExecuteReader(); if (rs.Read()) { count = Int32.Parse(rs["count"].ToString()); } } catch (Exception exception) { System.Diagnostics.Trace.WriteLine("[CustomerDAO:getNumberOfCustomerBySSN] Exception " + exception.StackTrace); } finally { connectionDao.closeConnection(conn); connectionDao.closeDabaseEntities(cmd, rs); } return count; }
public string TicketAdd(Ticket ticket) { SqlConnection conn = null; SqlTransaction trans = null; string returnString = IdProConstants.SUCCESS; TicketDao ticketdao = new TicketDao(); ConnectionDao ConnectionDao = new ConnectionDao(); try { conn = ConnectionDao.getConnection(); trans = conn.BeginTransaction(); //ticket.tickettypeid = ticketdao.addticketsTypedetail(conn, trans, ticket); //if (!ticket.tickettypeid.Equals(0)) //{ ticket.ticketid = ticketdao.addticketsdetail(conn, trans, ticket); if (!ticket.ticketid.Equals(0)) { ticket.noteid = ticketdao.addticketsNotedetail(conn, trans, ticket); if (!ticket.noteid.Equals(0)) { returnString = ticketdao.addticketsAssignment(conn, trans, ticket); } else { trans.Commit(); } } else { trans.Rollback(); } trans.Commit(); } //else //{ // trans.Rollback(); //} //} catch (Exception exception) { trans.Rollback(); System.Diagnostics.Trace.WriteLine("[EmployeeServices:addEmployee] Exception " + exception.StackTrace); } finally { ConnectionDao.closeConnection(conn); } return returnString; }
public string updateEmployee(Employee employee) { SqlConnection conn = null; SqlTransaction trans = null; string returnString = IdProConstants.SUCCESS; UserDAO userDao = new UserDAO(); EmployeeDao EmployeeDao = new EmployeeDao(); ConnectionDao ConnectionDao = new ConnectionDao(); UserServices userServices = new UserServices(); Employee employeeById = EmployeeDao.getEmployeeById(employee.EmployeeId); if (!(employeeById.Email.Trim().Equals(employee.Email.Trim())) && isEmployeeEmailexist(employee.Email.Trim())) { returnString = "Employee Email already Exist in the system"; } else if (!(employeeById.USER.Username.Trim().ToUpper().Equals(employee.USER.Username.Trim().ToUpper())) && userServices.isUserNameExist(employee.USER.Username)) { returnString = "UserName already Exit in the system"; } else { try { conn = ConnectionDao.getConnection(); trans = conn.BeginTransaction(); HttpContext.Current.Session["prevUserName"] = employeeById.USER.Username; returnString = userDao.updateUser(conn, trans, employee.USER); if (IdProConstants.SUCCESS.Equals(returnString)) { returnString = EmployeeDao.updateEmployee(conn, trans, employee); } if (IdProConstants.SUCCESS.Equals(returnString)) { trans.Commit(); } else { trans.Rollback(); } } catch (Exception exception) { trans.Rollback(); System.Diagnostics.Trace.WriteLine("[EmployeeServices:updateEmployee] Exception " + exception.StackTrace); } finally { ConnectionDao.closeConnection(conn); } } return returnString; }
public string addEmployee(Employee employee) { SqlConnection conn = null; SqlTransaction trans = null; string returnString = IdProConstants.SUCCESS; UserDAO userDao = new UserDAO(); EmployeeDao EmployeeDao = new EmployeeDao(); ConnectionDao ConnectionDao = new ConnectionDao(); UserServices userServices = new UserServices(); if (isEmployeeEmailexist(employee.Email.Trim())) { returnString = "Employee Email already Exist in the system"; } // else if (userServices.isUserNameExist(employee.USER.Username)) else if (userServices.isUserNameExist(employee.Username)) { returnString = "UserName already Exit in the system"; } else { try { conn = ConnectionDao.getConnection(); trans = conn.BeginTransaction(); returnString = userDao.addUser(conn, trans, employee.USER); if (IdProConstants.SUCCESS.Equals(returnString)) { returnString = EmployeeDao.addEmployee(conn, trans, employee); } if (IdProConstants.SUCCESS.Equals(returnString)) { trans.Commit(); } else { trans.Rollback(); } } catch (Exception exception) { trans.Rollback(); System.Diagnostics.Trace.WriteLine("[EmployeeServices:addEmployee] Exception " + exception.StackTrace); } finally { ConnectionDao.closeConnection(conn); } } return returnString; }
public Employee getEmployeeByUserName(string userName) { ConnectionDao ConnectionDao = new ConnectionDao(); Employee employee = new Employee(); SqlCommand cmd = null; SqlConnection conn = null; SqlDataReader rs = null; string query = "select * from employees where userName=@userName"; try { conn = ConnectionDao.getConnection(); cmd = ConnectionDao.getSqlCommandWithoutTransaction(query, conn); SqlParameter param1 = new SqlParameter(); param1.ParameterName = "@userName"; param1.Value = userName; cmd.Parameters.Add(param1); rs = cmd.ExecuteReader(); if (rs.Read()) { employee.FirstName=(rs["first_name"].ToString().Trim()); employee.LastName=(rs["last_name"].ToString().Trim()); employee.Email=(rs["email"].ToString().Trim()); employee.EmployeeStatus=(rs["status"].ToString().Trim()); employee.EmployeeId = (rs["Employee_Id"].ToString().Trim()); employee.department = (rs["department"].ToString().Trim()); UserDAO userDao = new UserDAO(); User user = userDao.getUserByUserName(userName); employee.USER=user; } else { employee = null; } } catch (Exception exception) { System.Diagnostics.Trace.WriteLine("[EmployeeDAO:getEmployeeByUserName] Exception " + exception.StackTrace); employee = null; } finally { ConnectionDao.closeConnection(conn); ConnectionDao.closeDabaseEntities(cmd, rs); } return employee; }
public Employee getempdepartment(string department) { ConnectionDao connectionDao = new ConnectionDao(); Employee employee = new Employee(); SqlCommand cmd = null; SqlConnection conn = null; SqlDataReader rs = null; string query = "select * from Employees where UserName='******'"; try { conn = connectionDao.getConnection(); cmd = connectionDao.getSqlCommandWithoutTransaction(query, conn); rs = cmd.ExecuteReader(); if (rs.Read()) { employee.department = (rs["Department"].ToString().Trim()); } else { employee = null; } } catch (Exception exception) { System.Diagnostics.Trace.WriteLine("[EmployeeDao:getempdepartment] Exception " + exception.StackTrace); employee = null; } finally { connectionDao.closeConnection(conn); connectionDao.closeDabaseEntities(cmd, rs); } return employee; }
public Ticket getticketid(string ticketid) { ConnectionDao connectionDao = new ConnectionDao(); Ticket ticket = new Ticket(); SqlCommand cmd = null; SqlConnection conn = null; SqlDataReader rs = null; HttpContext.Current.Session["accountid"] = "1006"; string query = "select * from Ticket where accountid='" + HttpContext.Current.Session["accountid"] + "'"; try { conn = connectionDao.getConnection(); cmd = connectionDao.getSqlCommandWithoutTransaction(query, conn); rs = cmd.ExecuteReader(); if (rs.Read()) { ticket.ticketgetid = (rs["ticketid"].ToString().Trim()); strid = Convert.ToString(ticket.ticketgetid); } else { ticket = null; } } catch (Exception exception) { System.Diagnostics.Trace.WriteLine("[TicketDao:getticketid] Exception " + exception.StackTrace); ticket = null; } finally { connectionDao.closeConnection(conn); connectionDao.closeDabaseEntities(cmd, rs); } return ticket; }
public User getUserByUserName(string userName) { ConnectionDao connectionDao = new ConnectionDao(); User user = new User(); Employee emp = new Employee(); SqlCommand cmd = null; SqlConnection conn = null; SqlDataReader rs = null; string query = "select * from Users where userName='******'"; try { conn = connectionDao.getConnection(); cmd = connectionDao.getSqlCommandWithoutTransaction(query, conn); //SqlParameter param1 = new SqlParameter(); //param1.ParameterName = emp.Username; //param1.Value = emp.Username; //cmd.Parameters.Add(param1); rs = cmd.ExecuteReader(); if (rs.Read()) { user.Username=(rs["userName"].ToString().Trim()); user.Password=(rs["password"].ToString().Trim()); user.Role=(rs["role"].ToString().Trim()); } else { user = null; } } catch (Exception exception) { System.Diagnostics.Trace.WriteLine("[UserDAO:getUserByUserName] Exception " + exception.StackTrace); user = null; } finally { connectionDao.closeConnection(conn); connectionDao.closeDabaseEntities(cmd, rs); } return user; }
public string customeradd(customer customer1, Account account) { string str = ""; SqlConnection conn = null; SqlTransaction trans = null; string returnString = IdProConstants.SUCCESS; CustomerDAO customerdao = new CustomerDAO(); AccountDao accountdao = new AccountDao(); ConnectionDao ConnectionDao = new ConnectionDao(); Customer_Account_O2M customerAccountO2M = new Customer_Account_O2M(); Customer_Account_O2MDAO customerAccountO2Mservice = new Customer_Account_O2MDAO(); try { conn = ConnectionDao.getConnection(); trans = conn.BeginTransaction(); customerAccountO2M.CustomerID = customerdao.addCustomerBasicInfo(conn, trans, customer1); if (!customerAccountO2M.CustomerID.Equals(0)) { customerAccountO2M.AccountID = accountdao.addAccountBasicInfo(conn, trans, account); if (!customerAccountO2M.AccountID.Equals(0)) { returnString = customerAccountO2Mservice.addCustomerAccountO2MInfo(conn, trans,customerAccountO2M); } str = customer1.cofirstname; if (str != "") { customerAccountO2M.CustomerID = customerdao.addCustomerCoinfo(conn, trans, customer1); if (!customerAccountO2M.CustomerID.Equals(0)) { customerAccountO2M.AccountID = accountdao.addAccountBasicInfo(conn, trans, account); if (!customerAccountO2M.AccountID.Equals(0)) { returnString = customerAccountO2Mservice.addCustomerAccountO2MInfo(conn, trans, customerAccountO2M); } } } } if (returnString.Equals(IdProConstants.SUCCESS)) { trans.Commit(); } else { trans.Rollback(); } } catch (Exception exception) { trans.Rollback(); System.Diagnostics.Trace.WriteLine("[EmployeeServices:addEmployee] Exception " + exception.StackTrace); } finally { ConnectionDao.closeConnection(conn); } string finalreturnvalue=""; if (returnString == "Success") { finalreturnvalue = "Thanks record saved successfully"; } else { finalreturnvalue = "Sorry, Your request could not be processed. Please try after some time"; } return finalreturnvalue; }