Пример #1
0
        private void btn_upd_Click(object sender, EventArgs e)
        {
            int    r    = 0;
            String code = "";

            isnew = false;

            if (dgv_list.Rows.Count > 1)
            {
                try
                {
                    r = dgv_list.CurrentRow.Index;
                    cbo_employee.SelectedValue = dgv_list["dgvl_empno", r].Value.ToString();
                    code          = dgv_list["dgvl_code", r].Value.ToString();
                    txt_code.Text = code;
                    txt_desc.Text = dgv_list["dgvl_description", r].Value.ToString();
                    cbo_contraacct.SelectedValue = dgv_list["dgvl_trn_type", r].Value.ToString();
                    cbo_stocklocation.Text       = dgv_list["dgvl_location", r].Value.ToString();
                    cbo_costcenter.Text          = dgv_list["dgvl_ccname", r].Value.ToString();
                    cbo_scc.Text        = dgv_list["dgvl_sub_costcenter", r].Value.ToString();
                    dtp_deduction.Value = gm.toDateValue(dgv_list["dgvl_deduction_date", r].Value.ToString());
                    dtp_trnxdt.Value    = gm.toDateValue(dgv_list["dgvl_trnxdate", r].Value.ToString());
                    txt_amnt_loan.Text  = gm.toNormalDoubleFormat(dgv_list["dgvl_loan_amount", r].Value.ToString()).ToString("0.00");
                    txt_deduction.Text  = gm.toNormalDoubleFormat(dgv_list["dgvl_deduction_amount", r].Value.ToString()).ToString("0.00");
                }
                catch { }

                //disp_itemlist(code);
                //total_amountdue();
                goto_tbcntrl_info();

                //goto_win2();
            }
        }
Пример #2
0
 private void txt_f_month_TextChanged(object sender, EventArgs e)
 {
     if (txt_f_month.Text.Length != 0)
     {
         try
         {
             double n = gm.toNormalDoubleFormat(txt_f_month.Text);
             if (0 < n && n <= 12)
             {
                 txt_f_month.Text = n.ToString("0");
                 return;
             }
         } catch { }
         txt_f_month.Text = DateTime.Now.ToString("MM");
     }
 }
        void calculate_gross()
        {
            Double gross = gm.toNormalDoubleFormat(txt_basic_pay.Text) + gm.toNormalDoubleFormat(txt_reg_ot_b.Text) + gm.toNormalDoubleFormat(txt_dayoffot_b.Text) + gm.toNormalDoubleFormat(txt_legalhol_ot_b.Text) + gm.toNormalDoubleFormat(txt_specialhol_ot_b.Text) + gm.toNormalDoubleFormat(txt_legalhol_pay_b.Text) + gm.toNormalDoubleFormat(txt_specialhol_pay_b.Text) + gm.toNormalDoubleFormat(txt_night_diff_b.Text) + gm.toNormalDoubleFormat(txt_other_earning.Text) + gm.toNormalDoubleFormat(txt_vl_b.Text) + gm.toNormalDoubleFormat(txt_sl_b.Text) + gm.toNormalDoubleFormat(txt_pl_b.Text) + gm.toNormalDoubleFormat(txt_legalhol_pay_b.Text) + gm.toNormalDoubleFormat(txt_specialhol_pay_b.Text);

            lbl_total_gross.Text = gm.toAccountingFormat(gross);
        }
