/// <summary> /// To Update details of Shift in Shift table /// Created By : Chintan, 06-10-2015 /// Modified By : /// </summary> public ApplicationResult Shift_Update(ShiftBo objShiftBo, string strFromTime, string strToTime) { try { pSqlParameter = new SqlParameter[6]; pSqlParameter[0] = new SqlParameter("@ShiftId", SqlDbType.Int); pSqlParameter[0].Direction = ParameterDirection.Input; pSqlParameter[0].Value = objShiftBo.ShiftId; pSqlParameter[1] = new SqlParameter("@Name", SqlDbType.NVarChar); pSqlParameter[1].Direction = ParameterDirection.Input; pSqlParameter[1].Value = objShiftBo.Name; pSqlParameter[2] = new SqlParameter("@FromTime", SqlDbType.VarChar); pSqlParameter[2].Direction = ParameterDirection.Input; pSqlParameter[2].Value = strFromTime; pSqlParameter[3] = new SqlParameter("@ToTime", SqlDbType.VarChar); pSqlParameter[3].Direction = ParameterDirection.Input; pSqlParameter[3].Value = strToTime; pSqlParameter[4] = new SqlParameter("@LastModifiedBy", SqlDbType.Int); pSqlParameter[4].Direction = ParameterDirection.Input; pSqlParameter[4].Value = objShiftBo.LastModifiedBy; pSqlParameter[5] = new SqlParameter("@LastModifiedDate", SqlDbType.DateTime); pSqlParameter[5].Direction = ParameterDirection.Input; pSqlParameter[5].Value = objShiftBo.LastModifiedDate; sSql = "usp_tbl_Shift_Update"; DataTable dtResult = new DataTable(); dtResult = Database.ExecuteDataTable(CommandType.StoredProcedure, sSql, pSqlParameter); ApplicationResult objResults = new ApplicationResult(dtResult); objResults.Status = ApplicationResult.CommonStatusType.Success; return(objResults); } catch (Exception ex) { throw ex; } finally { objShiftBo = null; } }
protected void btnSave_OnClick(object sender, EventArgs e) { try { ShiftBo objShiftBo = new ShiftBo(); ShiftBl objShiftBl = new ShiftBl(); string strFromTime = string.Empty; string strToTime = string.Empty; objShiftBo.Name = txtName.Text.Trim(); strFromTime = txtFromTime.Text; strToTime = txtToTime.Text; if (ViewState["Mode"].ToString() == "Save") { objShiftBo.CreatedBy = Convert.ToInt32(Session[ApplicationSession.Userid]); objShiftBo.CreatedDate = DateTime.UtcNow.AddHours(5.5); var objResult = objShiftBl.Shift_Insert(objShiftBo, strFromTime, strToTime); if (objResult != null) { if (objResult.ResultDt.Rows.Count > 0) { int intStatus = Convert.ToInt32(objResult.ResultDt.Rows[0]["Status"].ToString()); if (intStatus == 0) { ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('" + txtName.Text + " is already exist.');</script>"); } else { ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Record Saved Successfully.');</script>"); ClearAll(); BindgvShift(); PanelVisibilityMode(true, false); } } } } else if (ViewState["Mode"].ToString() == "Edit") { objShiftBo.LastModifiedBy = Convert.ToInt32(Session[ApplicationSession.Userid]); objShiftBo.LastModifiedDate = DateTime.UtcNow.AddHours(5.5); objShiftBo.ShiftId = Convert.ToInt32(ViewState["ID"].ToString()); var objResult = objShiftBl.Shift_Update(objShiftBo, strFromTime, strToTime); if (objResult != null) { if (objResult.ResultDt.Rows.Count > 0) { int intStatus = Convert.ToInt32(objResult.ResultDt.Rows[0]["Status"].ToString()); if (intStatus == 0) { ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('" + txtName.Text + " is already exist.');</script>"); } else { ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Record Updated Successfully.');</script>"); ClearAll(); BindgvShift(); PanelVisibilityMode(true, false); } } } } } catch (Exception ex) { log.Error("Error", ex); ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Oops! There is some technical Problem. Contact to your Administrator.');</script>"); } }
/// <summary> /// To Insert details of Shift in Shift table /// Created By : Chintan, 06-10-2015 /// Modified By : /// </summary> public ApplicationResult Shift_Insert(ShiftBo objShiftBo, string strFromTime, string strToTime) { try { pSqlParameter = new SqlParameter[6]; pSqlParameter[0] = new SqlParameter("@Name", SqlDbType.NVarChar); pSqlParameter[0].Direction = ParameterDirection.Input; pSqlParameter[0].Value = objShiftBo.Name; pSqlParameter[1] = new SqlParameter("@FromTime", SqlDbType.VarChar); pSqlParameter[1].Direction = ParameterDirection.Input; pSqlParameter[1].Value = strFromTime; pSqlParameter[2] = new SqlParameter("@ToTime", SqlDbType.VarChar); pSqlParameter[2].Direction = ParameterDirection.Input; pSqlParameter[2].Value = strToTime; pSqlParameter[3] = new SqlParameter("@IsDeleted", SqlDbType.Int); pSqlParameter[3].Direction = ParameterDirection.Input; pSqlParameter[3].Value = objShiftBo.IsDeleted; pSqlParameter[4] = new SqlParameter("@CreatedDate", SqlDbType.DateTime); pSqlParameter[4].Direction = ParameterDirection.Input; pSqlParameter[4].Value = objShiftBo.CreatedDate; pSqlParameter[5] = new SqlParameter("@CreatedBy", SqlDbType.Int); pSqlParameter[5].Direction = ParameterDirection.Input; pSqlParameter[5].Value = objShiftBo.CreatedBy; sSql = "usp_tbl_Shift_Insert"; //int iResult = Database.ExecuteNonQuery(CommandType.StoredProcedure, sSql, pSqlParameter); //if (iResult > 0) //{ // ApplicationResult objResults = new ApplicationResult(); // objResults.Status = ApplicationResult.CommonStatusType.Success; // return objResults; //} //else //{ // ApplicationResult objResults = new ApplicationResult(); // objResults.Status = ApplicationResult.CommonStatusType.Failure; // return objResults; //} DataTable dtResult = new DataTable(); dtResult = Database.ExecuteDataTable(CommandType.StoredProcedure, sSql, pSqlParameter); ApplicationResult objResults = new ApplicationResult(dtResult); objResults.Status = ApplicationResult.CommonStatusType.Success; return(objResults); } catch (Exception ex) { throw ex; } finally { objShiftBo = null; } }