protected void btnSave_Click(object sender, EventArgs e) { CommodityGradingFactorBLL obj = new CommodityGradingFactorBLL(); obj.Id = Guid.NewGuid(); if (this.chkIsCommodity.Checked == true) { obj.CommodityId = new Guid(this.cboCommodity.SelectedValue.ToString()); } else { obj.CommodityId = new Guid(this.cboCommodityGrade.SelectedValue.ToString()); } obj.GradingFactorGroupId = new Guid(this.cboGradingFactorName.SelectedValue.ToString()); obj.Status = (CommodityGradingFactorStatus)(int.Parse(this.cboStatus.SelectedValue.ToString())); obj.CreatedBy = UserBLL.GetCurrentUser(); obj.isForCommodity = this.chkIsCommodity.Checked; if (obj.Save() == true) { this.lblMessage.Text = "Data updated Successfully."; } else { this.lblMessage.Text = "Unable to update data."; } }
public static bool Save(CommodityGradingFactorBLL obj, SqlTransaction tran) { int Affectedrow = -1; string strsql = "spInsertCommodityGradingFactor"; SqlParameter[] arPar = new SqlParameter[6]; try { arPar[0] = new SqlParameter("@Id", SqlDbType.UniqueIdentifier); arPar[0].Value = obj.Id; arPar[1] = new SqlParameter("@CommodityId", SqlDbType.UniqueIdentifier); arPar[1].Value = obj.CommodityId; arPar[2] = new SqlParameter("@GradingFactorGroupId", SqlDbType.UniqueIdentifier); arPar[2].Value = obj.GradingFactorGroupId; arPar[3] = new SqlParameter("@Status", SqlDbType.Int); arPar[3].Value = (int)obj.Status; arPar[4] = new SqlParameter("@CreatedBy", SqlDbType.UniqueIdentifier); arPar[4].Value = UserBLL.GetCurrentUser(); arPar[5] = new SqlParameter("@isForCommodity", SqlDbType.Bit); arPar[5].Value = obj.isForCommodity; Affectedrow = SqlHelper.ExecuteNonQuery(tran, CommandType.StoredProcedure, strsql, arPar); if (Affectedrow == 1) { return(true); } else { return(false); } } catch (Exception ex) { throw ex; } }
private void Search() { List <CommodityGradingFactorBLL> list = new List <CommodityGradingFactorBLL>(); CommodityGradingFactorBLL obj = new CommodityGradingFactorBLL(); if (this.cboSearchCommodityGrade.SelectedValue != "") { list = obj.GetByCommodityId(new Guid(this.cboSearchCommodityGrade.SelectedValue.ToString())); } else if (this.cboSearchCommodity.SelectedValue != "") { list = obj.GetByCommodityId(new Guid(this.cboSearchCommodity.SelectedValue.ToString())); } this.gvGroup.DataSource = list; this.gvGroup.DataBind(); }
protected void gvGroup_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "cmdCancel") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow rw = this.gvGroup.Rows[index]; Label lblId = (Label)rw.FindControl("lblId"); if (lblId != null) { Guid Id = new Guid(lblId.Text); CommodityGradingFactorBLL obj = new CommodityGradingFactorBLL(); if (obj.Inactive(Id) == true) { this.lblMessage.Text = "Data Updated Successfully"; this.gvGroup.EditIndex = -1; Search(); } else { this.lblMessage.Text = "Unable to Update Data"; } } } }
public static List <CommodityGradingFactorBLL> GetByCommodityId(Guid CommodityId) { string strSql = "spGetCommodityGradingFactorGroupByCommodityId"; SqlConnection conn = new SqlConnection(); List <CommodityGradingFactorBLL> list; try { conn = Connection.getConnection(); SqlParameter[] arPar = new SqlParameter[1]; SqlDataReader reader; arPar[0] = new SqlParameter("@CommodityId", SqlDbType.UniqueIdentifier); arPar[0].Value = CommodityId; reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql, arPar); if (reader != null) { if (reader.HasRows) { list = new List <CommodityGradingFactorBLL>(); while (reader.Read()) { CommodityGradingFactorBLL obj = new CommodityGradingFactorBLL(); if (reader["Id"] != DBNull.Value) { obj.Id = new Guid(reader["Id"].ToString()); } if (reader["CommodityId"] != DBNull.Value) { obj.CommodityId = new Guid(reader["CommodityId"].ToString()); } if (reader["GradingFactorGroupId"] != DBNull.Value) { obj.GradingFactorGroupId = new Guid(reader["GradingFactorGroupId"].ToString()); } if (reader["Status"] != DBNull.Value) { obj.Status = (CommodityGradingFactorStatus)int.Parse(reader["Status"].ToString()); } if (reader["CreatedBy"] != DBNull.Value) { obj.CreatedBy = new Guid(reader["CreatedBy"].ToString()); } if (reader["CreatedTimestamp"] != DBNull.Value) { obj.CreatedTimestamp = DateTime.Parse(reader["CreatedTimestamp"].ToString()); } if (reader["LastModifiedBy"] != DBNull.Value) { obj.LastModifiedBy = new Guid(reader["LastModifiedBy"].ToString()); } if (reader["LastModifiedTimestamp"] != DBNull.Value) { obj.LastModifiedTimestamp = DateTime.Parse(reader["LastModifiedTimestamp"].ToString()); } if (reader["IsForCommodity"] != DBNull.Value) { obj.isForCommodity = bool.Parse(reader["IsForCommodity"].ToString()); } obj.GroupName = reader["GradingFactorGroupName"].ToString(); list.Add(obj); } return(list); } } else { return(null); } } catch (Exception ex) { throw ex; } finally { if (conn.State == ConnectionState.Open) { conn.Close(); } } return(null); }