void Reset() { TxtClaimName.Text = ""; TxtClaimDiscription.Text = ""; ddlMonth.SelectedIndex = 0; txtCalValue.Text = ""; DdlValueType.SelectedIndex = 0; TxtYear.Text = ""; TxtClaimName.Focus(); TxtYear.Text = DateTime.Now.Year.ToString(); int CurrentMonth = Convert.ToInt32(DateTime.Now.Month.ToString()); ddlMonth.SelectedValue = (CurrentMonth).ToString(); foreach (GridViewRow Gvrow in gvEmpLeave.Rows) { CheckBox ChkHeader = (CheckBox)gvEmpLeave.HeaderRow.FindControl("chkgvSelectAll"); CheckBox ChkItem = (CheckBox)Gvrow.FindControl("chkgvSelect"); ChkHeader.Checked = false; ChkItem.Checked = false; } }
protected void btnSave_Click(object sender, EventArgs e) { Session["Querystring"] = null; Session["ClaimRecord"] = null; Session["Document"] = null; Session["ClaimType"] = null; Session["Month"] = null; Session["Year"] = null; int b = 0; DataTable DtClaimRecord = new DataTable(); string[] Montharr = new string[12]; Montharr[0] = "January"; Montharr[1] = "February"; Montharr[2] = "March"; Montharr[3] = "April"; Montharr[4] = "May"; Montharr[5] = "June"; Montharr[6] = "July"; Montharr[7] = "August"; Montharr[8] = "September"; Montharr[9] = "October"; Montharr[10] = "November"; Montharr[11] = "December"; if (Rbtndocument.Checked == true) { DtClaimRecord = ObjFile.Get_FileTransaction(Session["CompId"].ToString(), "0"); } if (RbtnDirectory.Checked == true) { DtClaimRecord = ObjFile.Get_FileTransaction(Session["CompId"].ToString(), "0"); } if (rbtnPenalty.Checked == true) { DtClaimRecord = ObjPenalty.GetRecord_From_PayEmployeePenalty(Session["CompId"].ToString(), "0", "0", ddlMonth.SelectedValue, TxtYear.Text, "", ""); } if (rbtnLoan.Checked == true) { DtClaimRecord = ObjLoan.GetRecord_From_PayEmployeeLoan(Session["CompId"].ToString(), "0", "Running"); string startadate = ddlMonth.SelectedValue + "/" + "1" + "/" + TxtYear.Text; int DaysInmonth = DateTime.DaysInMonth(Convert.ToInt32(TxtYear.Text), Convert.ToInt32(ddlMonth.SelectedValue)); string enddate = ddlMonth.SelectedValue + "/" + DaysInmonth + "/" + TxtYear.Text; DtClaimRecord = new DataView(DtClaimRecord, "Loan_Approval_Date>='" + startadate + "' and Loan_Approval_Date <='" + enddate + "'", "", DataViewRowState.CurrentRows).ToTable(); Session["Month"] = ddlMonth.SelectedItem.Text; Session["Year"] = TxtYear.Text; } if (rbtnClaimType.Checked == true) { if (ddlClaimType.SelectedIndex == 0) { DisplayMessage("Select Claim Type"); ddlClaimType.Focus(); return; } int ClaimType = Convert.ToInt32(ddlClaimType.SelectedIndex); Session["ClaimType"] = ClaimType; string TransNo = string.Empty; if (ddlClaimType.SelectedIndex == 1) { DtClaimRecord = ObjClaim.GetRecord_From_PayEmployeeClaim(Session["CompId"].ToString(), "0", "0", ddlMonth.SelectedValue, TxtYear.Text, "Approved", "", ""); } if (ddlClaimType.SelectedIndex == 2) { DtClaimRecord = ObjClaim.GetRecord_From_PayEmployeeClaim(Session["CompId"].ToString(), "0", "0", ddlMonth.SelectedValue, TxtYear.Text, "Cancelled", "", ""); } if (ddlClaimType.SelectedIndex == 3) { DtClaimRecord = ObjClaim.GetRecord_From_PayEmployeeClaim(Session["CompId"].ToString(), "0", "0", ddlMonth.SelectedValue, TxtYear.Text, "Pending", "", ""); } } if (rbtnGroup.Checked) { string GroupIds = string.Empty; string EmpIds = string.Empty; for (int i = 0; i < lbxGroup.Items.Count; i++) { if (lbxGroup.Items[i].Selected) { GroupIds += lbxGroup.Items[i].Value + ","; } } if (GroupIds != "") { DataTable dtEmp = objEmp.GetEmployeeMaster(Session["CompId"].ToString()); dtEmp = new DataView(dtEmp, "Brand_Id='" + Session["BrandId"].ToString() + "' and Location_Id='" + Session["LocId"].ToString() + "'", "", DataViewRowState.CurrentRows).ToTable(); DataTable dtEmpInGroup = objGroupEmp.GetGroup_EmployeeById(Session["CompId"].ToString()); dtEmpInGroup = new DataView(dtEmpInGroup, "Group_Id in(" + GroupIds.Substring(0, GroupIds.Length - 1) + ")", "", DataViewRowState.CurrentRows).ToTable(); for (int i = 0; i < dtEmpInGroup.Rows.Count; i++) { if (!EmpIds.Split(',').Contains(dtEmpInGroup.Rows[i]["Emp_Id"].ToString())) { EmpIds += dtEmpInGroup.Rows[i]["Emp_Id"].ToString() + ","; } } //DisplayMessage("Select Group First"); if (Rbtndocument.Checked == true) { Session["Querystring"] = EmpIds; Session["ClaimRecord"] = DtClaimRecord; Session["Document"] = "Document"; Response.Redirect("../HR_Report/EmpDirectoryReport.aspx"); } if (RbtnDirectory.Checked == true) { Session["Document"] = "Directory"; Session["Querystring"] = EmpIds; Session["ClaimRecord"] = DtClaimRecord; Response.Redirect("../HR_Report/EmpDirectoryReport.aspx"); } if (rbtnPenalty.Checked == true) { Session["Querystring"] = EmpIds; Session["ClaimRecord"] = DtClaimRecord; Response.Redirect("../HR_Report/PenaltyReport.aspx"); } if (rbtnLoan.Checked == true) { Session["Querystring"] = EmpIds; Session["ClaimRecord"] = DtClaimRecord; //Response.Redirect("~/Reports/ClaimReport.aspx"); Response.Redirect("../HR_Report/LoanReport.aspx"); } if (RbtnloanDetail.Checked == true) { if (Ddlloantype.SelectedIndex == 0) { Ddlloantype.Focus(); DisplayMessage("Select Loan Type"); return; } Session["Querystring"] = Ddlloantype.SelectedValue; string[] Empid = EmpIds.Split(','); DtClaimRecord.Columns.Add("Empid"); DtClaimRecord.Columns.Add("EmpName"); DtClaimRecord.Columns.Add("Loan_Name"); DtClaimRecord.Columns.Add("Installment"); DtClaimRecord.Columns.Add("PaidAmount"); DtClaimRecord.Columns.Add("Status"); DtClaimRecord.Columns.Add("Month"); DtClaimRecord.Columns.Add("Year"); DtClaimRecord.Columns.Add("Loan_Id"); DtClaimRecord.Columns.Add("Loan_Amount"); DtClaimRecord.Columns.Add("Loan_Duration"); DtClaimRecord.Columns.Add("Loan_Interest"); DtClaimRecord.Columns.Add("Gross_Amount"); DtClaimRecord.Columns.Add("Sum_PaidAmount"); for (int i = 0; i < Empid.Length - 1; i++) { DataTable dtloanmaster = new DataTable(); DataTable dtloandetail = new DataTable(); dtloanmaster = ObjLoan.GetRecord_From_PayEmployeeLoan(Session["CompId"].ToString(), "0", "Running"); dtloanmaster = new DataView(dtloanmaster, "Emp_id=" + Empid[i].ToString() + "", "", DataViewRowState.CurrentRows).ToTable(); if (dtloanmaster.Rows.Count > 0) { for (int k = 0; k < dtloanmaster.Rows.Count; k++) { string loanid = dtloanmaster.Rows[k]["Loan_id"].ToString(); dtloandetail = ObjLoan.GetRecord_From_PayEmployeeLoanDetail(loanid); if (dtloandetail.Rows.Count > 0) { if (Ddlloantype.SelectedValue == "2") { dtloandetail = new DataView(dtloandetail, "Month=" + ddlMonth.SelectedValue + " and Year=" + TxtYear.Text + "", "", DataViewRowState.CurrentRows).ToTable(); } for (int j = 0; j < dtloandetail.Rows.Count; j++) { int month = Convert.ToInt32(dtloandetail.Rows[j]["Month"].ToString()); DataRow Tablerow = DtClaimRecord.NewRow(); Tablerow[0] = dtloanmaster.Rows[k]["Emp_Id"].ToString(); Tablerow[1] = dtloanmaster.Rows[k]["Emp_Name"].ToString(); Tablerow[2] = dtloanmaster.Rows[k]["Loan_Name"].ToString(); Tablerow[3] = dtloandetail.Rows[j]["Montly_Installment"].ToString(); Tablerow[4] = dtloandetail.Rows[j]["Employee_Paid"].ToString(); Tablerow[5] = dtloandetail.Rows[j]["Is_Status"].ToString(); Tablerow[6] = Montharr[month - 1].ToString(); Tablerow[7] = dtloandetail.Rows[j]["Year"].ToString(); Tablerow[8] = dtloanmaster.Rows[k]["Loan_Id"].ToString(); Tablerow[9] = dtloanmaster.Rows[k]["Loan_Amount"].ToString(); Tablerow[10] = dtloanmaster.Rows[k]["Loan_Duration"].ToString(); Tablerow[11] = dtloanmaster.Rows[k]["Loan_Interest"].ToString(); Tablerow[12] = dtloanmaster.Rows[k]["Gross_Amount"].ToString(); DtClaimRecord.Rows.Add(Tablerow); } } } } } Session["ClaimRecord"] = DtClaimRecord; Response.Redirect("../HR_Report/LoanDetailReport.aspx"); } //end scope of rbtnloanddetail if (rbtnClaimType.Checked == true) { Session["Querystring"] = EmpIds; Session["ClaimRecord"] = DtClaimRecord; Response.Redirect("../HR_Report/ClaimReport.aspx"); } // code for loan detail report } } else { if (lblSelectRecd.Text == "") { DisplayMessage("Select Employee First"); return; } //DisplayMessage("Select Group First"); //Response.Redirect("~/Reports/ClaimReport.aspx"); if (Rbtndocument.Checked == true) { Session["Querystring"] = lblSelectRecd.Text; Session["ClaimRecord"] = DtClaimRecord; Session["Document"] = "Document"; Response.Redirect("../HR_Report/EmpDirectoryReport.aspx"); } if (RbtnDirectory.Checked == true) { Session["Document"] = "Directory"; Session["Querystring"] = lblSelectRecd.Text; Session["ClaimRecord"] = DtClaimRecord; Response.Redirect("../HR_Report/EmpDirectoryReport.aspx"); } if (rbtnPenalty.Checked == true) { Session["Querystring"] = lblSelectRecd.Text; Session["ClaimRecord"] = DtClaimRecord; Response.Redirect("../HR_Report/PenaltyReport.aspx"); } if (rbtnLoan.Checked == true) { Session["Querystring"] = lblSelectRecd.Text; Session["ClaimRecord"] = DtClaimRecord; //Response.Redirect("~/Reports/ClaimReport.aspx"); Response.Redirect("../HR_Report/LoanReport.aspx"); } if (RbtnloanDetail.Checked == true) { if (Ddlloantype.SelectedIndex == 0) { Ddlloantype.Focus(); DisplayMessage("Select Loan Type"); return; } Session["Querystring"] = Ddlloantype.SelectedValue; string[] Empid = lblSelectRecd.Text.Split(','); DtClaimRecord.Columns.Add("Empid"); DtClaimRecord.Columns.Add("EmpName"); DtClaimRecord.Columns.Add("Loan_Name"); DtClaimRecord.Columns.Add("Installment"); DtClaimRecord.Columns.Add("PaidAmount"); DtClaimRecord.Columns.Add("Status"); DtClaimRecord.Columns.Add("Month"); DtClaimRecord.Columns.Add("Year"); DtClaimRecord.Columns.Add("Loan_Id"); DtClaimRecord.Columns.Add("Loan_Amount"); DtClaimRecord.Columns.Add("Loan_Duration"); DtClaimRecord.Columns.Add("Loan_Interest"); DtClaimRecord.Columns.Add("Gross_Amount"); DtClaimRecord.Columns.Add("Sum_PaidAmount"); for (int i = 0; i < Empid.Length - 1; i++) { DataTable dtloanmaster = new DataTable(); DataTable dtloandetail = new DataTable(); dtloanmaster = ObjLoan.GetRecord_From_PayEmployeeLoan(Session["CompId"].ToString(), "0", "Running"); dtloanmaster = new DataView(dtloanmaster, "Emp_id=" + Empid[i].ToString() + "", "", DataViewRowState.CurrentRows).ToTable(); if (dtloanmaster.Rows.Count > 0) { for (int k = 0; k < dtloanmaster.Rows.Count; k++) { string loanid = dtloanmaster.Rows[k]["Loan_id"].ToString(); dtloandetail = ObjLoan.GetRecord_From_PayEmployeeLoanDetail(loanid); if (dtloandetail.Rows.Count > 0) { if (Ddlloantype.SelectedValue == "2") { dtloandetail = new DataView(dtloandetail, "Month=" + ddlMonth.SelectedValue + " and Year=" + TxtYear.Text + "", "", DataViewRowState.CurrentRows).ToTable(); } //dtloandetail = new DataView(dtloandetail, "Month=" + ddlMonth.SelectedValue + " and Year=" + TxtYear.Text + "", "", DataViewRowState.CurrentRows).ToTable(); for (int j = 0; j < dtloandetail.Rows.Count; j++) { int month = Convert.ToInt32(dtloandetail.Rows[j]["Month"].ToString()); DataRow dr_Row = DtClaimRecord.NewRow(); dr_Row[0] = dtloanmaster.Rows[k]["Emp_Id"].ToString(); dr_Row[1] = dtloanmaster.Rows[k]["Emp_Name"].ToString(); dr_Row[2] = dtloanmaster.Rows[k]["Loan_Name"].ToString(); dr_Row[3] = dtloandetail.Rows[j]["Montly_Installment"].ToString(); dr_Row[4] = dtloandetail.Rows[j]["Employee_Paid"].ToString(); dr_Row[5] = dtloandetail.Rows[j]["Is_Status"].ToString(); dr_Row[6] = Montharr[month - 1].ToString(); dr_Row[7] = TxtYear.Text; dr_Row[8] = dtloanmaster.Rows[k]["Loan_Id"].ToString(); dr_Row[9] = dtloanmaster.Rows[k]["Loan_Amount"].ToString(); dr_Row[10] = dtloanmaster.Rows[k]["Loan_Duration"].ToString(); dr_Row[11] = dtloanmaster.Rows[k]["Loan_Interest"].ToString(); dr_Row[12] = dtloanmaster.Rows[k]["Gross_Amount"].ToString(); DtClaimRecord.Rows.Add(dr_Row); } } } } } Session["ClaimRecord"] = DtClaimRecord; Response.Redirect("../HR_Report/LoanDetailReport.aspx"); } //end scope of rbtnloanddetail if (rbtnClaimType.Checked == true) { Session["Querystring"] = lblSelectRecd.Text; Session["ClaimRecord"] = DtClaimRecord; Response.Redirect("../HR_Report/ClaimReport.aspx"); } } if (b != 0) { rbtnEmp.Checked = true; rbtnGroup.Checked = false; EmpGroup_CheckedChanged(null, null); } else { TxtYear.Text = DateTime.Now.Year.ToString(); int CurrentMonth = Convert.ToInt32(DateTime.Now.Month.ToString()); ddlMonth.SelectedValue = (CurrentMonth).ToString(); foreach (GridViewRow Gvrow in gvEmpLeave.Rows) { CheckBox ChkHeader = (CheckBox)gvEmpLeave.HeaderRow.FindControl("chkgvSelectAll"); CheckBox ChkItem = (CheckBox)Gvrow.FindControl("chkgvSelect"); ChkHeader.Checked = false; ChkItem.Checked = false; } //DisplayMessage("Record Not Saved"); } }