protected void btnSave_OnClick(object sender, EventArgs e) { try { MassBalanceBO objMassBalanceBO = new MassBalanceBO(); //ApplicationResult objResult = new ApplicationResult(); MassBalanceBl objMassBalanceBl = new MassBalanceBl(); objMassBalanceBO.Date = DateTime.ParseExact(txtDate.Text.Trim(), "dd/MM/yyyy", CultureInfo.InvariantCulture); objMassBalanceBO.MilkKg = float.Parse(txtMilkKg.Text.Trim()); objMassBalanceBO.FATMilkKg = float.Parse(txtMilkFAT.Text.Trim()); objMassBalanceBO.SNFMilkKg = float.Parse(txtMilkSNF.Text.Trim()); objMassBalanceBO.SugarMilkKg = float.Parse(txtMilkSugar.Text.Trim()); objMassBalanceBO.QtyOfPowder = float.Parse(txtQtyofPowder.Text.Trim()); objMassBalanceBO.FATQty = float.Parse(txtTSFAT.Text.Trim()); objMassBalanceBO.SNFQty = float.Parse(txtTSSNF.Text.Trim()); objMassBalanceBO.SugarQty = float.Parse(txtTSSugar.Text.Trim()); objMassBalanceBO.TotalSolidKG = float.Parse(txtTotalSolid.Text.Trim()); objMassBalanceBO.Variation = float.Parse(txtVariation.Text.Trim()); objMassBalanceBO.UserId = Convert.ToInt32(Session[ApplicationSession.Userid]); switch (ViewState["Mode"].ToString()) { case "Save": objMassBalanceBO.CreatedBy = Convert.ToInt32(Session[ApplicationSession.Userid]); objMassBalanceBO.CreatedDate = DateTime.UtcNow.AddHours(5.5); break; case "Edit": objMassBalanceBO.LastModifiedBy = Convert.ToInt32(Session[ApplicationSession.Userid]); objMassBalanceBO.LastModifiedDate = DateTime.UtcNow.AddHours(5.5); break; } if (ViewState["Mode"].ToString() == "Save") { var objResult = objMassBalanceBl.MassBalance_Insert(objMassBalanceBO); if (objResult.Status == ApplicationResult.CommonStatusType.Success) { ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Record Saved Successfully.');</script>"); ClearAll(); BindgvMassBalance(); // PanelVisibilityMode(true, false); } } else if (ViewState["Mode"].ToString() == "Edit") { objMassBalanceBO.Id = Convert.ToInt32(ViewState["MassBalanceID"].ToString()); var objResult = objMassBalanceBl.MassBalance_Update(objMassBalanceBO); if (objResult.Status == ApplicationResult.CommonStatusType.Success) { ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Record Updated Successfully.');</script>"); ClearAll(); BindgvMassBalance(); 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 Update details of MassBalance in MassBalance table /// Created By : pavan, 12-07-2017 /// Modified By : /// </summary> /// <param name="objMassBalanceBO"></param> /// <returns></returns> public ApplicationResult MassBalance_Update(MassBalanceBO objMassBalanceBO) { try { pSqlParameter = new SqlParameter[15]; pSqlParameter[0] = new SqlParameter("@Id", SqlDbType.Int); pSqlParameter[0].Direction = ParameterDirection.Input; pSqlParameter[0].Value = objMassBalanceBO.Id; pSqlParameter[1] = new SqlParameter("@MilkKg", SqlDbType.Float); pSqlParameter[1].Direction = ParameterDirection.Input; pSqlParameter[1].Value = objMassBalanceBO.MilkKg; pSqlParameter[2] = new SqlParameter("@FATMilkKg", SqlDbType.Float); pSqlParameter[2].Direction = ParameterDirection.Input; pSqlParameter[2].Value = objMassBalanceBO.FATMilkKg; pSqlParameter[3] = new SqlParameter("@SNFMilkKg", SqlDbType.Float); pSqlParameter[3].Direction = ParameterDirection.Input; pSqlParameter[3].Value = objMassBalanceBO.SNFMilkKg; pSqlParameter[4] = new SqlParameter("@SugarMilkKg", SqlDbType.Float); pSqlParameter[4].Direction = ParameterDirection.Input; pSqlParameter[4].Value = objMassBalanceBO.SugarMilkKg; pSqlParameter[5] = new SqlParameter("@QtyOfPowder", SqlDbType.Float); pSqlParameter[5].Direction = ParameterDirection.Input; pSqlParameter[5].Value = objMassBalanceBO.QtyOfPowder; pSqlParameter[6] = new SqlParameter("@FATQty", SqlDbType.Float); pSqlParameter[6].Direction = ParameterDirection.Input; pSqlParameter[6].Value = objMassBalanceBO.FATQty; pSqlParameter[7] = new SqlParameter("@SNFQty", SqlDbType.Float); pSqlParameter[7].Direction = ParameterDirection.Input; pSqlParameter[7].Value = objMassBalanceBO.SNFQty; pSqlParameter[8] = new SqlParameter("@SugarQty", SqlDbType.Float); pSqlParameter[8].Direction = ParameterDirection.Input; pSqlParameter[8].Value = objMassBalanceBO.SugarQty; pSqlParameter[9] = new SqlParameter("@UserId", SqlDbType.Int); pSqlParameter[9].Direction = ParameterDirection.Input; pSqlParameter[9].Value = objMassBalanceBO.UserId; pSqlParameter[10] = new SqlParameter("@Date", SqlDbType.DateTime); pSqlParameter[10].Direction = ParameterDirection.Input; pSqlParameter[10].Value = objMassBalanceBO.Date; pSqlParameter[11] = new SqlParameter("@LastModifiedBy", SqlDbType.Int); pSqlParameter[11].Direction = ParameterDirection.Input; pSqlParameter[11].Value = objMassBalanceBO.LastModifiedBy; pSqlParameter[12] = new SqlParameter("@LastModifiedDate", SqlDbType.DateTime); pSqlParameter[12].Direction = ParameterDirection.Input; pSqlParameter[12].Value = objMassBalanceBO.LastModifiedDate; pSqlParameter[13] = new SqlParameter("@TotalSolidKG", SqlDbType.Float); pSqlParameter[13].Direction = ParameterDirection.Input; pSqlParameter[13].Value = objMassBalanceBO.TotalSolidKG; pSqlParameter[14] = new SqlParameter("@Variation", SqlDbType.Float); pSqlParameter[14].Direction = ParameterDirection.Input; pSqlParameter[14].Value = objMassBalanceBO.Variation; sSql = "usp_tbl_MassBalance_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 { objMassBalanceBO = null; } }