/// <summary> /// To Insert details of SILO in SILO table /// Created By : Chintan, 06-10-2015 /// Modified By : /// </summary> public ApplicationResult Silo_Insert(SiloBo objSILOBo) { try { pSqlParameter = new SqlParameter[5]; pSqlParameter[0] = new SqlParameter("@Name", SqlDbType.NVarChar); pSqlParameter[0].Direction = ParameterDirection.Input; pSqlParameter[0].Value = objSILOBo.Name; pSqlParameter[1] = new SqlParameter("@PLCValue", SqlDbType.Real); pSqlParameter[1].Direction = ParameterDirection.Input; pSqlParameter[1].Value = objSILOBo.PLCValue; pSqlParameter[2] = new SqlParameter("@IsDeleted", SqlDbType.Int); pSqlParameter[2].Direction = ParameterDirection.Input; pSqlParameter[2].Value = objSILOBo.IsDeleted; pSqlParameter[3] = new SqlParameter("@CreatedBy", SqlDbType.Int); pSqlParameter[3].Direction = ParameterDirection.Input; pSqlParameter[3].Value = objSILOBo.CreatedBy; pSqlParameter[4] = new SqlParameter("@CreatedDate", SqlDbType.DateTime); pSqlParameter[4].Direction = ParameterDirection.Input; pSqlParameter[4].Value = objSILOBo.CreatedDate; sSql = "usp_tbl_SILO_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 { objSILOBo = null; } }
/// <summary> /// To Update details of SILO in SILO table /// Created By : Chintan, 06-10-2015 /// Modified By : /// </summary> public ApplicationResult Silo_Update(SiloBo objSILOBo) { try { pSqlParameter = new SqlParameter[5]; pSqlParameter[0] = new SqlParameter("@SILOID", SqlDbType.Int); pSqlParameter[0].Direction = ParameterDirection.Input; pSqlParameter[0].Value = objSILOBo.SILOID; pSqlParameter[1] = new SqlParameter("@Name", SqlDbType.NVarChar); pSqlParameter[1].Direction = ParameterDirection.Input; pSqlParameter[1].Value = objSILOBo.Name; pSqlParameter[2] = new SqlParameter("@PLCValue", SqlDbType.Real); pSqlParameter[2].Direction = ParameterDirection.Input; pSqlParameter[2].Value = objSILOBo.PLCValue; pSqlParameter[3] = new SqlParameter("@LastModifiedBy", SqlDbType.Int); pSqlParameter[3].Direction = ParameterDirection.Input; pSqlParameter[3].Value = objSILOBo.LastModifiedBy; pSqlParameter[4] = new SqlParameter("@LastModifiedDate", SqlDbType.DateTime); pSqlParameter[4].Direction = ParameterDirection.Input; pSqlParameter[4].Value = objSILOBo.LastModifiedDate; sSql = "usp_tbl_SILO_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 { objSILOBo = null; } }
protected void btnSave_OnClick(object sender, EventArgs e) { try { SiloBo objSiloBo = new SiloBo(); SiloBl objSiloBl = new SiloBl(); objSiloBo.Name = txtName.Text.Trim(); objSiloBo.PLCValue = Convert.ToInt32(txtPLCValue.Text); if (ViewState["Mode"].ToString() == "Save") { objSiloBo.CreatedBy = Convert.ToInt32(Session[ApplicationSession.Userid]); objSiloBo.CreatedDate = DateTime.UtcNow.AddHours(5.5); var objResult = objSiloBl.Silo_Insert(objSiloBo); 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(); BindgvSilo(); PanelVisibilityMode(true, false); } } } } else if (ViewState["Mode"].ToString() == "Edit") { objSiloBo.LastModifiedBy = Convert.ToInt32(Session[ApplicationSession.Userid]); objSiloBo.LastModifiedDate = DateTime.UtcNow.AddHours(5.5); objSiloBo.SILOID = Convert.ToInt32(ViewState["ID"].ToString()); var objResult = objSiloBl.Silo_Update(objSiloBo); 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(); BindgvSilo(); 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>"); } }