예제 #1
0
        void calculatePaid()
        {
            totalPaid = 0;
            foreach (DataGridViewRow DGVR in payment_DGV.Rows)
            {
                totalPaid += Convert.ToInt32(GF.removeCommaDotFromNumber(DGVR.Cells["payment_amount"].Value.ToString()));
            }

            total_payment_txt.Text = GF.formatNumber(totalPaid);
        }
예제 #2
0
        public static void addPaymentRow(DataGridView DGV, string[] Data, string payment_type_int)
        {
            int    index = -1;
            string payment_type_colName = "";

            foreach (DataGridViewColumn DGVC in DGV.Columns)
            {
                if (DGVC.Name.IndexOf("payment_type") != -1 && DGVC.Index > 0)
                {
                    payment_type_colName = DGVC.Name;
                    break;
                }
            }

            foreach (DataGridViewRow DGVR in DGV.Rows)
            {
                if (payment_type_int == "0" && DGVR.Cells[payment_type_colName].Value.ToString() == payment_type_int)
                {
                    index = DGVR.Index;
                    break;
                }

                if (payment_type_int == "1" && !string.IsNullOrEmpty(Data[2]) && !string.IsNullOrEmpty(Data[3]) && (DGVR.Cells[payment_type_colName].Value ?? "").ToString() == payment_type_int)
                {
                    if ((DGVR.Cells[2].Value ?? "").ToString() == Data[2] && (DGVR.Cells[3].Value ?? "").ToString() == Data[3])
                    {
                        index = DGVR.Index;
                        break;
                    }
                }
            }

            if (index == -1)
            {
                DGV.Rows.Add(Data);
            }
            else
            {
                DataGridViewRow DGVR = DGV.Rows[index];
                DGVR.Cells[1].Value = (Convert.ToInt32(GF.removeCommaDotFromNumber(DGVR.Cells[1].Value.ToString())) + Convert.ToInt32(GF.removeCommaDotFromNumber(Data[1]))).ToString();
            }
        }
예제 #3
0
        private void add_payment_btn_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(price.Text.Trim()))
            {
                GF.Error("กรุณาระบุ 'ราคา' ก่อน !!");
                price.Select();
                return;
            }

            calculatePaid();
            if (Convert.ToInt32(GF.removeCommaDotFromNumber(total_payment_txt.Text.Trim())) == Convert.ToInt32(price.Text.Trim()))
            {
                GF.Error("ชำระเงินครบแล้ว !!");
                return;
            }
            using member_pt_payment memberPTPayment = new();
            memberPTPayment.max_amount = Convert.ToInt32(price.Text.Trim()) - totalPaid;
            memberPTPayment.Owner      = this;
            memberPTPayment.ShowDialog();
            this.BringToFront();
            this.Activate();
        }
