/// <summary> /// to update and delete the grievances /// to call SetUpdateMode() method,and /// to clear the fields /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void grievances_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EditRow") { ViewState["GRIEVANCEID"] = e.CommandArgument; GetGrievancedatarow(); SetUpdateMode(true); ResolutionStatusChange.Visible = true; } else if (e.CommandName == "DeleteRow") { int Result = 0; int GrievanceID = Convert.ToInt32(e.CommandArgument); GrievancesBLL objGrievancesBLL = new GrievancesBLL(); Result = objGrievancesBLL.Delete(GrievanceID); if (Result == -1) { BindGrid(); } ResolutionStatusChange.Visible = false; SetUpdateMode(false); ClearDetails(); } }
/// <summary> /// get the data from database and bind it to grid /// </summary> private void BindGrid() { GrievancesBLL objGrievancesBLL = new GrievancesBLL(); grdgrvlist.DataSource = objGrievancesBLL.Getgrievancedata(Convert.ToInt32(Session["HH_ID"])); grdgrvlist.DataBind(); }
/// <summary> /// get category data from database /// </summary> private void Getcategory() { GrievancesBLL GrievancesBLL = new GrievancesBLL(); categoryDropDownList.DataSource = GrievancesBLL.Getcategory(); categoryDropDownList.DataTextField = "GrievCategory"; categoryDropDownList.DataValueField = "GrievCategoryID"; categoryDropDownList.DataBind(); }
/// <summary> /// to assign the data from database to the textbox's districtTextBox, countyTextBox /// subcountyTextBox,parishTextBox,villageTextBox /// </summary> /// <param name="hhid"></param> private void screenIntialization(int hhid) { GrievancesBLL objGrievancesBLL = new GrievancesBLL(); GrievancesBO GrievancesBOobj = new GrievancesBO(); GrievancesBOobj = objGrievancesBLL.getscreenIntialization(hhid); districtTextBox.Text = GrievancesBOobj.District; countyTextBox.Text = GrievancesBOobj.County; subcountyTextBox.Text = GrievancesBOobj.SubCounty; parishTextBox.Text = GrievancesBOobj.Parish; villageTextBox.Text = GrievancesBOobj.Village; }
/// <summary> /// get Grievance data from database /// </summary> public void getGrievance() { GrievancesBLL objGrievancesBLL = new GrievancesBLL(); GrievancesBO GrievancesBOobj = new GrievancesBO(); //GrievancesBO GrievancesBOobj = (new GrievancesBLL()).getGrievance(Convert.ToInt32(ViewState["GrievanceID"])); //if (GrievancesBOobj != null) // lblCategoryAssign.Text = GrievancesBOobj.GrievCategory; //lblCreatedDateAssign.Text = GrievancesBOobj.CreatedDate.ToString(); //descriptionTextBox.Text = GrievancesBOobj.Description; int GrievanceID = Convert.ToInt32(ViewState["GrievanceID"]); GrievancesBOobj = objGrievancesBLL.GetGrievanceClosure(GrievanceID); if (GrievancesBOobj != null) { lblCategoryAssign.Text = GrievancesBOobj.GrievCategory; lblCreatedDateAssign.Text = GrievancesBOobj.CreatedDate.ToString(UtilBO.DateFormatFull); txtClosureComments.Text = GrievancesBOobj.ClosureComments; } }
/// <summary> /// to Save the data to the database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { int count = 0; string descriptionText = ""; string message = ""; GrievancesBLL objGrievancesBLL = new GrievancesBLL(); GrievancesBO GrievancesBOobj = null; if (Convert.ToInt32(ViewState["GRIEVANCEID"]) > 0) { try { string hhid = Session["HH_ID"].ToString(); GrievancesBOobj = new GrievancesBO(); GrievancesBOobj.GrievanceID = Convert.ToInt32(ViewState["GRIEVANCEID"]); GrievancesBOobj.GrievCategoryID = Convert.ToInt32(categoryDropDownList.SelectedValue); descriptionText = descriptionTextBox.Text.Trim(); if (descriptionText.Length >= 1000) { descriptionText = descriptionText.Substring(0, 1000); } GrievancesBOobj.Description = descriptionText; descriptionText = actionTextBox.Text.Trim(); if (descriptionText.Length >= 500) { descriptionText = descriptionText.Substring(0, 500); } GrievancesBOobj.ActionTaken = descriptionText; if (actionDatePicker.Text.Trim() != "") { GrievancesBOobj.ActionTakenDate = Convert.ToDateTime(actionDatePicker.Text.ToString()); } GrievancesBOobj.ActionTakenBy = Convert.ToInt32(actionDropDownList.SelectedValue.ToString().Trim()); descriptionText = basicTextBox.Text.Trim(); if (descriptionText.Length >= 500) { descriptionText = descriptionText.Substring(0, 500); } GrievancesBOobj.BasicFacts = descriptionText; descriptionText = resolutionTextBox.Text.Trim(); if (descriptionText.Length >= 500) { descriptionText = descriptionText.Substring(0, 500); } GrievancesBOobj.Resolution = descriptionText; if (resolutionDatePicker.Text.Trim() != "") { GrievancesBOobj.ResolutionDate = Convert.ToDateTime(resolutionDatePicker.Text.ToString()); } GrievancesBOobj.ResolvedBy = Convert.ToInt32(resolDropDownList.SelectedValue.ToString().Trim()); GrievancesBOobj.CreatedBy = Convert.ToInt32(Session["USER_ID"]); GrievancesBLL objGrievancBLL = new GrievancesBLL(); if ((resolDropDownList.SelectedItem.Value.ToString()) == "0") { GrievancesBOobj.ResolutionStatus = "P"; count = objGrievancBLL.EditGRIEVANCE(GrievancesBOobj); message = "Data updated successfully"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Updated", "ShowUpdateMessage('" + message + "');", true); } else { bool approverExists = CheckApprover(); //Send email for Approval if Approver Exists if (approverExists) { GrievancesBOobj.ResolutionStatus = "S"; count = objGrievancBLL.EditGRIEVANCE(GrievancesBOobj); message = "Data updated successfully"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Updated", "ShowUpdateMessage('" + message + "');", true); string scriptContent = string.Format("SendApprovalEmail('{0}',{1},{2},{3},'{4}',{5});", UtilBO.WorkflowGrievances, Convert.ToInt32(Session["PROJECT_ID"]), Convert.ToInt32(Session["USER_ID"]), Convert.ToInt32(Session["HH_ID"]), UtilBO.WorkflowGrievances, Convert.ToInt32(ViewState["GRIEVANCEID"]) ); ScriptManager.RegisterStartupScript(this, this.GetType(), "Updated2", scriptContent, true); } else { message = "You are trying to resolve the status, but the Approver for Grievance Resolution is not defined."; } } ClearDetails(); SetUpdateMode(false); BindGrid(); ResolutionStatusChange.Visible = false; } catch (Exception ex) { throw ex; } finally { objGrievancesBLL = null; } } else { // insert try { string hhid = Session["HH_ID"].ToString(); GrievancesBOobj = new GrievancesBO(); GrievancesBOobj.GrievanceID = Convert.ToInt32(ViewState["GRIEVANCEID"]); GrievancesBOobj.GrievCategoryID = Convert.ToInt32(categoryDropDownList.SelectedValue); descriptionText = descriptionTextBox.Text.Trim(); if (descriptionText.Length >= 1000) { descriptionText = descriptionText.Substring(0, 1000); } GrievancesBOobj.Description = descriptionText; GrievancesBOobj.ActionTaken = actionTextBox.Text.ToString().Trim(); if (actionDatePicker.Text.Trim() != "") { GrievancesBOobj.ActionTakenDate = Convert.ToDateTime(actionDatePicker.Text.ToString()); } GrievancesBOobj.ActionTakenBy = Convert.ToInt32(actionDropDownList.SelectedValue.ToString().Trim()); descriptionText = basicTextBox.Text.Trim(); if (descriptionText.Length >= 500) { descriptionText = descriptionText.Substring(0, 500); } GrievancesBOobj.BasicFacts = descriptionText; descriptionText = resolutionTextBox.Text.Trim(); if (descriptionText.Length >= 500) { descriptionText = descriptionText.Substring(0, 500); } GrievancesBOobj.Resolution = descriptionText; if (resolutionDatePicker.Text.Trim() != "") { GrievancesBOobj.ResolutionDate = Convert.ToDateTime(resolutionDatePicker.Text.ToString()); } GrievancesBOobj.ResolvedBy = Convert.ToInt32(resolDropDownList.SelectedValue.ToString().Trim()); if ((resolDropDownList.SelectedItem.Value.ToString()) == "0") { GrievancesBOobj.ResolutionStatus = "P"; } else { GrievancesBOobj.ResolutionStatus = "P"; } GrievancesBOobj.CreatedBy = Convert.ToInt32(Session["USER_ID"]); GrievancesBOobj.Hhid = Convert.ToInt32(hhid); GrievancesBLL GrievancesBLL = new GrievancesBLL(); count = GrievancesBLL.Insert(GrievancesBOobj); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "ShowSaveMessage('');", true); ClearDetails(); SetUpdateMode(false); BindGrid(); } catch (Exception ex) { throw ex; } finally { objGrievancesBLL = null; } } //projectFrozen(); //ChangeRequestStatusGrievances(); }
/// <summary> /// to get the grievance data row by row /// </summary> private void GetGrievancedatarow() { GrievancesBLL objGrievancesBLL = new GrievancesBLL(); int GrievanceID = 0; if (ViewState["GRIEVANCEID"] != null) { GrievanceID = Convert.ToInt32(ViewState["GRIEVANCEID"]); } //For Upload Documents Added by Anjankumar lnkUploadDoc.Attributes.Clear(); lnkViewUploadDoc.Attributes.Clear(); int hhid = Convert.ToInt32(Session["HH_ID"]); int userID = Convert.ToInt32(Session["USER_ID"]); string paramUploadDoc = string.Format("OpenUploadDocumnet({0},{1},{2},'{3}','{4}','{5}');", Convert.ToInt32(Session["PROJECT_ID"]), hhid, userID, Session["PROJECT_CODE"].ToString(), "GRV", GrievanceID); string paramViewDocs = string.Format("OpenUploadDocumnetlist({0},{1},{2},'{3}','{4}','{5}');", Convert.ToInt32(Session["PROJECT_ID"]), hhid, userID, Session["PROJECT_CODE"].ToString(), "GRV", GrievanceID); lnkUploadDoc.Attributes.Add("onclick", paramUploadDoc); lnkViewUploadDoc.Attributes.Add("onclick", paramViewDocs); // End Documnts GrievancesBO GrievancesBOobj = new GrievancesBO(); GrievancesBOobj = objGrievancesBLL.GetGrievancedatarow(GrievanceID); categoryDropDownList.ClearSelection(); if (categoryDropDownList.Items.FindByValue(GrievancesBOobj.GrievCategoryID.ToString()) != null) { categoryDropDownList.Items.FindByValue(GrievancesBOobj.GrievCategoryID.ToString()).Selected = true; } //Getactionby(); actionDropDownList.ClearSelection(); if (actionDropDownList.Items.FindByValue(GrievancesBOobj.ActionTakenBy.ToString()) != null) { actionDropDownList.Items.FindByValue(GrievancesBOobj.ActionTakenBy.ToString()).Selected = true; } //Getresolby(); resolDropDownList.ClearSelection(); if (resolDropDownList.Items.FindByValue(GrievancesBOobj.ResolvedBy.ToString()) != null) { resolDropDownList.Items.FindByValue(GrievancesBOobj.ResolvedBy.ToString()).Selected = true; } descriptionTextBox.Text = GrievancesBOobj.Description.ToString(); actionTextBox.Text = GrievancesBOobj.ActionTaken.ToString(); if (GrievancesBOobj.ActionTakenDate != DateTime.MinValue) { actionDatePicker.Text = GrievancesBOobj.ActionTakenDate.ToString(UtilBO.DateFormat); } basicTextBox.Text = GrievancesBOobj.BasicFacts.ToString(); resolutionTextBox.Text = GrievancesBOobj.Resolution.ToString(); if (GrievancesBOobj.ResolutionDate != DateTime.MinValue) { resolutionDatePicker.Text = GrievancesBOobj.ResolutionDate.ToString(UtilBO.DateFormat); } }