protected void cboCommodity_SelectedIndexChanged(object sender, EventArgs e) { Guid CommodityGradeId = Guid.Empty; try { CommodityGradeId = new Guid(this.cboCommodity.SelectedValue.ToString()); } catch { this.lblMsg.Text = "Please Select commodity Grade."; return; } if (CommodityGradeId != Guid.Empty) { GradingFactorBLL obj = new GradingFactorBLL(); List <GradingFactorBLL> list = new List <GradingFactorBLL>(); if (this.chkRecivedGrade.Checked == false) { list = obj.GetGradingFactors(CommodityGradeId); } else { list = null; } this.gvGradingFactors.DataSource = list; this.gvGradingFactors.DataBind(); } else { this.lblMsg.Text = "Please Select commodity Grade."; return; } this.UpdatePanel1.Update(); }
private void Search() { List <GradingFactorBLL> list = null; this.gvGF.DataSource = list; this.DataBind(); GradingFactorBLL obj = new GradingFactorBLL(); Nullable <Guid> GFTID = null; if (this.cboSearchGradingFactorTypeId.SelectedValue != "") { GFTID = new Guid(this.cboSearchGradingFactorTypeId.SelectedValue); } Nullable <GradingFactorStatus> Status = null; if (this.cboSearchStatus.SelectedValue != "") { Status = (GradingFactorStatus)(int.Parse(this.cboSearchStatus.SelectedValue)); } list = obj.Search(this.txtSearchGradingFactorName.Text, GFTID, Status); if (list != null) { ViewState["listGF"] = list; this.gvGF.DataSource = list; this.DataBind(); } }
private void LoadGradingFactors(Guid Commodity, Guid CommodityGradeId) { List <GradingFactorBLL> list = new List <GradingFactorBLL>(); GradingFactorBLL obj = new GradingFactorBLL(); if (Commodity != Guid.Empty) { if (this.chkRecivedGrade.Checked == false || Commodity.ToString().ToUpper().Trim() != ConfigurationSettings.AppSettings["CoffeeId"].ToUpper().Trim()) { list = obj.GetGradingFactors(Commodity); } else { if (Commodity.ToString().ToUpper().Trim() == ConfigurationSettings.AppSettings["CoffeeId"].ToUpper().Trim()) { list = new List <GradingFactorBLL>(); } } } if (Commodity.ToString().ToUpper().Trim() == ConfigurationSettings.AppSettings["CoffeeId"].ToUpper().Trim()) { if (CommodityGradeId != Guid.Empty) { List <GradingFactorBLL> objList = null; objList = obj.GetGradingFactors(CommodityGradeId); if (objList != null) { if (list == null) { list = new List <GradingFactorBLL>(); } foreach (GradingFactorBLL o in objList) { list.Add(o); } } } } if (list != null) { if (list.Count > 0) { list = (from w in list orderby w.Rank ascending select w).ToList(); this.gvGradingFactors.DataSource = list; this.gvGradingFactors.DataBind(); this.UpdatePanel1.Update(); } } }
protected void chkRecivedGrade_CheckedChanged(object sender, EventArgs e) { if (this.chkRecivedGrade.Checked == true) { Guid CommodityGradeId = Guid.Empty; try { CommodityGradeId = new Guid(this.cboCommodity.SelectedValue.ToString()); } catch { this.lblMsg.Text = "Please Select commodity Grade."; return; } if (CommodityGradeId != Guid.Empty) { GradingFactorBLL obj = new GradingFactorBLL(); List <GradingFactorBLL> list = new List <GradingFactorBLL>(); list = obj.GetGradingFactors(CommodityGradeId); this.gvGradingFactors.DataSource = list; this.gvGradingFactors.DataBind(); } else { this.lblMsg.Text = "Please Select commodity Grade."; return; } this.UpdatePanel1.Update(); this.cboStatus.Items.Clear(); this.cboStatus.Items.Add(new ListItem("Please Select Status", "")); this.cboStatus.Items.Add(new ListItem("Approved", "1")); this.cboStatus.Items.Add(new ListItem("Cancelled", "2")); } else { this.gvGradingFactors.DataSource = null; this.gvGradingFactors.DataBind(); this.cboCommodityGrade_CascadingDropDown.SelectedValue = ""; if (this.cboCommodity.SelectedValue != "") { LoadGradingFactors(new Guid(this.cboCommodity.SelectedValue.ToString())); } // remove Status this.cboStatus.Items.Clear(); this.cboStatus.Items.Add(new ListItem("Please Select Status", "")); this.cboStatus.Items.Add(new ListItem("Moisture Fail", "5")); this.cboStatus.Items.Add(new ListItem("General Requierment fail", "6")); } }
public void LoadGradingFactorsProductionYearChange() { Guid oldGradeId = new Guid(ViewState["OldCommodityGrade"].ToString()); Guid SelectedGuid = Guid.Empty; try { string strTempCommGrade = this.cboCommodityGrade_CascadingDropDown.SelectedValue.ToString(); string[] arrTemp = strTempCommGrade.Split(':'); SelectedGuid = new Guid(arrTemp[0].ToString()); } catch { } // we need to Remove the Grading factors this.pnlGradingFactorsOld.Visible = false; this.pnlGradingFactorsOld.GroupingText = "Old Grading Factor."; isGradeChanged = true; if (isGradeChanged == true) { this.pnlGradingFactorsNew.Visible = true; GradingFactorBLL obj = new GradingFactorBLL(); List <GradingFactorBLL> list = new List <GradingFactorBLL>(); list = (obj.GetGradingFactors(new Guid(this.cboCommodity.SelectedValue.ToString()))); try { list.AddRange(obj.GetGradingFactors(new Guid(this.cboCommodityGrade.SelectedValue.ToString()))); this.lblmsg2.Text = ""; } catch { if (this.chkRecivedGrade.Checked == true) { // this.lblmsg2.Text = "Please check if all Grading Factors for the grade are displayed."; } } this.gvGradingFactorsNew.DataSource = list; this.gvGradingFactorsNew.DataBind(); } this.UpdatePanel1.Update(); }
private void LoadGradingFactors(Guid CommodityGradeId) { if (CommodityGradeId != Guid.Empty) { GradingFactorBLL obj = new GradingFactorBLL(); List <GradingFactorBLL> list = new List <GradingFactorBLL>(); list = obj.GetGradingFactors(CommodityGradeId); this.gvGradingFactors.DataSource = list; this.gvGradingFactors.DataBind(); } else { this.lblMsg.Text = "Please Select commodity Grade."; return; } this.UpdatePanel1.Update(); }
public static bool Update(GradingFactorBLL obj, SqlTransaction tran) { int Affectedrow = 0; string strSql = "spUpdateGradingFactor"; SqlParameter[] arPar = new SqlParameter[5]; try { arPar[0] = new SqlParameter("@id", SqlDbType.UniqueIdentifier); arPar[0].Value = obj.Id; arPar[1] = new SqlParameter("@GradingTypeId", SqlDbType.UniqueIdentifier); arPar[1].Value = obj.GradingTypeId; arPar[2] = new SqlParameter("@GradingFactorName", SqlDbType.VarChar, 250); arPar[2].Value = obj.GradingFactorName; arPar[3] = new SqlParameter("@Status", SqlDbType.Int); arPar[3].Value = (int)obj.Status; arPar[4] = new SqlParameter("@LastModifiedBy", SqlDbType.UniqueIdentifier); arPar[4].Value = UserBLL.GetCurrentUser(); Affectedrow = SqlHelper.ExecuteNonQuery(tran, CommandType.StoredProcedure, strSql, arPar); if (Affectedrow == 1) { return(true); } else { return(false); } } catch (Exception ex) { throw ex; } }
protected void btnSave_Click(object sender, EventArgs e) { Guid GradingFactorTypeId = Guid.Empty; GradingFactorTypeId = new Guid(this.cboGradingFactorType.SelectedValue); GradingFactorBLL obj = new GradingFactorBLL(); obj.Id = Guid.NewGuid(); obj.GradingFactorName = this.txtGradingFactorName.Text; obj.Status = (GradingFactorStatus)(int.Parse(this.cboStatus.SelectedValue.ToString())); obj.GradingTypeId = GradingFactorTypeId; if (obj.Save() == true) { this.lblMessage.Text = "Data updated Successfully"; } else { this.lblMessage.Text = "Unable to inser Data please try Again"; } }
public static GradingFactorBLL GetById(Guid Id) { string strSql = "spGetGradingFactorByid"; GradingFactorBLL obj; SqlDataReader reader; SqlConnection conn = new SqlConnection(); SqlParameter[] arPar = new SqlParameter[1]; arPar[0] = new SqlParameter("@id", SqlDbType.UniqueIdentifier); arPar[0].Value = Id; try { conn = Connection.getConnection(); reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql, arPar); if (reader.HasRows) { obj = new GradingFactorBLL(); if (reader.Read()) { obj.Id = new Guid(reader["Id"].ToString()); if (reader["GradingTypeId"] != DBNull.Value) { obj.GradingTypeId = new Guid(reader["GradingTypeId"].ToString()); } obj.GradingFactorName = reader["GradingFactorName"].ToString(); if (reader["Status"] != DBNull.Value) { obj.Status = (GradingFactorStatus)(int.Parse(reader["Status"].ToString())); } if (reader["Rank"] != DBNull.Value) { obj.Rank = int.Parse(reader["Rank"].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.CreatedBy = new Guid(reader["LastModifiedBy"].ToString()); } if (reader["LastModifiedTimestamp"] != DBNull.Value) { obj.LastModifiedTimestamp = DateTime.Parse(reader["LastModifiedTimestamp"].ToString()); } } conn.Close(); return(obj); } else { return(null); } } catch (Exception ex) { throw ex; } finally { if (conn != null && conn.State == ConnectionState.Open) { conn.Close(); } } }
public static List <GradingFactorBLL> Search(String Name, Nullable <Guid> GradingfactorTypeId, Nullable <GradingFactorStatus> Status) { string strwhere = " where "; string strSql = "select tblGradingFactor.Id,tblGradingFactor.GradingTypeId,tblGradingFactor.GradingFactorName, "; strSql += " tblGradingFactor.Id,tblGradingFactor.GradingTypeId,tblGradingFactor.GradingFactorName, "; strSql += " tblGradingFactor.Status,tblGradingFactor.CreatedBy,tblGradingFactor.CreatedTimestamp, "; strSql += " tblGradingFactor.LastModifiedBy,tblGradingFactor.LastModifiedTimestamp , tblGradingFactorType.Type as GradingFactorTypeName "; strSql += " from tblGradingFactor "; strSql += " inner join tblGradingFactorType on tblGradingFactorType.Id = GradingTypeId "; if (Name != "") { strwhere += "tblGradingFactor.GradingFactorName like '" + Name.Trim() + "' "; } if (GradingfactorTypeId != null) { if (strwhere != " where ") { strwhere += " Or tblGradingFactor.GradingTypeId= '" + GradingfactorTypeId.ToString() + "' "; } else { strwhere += "tblGradingFactor.GradingTypeId= '" + GradingfactorTypeId.ToString() + "' "; } } if (Status != null) { if (strwhere != " where ") { strwhere += " or tblGradingFactor.Status= " + ((int)Status.Value).ToString() + " "; } else { strwhere += " tblGradingFactor.Status= " + ((int)Status.Value).ToString() + " "; } } if (strwhere != " where ") { strSql += " " + strwhere; } else { throw new NULLSearchParameterException("No Search Parameter provided"); } List <GradingFactorBLL> list; SqlDataReader reader; SqlConnection conn = Connection.getConnection(); reader = SqlHelper.ExecuteReader(conn, CommandType.Text, strSql); if (reader.HasRows) { list = new List <GradingFactorBLL>(); while (reader.Read()) { GradingFactorBLL obj = new GradingFactorBLL(); if (reader["Id"] != DBNull.Value) { obj.Id = new Guid(reader["Id"].ToString()); } if (reader["GradingTypeId"] != DBNull.Value) { obj.GradingTypeId = new Guid(reader["GradingTypeId"].ToString()); } if (reader["GradingFactorName"] != DBNull.Value) { obj.GradingFactorName = reader["GradingFactorName"].ToString(); } if (reader["Status"] != DBNull.Value) { obj.Status = (GradingFactorStatus)(int.Parse(reader["Status"].ToString())); } if (reader["GradingFactorTypeName"] != DBNull.Value) { obj.GradingFactorTypeName = reader["GradingFactorTypeName"].ToString(); } list.Add(obj); } if (conn.State == ConnectionState.Open) { conn.Close(); } return(list); } else { if (conn.State == ConnectionState.Open) { conn.Close(); } return(null); } }
public static List <GradingFactorBLL> GetGradingFactors(Guid CommodityGradeId) { string strSql = "spGetGradingFactors"; SqlConnection conn = null; List <GradingFactorBLL> list; try { SqlParameter[] arPar = new SqlParameter[1]; arPar[0] = new SqlParameter("@CommodityId", SqlDbType.UniqueIdentifier); arPar[0].Value = CommodityGradeId; SqlDataReader reader; conn = Connection.getConnection(); reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql, arPar); if (reader != null) { if (reader.HasRows) { list = new List <GradingFactorBLL>(); while (reader.Read()) { GradingFactorBLL obj = new GradingFactorBLL(); if (reader["Id"] != DBNull.Value) { try { obj.Id = new Guid(reader["Id"].ToString()); } catch (Exception ex) { throw new Exception("Unable to get Grading Value", ex); } } if (reader["GradingFactorName"] != DBNull.Value) { obj.GradingFactorName = reader["GradingFactorName"].ToString(); } if (reader["ValueType"] != DBNull.Value) { obj.DataType = reader["ValueType"].ToString(); } if (reader["PossibleValues"] != DBNull.Value) { obj.PossibleValues = reader["PossibleValues"].ToString(); } if (reader["FailPoint"] != DBNull.Value) { try { obj.FailPoint = reader["FailPoint"].ToString(); } catch { } } if (reader["isMax"] != DBNull.Value) { try { obj.IsMax = (FailPointComparsion)Int32.Parse(reader["isMax"].ToString()); } catch { } } if (reader["isInTotalValue"] != DBNull.Value) { try { obj.IsInTotalValue = bool.Parse(reader["isInTotalValue"].ToString()); } catch { obj.IsInTotalValue = false; } } else { obj.IsInTotalValue = false; } list.Add(obj); } return(list); } } else { return(null); } } catch (Exception ex) { throw ex; } finally { conn.Close(); } return(null); }
protected void btnSave_Click(object sender, EventArgs e) { this.lblMsg.Text = ""; if (this.cboCommodityGrade.SelectedValue != "") { if (this.chkRecivedGrade.Checked == false) { this.lblMsg.Text = "Grade Received is Not Checked."; this.lblMsg.ForeColor = System.Drawing.Color.Red; this.cboCommodityGrade.SelectedIndex = -1; this.cboCommodityClass.SelectedIndex = -1; loadData(); this.cboCommodityGrade.SelectedIndex = -1; this.cboCommodityGrade_CascadingDropDown.SelectedValue = ""; return; } } Nullable <float> totalValue = null; GradingResultStatus GenralReqiurmentStatus; GenralReqiurmentStatus = GradingResultStatus.Undertermined; List <GradingResultDetailBLL> list = new List <GradingResultDetailBLL>(); #region Checking GradingFactors foreach (GridViewRow row in this.gvGradingFactors.Rows) { GradingResultDetailBLL objResult = new GradingResultDetailBLL(); Guid GradingFactorId; string possibleValue; string dataType; string value; string FailPoint = string.Empty; int isMax = -1; // get the Id and the value. Label lblId = new Label(); try { lblId = row.FindControl("lblId") as Label; GradingFactorId = new Guid(lblId.Text); } catch (InvalidCastException) { this.lblMsg.Text = "An error has occured please try again.If the error persits contact the administrator."; return; } //Get Possible Values try { Label lblPossibleTypes = new Label(); lblPossibleTypes = (Label)row.FindControl("lblPossibleTypes"); possibleValue = lblPossibleTypes.Text; } catch { this.lblMsg.Text = "An error has occured please try again.If the error persits contact the administrator."; return; } // get DataType try { Label lblDataType = new Label(); lblDataType = (Label)row.FindControl("lblDataType"); dataType = lblDataType.Text; } catch (Exception ex) { throw ex; } // get Value. try { TextBox txtGradingFactorValue = new TextBox(); txtGradingFactorValue = (TextBox)row.FindControl("txtGradingFactorValue"); value = txtGradingFactorValue.Text; if (value == "" || value == String.Empty) { row.FindControl("lblEmpty").Visible = true; } } catch (Exception ex) { throw new Exception("An error has occured please try again.If the error persits contact the administrator.", ex); } // if it is a Genral req. try { Label lblFailPoint = new Label(); lblFailPoint = (Label)row.FindControl("lblFailPoint"); FailPoint = lblFailPoint.Text; } catch { } try { Label lblisMax = new Label(); lblisMax = (Label)row.FindControl("lblisMax"); if (string.IsNullOrEmpty(lblisMax.Text) != true) { try { isMax = GradingFactorBLL.ParseTextGradingResultStatus(lblisMax.Text); } catch { this.lblMsg.Text = "Invalid Grading Result Comparision.Please try again."; return; } } } catch { } //IsInTotalValue bool IsInTotalValue = false; try { Label lblisTotalValue = new Label(); lblisTotalValue = (Label)row.FindControl("lblisTotalValue"); if (string.IsNullOrEmpty(lblisTotalValue.Text) != true) { try { if (lblisTotalValue.Text == "True") { IsInTotalValue = true; } } catch { IsInTotalValue = false; } } } catch { } if (IsInTotalValue == true) { if (totalValue == null) { totalValue = 0; } totalValue += float.Parse(value); } //Check Data Type. if (value == "") { Label lblmessage; lblmessage = row.FindControl("lblEmpty") as Label; if (lblmessage != null) { lblmessage.Text = "*"; lblmessage.Visible = true; lblmessage.ForeColor = System.Drawing.Color.Red; } return; } else { if (DataValidationBLL.isDataValidForDataType(value, dataType) == false) { Label lblmessage; lblmessage = row.FindControl("lblEmpty") as Label; if (lblmessage != null) { lblmessage.Text = "Error in Data Type"; lblmessage.Visible = true; lblmessage.ForeColor = System.Drawing.Color.Red; } return; } } // check in possible Values if (DataValidationBLL.isExists(value, possibleValue) == false) { Label lblmessage; lblmessage = row.FindControl("lblEmpty") as Label; if (lblmessage != null) { lblmessage.Text = "Data Should Be one of the following: " + possibleValue; lblmessage.Visible = true; lblmessage.ForeColor = System.Drawing.Color.Red; } return; } objResult.GradingFactorId = GradingFactorId; objResult.RecivedValue = value; objResult.Status = GradingResultDetailStatus.Active; list.Add(objResult); Label lblmessage1; lblmessage1 = row.FindControl("lblEmpty") as Label; if (lblmessage1 != null) { lblmessage1.Text = ""; lblmessage1.Visible = false; } // Check if is a General requirment. GradingFactorBLL objGenralReqiurment = new GradingFactorBLL(); if (((GradingResultStatus)int.Parse(this.cboStatus.SelectedValue)) == GradingResultStatus.New || ((GradingResultStatus)int.Parse(this.cboStatus.SelectedValue)) == GradingResultStatus.Approved) { GenralReqiurmentStatus = objGenralReqiurment.GetGradingResultStatus(value, (FailPointComparsion)(isMax), FailPoint, dataType); } else { GenralReqiurmentStatus = (GradingResultStatus)int.Parse(this.cboStatus.SelectedValue); } } #endregion // Check if is a General requirment. if (((GradingResultStatus)int.Parse(this.cboStatus.SelectedValue)) == GradingResultStatus.New || ((GradingResultStatus)int.Parse(this.cboStatus.SelectedValue)) == GradingResultStatus.Approved) { GenralReqiurmentStatus = GradingResultStatus.Approved; } else { GenralReqiurmentStatus = (GradingResultStatus)int.Parse(this.cboStatus.SelectedValue); } //Get Commodity Grade Guid CommodityGradeId = Guid.Empty; if (this.chkRecivedGrade.Checked == true) { try { CommodityGradeId = new Guid(this.cboCommodityGrade.SelectedValue.ToString()); } catch { this.lblMsg.Text = "Please Select Commodity Grade."; return; } } //#region Checking Total Value ////Check Grading is OK //if (this.chkRecivedGrade.Checked == true) //{ // bool ValidGrade = false; // CommodityGradeFactorValueBLL objGradeFactorValueBLL = new CommodityGradeFactorValueBLL(); // objGradeFactorValueBLL = objGradeFactorValueBLL.GetActiveValueByCommodoityGradeId(CommodityGradeId); // GradingResultDetailBLL objGradingResultDetail = new GradingResultDetailBLL(); // if (totalValue != null) // { // string err = ""; // ValidGrade = objGradingResultDetail.PreInsertHasValidGradingResult((float)totalValue, CommodityGradeId, out err); // if (ValidGrade == false) // { // this.lblMsg.Text = err + " Total Value : " + totalValue.ToString(); // this.lblMsg.ForeColor = System.Drawing.Color.Red; // return; // } // } //} //#endregion Nullable <Guid> Id = null; GradingResultBLL obj = new GradingResultBLL(); try { obj.GradingId = new Guid(this.cboGradingCode.SelectedValue.ToString()); } catch { this.lblMsg.Text = "Please select Grading Code"; return; } obj.CommodityGradeId = CommodityGradeId; obj.IsSupervisor = this.isSupervisor.Checked; //obj.Status = (GradingResultStatus)Convert.ToInt32(this.cboStatus.SelectedValue); obj.Status = GenralReqiurmentStatus; obj.Remark = this.txtRemark.Text; if (this.cboProductionYear.SelectedValue.ToString() != "") { obj.ProductionYear = int.Parse(this.cboProductionYear.SelectedValue.ToString()); } try { obj.GradeRecivedTimeStamp = Convert.ToDateTime(this.txtDateRecived.Text + " " + this.txtTimeRecived.Text); } catch { this.lblMsg.Text = "Please check grade recieved date and try again"; return; } obj.CreatedBy = UserBLL.GetCurrentUser(); try { Id = obj.Add(list, obj.TrackingNo); } catch (Exception ex) { throw ex; } if (Id != null) { this.lblMsg.Text = "Result Added Successfully."; Session["GRID"] = Id.ToString(); string strTranNo = Session["AddGradingRecivedTranNo"].ToString(); Session["AddGradingRecivedTranNo"] = null; Response.Redirect("ListInbox.aspx"); } else { this.lblMsg.Text = "Data can not be added please check the form and try again.If the error persists contact the administrator."; } }
protected void btnSave_Click(object sender, EventArgs e) { GradingFactorBLL obj = new GradingFactorBLL(); obj.CommodityGradeId = new Guid(this.cboCommodityGrade.SelectedValue.ToString()); }
protected void gvGF_RowDataBound(object sender, GridViewRowEventArgs e) { if (this.gvGF.EditIndex == e.Row.RowIndex && this.gvGF.EditIndex != -1) { GridViewRow rw = e.Row; //Update the Grading Factor Name GradingFactorBLL objOld = new GradingFactorBLL(); Label lblId = (Label)rw.FindControl("lblEditId"); TextBox txtGFN = (TextBox)rw.FindControl("txtGradingFactorName"); DropDownList dr = (DropDownList)rw.FindControl("cboEditGradingFactorType"); DropDownList drStatus = (DropDownList)rw.FindControl("cboEditStatus"); Label lblGTId = (Label)rw.FindControl("GradingTypeId"); if (lblId != null) { objOld.Id = new Guid(lblId.Text); } if (txtGFN != null) { objOld.GradingFactorName = txtGFN.Text; } if (dr != null) { objOld.GradingTypeId = new Guid(lblGTId.Text); objOld.GradingFactorTypeName = dr.SelectedItem.ToString(); } if (drStatus != null) { if (drStatus.SelectedValue != "") { if (drStatus.SelectedValue == "Active") { objOld.Status = GradingFactorStatus.Active; } else if (drStatus.SelectedValue == "Cancelled") { objOld.Status = GradingFactorStatus.Cancelled; } } } ViewState["OldGF"] = objOld; GradingFactorTypeBLL objGFT = new GradingFactorTypeBLL(); List <GradingFactorTypeBLL> listGFT = objGFT.GetActiveGradingfactorType(); if (dr != null) { if (listGFT != null) { dr.Items.Clear(); dr.AppendDataBoundItems = true; foreach (GradingFactorTypeBLL i in listGFT) { dr.Items.Add(new ListItem(i.GradingFactorTypeName, i.Id.ToString())); } dr.AppendDataBoundItems = false; } } if (lblGTId != null) { dr.SelectedValue = lblGTId.Text; } } }
protected void gvGF_RowUpdating(object sender, GridViewUpdateEventArgs e) { //Code to Update. //get the old Value // get the new value int editindex = -1; editindex = this.gvGF.EditIndex; GridViewRow rw = this.gvGF.Rows[editindex]; if (editindex != -1) { //Update the Grading Factor Name GradingFactorBLL obj = new GradingFactorBLL(); Label lblId = (Label)rw.FindControl("lblEditId"); TextBox txtGFN = (TextBox)rw.FindControl("txtGradingFactorName"); DropDownList dr = (DropDownList)rw.FindControl("cboEditGradingFactorType"); DropDownList drStatus = (DropDownList)rw.FindControl("cboEditStatus"); if (lblId != null) { obj.Id = new Guid(lblId.Text); } if (txtGFN != null) { obj.GradingFactorName = txtGFN.Text; } if (dr != null) { obj.GradingTypeId = new Guid(dr.SelectedValue.ToString()); obj.GradingFactorTypeName = dr.SelectedItem.ToString(); } if (drStatus != null) { if (drStatus.SelectedValue != "") { if (drStatus.SelectedValue == "Active") { obj.Status = GradingFactorStatus.Active; } else if (drStatus.SelectedValue == "Cancelled") { obj.Status = GradingFactorStatus.Cancelled; } } } bool isSaved = false; GradingFactorBLL objOld = new GradingFactorBLL(); objOld = (GradingFactorBLL)ViewState["OldGF"]; isSaved = obj.Update(objOld); if (isSaved == true) { this.lblMessage.Text = "Data updated Successfully."; this.gvGF.EditIndex = -1; gvGF.DataBind(); Search(); } else { this.lblMessage.Text = "Unable to update Data."; } } }