/// <summary> /// Set Grid Data source /// </summary> /// <param name="addRow"></param> /// <param name="deleteRow"></param>e private void BindGrid() { string hhid = Session["HH_ID"].ToString(); DamagedCropsBLL DamagedCropsBLLobj = new DamagedCropsBLL(); grdDamagedCrops.DataSource = DamagedCropsBLLobj.GetDamagedCrops(hhid); grdDamagedCrops.DataBind(); }
/// <summary> /// to fetch values to dropdownlist /// </summary> private void GetDamagedBy() { DamagedCropsBLL BLLobj = new DamagedCropsBLL(); ddlDamagedBy.DataSource = BLLobj.GetDamagedBy(); ddlDamagedBy.DataTextField = "CROPDAMAGEDBYOTHER"; ddlDamagedBy.DataValueField = "CROPDAMAGEDBYID"; ddlDamagedBy.DataBind(); }
/// <summary> /// to fetch details and assign to textbox /// </summary> private void GetData() { DamagedCropsBLL DamagedCropsBLLobj = new DamagedCropsBLL(); int damageCropId = 0; if (ViewState["DAMAGED_CROPID"] != null) { damageCropId = Convert.ToInt32(ViewState["DAMAGED_CROPID"]); } DamagedCropsBO BOobj = new DamagedCropsBO(); BOobj = DamagedCropsBLLobj.GetData(damageCropId); DAMAGED_CROPIDTextBox.Text = BOobj.DAMAGED_CROPID.ToString(); txtbxDamagedCropFormRefNo.Text = BOobj.DMGCRPFORMREFNO; ddlCropName.ClearSelection(); if (ddlCropName.Items.FindByValue(BOobj.CROPID.ToString()) != null) { ddlCropName.Items.FindByValue(BOobj.CROPID.ToString()).Selected = true; } ddlCropType.ClearSelection(); if (ddlCropType.Items.FindByValue(BOobj.CROPTYPEID.ToString()) != null) { ddlCropType.Items.FindByValue(BOobj.CROPTYPEID.ToString()).Selected = true; } ddlCropDescription.ClearSelection(); if (ddlCropDescription.Items.FindByValue(BOobj.CROPDESCRIPTIONID.ToString()) != null) { ddlCropDescription.Items.FindByValue(BOobj.CROPDESCRIPTIONID.ToString()).Selected = true; } DateDamaged.Text = BOobj.DATEDAMAGED.ToString(UtilBO.DateFormat); ddlDamagedBy.ClearSelection(); if (ddlDamagedBy.Items.FindByValue(BOobj.CROPDAMAGEDBYID.ToString()) != null) { ddlDamagedBy.Items.FindByValue(BOobj.CROPDAMAGEDBYID.ToString()).Selected = true; } DamagedByTextBox.Text = BOobj.CROPDAMAGEDBYOTHER; updDamagedBy.Update(); txtbxQuantity.Text = UtilBO.CurrencyFormat(BOobj.QUANTITY); txtbxCropRate.Text = UtilBO.CurrencyFormat(BOobj.CROPRATE); txtbxAmountPaid.Text = UtilBO.CurrencyFormat(BOobj.AMOUNTPAID); CommentsTextBox.Text = BOobj.COMMENTS; }
/// <summary> /// to delete data from database /// </summary> /// <param name="damageCropId"></param> private void DeleteData(int damageCropId) { DamagedCropsBLL DamagedCropsBLLobj = new DamagedCropsBLL(); // int damageCropId = 0; int Result = 0; //if (ViewState["DAMAGED_CROPID"] != null) // damageCropId = Convert.ToInt32(ViewState["DAMAGED_CROPID"].ToString()); Result = DamagedCropsBLLobj.DeleteData(damageCropId); }
/// <summary> /// to save details to database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { int count = 0; if (DAMAGED_CROPIDTextBox.Text.ToString().Trim() == string.Empty) { DamagedCropsBLL BLLobj = new DamagedCropsBLL(); DamagedCropsBO DamagedCropsobj = new DamagedCropsBO(); try { string uID = Session["USER_ID"].ToString(); string hhid = Session["HH_ID"].ToString(); DamagedCropsobj.HHID = Convert.ToInt32(hhid); DamagedCropsobj.DMGCRPFORMREFNO = txtbxDamagedCropFormRefNo.Text; DamagedCropsobj.CROPID = Convert.ToInt32(ddlCropName.SelectedValue); DamagedCropsobj.CROPTYPEID = Convert.ToInt32(ddlCropType.SelectedValue); DamagedCropsobj.CROPDESCRIPTIONID = Convert.ToInt32(ddlCropDescription.SelectedValue); DamagedCropsobj.DATEDAMAGED = Convert.ToDateTime(DateDamaged.Text.ToString()); DamagedCropsobj.CROPDAMAGEDBYID = Convert.ToInt32(ddlDamagedBy.SelectedValue); if (DamagedByTextBox.Text != string.Empty) { DamagedCropsobj.CROPDAMAGEDBYOTHER = DamagedByTextBox.Text; } else { DamagedCropsobj.CROPDAMAGEDBYOTHER = ""; } DamagedCropsobj.QUANTITY = Convert.ToDecimal(txtbxQuantity.Text); DamagedCropsobj.CROPRATE = Convert.ToDecimal(txtbxCropRate.Text); DamagedCropsobj.AMOUNTPAID = DamagedCropsobj.QUANTITY * DamagedCropsobj.CROPRATE; if (CommentsTextBox.Text.Length > 1000) { DamagedCropsobj.COMMENTS = CommentsTextBox.Text.Substring(0, 1000); } else { DamagedCropsobj.COMMENTS = CommentsTextBox.Text; } DamagedCropsobj.ISDELETED = "False"; DamagedCropsobj.CREATEDBY = Convert.ToInt32(uID); if (photoFileUpload.HasFile) { byte[] fileBytes = photoFileUpload.FileBytes; if (fileBytes != null) { DamagedCropsobj.Photo = fileBytes; } } DamagedCropsBLL DamagedCropsBLLobj = new DamagedCropsBLL(); count = DamagedCropsBLLobj.Insert(DamagedCropsobj); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "ShowSaveMessage('');", true); BindGrid(); ClearData(); } catch (Exception ex) { throw ex; } finally { BLLobj = null; } } else if (DAMAGED_CROPIDTextBox.Text.ToString().Trim() != string.Empty) { DamagedCropsBLL BLLobj = new DamagedCropsBLL(); try { string uID = Session["USER_ID"].ToString(); string hhid = Session["HH_ID"].ToString(); DamagedCropsBO DamagedCropsobj = new DamagedCropsBO(); DamagedCropsobj.HHID = Convert.ToInt32(hhid); DamagedCropsobj.DAMAGED_CROPID = Convert.ToInt32(DAMAGED_CROPIDTextBox.Text); DamagedCropsobj.DMGCRPFORMREFNO = txtbxDamagedCropFormRefNo.Text; DamagedCropsobj.CROPID = Convert.ToInt32(ddlCropName.SelectedValue); DamagedCropsobj.CROPTYPEID = Convert.ToInt32(ddlCropType.SelectedValue); DamagedCropsobj.CROPDESCRIPTIONID = Convert.ToInt32(ddlCropDescription.SelectedValue); DamagedCropsobj.DATEDAMAGED = Convert.ToDateTime(DateDamaged.Text.ToString()); DamagedCropsobj.CROPDAMAGEDBYID = Convert.ToInt32(ddlDamagedBy.SelectedValue); DamagedCropsobj.CROPDAMAGEDBYOTHER = DamagedByTextBox.Text; DamagedCropsobj.QUANTITY = Convert.ToDecimal(txtbxQuantity.Text); DamagedCropsobj.CROPRATE = Convert.ToDecimal(txtbxCropRate.Text); DamagedCropsobj.AMOUNTPAID = DamagedCropsobj.QUANTITY * DamagedCropsobj.CROPRATE; if (CommentsTextBox.Text.Length > 1000) { DamagedCropsobj.COMMENTS = CommentsTextBox.Text.Substring(0, 1000); } else { DamagedCropsobj.COMMENTS = CommentsTextBox.Text; } DamagedCropsobj.ISDELETED = "False"; DamagedCropsobj.CREATEDBY = Convert.ToInt32(uID); if (photoFileUpload.HasFile) { byte[] fileBytes = photoFileUpload.FileBytes; if (fileBytes != null) { DamagedCropsobj.Photo = fileBytes; } } DamagedCropsBLL DamagedCropsBLLobj = new DamagedCropsBLL(); count = BLLobj.Update(DamagedCropsobj); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Updated", "ShowUpdateMessage('');", true); BindGrid(); ClearData(); SetUpdateMode(false); } catch (Exception ex) { throw ex; } finally { BLLobj = null; } } ChangeRequestStatusDamageCrops(); projectFrozen(); }