public bool UpdateShifts(int shiftId, MasterShifts objShift) { DBDataHelper.ConnectionString = ConfigurationManager.ConnectionStrings["CSBiometricAttendance"].ConnectionString; List <SqlParameter> lstShift = new List <SqlParameter>(); lstShift.Add(new SqlParameter("@shiftId", shiftId)); lstShift.Add(new SqlParameter("@name", objShift.Name)); lstShift.Add(new SqlParameter("@firstHalfStart", objShift.FirstHalfStart)); lstShift.Add(new SqlParameter("@firstHalfEnd", objShift.FirstHalfEnd)); lstShift.Add(new SqlParameter("@secondHalfStart", objShift.SecondHalfStart)); lstShift.Add(new SqlParameter("@secondHalfEnd", objShift.SecondHalfEnd)); lstShift.Add(new SqlParameter("@shlDuration", objShift.SHLDuration)); lstShift.Add(new SqlParameter("@updatedOn", DateTime.Now)); DataTable dt = new DataTable(); DataSet ds; try { using (DBDataHelper objDDBDataHelper = new DBDataHelper()) { objDDBDataHelper.ExecSQL("spUpdateShift", SQLTextType.Stored_Proc, lstShift); } return(true); } catch (Exception) { return(false); } }
public void GetShiftsById(int Id, out MasterShifts objShift) //to be edited { DBDataHelper.ConnectionString = ConfigurationManager.ConnectionStrings["CSBiometricAttendance"].ConnectionString; DataTable dt = new DataTable(); List <SqlParameter> lst = new List <SqlParameter>(); lst.Add(new SqlParameter("@id", Id)); DataSet ds; int i = 0; MasterShifts objShifts1 = new MasterShifts(); using (DBDataHelper objDDBDataHelper = new DBDataHelper()) { ds = objDDBDataHelper.GetDataSet("spGetShiftsById", SQLTextType.Stored_Proc, lst); List <MasterShifts> lstShifts = new List <MasterShifts>(); foreach (DataRow rows in ds.Tables[0].Rows) { objShifts1.Id = Convert.ToInt32(ds.Tables[0].Rows[i][0]); objShifts1.Name = ds.Tables[0].Rows[i][1].ToString(); objShifts1.FirstHalfStart = TimeSpan.Parse(ds.Tables[0].Rows[i][2].ToString()); objShifts1.FirstHalfEnd = TimeSpan.Parse(ds.Tables[0].Rows[i][3].ToString()); objShifts1.SecondHalfStart = TimeSpan.Parse(ds.Tables[0].Rows[i][4].ToString()); objShifts1.SecondHalfEnd = TimeSpan.Parse(ds.Tables[0].Rows[i][5].ToString()); objShifts1.SHLDuration = TimeSpan.Parse(ds.Tables[0].Rows[i][6].ToString()); i++; } objShift = objShifts1; } }
/// <summary> /// Get all shifts /// </summary> /// <returns>List of Shifts object</returns> public List <MasterShifts> GetAllShifts() { DBDataHelper.ConnectionString = ConfigurationManager.ConnectionStrings["CSBiometricAttendance"].ConnectionString; DataTable dt = new DataTable(); DataSet ds; int i = 0; using (DBDataHelper objDDBDataHelper = new DBDataHelper()) { ds = objDDBDataHelper.GetDataSet("spGetAllShifts", SQLTextType.Stored_Proc); List <MasterShifts> lstShifts = new List <MasterShifts>(); foreach (DataRow rows in ds.Tables[0].Rows) { MasterShifts objShifts = new MasterShifts(); objShifts.Id = Convert.ToInt32(ds.Tables[0].Rows[i][0]); objShifts.Name = ds.Tables[0].Rows[i][1].ToString(); objShifts.FirstHalfStart = TimeSpan.Parse(ds.Tables[0].Rows[i][2].ToString()); objShifts.FirstHalfEnd = TimeSpan.Parse(ds.Tables[0].Rows[i][3].ToString()); objShifts.SecondHalfStart = TimeSpan.Parse(ds.Tables[0].Rows[i][4].ToString()); objShifts.SecondHalfEnd = TimeSpan.Parse(ds.Tables[0].Rows[i][5].ToString()); objShifts.SHLDuration = TimeSpan.Parse(ds.Tables[0].Rows[i][6].ToString()); objShifts.IsActive = Convert.ToBoolean(ds.Tables[0].Rows[i][7]); lstShifts.Add(objShifts); i++; } return(lstShifts); } }
protected void lnkbtnShifts_Click(object sender, EventArgs e) { MasterShifts objShift = new MasterShifts(); objShift.Name = txtName.Text; objShift.FirstHalfStart = TimeSpan.Parse(txtFirstHalfStart.Text); objShift.FirstHalfEnd = TimeSpan.Parse(txtFirstHalfEnd.Text); objShift.SecondHalfStart = TimeSpan.Parse(txtSecondHalfStart.Text); objShift.SecondHalfEnd = TimeSpan.Parse(txtSecondHalfEnd.Text); objShift.SHLDuration = TimeSpan.Parse(txtSLDuration.Text); MasterEntries objMasterEntry = new MasterEntries(); objMasterEntry.AddShift(objShift); grdShiftsBind(); }
protected void btnEditShifts_Click(object sender, EventArgs e) { MasterEntries objMasterEntry = new MasterEntries(); int Id = Convert.ToInt32(Session["shiftId"]); MasterShifts objShift = new MasterShifts(); objShift.Name = txtEditName.Text; objShift.FirstHalfStart = TimeSpan.Parse(txtEditFirstHalfStart.Text); objShift.FirstHalfEnd = TimeSpan.Parse(txtEditFirstHalfEnd.Text); objShift.SecondHalfStart = TimeSpan.Parse(txtEditSecondHalfStart.Text); objShift.SecondHalfEnd = TimeSpan.Parse(txtEditSecondHalfEnd.Text); objShift.SHLDuration = TimeSpan.Parse(txtEditSLDuration.Text); objMasterEntry.UpdateShifts(Id, objShift); grdShiftsBind(); popupEditShifts.Hide(); }
protected void lkbEditShift_Click(object sender, EventArgs e) { MasterEntries objMasterEntry = new MasterEntries(); LinkButton b = (LinkButton)sender; int Id = Convert.ToInt32(b.CommandArgument); MasterShifts objShift = new MasterShifts(); objMasterEntry.GetShiftsById(Id, out objShift); Session["shiftId"] = Id; txtEditName.Text = objShift.Name.ToString(); txtEditFirstHalfStart.Text = objShift.FirstHalfStart.ToString(); txtEditFirstHalfEnd.Text = objShift.FirstHalfEnd.ToString(); txtEditSecondHalfStart.Text = objShift.SecondHalfStart.ToString(); txtEditSecondHalfEnd.Text = objShift.SecondHalfEnd.ToString(); txtEditSLDuration.Text = objShift.SHLDuration.ToString(); popupEditShifts.Show(); }
public bool UpdateShifts(int shiftId, MasterShifts objShift) { DBDataHelper.ConnectionString = ConfigurationManager.ConnectionStrings["CSBiometricAttendance"].ConnectionString; List<SqlParameter> lstShift = new List<SqlParameter>(); lstShift.Add(new SqlParameter("@shiftId", shiftId)); lstShift.Add(new SqlParameter("@name", objShift.Name)); lstShift.Add(new SqlParameter("@firstHalfStart", objShift.FirstHalfStart)); lstShift.Add(new SqlParameter("@firstHalfEnd", objShift.FirstHalfEnd)); lstShift.Add(new SqlParameter("@secondHalfStart", objShift.SecondHalfStart)); lstShift.Add(new SqlParameter("@secondHalfEnd", objShift.SecondHalfEnd)); lstShift.Add(new SqlParameter("@shlDuration", objShift.SHLDuration)); lstShift.Add(new SqlParameter("@updatedOn", DateTime.Now)); DataTable dt = new DataTable(); DataSet ds; try { using (DBDataHelper objDDBDataHelper = new DBDataHelper()) { objDDBDataHelper.ExecSQL("spUpdateShift", SQLTextType.Stored_Proc, lstShift); } return true; } catch(Exception) { return false; } }
public void GetShiftsById(int Id, out MasterShifts objShift) //to be edited { DBDataHelper.ConnectionString = ConfigurationManager.ConnectionStrings["CSBiometricAttendance"].ConnectionString; DataTable dt = new DataTable(); List<SqlParameter> lst = new List<SqlParameter>(); lst.Add(new SqlParameter("@id", Id)); DataSet ds; int i = 0; MasterShifts objShifts1 = new MasterShifts(); using (DBDataHelper objDDBDataHelper = new DBDataHelper()) { ds = objDDBDataHelper.GetDataSet("spGetShiftsById", SQLTextType.Stored_Proc, lst); List<MasterShifts> lstShifts = new List<MasterShifts>(); foreach (DataRow rows in ds.Tables[0].Rows) { objShifts1.Id = Convert.ToInt32(ds.Tables[0].Rows[i][0]); objShifts1.Name = ds.Tables[0].Rows[i][1].ToString(); objShifts1.FirstHalfStart = TimeSpan.Parse(ds.Tables[0].Rows[i][2].ToString()); objShifts1.FirstHalfEnd = TimeSpan.Parse(ds.Tables[0].Rows[i][3].ToString()); objShifts1.SecondHalfStart = TimeSpan.Parse(ds.Tables[0].Rows[i][4].ToString()); objShifts1.SecondHalfEnd = TimeSpan.Parse(ds.Tables[0].Rows[i][5].ToString()); objShifts1.SHLDuration = TimeSpan.Parse(ds.Tables[0].Rows[i][6].ToString()); i++; } objShift = objShifts1; } }
/// <summary> /// Get all shifts /// </summary> /// <returns>List of Shifts object</returns> public List<MasterShifts> GetAllShifts() { DBDataHelper.ConnectionString = ConfigurationManager.ConnectionStrings["CSBiometricAttendance"].ConnectionString; DataTable dt = new DataTable(); DataSet ds; int i = 0; using (DBDataHelper objDDBDataHelper = new DBDataHelper()) { ds = objDDBDataHelper.GetDataSet("spGetAllShifts", SQLTextType.Stored_Proc); List<MasterShifts> lstShifts = new List<MasterShifts>(); foreach (DataRow rows in ds.Tables[0].Rows) { MasterShifts objShifts = new MasterShifts(); objShifts.Id = Convert.ToInt32(ds.Tables[0].Rows[i][0]); objShifts.Name = ds.Tables[0].Rows[i][1].ToString(); objShifts.FirstHalfStart = TimeSpan.Parse(ds.Tables[0].Rows[i][2].ToString()); objShifts.FirstHalfEnd = TimeSpan.Parse(ds.Tables[0].Rows[i][3].ToString()); objShifts.SecondHalfStart = TimeSpan.Parse(ds.Tables[0].Rows[i][4].ToString()); objShifts.SecondHalfEnd = TimeSpan.Parse(ds.Tables[0].Rows[i][5].ToString()); objShifts.SHLDuration = TimeSpan.Parse(ds.Tables[0].Rows[i][6].ToString()); objShifts.IsActive = Convert.ToBoolean(ds.Tables[0].Rows[i][7]); lstShifts.Add(objShifts); i++; } return lstShifts; } }
public MasterShifts GetShiftForEmployeeDateWise(int employeeId, DateTime date) { int shiftId = 0; if (!IsShiftEntryDateWiseExists(employeeId, date, out shiftId)) { string shiftQuery = @"Select ShiftId from tblEmployees Where EmployeeId=@employeeId AND isDeleted = 0"; List<SqlParameter> list_params_1 = new List<SqlParameter>() { new SqlParameter("@employeeId",employeeId) }; DataTable dtShiftId; using (DBDataHelper helper = new DBDataHelper()) { dtShiftId = helper.GetDataTable(shiftQuery, SQLTextType.Query, list_params_1); } if (dtShiftId.Rows.Count > 0) { shiftId = Convert.ToInt32(dtShiftId.Rows[0][0].ToString()); } } string query = @"Select * from tblMasterShifts Where Id=@shiftId"; List<SqlParameter> list_params = new List<SqlParameter>() { new SqlParameter("@shiftId",shiftId) }; DataTable dt; using (DBDataHelper helper = new DBDataHelper()) { dt = helper.GetDataTable(query, SQLTextType.Query, list_params); } MasterShifts objMasterShift = new MasterShifts(); if (dt.Rows.Count > 0) { objMasterShift.Id = (dt.Rows[0][0] == DBNull.Value) ? 0 : Convert.ToInt32(dt.Rows[0][0]); objMasterShift.Name = (dt.Rows[0][1] == DBNull.Value) ? string.Empty : (dt.Rows[0][1]).ToString(); objMasterShift.FirstHalfStart = (dt.Rows[0][2] == DBNull.Value) ? new TimeSpan() : (TimeSpan)(dt.Rows[0][2]); objMasterShift.FirstHalfEnd = (dt.Rows[0][3] == DBNull.Value) ? new TimeSpan() : (TimeSpan)(dt.Rows[0][3]); objMasterShift.SecondHalfStart = (dt.Rows[0][4] == DBNull.Value) ? new TimeSpan() : (TimeSpan)(dt.Rows[0][4]); objMasterShift.SecondHalfEnd = (dt.Rows[0][5] == DBNull.Value) ? new TimeSpan() : (TimeSpan)(dt.Rows[0][5]); objMasterShift.SHLDuration = (dt.Rows[0][6] == DBNull.Value) ? new TimeSpan() : (TimeSpan)(dt.Rows[0][6]); } return objMasterShift; }
public MasterShifts GetShiftForEmployee(int employeeId) { string query = @"Select tblMasterShifts.Id,tblMasterShifts.Name,tblMasterShifts.FirstHalfStart,tblMasterShifts.FirstHalfEnd, tblMasterShifts.SecondHalfStart,tblMasterShifts.SecondHalfEnd,tblMasterShifts.SHLDuration FROM tblMasterShifts,tblEmployees WHERE EmployeeId=@employeeId AND tblMasterShifts.Id = tblEmployees.ShiftId AND tblMasterShifts.isDeleted = 0"; List<SqlParameter> list_params = new List<SqlParameter>() { new SqlParameter("@employeeId",employeeId) }; DataTable dt; using (DBDataHelper helper = new DBDataHelper()) { dt = helper.GetDataTable(query, SQLTextType.Query, list_params); } MasterShifts objMasterShift = new MasterShifts(); if (dt.Rows.Count > 0) { objMasterShift.Id = (dt.Rows[0][0] == DBNull.Value) ? 0 : Convert.ToInt32(dt.Rows[0][0]); objMasterShift.Name = (dt.Rows[0][1] == DBNull.Value) ? string.Empty : (dt.Rows[0][1]).ToString(); objMasterShift.FirstHalfStart = (dt.Rows[0][2] == DBNull.Value) ? new TimeSpan() : (TimeSpan)(dt.Rows[0][2]); objMasterShift.FirstHalfEnd = (dt.Rows[0][3] == DBNull.Value) ? new TimeSpan() : (TimeSpan)(dt.Rows[0][3]); objMasterShift.SecondHalfStart = (dt.Rows[0][4] == DBNull.Value) ? new TimeSpan() : (TimeSpan)(dt.Rows[0][4]); objMasterShift.SecondHalfEnd = (dt.Rows[0][5] == DBNull.Value) ? new TimeSpan() : (TimeSpan)(dt.Rows[0][5]); objMasterShift.SHLDuration = (dt.Rows[0][6] == DBNull.Value) ? new TimeSpan() : (TimeSpan)(dt.Rows[0][6]); } return objMasterShift; }