Пример #4
0
        private void bg_worker_DoWork(object sender, DoWorkEventArgs e)
        {
            String    table = "hr_emp_payroll", col = "", val = "", emp_pay_code = "";
            String    summ_code = "", empid = "", days_worked = "", absences = "", late = "", undertime = "", overtime = "", ppid = "", sss_bracket = "", philhealth_bracket = "", pagibig_bracket = "";
            Double    total_late = 0.00, total_under_time = 0.00, total_overtime = 0.00, leaves_amnt = 0.00, other_deduc = 0.00, other_earn = 0.00, advances_loans = 0.00, pag_ibig_a = 0.00, philhealth_cont_a = 0.00, sss_cont_a = 0.00;
            DataTable dtr = get_generated_dtr(), dttmp = new DataTable();
            Boolean   success = false;
            int       bar     = 1;

            if (dtr.Rows.Count > 0)
            {
                try
                {
                    pbar.Invoke(new Action(() =>
                    {
                        pbar.Maximum = dtr.Rows.Count;
                    }));
                    for (int r = 0; r < dtr.Rows.Count; r++)
                    {
                        ppid        = dtr.Rows[r]["ppid"].ToString();
                        empid       = dtr.Rows[r]["empid"].ToString();
                        days_worked = dtr.Rows[r]["days_worked"].ToString();
                        absences    = dtr.Rows[r]["absences"].ToString();
                        late        = dtr.Rows[r]["late"].ToString();
                        undertime   = dtr.Rows[r]["undertime"].ToString();
                        overtime    = dtr.Rows[r]["total_overtime"].ToString();
                        try
                        {
                            total_late = Convert.ToDouble(TimeSpan.Parse(late).TotalHours);
                        }
                        catch (Exception ex)
                        {
                            total_late = 0.00;
                        }

                        try
                        {
                            total_under_time = Convert.ToDouble(TimeSpan.Parse(undertime).TotalHours);
                        }
                        catch (Exception ex)
                        {
                            total_under_time = 0.00;
                        }
                        try
                        {
                            total_overtime = Convert.ToDouble(TimeSpan.Parse(overtime).TotalHours);
                        }
                        catch (Exception ex)
                        {
                            total_overtime = 0.00;
                        }

                        chk_oearn.Invoke(new Action(() => {
                            if (chk_oearn.Checked)
                            {
                                DataTable tdt = db.QueryBySQLCode("SELECT * FROM rssys.hr_deduction_entry WHERE payroll_period='" + ppid + "' AND emp_no='" + empid + "'");
                                if (tdt != null)
                                {
                                    for (int i = 0; i < tdt.Rows.Count; i++)
                                    {
                                        other_earn += gm.toNormalDoubleFormat(tdt.Rows[i]["amount"].ToString());
                                    }
                                }
                            }
                        }));
                        chk_odeduc.Invoke(new Action(() =>
                        {
                            if (chk_odeduc.Checked)
                            {
                                DataTable tdt = db.QueryBySQLCode("SELECT * FROM rssys.hr_deduction_entry WHERE payroll_period='" + ppid + "' AND emp_no='" + empid + "'");

                                if (tdt != null)
                                {
                                    for (int i = 0; i < tdt.Rows.Count; i++)
                                    {
                                        other_deduc += gm.toNormalDoubleFormat(tdt.Rows[i]["amount"].ToString());
                                    }
                                }
                            }
                        }));


                        chk_loan.Invoke(new Action(() =>
                        {
                            if (chk_loan.Checked)
                            {
                                DataTable tdt = db.QueryBySQLCode("SELECT * FROM rssys.hr_loanhdr l LEFT JOIN rssys.hr_payrollpariod pp ON l.loan_transdate BETWEEN pp.date_from AND pp.date_to  WHERE pp.pay_code='" + ppid + "' AND l.employee_no='" + empid + "'");

                                if (tdt != null)
                                {
                                    for (int i = 0; i < tdt.Rows.Count; i++)
                                    {
                                        advances_loans += gm.toNormalDoubleFormat(tdt.Rows[i]["loan_amount"].ToString());
                                    }
                                }
                            }
                        }));

                        chk_leave.Invoke(new Action(() =>
                        {
                            if (chk_leave.Checked)
                            {
                                DataTable tdt = db.QueryBySQLCode("SELECT * from rssys.hr_leaves l LEFT JOIN rssys.hr_payrollpariod pp ON l.d_filed BETWEEN pp.date_from AND pp.date_to WHERE COALESCE(l.cancel,l.cancel,'')<>'Y' AND pp.pay_code='" + ppid + "' AND l.empid='" + empid + "'");

                                if (tdt != null)
                                {
                                    for (int i = 0; i < tdt.Rows.Count; i++)
                                    {
                                        leaves_amnt += gm.toNormalDoubleFormat(tdt.Rows[i]["leave_amount"].ToString());
                                    }
                                }
                            }
                        }));


                        emp_pay_code = db.get_pk("emp_pay_code");
                        col          = "emp_pay_code,empid,days_worked,abcences,late,undertime,overtime,ppid,other_deduction, other_earnings, leave_amnt, advances_loans";
                        val          = "'" + emp_pay_code + "','" + empid + "','" + days_worked + "','" + absences + "','" + total_late.ToString("0.00") + "','" + total_under_time.ToString("0.00") + "','" + total_overtime.ToString("0.00") + "','" + ppid + "','" + other_deduc + "','" + other_earn + "','" + leaves_amnt + "','" + advances_loans + "'";



                        dttmp = db.QueryBySQLCode("SELECT  COALESCE(emp_ee,0.00) +  COALESCE(emp_er,0.00) AS total, pagibig_bracket FROM rssys.hr_hdmf h JOIN rssys.hr_employee e ON (e.pagibig_bracket=h.code AND e.empid='" + empid + "')");
                        if (dttmp != null)
                        {
                            try
                            {
                                pag_ibig_a      = gm.toNormalDoubleFormat(dttmp.Rows[0]["total"].ToString());
                                pagibig_bracket = dttmp.Rows[0]["pagibig_bracket"].ToString();
                            } catch { }
                        }
                        dttmp = db.QueryBySQLCode("SELECT COALESCE(empshare_sc,0.00) + COALESCE(empshare_ec,0.00) + COALESCE(s_ec,0.00) AS total, sss_bracket FROM rssys.hr_sss h JOIN rssys.hr_employee e ON (e.sss_bracket=h.code AND e.empid='" + empid + "')");
                        if (dttmp != null)
                        {
                            try
                            {
                                sss_cont_a  = gm.toNormalDoubleFormat(dttmp.Rows[0]["total"].ToString());
                                sss_bracket = dttmp.Rows[0]["sss_bracket"].ToString();
                            } catch { }
                        }
                        dttmp = db.QueryBySQLCode("SELECT COALESCE(emp_ee,0.00) + COALESCE(emp_er,0.00) AS total, philhealth_bracket FROM rssys.hr_philhealth h JOIN rssys.hr_employee e ON (e.philhealth_bracket=h.code AND e.empid='" + empid + "')");
                        if (dttmp != null)
                        {
                            try
                            {
                                philhealth_cont_a  = gm.toNormalDoubleFormat(dttmp.Rows[0]["total"].ToString());
                                philhealth_bracket = dttmp.Rows[0]["philhealth_bracket"].ToString();
                            } catch { }
                        }

                        col += ",regular_pay, basic_pay, vl_a, vl_b, sl_a, sl_b, pl_a, pl_b, regular_ot_a, reqular_ot_b, dayoff_ot_a, dayoff_ot_b, legal_hol_ot_a, legal_hol_ot_b, special_hol_ot_a, special_hol_ot_b, legal_hol_pay_a, legal_hol_pay_b, spl_hol_pay_a, spl_hol_pay_b,night_diff_a, night_diff_b, sss_cont_a, sss_cont_b,  sss_cont_c, philhealth_cont_a, philhealth_cont_b, pag_ibig_a, pag_ibig_b, others, w_tax, late_amnt, absent_amnt, sss_bracket, philhealth_bracket, pagibig_bracket";
                        val += ",'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0','0', '" + sss_cont_a.ToString("0.00") + "', '0',  '0', '" + philhealth_cont_a.ToString("0.00") + "', '0', '" + pag_ibig_a.ToString("0.00") + "', '0', '0', '0', '0', '0','" + sss_bracket + "','" + philhealth_bracket + "','" + pagibig_bracket + "'";

                        if (db.InsertOnTable(table, col, val))
                        {
                            col = "isgenerated='1'";

                            if (db.UpdateOnTable("hr_dtr_sum_employees", col, "empid='" + empid + "' AND ppid='" + ppid + "'"))
                            {
                                success = true;
                                inc_pbar(bar, dtr.Rows.Count);
                                bar++;
                            }
                            db.set_pkm99("emp_pay_code", db.get_nextincrementlimitchar(emp_pay_code, 8));
                        }
                    }
                    if (success)
                    {
                        String period = get_payrol_period(ppid);
                        MessageBox.Show("New payroll was generated From " + period + " .");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Payroll cannot be generated. Something went wrong. " + ex.Message);
                }
            }
            else
            {
                MessageBox.Show("No generated DTR is available.");
            }
        }
Пример #5
0
        private void btn_save_Click(object sender, EventArgs e)
        {
            Boolean        success = false, ok = false;
            String         notificationText = "";
            z_Notification notify           = new z_Notification();

            String branch = GlobalClass.branch;
            String col = "", val = "";
            String notifyadd = null, id = "";
            String table = "hr_sss";


            if (String.IsNullOrEmpty(txt_code.Text))
            {
                MessageBox.Show("Please enter the required fields.");
                return;
            }

            String code        = txt_code.Text;
            String bracket1    = gm.toNormalDoubleFormat(txt_bracket1.Text).ToString("0.00");
            String bracket2    = gm.toNormalDoubleFormat(txt_bracket2.Text).ToString("0.00");
            String s_credit    = gm.toNormalDoubleFormat(txt_s_credit.Text).ToString("0.00");
            String empshare_sc = gm.toNormalDoubleFormat(txt_empshare_sc.Text).ToString("0.00");
            String s_ec        = gm.toNormalDoubleFormat(txt_s_ec.Text).ToString("0.00");
            String empshare_ec = gm.toNormalDoubleFormat(txt_empshare_ec.Text).ToString("0.00");

            if (isnew)
            {
                col = "code,bracket1,bracket2,s_credit,empshare_sc,s_ec,empshare_ec";
                val = "" + db.str_E(code) + ",'" + bracket1 + "','" + bracket2 + "','" + s_credit + "','" + empshare_sc + "','" + s_ec + "','" + empshare_ec + "'";

                db.DeleteOnTable(table, "code=" + db.str_E(code) + " AND cancel='Y'");
                if (db.InsertOnTable(table, col, val))
                {
                    success = true;
                }
                else
                {
                    success = false;
                    //db.DeleteOnTable(table, "code='" + code + "'");
                    MessageBox.Show("Failed on saving.");
                }
            }
            else
            {
                col = "bracket1='" + bracket1 + "',bracket2='" + bracket2 + "',s_credit='" + s_credit + "',empshare_sc='" + empshare_sc + "',s_ec='" + s_ec + "',empshare_ec='" + empshare_ec + "'";

                if (db.UpdateOnTable(table, col, "code=" + db.str_E(code) + ""))
                {
                    success = true;
                }
                else
                {
                    success = false;
                    MessageBox.Show("Failed on saving.");
                }
            }

            if (success)
            {
                goto_win1();
                frm_clear();
                disp_list();
            }
        }
Пример #6
0
        private void btn_save_Click(object sender, EventArgs e)
        {
            Boolean        success = false, ok = false;
            String         notificationText = "";
            z_Notification notify           = new z_Notification();

            String branch = GlobalClass.branch;
            String col = "", val = "";
            String notifyadd = null, id = "";
            String table = "hr_leaves";

            if (String.IsNullOrEmpty(txt_code.Text))
            {
                MessageBox.Show("Please enter the required fields.");
                return;
            }
            if (cbo_employee.SelectedIndex == -1)
            {
                MessageBox.Show("Please select an employee.");
                cbo_employee.DroppedDown = true;
                return;
            }
            if (cbo_leave_pay.Text == "YES" && gm.toNormalDoubleFormat(txt_amount.Text) == 0)
            {
                MessageBox.Show("Please input leave amount.");
                return;
            }

            String lvcode     = txt_code.Text;
            String no_of_days = Double.Parse(txt_no_of_days.Text).ToString();

            String d_filed      = dtp_filed.Value.ToString("yyyy-MM-dd");
            String leave_from   = dtp_lfrm.Value.ToString("yyyy-MM-dd");
            String leave_to     = dtp_lto.Value.ToString("yyyy-MM-dd");
            String leave_amount = txt_amount.Text;
            String empid        = (cbo_employee.SelectedValue ?? "").ToString();
            String leave_pay    = cbo_leave_pay.Text;
            String leave_type   = (cbo_leave.SelectedValue ?? "").ToString();

            String frm_am = Convert.ToString(chk_fam.Checked);
            String frm_pm = Convert.ToString(chk_fpm.Checked);
            String to_am  = Convert.ToString(chk_tam.Checked);
            String to_pm  = Convert.ToString(chk_tpm.Checked);

            // hr_leaves, lvcode, empid, d_filed, leave_from, leave_to, frm_am, frm_pm, to_am, to_pm, no_of_days, leave_pay, leave_type
            if (isnew)
            {
                col = "lvcode, empid, d_filed, leave_from, leave_to, frm_am, frm_pm, to_am, to_pm, no_of_days, leave_pay, leave_type, leave_amount";
                val = "'" + lvcode + "', '" + empid + "', '" + d_filed + "', '" + leave_from + "', '" + leave_to + "', '" + frm_am + "', '" + frm_pm + "', '" + to_am + "', '" + to_pm + "', '" + no_of_days + "', '" + leave_pay + "', '" + leave_type + "', '" + leave_amount + "'";

                db.DeleteOnTable(table, "lvcode='" + lvcode + "' AND cancel='Y'");
                if (db.InsertOnTable(table, col, val))
                {
                    success = true;
                }
                else
                {
                    success = false;
                    //db.DeleteOnTable(table, "code='" + code + "'");
                    MessageBox.Show("Failed on saving.");
                }
            }
            else
            {
                col = "empid='" + empid + "', d_filed='" + d_filed + "', leave_from='" + leave_from + "', leave_to='" + leave_to + "', frm_am='" + frm_am + "', frm_pm='" + frm_pm + "', to_am='" + to_am + "', to_pm='" + to_pm + "', no_of_days='" + no_of_days + "', leave_pay='" + leave_pay + "', leave_type='" + leave_type + "', leave_amount='" + leave_amount + "'";
                if (db.UpdateOnTable(table, col, "lvcode='" + lvcode + "'"))
                {
                    success = true;
                }
                else
                {
                    success = false;
                    MessageBox.Show("Failed on saving.");
                }
            }
            if (success)
            {
                goto_win1();
                frm_clear();
                disp_list();
            }
        }
        private void display_emp_payroll(String pay_code, String empid, String ppid)
        {
            DataTable payroll = null;
            int       count_dayoff = 0, dayoff = 0, days = 0;
            Double    daily_rate = 0.00, pay_rate = 0.00, hour_rate = 0.00, minute_rate = 0.00;



            try
            {
                payroll = db.QueryBySQLCode("SELECT ep.*,emp.fixed_rate,emp.empid,emp.dayoff1,emp.dayoff2,emp.shift_sched_from,emp.shift_sched_to,emp.pay_rate,rt.*,CONCAT(emp.firstname, ' ',emp.lastname) as name, CONCAT(to_char(p.date_from, 'mm/dd/yyyy'),' To ',to_char(p.date_to, 'mm/dd/yyyy')) as period FROM rssys.hr_emp_payroll ep LEFT JOIN rssys.hr_employee emp ON emp.empid = ep.empid LEFT JOIN rssys.hr_payrollpariod p ON p.pay_code = ep.ppid LEFT JOIN rssys.hr_rate_type rt ON rt.ratecode = emp.rate_type WHERE emp.empid = '" + empid + "' and ep.emp_pay_code = '" + pay_code + "' ORDER BY p.date_from,p.date_to ASC  ");
                if (payroll.Rows.Count > 0)
                {
                    try
                    {
                        disp_legal_hol_pay(empid, ppid);
                        txt_empname.Text    = payroll.Rows[0]["name"].ToString();
                        txt_pay_period.Text = (payroll.Rows[0]["period"] ?? "0").ToString();
                        txt_pay_rate.Text   = gm.toNormalDoubleFormat((payroll.Rows[0]["pay_rate"] ?? "0.00").ToString()).ToString("0.00");
                        txt_rate_type.Text  = (payroll.Rows[0]["description"] ?? "0.00").ToString();
                        txt_dayswoked.Text  = gm.toNormalDoubleFormat((payroll.Rows[0]["days_worked"] ?? "0.00").ToString()).ToString("0.00");
                        txt_absent.Text     = gm.toNormalDoubleFormat((payroll.Rows[0]["abcences"] ?? "0").ToString()).ToString("0.00");

                        if (payroll.Rows[0]["late"].ToString() == "" && payroll.Rows[0]["undertime"].ToString() == "")
                        {
                            txt_late_ut.Text = "0.00";
                        }
                        else if (payroll.Rows[0]["late"].ToString() == "" && payroll.Rows[0]["undertime"].ToString() != "")
                        {
                            txt_late_ut.Text = payroll.Rows[0]["undertime"].ToString();
                        }
                        else if (payroll.Rows[0]["undertime"].ToString() == "" && payroll.Rows[0]["late"].ToString() != "")
                        {
                            txt_late_ut.Text = payroll.Rows[0]["late"].ToString();
                        }
                        else
                        {
                            txt_late_ut.Text = (Convert.ToDouble(payroll.Rows[0]["late"].ToString()) + Convert.ToDouble(payroll.Rows[0]["undertime"].ToString())).ToString("0.00");
                        }
                    }
                    catch (Exception ex)
                    {
                    }



                    txt_vl_a.Text             = (payroll.Rows[0]["vl_a"] ?? "0.00").ToString();
                    txt_vl_b.Text             = gm.toNormalDoubleFormat((payroll.Rows[0]["vl_b"] ?? "0.00").ToString()).ToString("0.00");
                    txt_sl_a.Text             = (payroll.Rows[0]["sl_a"] ?? "0.00").ToString();
                    txt_sl_b.Text             = gm.toNormalDoubleFormat((payroll.Rows[0]["sl_b"] ?? "0.00").ToString()).ToString("0.00");
                    txt_pl_a.Text             = (payroll.Rows[0]["pl_a"] ?? "0.00").ToString();
                    txt_pl_b.Text             = gm.toNormalDoubleFormat((payroll.Rows[0]["pl_b"] ?? "0.00").ToString()).ToString("0.00");
                    txt_reg_ot_a.Text         = (payroll.Rows[0]["regular_ot_a"] ?? "0.00").ToString();
                    txt_reg_ot_b.Text         = gm.toNormalDoubleFormat((payroll.Rows[0]["reqular_ot_b"] ?? "0.00").ToString()).ToString("0.00");
                    txt_dayoffot_a.Text       = (payroll.Rows[0]["dayoff_ot_a"] ?? "0.00").ToString();
                    txt_dayoffot_b.Text       = gm.toNormalDoubleFormat((payroll.Rows[0]["dayoff_ot_b"] ?? "0.00").ToString()).ToString("0.00");
                    txt_legalhol_ot_a.Text    = (payroll.Rows[0]["legal_hol_ot_a"] ?? "0.00").ToString();
                    txt_legalhol_ot_b.Text    = gm.toNormalDoubleFormat((payroll.Rows[0]["legal_hol_ot_b"] ?? "0.00").ToString()).ToString("0.00");
                    txt_specialhol_ot_a.Text  = (payroll.Rows[0]["special_hol_ot_a"] ?? "0.00").ToString();
                    txt_specialhol_ot_b.Text  = gm.toNormalDoubleFormat((payroll.Rows[0]["special_hol_ot_b"] ?? "0.00").ToString()).ToString("0.00");
                    txt_legalhol_pay_a.Text   = (payroll.Rows[0]["legal_hol_pay_a"] ?? "0.00").ToString();
                    txt_legalhol_pay_b.Text   = gm.toNormalDoubleFormat((payroll.Rows[0]["legal_hol_pay_b"] ?? "0.00").ToString()).ToString("0.00");
                    txt_specialhol_pay_a.Text = (payroll.Rows[0]["spl_hol_pay_a"] ?? "0.00").ToString();
                    txt_specialhol_pay_b.Text = gm.toNormalDoubleFormat((payroll.Rows[0]["spl_hol_pay_b"] ?? "0.00").ToString()).ToString("0.00");
                    txt_night_diff_a.Text     = (payroll.Rows[0]["night_diff_a"] ?? "0.00").ToString();
                    txt_night_diff_b.Text     = gm.toNormalDoubleFormat((payroll.Rows[0]["night_diff_b"] ?? "0.00").ToString()).ToString("0.00");
                    txt_other_earning.Text    = gm.toNormalDoubleFormat((payroll.Rows[0]["other_earnings"] ?? "0.00").ToString()).ToString("0.00");
                    txt_sss_a.Text            = gm.toNormalDoubleFormat((payroll.Rows[0]["sss_cont_a"] ?? "0.00").ToString()).ToString("0.00");
                    txt_philhealth_a.Text     = gm.toNormalDoubleFormat((payroll.Rows[0]["philhealth_cont_a"] ?? "0.00").ToString()).ToString("0.00");
                    txt_pagibig_a.Text        = gm.toNormalDoubleFormat((payroll.Rows[0]["pag_ibig_a"] ?? "0.00").ToString()).ToString("0.00");
                    //txt_sss_b.Text = (payroll.Rows[0]["sss_cont_b"]??"0.00").ToString();
                    //txt_sss_con_c.Text = (payroll.Rows[0]["sss_cont_c"]??"0.00").ToString();
                    //txt_philhealth_a.Text = (payroll.Rows[0]["philhealth_cont_a"]??"0.00").ToString();
                    //txt_philhealth_b.Text = (payroll.Rows[0]["philhealth_cont_b"]??"0.00").ToString();
                    //txt_pagibig_a.Text = (payroll.Rows[0]["pag_ibig_a"]??"0.00").ToString();
                    //txt_pagibig_b.Text = payroll.Rows[0]["pag_ibig_b"].ToString();
                    txt_wtax.Text             = gm.toNormalDoubleFormat((payroll.Rows[0]["w_tax"] ?? "0.00").ToString()).ToString("0.00");
                    txt_other_deductions.Text = gm.toNormalDoubleFormat((payroll.Rows[0]["other_deduction"] ?? "0.00").ToString()).ToString("0.00");
                    txt_others.Text           = gm.toNormalDoubleFormat((payroll.Rows[0]["others"] ?? "0.00").ToString()).ToString("0.00");
                    txt_advance_loans.Text    = gm.toNormalDoubleFormat((payroll.Rows[0]["advances_loans"] ?? "0.00").ToString()).ToString("0.00");
                    txt_leaves.Text           = gm.toNormalDoubleFormat((payroll.Rows[0]["leave_amnt"] ?? "0.00").ToString()).ToString("0.00");

                    pay_rate = Convert.ToDouble((payroll.Rows[0]["pay_rate"] ?? "0.00").ToString());

                    if (payroll.Rows[0]["dayoff1"].ToString() != "-1")
                    {
                        count_dayoff = 1;
                    }

                    if (payroll.Rows[0]["dayoff2"].ToString() != "-1")
                    {
                        count_dayoff = 2;
                    }

                    if (count_dayoff == 2)
                    {
                        days = 261;
                    }
                    else if (count_dayoff == 1)
                    {
                        days = 312;
                    }
                    else
                    {
                        days = 365;
                    }

                    if (payroll.Rows[0]["ratecode"].ToString() == "M")
                    {
                        if (payroll.Rows[0]["fixed_rate"].ToString() == "1")
                        {
                            daily_rate      = (pay_rate * 12) / days; //pay_rate = monthly rate
                            pay_rate        = pay_rate / 2;           //pay_rate = half of the month rate
                            txt_regpay.Text = pay_rate.ToString("0.00");
                        }
                        else
                        {
                            try
                            {
                                daily_rate      = (pay_rate * 12) / days;
                                txt_regpay.Text = (Convert.ToDouble(txt_dayswoked.Text) * daily_rate).ToString("0.00");
                            }
                            catch (Exception ex)
                            {
                                txt_regpay.Text = "0.00";
                            }
                        }
                    }
                    else if (payroll.Rows[0]["ratecode"].ToString() == "D")
                    {
                        try
                        {
                            daily_rate      = (Convert.ToDouble(txt_dayswoked.Text) * pay_rate);
                            txt_regpay.Text = daily_rate.ToString("0.00");
                        }
                        catch (Exception ex)
                        {
                            txt_regpay.Text = "0.00";
                        }
                    }
                    else if (payroll.Rows[0]["ratecode"].ToString() == "W")
                    {
                        try
                        {
                            int year      = DateTime.Now.Year;
                            int week_days = 0;
                            if (DateTime.IsLeapYear(year))
                            {
                                if (count_dayoff == 2)
                                {
                                    week_days = 261;
                                }
                            }
                            else
                            {
                                week_days = 260;
                            }
                            daily_rate = pay_rate;
                            //daily_rate = (pay_rate * 12) / week_days;     //previous daily rate ?
                            txt_regpay.Text = (Convert.ToDouble(txt_dayswoked.Text) * pay_rate).ToString("0.00");
                        }
                        catch (Exception ex)
                        {
                            txt_regpay.Text = "0.00";
                        }
                    }
                    try
                    {
                        hour_rate = pay_rate / 8;
                    }
                    catch (Exception ex)
                    {
                        hour_rate = 0.00;
                    }

                    try
                    {
                        minute_rate = pay_rate / 480;
                    }
                    catch (Exception ex)
                    {
                        minute_rate = 0.00;
                    }

                    try
                    {
                        // Double lat_ut = (Convert.ToDouble(txt_late_ut.Text) * 60) * minute_rate;  //updated
                        Double lat_ut = (Convert.ToDouble(txt_late_ut.Text)) * minute_rate;
                        txt_late_ut_amt.Text = lat_ut.ToString("0.00");
                    }
                    catch (Exception ex)
                    {
                        txt_late_ut_amt.Text = "0.00";
                    }

                    try
                    {
                        txt_absent_amount.Text = (Convert.ToDouble(txt_absent.Text) * pay_rate).ToString("0.00");
                    }
                    catch (Exception ex)
                    {
                        txt_absent_amount.Text = "0.00";
                    }
                    try
                    {
                        if (payroll.Rows[0]["fixed_rate"].ToString() == "1")
                        {
                            Double regpay     = Convert.ToDouble(txt_regpay.Text);
                            Double absent_amt = Convert.ToDouble(txt_absent_amount.Text);
                            Double late_amt   = Convert.ToDouble(txt_late_ut_amt.Text);
                            Double basic_pay  = regpay - (absent_amt + late_amt);
                            txt_basic_pay.Text = basic_pay.ToString("0.00");
                        }
                    }
                    catch (Exception ex)
                    {
                        txt_basic_pay.Text = "0.00";
                    }
                }
                calculate_gross();
                calculate_net();
            }
            catch { }
        }