public KwikPay Update(KwikPay ins) { //...Get User and Date Data... string ModifiedDate = string.Format("{0:yyyy-MM-dd hh:mm:ss}", DateTime.Now); string EmployeeId = Convert.ToString(HttpContext.Current.Session["Username"]); //...Database Connection... DataBaseConnection dbConn = new DataBaseConnection(); SqlConnection con = dbConn.SqlConn(); con.Open(); SqlCommand cmdI = con.CreateCommand(); cmdI.Connection = con; //...Update Record... cmdI.Parameters.Clear(); cmdI.CommandText = StoredProcedures.KwikPayUpdate; cmdI.CommandType = System.Data.CommandType.StoredProcedure; cmdI.Parameters.AddWithValue("@KwikPayID", ins.KwikPayID); cmdI.Parameters.AddWithValue("@ActualDate", ins.ActualDate); cmdI.Parameters.AddWithValue("@Amount", ins.Amount); cmdI.Parameters.AddWithValue("@CreatedDate", DateTime.Now); cmdI.Parameters.AddWithValue("@KwikPayTypeID", ins.KwikPayTypeID); cmdI.Parameters.AddWithValue("@UserID", EmployeeId); cmdI.Parameters.AddWithValue("@CompanyID", ins.CompanyID); cmdI.Parameters.AddWithValue("@ModifiedDate", ModifiedDate); cmdI.Parameters.AddWithValue("@ModifiedBy", EmployeeId); cmdI.Parameters.AddWithValue("@EmployeeID", ins.EmployeeID); cmdI.ExecuteNonQuery(); cmdI.Connection.Close(); return(ins); }
public List <KwikPay> GetAllKwikPay() { //...Create New Instance of Object... List <KwikPay> list = new List <KwikPay>(); KwikPay ins; //...Database Connection... DataBaseConnection dbConn = new DataBaseConnection(); SqlConnection con = dbConn.SqlConn(); SqlCommand cmdI; //...SQL Commands... cmdI = new SqlCommand("SELECT kp.*,kpt.KwikPayType, e.Name FROM t_KwikPay kp inner join l_KwikPayType kpt on kp.KwikPayTypeID = kpt.KwikPayTypeID inner join Employee e on kp.EmployeeID = e.EmployeeID where kp.Removed=0", con); cmdI.Connection.Open(); SqlDataReader drI = cmdI.ExecuteReader(); //...Retrieve Data... if (drI.HasRows) { while (drI.Read()) { ins = new KwikPay(); ins.KwikPayID = Convert.ToInt32(drI["KwikPayID"]); ins.ActualDate = Convert.ToDateTime(drI["ActualDate"]); ins.Amount = Convert.ToDecimal(drI["Amount"]); ins.CreatedDate = Convert.ToDateTime(drI["CreatedDate"]); ins.KwikPayTypeID = Convert.ToInt32(drI["KwikPayTypeID"]); ins.kwikpaytype = drI["KwikPayType"].ToString(); ins.UserID = Convert.ToString(drI["UserID"]); ins.CompanyID = Convert.ToInt32(drI["CompanyID"]); ins.ModifiedDate = Convert.ToDateTime(drI["ModifiedDate"]); ins.ModifiedBy = Convert.ToString(drI["ModifiedBy"]); ins.Removed = Convert.ToBoolean(drI["Removed"]); ins.EmployeeID = drI["Name"].ToString(); list.Add(ins); } } //...Close Connections... drI.Close(); con.Close(); //...Return... return(list); }
public List<KwikPay> GetAllKwikPay() { //...Create New Instance of Object... List<KwikPay> list = new List<KwikPay>(); KwikPay ins; //...Database Connection... DataBaseConnection dbConn = new DataBaseConnection(); SqlConnection con = dbConn.SqlConn(); SqlCommand cmdI; //...SQL Commands... cmdI = new SqlCommand("SELECT kp.*,kpt.KwikPayType, e.Name FROM t_KwikPay kp inner join l_KwikPayType kpt on kp.KwikPayTypeID = kpt.KwikPayTypeID inner join Employee e on kp.EmployeeID = e.EmployeeID where kp.Removed=0", con); cmdI.Connection.Open(); SqlDataReader drI = cmdI.ExecuteReader(); //...Retrieve Data... if (drI.HasRows) { while (drI.Read()) { ins = new KwikPay(); ins.KwikPayID = Convert.ToInt32(drI["KwikPayID"]); ins.ActualDate = Convert.ToDateTime(drI["ActualDate"]); ins.Amount = Convert.ToDecimal(drI["Amount"]); ins.CreatedDate = Convert.ToDateTime(drI["CreatedDate"]); ins.KwikPayTypeID = Convert.ToInt32(drI["KwikPayTypeID"]); ins.kwikpaytype = drI["KwikPayType"].ToString(); ins.UserID = Convert.ToString(drI["UserID"]); ins.CompanyID = Convert.ToInt32(drI["CompanyID"]); ins.ModifiedDate = Convert.ToDateTime(drI["ModifiedDate"]); ins.ModifiedBy = Convert.ToString(drI["ModifiedBy"]); ins.Removed = Convert.ToBoolean(drI["Removed"]); ins.EmployeeID = drI["Name"].ToString(); list.Add(ins); } } //...Close Connections... drI.Close(); con.Close(); //...Return... return list; }
public List <KwikPay> GetKwikPaysPerEmployeeType(int UserTypeID) { //...Create New Instance of Object... List <KwikPay> list = new List <KwikPay>(); KwikPay ins; //...Database Connection... DataBaseConnection dbConn = new DataBaseConnection(); SqlConnection con = dbConn.SqlConn(); SqlCommand cmdI; //...SQL Commands... cmdI = new SqlCommand("SELECT * FROM t_KwikPay WHERE UserTypeID = " + UserTypeID, con); cmdI.Connection.Open(); SqlDataReader drI = cmdI.ExecuteReader(); //...Retrieve Data... if (drI.HasRows) { while (drI.Read()) { ins = new KwikPay(); ins.KwikPayID = Convert.ToInt32(drI["KwikPayID"]); ins.ActualDate = Convert.ToDateTime(drI["ActualDate"]); ins.Amount = Convert.ToDecimal(drI["Amount"]); ins.CreatedDate = Convert.ToDateTime(drI["CreatedDate"]); ins.KwikPayTypeID = Convert.ToInt32(drI["KwikPayTypeID"]); ins.UserID = Convert.ToString(drI["UserID"]); ins.CompanyID = Convert.ToInt32(drI["CompanyID"]); ins.ModifiedDate = Convert.ToDateTime(drI["ModifiedDate"]); ins.ModifiedBy = Convert.ToString(drI["ModifiedBy"]); ins.Removed = Convert.ToBoolean(drI["Removed"]); list.Add(ins); } } //...Close Connections... drI.Close(); con.Close(); //...Return... return(list); }
public KwikPay GetKwikPay(int KwikPayId) { //...Create New Instance of Object... KwikPay ins = new KwikPay(); //...Database Connection... DataBaseConnection dbConn = new DataBaseConnection(); SqlConnection con = dbConn.SqlConn(); SqlCommand cmdI; //...SQL Commands... cmdI = new SqlCommand("SELECT * FROM t_KwikPay WHERE KwikPayId =" + KwikPayId, con); cmdI.Connection.Open(); SqlDataReader drI = cmdI.ExecuteReader(); //...Retrieve Data... if (drI.HasRows) { while (drI.Read()) { ins.KwikPayID = Convert.ToInt32(drI["KwikPayID"]); ins.ActualDate = Convert.ToDateTime(drI["ActualDate"]); ins.Amount = Convert.ToDecimal(drI["Amount"]); ins.CreatedDate = Convert.ToDateTime(drI["CreatedDate"]); ins.KwikPayTypeID = Convert.ToInt32(drI["KwikPayTypeID"]); ins.UserID = Convert.ToString(drI["UserID"]); ins.CompanyID = Convert.ToInt32(drI["CompanyID"]); ins.ModifiedDate = Convert.ToDateTime(drI["ModifiedDate"]); ins.ModifiedBy = Convert.ToString(drI["ModifiedBy"]); ins.Removed = Convert.ToBoolean(drI["Removed"]); } } //...Close Connections... drI.Close(); con.Close(); //...Return... return ins; }
public KwikPay Insert(KwikPay ins) { //...Get User and Date Data... string ModifiedDate = string.Format("{0:yyyy-MM-dd hh:mm:ss}", DateTime.Now); string EmployeeId = Convert.ToString(HttpContext.Current.Session["Username"]); string strTrx = "KwikPayIns_" + EmployeeId; //...Database Connection... DataBaseConnection dbConn = new DataBaseConnection(); SqlConnection con = dbConn.SqlConn(); con.Open(); //...Command Interface... SqlCommand cmdI = con.CreateCommand(); SqlTransaction trx; trx = con.BeginTransaction(strTrx); cmdI.Connection = con; cmdI.Transaction = trx; try { //...Insert Record... cmdI.CommandText = StoredProcedures.KwikPayInsert; cmdI.CommandType = System.Data.CommandType.StoredProcedure; //cmdI.Parameters.AddWithValue("@KwikPayID", ins.KwikPayID); cmdI.Parameters.AddWithValue("@ActualDate", ins.ActualDate); cmdI.Parameters.AddWithValue("@Amount", ins.Amount); cmdI.Parameters.AddWithValue("@CreatedDate", DateTime.Now); cmdI.Parameters.AddWithValue("@KwikPayTypeID", ins.KwikPayTypeID); cmdI.Parameters.AddWithValue("@UserID", EmployeeId); cmdI.Parameters.AddWithValue("@CompanyID", ins.CompanyID); cmdI.Parameters.AddWithValue("@ModifiedDate", ModifiedDate); cmdI.Parameters.AddWithValue("@ModifiedBy", EmployeeId); cmdI.Parameters.AddWithValue("@Removed", ins.Removed); cmdI.Parameters.AddWithValue("@EmployeeID", ins.EmployeeID); //...Return new ID ins.KwikPayID = (int)cmdI.ExecuteScalar(); trx.Commit(); cmdI.Connection.Close(); } catch (SqlException ex) { if (trx != null) { trx.Rollback(); } } finally { //Check for close and respond accordingly if (con.State != ConnectionState.Closed) { con.Close(); } //Clean up con.Dispose(); cmdI.Dispose(); trx.Dispose(); } return(ins); }
public KwikPay Update(KwikPay ins) { //...Get User and Date Data... string ModifiedDate = string.Format("{0:yyyy-MM-dd hh:mm:ss}", DateTime.Now); string EmployeeId = Convert.ToString(HttpContext.Current.Session["Username"]); //...Database Connection... DataBaseConnection dbConn = new DataBaseConnection(); SqlConnection con = dbConn.SqlConn(); con.Open(); SqlCommand cmdI = con.CreateCommand(); cmdI.Connection = con; //...Update Record... cmdI.Parameters.Clear(); cmdI.CommandText = StoredProcedures.KwikPayUpdate; cmdI.CommandType = System.Data.CommandType.StoredProcedure; cmdI.Parameters.AddWithValue("@KwikPayID", ins.KwikPayID); cmdI.Parameters.AddWithValue("@ActualDate", ins.ActualDate); cmdI.Parameters.AddWithValue("@Amount", ins.Amount); cmdI.Parameters.AddWithValue("@CreatedDate", DateTime.Now); cmdI.Parameters.AddWithValue("@KwikPayTypeID", ins.KwikPayTypeID); cmdI.Parameters.AddWithValue("@UserID", EmployeeId); cmdI.Parameters.AddWithValue("@CompanyID", ins.CompanyID); cmdI.Parameters.AddWithValue("@ModifiedDate",ModifiedDate); cmdI.Parameters.AddWithValue("@ModifiedBy", EmployeeId); cmdI.Parameters.AddWithValue("@EmployeeID", ins.EmployeeID); cmdI.ExecuteNonQuery(); cmdI.Connection.Close(); return ins; }
public KwikPay Insert(KwikPay ins) { //...Get User and Date Data... string ModifiedDate = string.Format("{0:yyyy-MM-dd hh:mm:ss}", DateTime.Now); string EmployeeId = Convert.ToString(HttpContext.Current.Session["Username"]); string strTrx = "KwikPayIns_" + EmployeeId; //...Database Connection... DataBaseConnection dbConn = new DataBaseConnection(); SqlConnection con = dbConn.SqlConn(); con.Open(); //...Command Interface... SqlCommand cmdI = con.CreateCommand(); SqlTransaction trx; trx = con.BeginTransaction(strTrx); cmdI.Connection = con; cmdI.Transaction = trx; try { //...Insert Record... cmdI.CommandText = StoredProcedures.KwikPayInsert; cmdI.CommandType = System.Data.CommandType.StoredProcedure; //cmdI.Parameters.AddWithValue("@KwikPayID", ins.KwikPayID); cmdI.Parameters.AddWithValue("@ActualDate", ins.ActualDate); cmdI.Parameters.AddWithValue("@Amount", ins.Amount); cmdI.Parameters.AddWithValue("@CreatedDate", DateTime.Now); cmdI.Parameters.AddWithValue("@KwikPayTypeID", ins.KwikPayTypeID); cmdI.Parameters.AddWithValue("@UserID", EmployeeId); cmdI.Parameters.AddWithValue("@CompanyID", ins.CompanyID); cmdI.Parameters.AddWithValue("@ModifiedDate",ModifiedDate); cmdI.Parameters.AddWithValue("@ModifiedBy", EmployeeId); cmdI.Parameters.AddWithValue("@Removed", ins.Removed); cmdI.Parameters.AddWithValue("@EmployeeID", ins.EmployeeID); //...Return new ID ins.KwikPayID = (int)cmdI.ExecuteScalar(); trx.Commit(); cmdI.Connection.Close(); } catch (SqlException ex) { if (trx != null) trx.Rollback(); } finally { //Check for close and respond accordingly if (con.State != ConnectionState.Closed) { con.Close(); } //Clean up con.Dispose(); cmdI.Dispose(); trx.Dispose(); } return ins; }
public List<KwikPay> GetKwikPaysPerEmployee(int EmployeeID, DateTime date) { //...Create New Instance of Object... List<KwikPay> list = new List<KwikPay>(); KwikPay ins; //...Database Connection... DataBaseConnection dbConn = new DataBaseConnection(); SqlConnection con = dbConn.SqlConn(); SqlCommand cmdI; //...SQL Commands... cmdI = new SqlCommand("SELECT * FROM t_KwikPay WHERE EmployeeID = " + EmployeeID + " AND ActualDate = '" + date.ToShortDateString() + "' AND Removed=0", con); cmdI.Connection.Open(); SqlDataReader drI = cmdI.ExecuteReader(); //...Retrieve Data... if (drI.HasRows) { while (drI.Read()) { ins = new KwikPay(); ins.KwikPayID = Convert.ToInt32(drI["KwikPayID"]); ins.ActualDate = Convert.ToDateTime(drI["ActualDate"]); ins.Amount = Convert.ToDecimal(drI["Amount"]); ins.CreatedDate = Convert.ToDateTime(drI["CreatedDate"]); ins.KwikPayTypeID = Convert.ToInt32(drI["KwikPayTypeID"]); ins.UserID = Convert.ToString(drI["UserID"]); ins.CompanyID = Convert.ToInt32(drI["CompanyID"]); ins.ModifiedDate = Convert.ToDateTime(drI["ModifiedDate"]); ins.ModifiedBy = Convert.ToString(drI["ModifiedBy"]); ins.Removed = Convert.ToBoolean(drI["Removed"]); list.Add(ins); } } //...Close Connections... drI.Close(); con.Close(); //...Return... return list; }
public JsonResult _UpdateKwikPay(KwikPay ins) { KwikPay ins2 = KwikRep.Update(ins); //...Repopulate Grid... return Json(new GridModel(KwikRep.GetAllKwikPay())); }