예제 #4
0
        private void save_btn_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(hours.Text.Trim()))
            {
                GF.Error("กรุณาระบุ 'จำนวน ชั่วโมง' !!");
                hours.Select();
                return;
            }

            if (Convert.ToInt32(hours.Text.Trim()) <= 0)
            {
                GF.Error("'จำนวน ชั่วโมง' ต้องมากกว่า 0 !!");
                hours.Select();
                return;
            }

            if (string.IsNullOrEmpty(price.Text.Trim()))
            {
                GF.Error("กรุณาระบุ 'ราคา' !!");
                price.Select();
                return;
            }

            if (Convert.ToInt32(price.Text.Trim()) <= 0)
            {
                GF.Error("'ราคา' ต้องมากกว่า 0 !!");
                price.Select();
                return;
            }

            if (string.IsNullOrEmpty(start_date.Text.Replace(" ", "").Replace("/", "").Trim()))
            {
                GF.Error("กรุณาระบุ 'วันที่เริ่มต้น PT' !!");
                start_date.Select();
                return;
            }

            if (start_date.Text.Trim().Length < 10)
            {
                GF.Error("กรุณากรอก 'วันที่เริ่มต้น PT' ให้ครบ !!\r\n\r\n(หาก วัน หรือ เดือน เป็นเลขตัวเดียว ให้เติม 0 ข้างหน้า)");
                start_date.Select();
                return;
            }

            if (string.IsNullOrEmpty(expiry_date.Text.Replace(" ", "").Replace("/", "").Trim()))
            {
                GF.Error("กรุณาระบุ 'วันหมดอายุ PT' !!");
                expiry_date.Select();
                return;
            }

            if (expiry_date.Text.Trim().Length < 10)
            {
                GF.Error("กรุณากรอก 'วันหมดอายุ PT' ให้ครบ !!\r\n\r\n(หาก วัน หรือ เดือน เป็นเลขตัวเดียว ให้เติม 0 ข้างหน้า)");
                expiry_date.Select();
                return;
            }

            if (string.IsNullOrEmpty(age.Text.Trim()))
            {
                GF.Error("กรุณาระบุ 'อายุ' !!");
                age.Select();
                return;
            }

            if (Convert.ToInt32(age.Text.Trim()) <= 0)
            {
                GF.Error("'อายุ' ต้องมากกว่า 0 !!");
                age.Select();
                return;
            }

            if (pt_emp_id.SelectedIndex == 0 && !isForceAdd && !isForceEdit)
            {
                GF.Error("กรุณาเลือก 'เทรนเนอร์' !!");
                pt_emp_id.Select();
                return;
            }

            if (isForceAdd || isForceEdit)
            {
                if (amount_left.Text.Trim().Length == 0)
                {
                    GF.Error("กรุณาระบุ 'ชั่วโมงเหลือ' !!");
                    amount_left.Select();
                    return;
                }

                if (seller_emp_id.SelectedIndex == 0)
                {
                    GF.Error("กรุณาเลือก 'ผู้ขาย' !!");
                    seller_emp_id.Select();
                    return;
                }
            }

            string payment_list = "";

            string is_already_paid = "0";
            string do_not_insert_member_pt_payment = "0";

            double net_price_before_vat = 0.00;
            double vat = Convert.ToDouble(GF.Settings("vat"));
            int    current_total_paid = 0;

            calculatePaid();
            if (!isForceEdit && !isForceAdd)
            {
                if (Convert.ToInt32(GF.removeCommaDotFromNumber(total_payment_txt.Text.Trim())) < Convert.ToInt32(price.Text.Trim()))
                {
                    GF.Error("ยังชำระเงินไม่ครบ " + GF.formatNumber(price.Text.Trim()) + " บาท !!");
                    return;
                }

                if (Convert.ToInt32(GF.removeCommaDotFromNumber(total_payment_txt.Text.Trim())) > Convert.ToInt32(price.Text.Trim()))
                {
                    GF.Error("ชำระเงินเกิน " + price.Text.Trim() + " บาท !!");
                    return;
                }
            }

            foreach (DataGridViewRow DGVR in payment_DGV.Rows)
            {
                payment_list += DGVR.Cells["payment_type"].Value.ToString() + "##";
                payment_list += GF.removeCommaDotFromNumber(DGVR.Cells["payment_amount"].Value.ToString()) + "##";
                payment_list += DGVR.Cells["card_no"].Value.ToString() + "##";
                payment_list += DGVR.Cells["card_expiry_date"].Value.ToString() + "!!";

                current_total_paid += Convert.ToInt32(GF.removeCommaDotFromNumber(DGVR.Cells["payment_amount"].Value.ToString()));
            }

            if (!string.IsNullOrEmpty(payment_list.Trim()))
            {
                payment_list = payment_list.Substring(0, payment_list.Trim().Length - 2);
            }

            net_price_before_vat += (current_total_paid * 100) / (100 + vat);
            double vat_amount = current_total_paid - net_price_before_vat;

            Dictionary <string, string> values = new()
            {
                { "branch_id", GF.Settings("branch_id") },
                { "member_id", member_id },