Пример #1
0
        private void map_sum(DataRow row, total tot)
        {
            string actual    = tot.a.ToString("#.##");
            string overtime  = tot.o.ToString("#.##");
            string paid      = tot.p.ToString("#.##");
            string overtime1 = tot.ot1.ToString("#.##");

            if (tot.hourly_)
            {
                //actual = (tot.a * 8.0M).ToString("#.#");
                //overtime = (tot.o * 8.0M).ToString("#.#");
                //paid = (tot.p * 8.0M).ToString("#.#");
                //overtime1 = (tot.ot1 * 8.0M).ToString("#.#");
            }


            string line1 = string.Format("{0, -6} {1, -19} {2, -10} {3, -11} {4, 6} {5, 6} {6, 4} {7, 4}",
                                         new string(' ', 6), new string(' ', 19),
                                         new string(' ', 10), new string(' ', 11), new string('=', 6), new string('=', 6), new string('=', 4), new string('=', 4));
            string line2 = string.Format("{0, -6} {1, -19} {2, -10} {3, -11} {4, 6} {5, 6} {6, 4} {7, 4}",
                                         new string(' ', 6), new string(' ', 19),
                                         new string(' ', 10), new string(' ', 11), actual, paid, overtime, overtime1);

            lbxEmp.Items.Add(line1);
            lbxEmp.Items.Add(line2);
        }
Пример #2
0
        private void draw_emp(DataTable dt, DateTime d, DateTime f, string emp_id)
        {
            //try
            //{
            total tot = new total();

            tot.hourly_ = false;
            tot.a       = 0M; tot.p = 0M; tot.p = 0M; tot.ot1 = 0M;

            //string sql = string.Format("BookDate = '{0}' and EmpName = '{1}'", d, emp_id);
            string    sql = string.Format("EmpName = '{0}' and BookDate >= '{1}' and BookDate <= '{2}'", emp_id, d.Date, f.Date);
            DataTable v   = (new DataView(dt, sql, null, System.Data.DataViewRowState.CurrentRows)).ToTable();

            if (v == null)
            {
                return;
            }

            DataRow headrow = v.Rows[0];
            //string duty = (string)headrow["Duty"];
            string defpaycode = (string)headrow["DefPayCode"];

            map_head();
            foreach (DataRow row in v.Rows)
            {
                string paycode = defpaycode;
                if (!row["PayCode"].Equals(DBNull.Value))
                {
                    paycode = (string)row["Paycode"];
                }

                decimal ot1 = 0.0M;
                if (!row["LogOver1"].Equals(DBNull.Value))
                {
                    ot1 = (decimal)row["LogOver1"];
                }
                if (row["LogVessel"].Equals(DBNull.Value) && (decimal)row["LogHours"] == 0.0M &&
                    (decimal)row["LogOver"] == 0.0M && ot1 == 0.0M)
                {
                    //MessageBox.Show("Error : empty record <LogHours == 0, but LogOver == 0 and LogOver1 == 0");
                }
                else
                {
                    map_row(row, paycode);
                    sum_row(row, tot, paycode);
                }

                //if (!row["LogVessel"].Equals(DBNull.Value))
                //{
                //    if (tot.hourly_) MessageBox.Show("Error : Conversion to hourly detected !");
                //    map_row(row);
                //    sum_row(row, tot);
                //}
                //if (row["LogVessel"].Equals(DBNull.Value) && (decimal)row["LogHours"] != 0.0M)
                //{
                //    tot.hourly_ = true;
                //    map_row(row);
                //    sum_row(row, tot);
                //}
                //if (row["LogVessel"].Equals(DBNull.Value) && (decimal)row["LogHours"] == 0.0M
                //    && (decimal)row["LogOver"] != 0.0M)
                //{
                //    MessageBox.Show("Error : LogHours = 0, but LogOver != 0 !");
                //}

                //decimal ot1 = 0.0M;
                //if (!row["LogOver1"].Equals(DBNull.Value)) ot1 = (decimal)row["LogOver1"];

                //if (row["LogVessel"].Equals(DBNull.Value) && (decimal)row["LogHours"] == 0.0M
                //    && ot1 != 0.0M)
                //{
                //    MessageBox.Show("Error : LogHours = 0, but LogOver1 != 0 !");
                //}
            }
            try {
                map_sum(v.Rows[0], tot);
            }
            catch (Exception ex)
            {
                errDash.Fail(System.Reflection.MethodBase.GetCurrentMethod(), ex);
            }
        }
Пример #3
0
        private void sum_row(DataRow row, total tot, string paycode)
        {
            decimal a = ((decimal)row["LogHours"]);
            decimal o = ((decimal)row["LogOver"]);
            decimal p = a - o;

            //GS180316 - fix for Staff OverTime
            if (a == 0)
            {
                p = 0;
            }

            decimal ot1 = 0.0M;

            if (!row["LogOver1"].Equals(DBNull.Value))
            {
                ot1 = ((decimal)row["LogOver1"]);
            }

            int logshift = (int)row["LogShift"];

            string boat = "";
            string resp = "Salary";

            if (!row["LogVessel"].Equals(DBNull.Value))
            {
                boat = (string)row["LogVessel"];
                resp = (string)row["Resp"];
                resp = (resp.Trim().Equals("Capt") ? resp = "S" : resp = "D");
            }
            else
            {
                if (o == 0.0M && ot1 == 0.0M && logshift == 0)
                {
                    decimal hour_per_day = 8.0M;
                    if (paycode.Equals("Office"))
                    {
                        hour_per_day = 7.0M;
                    }
                    if (paycode.Equals("Dispatch"))
                    {
                        hour_per_day = 12.0M;
                    }

                    a = a * hour_per_day;
                    p = p * hour_per_day;
                }
            }

            //else
            //{
            //a = a * 8.0M;
            //o = o * 8.0M;
            //p = p * 8.0M;
            //ot1 = ot1 * 8.0M;
            //}

            tot.a   += a;
            tot.o   += o;
            tot.p   += p;
            tot.ot1 += ot1;
        }