protected void DDL_EmoloyeeName_SelectedIndexChanged(object sender, EventArgs e) { try { ViewState["UserCode"] = DDL_EmoloyeeName.SelectedValue; database db = new database(); PayGroupID = db.getDb_Value("select PayGrpID from tblEmployee where UserCode='" + ViewState["UserCode"] + "'"); if (PayGroupID > 0) { BL_SalarySettings objBL = new BL_SalarySettings(); EWA_SalarySettings objEWA = new EWA_SalarySettings(); objEWA.Action = "GetPayDetails"; objEWA.OrgId = Convert.ToInt32(ViewState["OrgID"]); objEWA.PayGrpID = Convert.ToInt32(PayGroupID); //int.Parse(PayGroupID).ToString();//Convert.ToInt32(ViewState["PayGrpID"]); objEWA.UserCode = DDL_EmoloyeeName.SelectedValue; objEWA.SalaryMonth = Convert.ToDateTime(txtMonth.Text).Month.ToString(); objEWA.PostedMonth = Convert.ToDateTime(txtMonth.Text).Month.ToString(); DataSet ds = objBL.GetSalarySettings(objEWA); if (ds.Tables[0].Rows.Count > 0 || ds.Tables[1].Rows.Count > 0 || ds.Tables[2].Rows.Count > 0 || ds.Tables[3].Rows.Count > 0) { Get_OrganizationDetails(Convert.ToInt32(ViewState["OrgID"])); lblName.Text = ds.Tables[4].Rows[0][1].ToString(); lblDesignation.Text = DDL_Designation.SelectedItem.ToString(); lblName1.Text = ds.Tables[4].Rows[0][1].ToString(); lblDesignation1.Text = DDL_Designation.SelectedItem.ToString(); double GrossSalary = 0, Deductions = 0, NetSalary = 0, leaveDeductions = 0; DataTable dt = new DataTable(); dt.Columns.Add("Description"); dt.Columns.Add("Earnings"); dt.Columns.Add("Deductions"); DataRow dr; if (ds.Tables[3].Rows.Count > 0) { dr = dt.NewRow(); dr[0] = "Basic Salary"; dr[1] = ds.Tables[3].Rows[0][0].ToString(); dr[2] = ""; dt.Rows.Add(dr); txtBasicSalary = Convert.ToDouble(ds.Tables[3].Rows[0][0].ToString()); GrossSalary = GrossSalary + Convert.ToDouble(ds.Tables[3].Rows[0][0].ToString()); } int i = 0; while (ds.Tables[0].Rows.Count > i) { dr = dt.NewRow(); dr[0] = ds.Tables[0].Rows[i][0].ToString(); dr[1] = ds.Tables[0].Rows[i][1].ToString(); dr[2] = ""; GrossSalary = GrossSalary + Convert.ToDouble(ds.Tables[0].Rows[i][1].ToString()); i++; dt.Rows.Add(dr); } i = 0; while (ds.Tables[1].Rows.Count > i) { dr = dt.NewRow(); dr[0] = ds.Tables[1].Rows[i][0].ToString(); dr[1] = ""; dr[2] = ds.Tables[1].Rows[i][1].ToString(); Deductions = Deductions + Convert.ToDouble(ds.Tables[1].Rows[i][1].ToString()); i++; dt.Rows.Add(dr); } int days = DateTime.DaysInMonth(Convert.ToDateTime(txtMonth.Text).Year, Convert.ToDateTime(txtMonth.Text).Month); double leaveday = 0; if (ds.Tables[2].Rows.Count > 0 && ds.Tables[2].Rows[0][0].ToString() != "") { leaveday = Convert.ToDouble(ds.Tables[2].Rows[0][0].ToString()); leaveDeductions = Convert.ToDouble((String.Format("{0:0.00}", (GrossSalary / days) * leaveday)).ToString()); dr = dt.NewRow(); dr[0] = "Leave Deductions"; dr[1] = ""; dr[2] = leaveDeductions; dt.Rows.Add(dr); Deductions = Deductions + leaveDeductions; } lblWorkday.Text = (days - leaveday).ToString(); lblAbsence.Text = leaveday.ToString(); lblWorkday1.Text = (days - leaveday).ToString(); lblAbsence1.Text = leaveday.ToString(); dr = dt.NewRow(); dr[0] = "Total"; dr[1] = GrossSalary; dr[2] = Deductions; dt.Rows.Add(dr); NetSalary = GrossSalary - Deductions; dr = dt.NewRow(); dr[0] = ""; dr[1] = "Net Salary"; dr[2] = NetSalary; dt.Rows.Add(dr); GridView1.DataSource = dt; GridView1.DataBind(); GridView2.DataSource = dt; GridView2.DataBind(); i = 0; while (GridView1.Rows.Count > i) { GridView1.Rows[i].Cells[1].HorizontalAlign = HorizontalAlign.Center; GridView1.Rows[i].Cells[2].HorizontalAlign = HorizontalAlign.Center; i++; } GridView1.Rows[GridView1.Rows.Count - 1].Cells[0].BorderStyle = BorderStyle.None; GridView1.Rows[GridView1.Rows.Count - 1].Cells[1].Font.Bold = true; GridView1.Rows[GridView1.Rows.Count - 1].Cells[2].Font.Bold = true; GridView1.Rows[GridView1.Rows.Count - 1].Cells[1].ForeColor = System.Drawing.Color.DodgerBlue; GridView1.Rows[GridView1.Rows.Count - 2].Cells[0].Font.Bold = true; GridView1.Rows[GridView1.Rows.Count - 2].Cells[1].Font.Bold = true; GridView1.Rows[GridView1.Rows.Count - 2].Cells[2].Font.Bold = true; GridView1.Rows[GridView1.Rows.Count - 2].Cells[0].HorizontalAlign = HorizontalAlign.Center; lblGross.Text = GrossSalary.ToString(); lblNet.Text = NetSalary.ToString(); txtGrossSalary = GrossSalary; txtNetSalary = NetSalary; txtDeductions = Deductions; lblGross1.Text = GrossSalary.ToString(); lblNet1.Text = NetSalary.ToString(); if (ds.Tables[4].Rows.Count > 0) { lblPaymentDate.Text = DateTime.Now.Date.ToShortDateString(); lblBankName.Text = ds.Tables[4].Rows[0][0].ToString(); lblHolderName.Text = ds.Tables[4].Rows[0][1].ToString(); lblAccountNumber.Text = ds.Tables[4].Rows[0][2].ToString(); lblBankBranch.Text = ds.Tables[4].Rows[0][3].ToString(); lblPaymentDate1.Text = DateTime.Now.Date.ToShortDateString(); lblBankName1.Text = ds.Tables[4].Rows[0][0].ToString(); lblHolderName1.Text = ds.Tables[4].Rows[0][1].ToString(); lblAccountNumber1.Text = ds.Tables[4].Rows[0][2].ToString(); lblBankBranch1.Text = ds.Tables[4].Rows[0][3].ToString(); } Panel2.Visible = true; btnPostSalary.Visible = true; btnPrintSalarySlip.Visible = true; } else { GeneralErr("Record Not Found...!"); } } else { msgBox.ShowMessage("Please Apply Pay Scale...!", "Information", UserControls.MessageBox.MessageStyle.Information); } } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }
protected void btnPostSalary_Click(object sender, EventArgs e) { BL_SalarySettings objBL = new BL_SalarySettings(); EWA_SalarySettings objEWA = new EWA_SalarySettings(); try { objEWA.EmployeeName = DDL_EmoloyeeName.SelectedItem.ToString(); objEWA.UserCode = DDL_EmoloyeeName.SelectedValue.ToString(); objEWA.Department = DDL_Department.SelectedItem.ToString(); objEWA.Designation = DDL_Designation.SelectedItem.ToString(); objEWA.SalaryMonth = txtMonth.Text.ToString(); objEWA.PostedMonth = Convert.ToDateTime(txtMonth.Text).ToString(); objEWA.BasicSalary = txtBasicSalary; objEWA.GorssSalary = txtGrossSalary; objEWA.TotalDeduction = txtDeductions; objEWA.LeaveDeduction = 0;//Convert.ToDouble(txtTotalLeave.Text); objEWA.NetSalary = txtNetSalary; objEWA.OrgId = Convert.ToInt32(Session["OrgId"]); objEWA.AcademicYearId = Convert.ToInt32(Session["AcademicYearId"]); objEWA.Action = "SalarySlipSave"; // CREATING DATA TABLE FOR GRID VIEW DataTable DataSalaryEarning = new DataTable(); DataSalaryEarning.Columns.Add("CategoryName"); DataSalaryEarning.Columns.Add("ContentValue"); DataSalaryEarning.Columns.Add("ContentAction"); string CategoryName, ContentValue, ContentAction; //foreach (GridViewRow gvrow in GridView1.Rows) //{ // CategoryName = GridView1.Rows[gvrow.RowIndex].Cells[0].Text; // if (GridView1.Rows[gvrow.RowIndex].Cells[1].Text != null) // { // ContentValue = GridView1.Rows[gvrow.RowIndex].Cells[1].Text; // DataSalaryEarning.Rows.Add(CategoryName, ContentValue, "Earning"); // } // else // { // ContentValue = GridView1.Rows[gvrow.RowIndex].Cells[2].Text; // DataSalaryEarning.Rows.Add(CategoryName, ContentValue, "Deduction"); // } // i++; //} //foreach (GridViewRow gvrow in grdDeduction.Rows) //{ // CategoryName = grdDeduction.Rows[gvrow.RowIndex].Cells[1].Text; // ContentValue = grdDeduction.Rows[gvrow.RowIndex].Cells[2].Text; // DataSalaryEarning.Rows.Add(CategoryName, ContentValue,"Deduction"); // i++; //} int flag = objBL.SaveSalarySlip(objEWA, DataSalaryEarning); DataSet dss = new DataSet(); DataSet dss1 = new DataSet(); if (flag > 0) { database db = new database(); for (int i = 0; (GridView1.Rows.Count - 2) > i; i++) { CategoryName = GridView1.Rows[i].Cells[0].Text; string date = DateTime.Now.ToShortDateString(); if (GridView1.Rows[i].Cells[1].Text != " ") { ContentValue = GridView1.Rows[i].Cells[1].Text; ContentAction = "Earning"; //db.insert("INSERT INTO tblPostSalaryContents (SalarySleepID,CategoryName,ContentValue,ContentAction,TransDate,AcademicYearId,IsActive) " + // "values('" + flag + "','" + CategoryName + "','" + ContentValue + "','" + ContentAction + "','" + date + "','" + Convert.ToInt32(Session["AcademicYearId"]) + "',1)"); } else { ContentValue = GridView1.Rows[i].Cells[2].Text; ContentAction = "Deduction"; //db.insert("INSERT INTO tblPostSalaryContents (SalarySleepID,CategoryName,ContentValue,ContentAction,TransDate,AcademicYearId,IsActive) " + // "values('" + flag + "','" + CategoryName + "','" + ContentValue + "','" + ContentAction + "','" + date + "','" + Convert.ToInt32(Session["AcademicYearId"]) + "',1)"); } objEWA.ContentValue = ContentValue; objEWA.ContentAction = ContentAction; objEWA.SalarySleepID = flag.ToString(); objEWA.CategoryName = CategoryName; dss1 = objBL.SaveSalaryContent(objEWA); } if (dss1.Tables[0].Rows.Count > 0) { if (dss1.Tables[0].Rows[0]["TokenId"].ToString() != "") { if (dss1.Tables[1].Rows[0]["SenderId"].ToString() != "") { SendPushNotification(dss1.Tables[0].Rows[0]["TokenId"].ToString(), dss1.Tables[0].Rows[0]["Subject"].ToString(), dss1.Tables[0].Rows[0]["OrgName"].ToString(), dss1.Tables[1].Rows[0]["SenderId"].ToString(), dss1.Tables[1].Rows[0]["AppKey"].ToString()); } } } txtMonth.Text = string.Empty; DDL_Department.ClearSelection(); rbtnFacultyType.ClearSelection(); DDL_Designation.ClearSelection(); DDL_EmoloyeeName.ClearSelection(); Panel2.Visible = false; btnPostSalary.Visible = false; btnPrintSalarySlip.Visible = false; msgBox.ShowMessage("Salary Posted Successfully !!!", "Saved", UserControls.MessageBox.MessageStyle.Successfull); } else { if (objEWA.Action == "Save") { msgBox.ShowMessage("Unable to Save !!!", "Critical", UserControls.MessageBox.MessageStyle.Critical); } if (objEWA.Action == "SalarySlipSave" && flag == 0) { Panel2.Visible = false; btnPostSalary.Visible = false; btnPrintSalarySlip.Visible = false; msgBox.ShowMessage("Salary already Posted !!!", "Information", UserControls.MessageBox.MessageStyle.Information); } } } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }
protected void btnShow_Click(object sender, EventArgs e) { try { ViewState["UserCode"] = Session["UserCode"].ToString(); BL_SalarySettings objBL = new BL_SalarySettings(); EWA_SalarySettings objEWA = new EWA_SalarySettings(); objEWA.Action = "StaffGetSalary_Details"; objEWA.OrgId = Convert.ToInt32(ViewState["OrgID"]); objEWA.PayGrpID = 0; objEWA.UserCode = Session["UserCode"].ToString(); objEWA.SalaryMonth = Convert.ToDateTime(txtMonth.Text).Month.ToString(); objEWA.PostedMonth = txtMonth.Text; DataSet ds = objBL.GetSalarySettings(objEWA); if (ds.Tables[0].Rows.Count > 0 && ds.Tables[1].Rows.Count > 0 && ds.Tables[2].Rows.Count > 0 && ds.Tables[3].Rows.Count > 0) { lbl_CollegeName.Text = ds.Tables[3].Rows[0]["OrgName"].ToString(); lbl_CollegeAddress.Text = ds.Tables[3].Rows[0]["Address"].ToString(); lbl_Number.Text = ds.Tables[3].Rows[0]["PhoneNo"].ToString(); lbl_website.Text = ds.Tables[3].Rows[0]["Website"].ToString(); lbl_CollegeName1.Text = lbl_CollegeName.Text; lbl_CollegeAddress1.Text = ds.Tables[3].Rows[0]["Address"].ToString(); lbl_Number1.Text = ds.Tables[3].Rows[0]["PhoneNo"].ToString(); lbl_website1.Text = ds.Tables[3].Rows[0]["Website"].ToString(); lblmonthyear.Text = Convert.ToDateTime(txtMonth.Text).ToString("MMMM") + " " + Convert.ToDateTime(txtMonth.Text).Year.ToString(); lblName.Text = ds.Tables[0].Rows[0]["EmployeeName"].ToString(); lblDesignation.Text = ds.Tables[0].Rows[0]["Designation"].ToString(); lblName1.Text = lblName.Text; lblmonthyear1.Text = lblmonthyear.Text; lblDesignation1.Text = lblDesignation.Text; lblGross.Text = ds.Tables[0].Rows[0]["GorssSalary"].ToString(); lblNet.Text = ds.Tables[0].Rows[0]["NetSalary"].ToString(); lblGross1.Text = lblGross.Text; lblNet1.Text = lblNet.Text; lblPaymentDate.Text = Convert.ToDateTime(ds.Tables[0].Rows[0]["TransDate"].ToString()).ToString("dd-MM-yyyy"); lblBankName.Text = ds.Tables[0].Rows[0]["BankName"].ToString(); lblHolderName.Text = lblName.Text; lblAccountNumber.Text = ds.Tables[0].Rows[0]["BankAccountNumber"].ToString(); lblBankBranch.Text = ds.Tables[0].Rows[0]["BankBranchName"].ToString(); lblPaymentDate1.Text = Convert.ToDateTime(ds.Tables[0].Rows[0]["TransDate"].ToString()).ToString("dd-MM-yyyy"); lblBankName1.Text = ds.Tables[0].Rows[0]["BankName"].ToString(); lblHolderName1.Text = lblName.Text; lblAccountNumber1.Text = ds.Tables[0].Rows[0]["BankAccountNumber"].ToString(); lblBankBranch1.Text = ds.Tables[0].Rows[0]["BankBranchName"].ToString(); int days = DateTime.DaysInMonth(Convert.ToDateTime(txtMonth.Text).Year, Convert.ToDateTime(txtMonth.Text).Month); double leaveday = 0; lblWorkday.Text = days.ToString(); lblAbsence.Text = "0"; lblWorkday1.Text = days.ToString(); lblAbsence1.Text = "0"; if (ds.Tables[2].Rows.Count > 0 && ds.Tables[2].Rows[0][0].ToString() != "") { leaveday = Convert.ToDouble(ds.Tables[2].Rows[0][0].ToString()); lblWorkday.Text = String.Format("{0:0.00}", (days - leaveday)).ToString(); lblAbsence.Text = leaveday.ToString(); lblWorkday1.Text = String.Format("{0:0.00}", (days - leaveday)).ToString(); lblAbsence1.Text = leaveday.ToString(); } DataTable dt = new DataTable(); dt.Columns.Add("Description"); dt.Columns.Add("Earnings"); dt.Columns.Add("Deductions"); DataRow dr; int i = 0; while (ds.Tables[1].Rows.Count > i) { if (ds.Tables[1].Rows[i]["ContentAction"].ToString() == "Earning") { dr = dt.NewRow(); dr[0] = ds.Tables[1].Rows[i]["CategoryName"].ToString(); dr[1] = ds.Tables[1].Rows[i]["ContentValue"].ToString(); dr[2] = ""; dt.Rows.Add(dr); } else { dr = dt.NewRow(); dr[0] = ds.Tables[1].Rows[i]["CategoryName"].ToString(); dr[1] = ""; dr[2] = ds.Tables[1].Rows[i]["ContentValue"].ToString(); dt.Rows.Add(dr); } i++; } dr = dt.NewRow(); dr[0] = "Total"; dr[1] = lblGross.Text; dr[2] = ds.Tables[0].Rows[0]["TotalDeduction"].ToString(); dt.Rows.Add(dr); dr = dt.NewRow(); dr[0] = ""; dr[1] = "Net Salary"; dr[2] = lblNet.Text; dt.Rows.Add(dr); GridView1.DataSource = dt; GridView1.DataBind(); GridView2.DataSource = dt; GridView2.DataBind(); i = 0; while (GridView1.Rows.Count > i) { GridView1.Rows[i].Cells[1].HorizontalAlign = HorizontalAlign.Center; GridView1.Rows[i].Cells[2].HorizontalAlign = HorizontalAlign.Center; i++; } GridView1.Rows[GridView1.Rows.Count - 1].Cells[0].BorderStyle = BorderStyle.None; GridView1.Rows[GridView1.Rows.Count - 1].Cells[1].Font.Bold = true; GridView1.Rows[GridView1.Rows.Count - 1].Cells[2].Font.Bold = true; GridView1.Rows[GridView1.Rows.Count - 1].Cells[1].ForeColor = System.Drawing.Color.DeepSkyBlue; GridView1.Rows[GridView1.Rows.Count - 1].Cells[2].ForeColor = System.Drawing.Color.DeepSkyBlue; Panel2.Visible = true; btnPrintSalarySlip.Visible = true; } else { Panel2.Visible = false; btnPrintSalarySlip.Visible = false; msgBox.ShowMessage("Salary not posted yet...!", "Information", UserControls.MessageBox.MessageStyle.Information); } } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }