Esempio n. 1
0
        private void member_pt_Load(object sender, EventArgs e)
        {
            GF.showLoading(this);

            if (onlySee)
            {
                disableAll();
            }

            if (isForceEdit || isForceAdd)
            {
                amount_left_lbl1.Visible = amount_left.Visible = amount_left_lbl2.Visible = true;
                seller_emp_lbl.Visible   = seller_emp_id.Visible = true;

                GF.disableBtn(add_payment_btn);
                payment_DGV.Enabled = false;
            }

            if (isAlreadyVoided)
            {
                amount_left.Enabled   = false;
                seller_emp_id.Enabled = false;
            }

            Dictionary <string, string> values = new()
            {
                { "branch_id", ((isForceAdd || isForceEdit || onlySee) ? "-1" : GF.Settings("branch_id")) }
            };

            Dictionary <string, object> Obj = DB.Post("PT/PTList/", values);

            if (Obj != null)
            {
                if (!isForceAdd && !isForceEdit)
                {
                    pt_emp_id.Items.Add(new ComboItem(0, "เลือก 'เทรนเนอร์'"));
                }

                if (Obj.ContainsKey("result"))
                {
                    foreach (Dictionary <string, object> Item in GF.ToType <Dictionary <string, object>[]>(Obj["result"]))
                    {
                        pt_emp_id.Items.Add(new ComboItem(GF.toInt(Item["emp_id"].ToString()), Item["fullname"].ToString() + " (" + Item["nickname"].ToString() + ")"));
                        seller_emp_id.Items.Add(new ComboItem(GF.toInt(Item["emp_id"].ToString()), Item["fullname"].ToString() + " (" + Item["nickname"].ToString() + ")"));
                    }
                }

                pt_emp_id.SelectedIndex     = 0;
                seller_emp_id.SelectedIndex = 0;
                GF.resizeComboBox(pt_emp_id);
                GF.resizeComboBox(seller_emp_id);
            }
            else
            {
                GF.Error("ไม่มีข้อมูล 'เทรนเนอร์' !!\r\n\r\nกรุณาแจ้งผู้ดูแลระบบ !!");
            }

            // GET BUY PT DATA
            if (!string.IsNullOrEmpty(member_pt_id))
            {
                values = new()
                {
                    { "member_pt_id", member_pt_id.Trim() }
                };

                Obj = DB.Post("Member/getBuyPTData/", values);

                if (Obj != null)
                {
                    if (Obj.ContainsKey("result"))
                    {
                        Dictionary <string, object> Item = GF.ToType <Dictionary <string, object> >(Obj["result"]);
                        if (Item.Keys.Count > 0)
                        {
                            hours.Text       = Item["max_hours"].ToString();
                            start_date.Text  = (Item["start_date"] ?? "").ToString();
                            expiry_date.Text = Item["expiry_date"].ToString();
                            price.Text       = Item["price"].ToString();
                            age.Text         = (Item["age"] ?? "").ToString();
                            amount_left.Text = (Item["left_hours"] ?? "").ToString();
                            note_txt.Text    = (Item["note"] ?? "").ToString();

                            foreach (ComboItem cb in pt_emp_id.Items)
                            {
                                if (cb.Key.ToString() == Item["pt_emp_id"].ToString())
                                {
                                    pt_emp_id.Text = cb.Value;
                                }
                            }

                            foreach (ComboItem cb in seller_emp_id.Items)
                            {
                                if (cb.Key.ToString() == Item["pt_seller_id"].ToString())
                                {
                                    seller_emp_id.Text = cb.Value;
                                }
                            }

                            string payment_data = (Item["payment_data"] ?? "").ToString().Trim();
                            if (!string.IsNullOrEmpty(payment_data))
                            {
                                payment_DGV.Rows.Clear();
                                string[] payment_record = payment_data.Split(new string[] { "!!" }, StringSplitOptions.None);
                                foreach (string payment_item in payment_record)
                                {
                                    string[] tmp = payment_item.Split(new string[] { "##" }, StringSplitOptions.None);
                                    string   the_payment_type = Array.Find(GF.payment_type, p => Convert.ToInt32(p.Key) == Convert.ToInt32(tmp[0].ToString())).Value;

                                    string[] Data =
                                    {
                                        the_payment_type,
                                        tmp[1].ToString(),
                                        (tmp[2] ?? "").ToString(),
                                        (tmp[3] ?? "").ToString(),
                                        tmp[4].ToString(),
                                        GF.formatDBDateTime(tmp[5].ToString()),
                                        tmp[6].ToString(),
                                        tmp[7].ToString()
                                    };

                                    GF.addPaymentRow(payment_DGV, Data, tmp[6].ToString());
                                }
                                payment_DGV.ClearSelection();
                            }
                        }
                    }
                }
            }

            GF.closeLoading();
        }
Esempio n. 2
0
        public config_employee_card()
        {
            InitializeComponent();

            GF.disableBtn(save_btn);
        }
        private void bill_no_KeyUp(object sender, KeyEventArgs e)
        {
            if (!string.IsNullOrEmpty(bill_no.Text.Trim()) && e.KeyCode == Keys.Enter)
            {
                GF.showLoading(this);
                Dictionary <string, string> values = new()
                {
                    { "bill_no", bill_no.Text.Trim() }
                };

                Dictionary <string, object> Obj = DB.Post("Shop/getDataByBillNo/", values);

                if (Obj != null)
                {
                    if (Obj.ContainsKey("result"))
                    {
                        Dictionary <string, object> item = GF.ToType <Dictionary <string, object> >(Obj["result"]);
                        if (item.Keys.Count > 0)
                        {
                            string Product_Data = item["product_data"].ToString();
                            string Payment_Data = item["payment_data"].ToString();
                            (this.Owner as shop).bill_id = item["bill_id"].ToString();

                            if (item["is_void"].ToString() == "0" && GF.isAdmin)
                            {
                                (this.Owner as shop).void_btn.Visible = true;
                                (this.Owner as shop).void_txt.Visible = false;
                                (this.Owner as shop).void_txt.Left    = 273;
                            }

                            if (item["is_void"].ToString() == "1")
                            {
                                (this.Owner as shop).void_txt.Visible = true;
                                (this.Owner as shop).void_txt.Text    = "*** บิลถูก VOID : " + item["void_reason"].ToString() + " ***\r\nโดย : " + item["void_by"].ToString() + " เมื่อ " + GF.formatDBDateTime(item["void_datetime"].ToString());
                                (this.Owner as shop).void_txt.Left    = (this.Owner as shop).void_btn.Left;
                            }

                            string[] tmp_data = Product_Data.Split(new string[] { "!!" }, StringSplitOptions.None);
                            foreach (string product in tmp_data)
                            {
                                string[] Item = product.Split(new string[] { "##" }, StringSplitOptions.None);
                                (this.Owner as shop).addRow(Item[0].ToString(), Item[1].ToString(), Item[2].ToString(), Item[3].ToString(), Item[5].ToString(), Item[6].ToString(), Item[7].ToString());
                            }

                            tmp_data = Payment_Data.Split(new string[] { "!!" }, StringSplitOptions.None);
                            foreach (string payment in tmp_data)
                            {
                                string[]     Item = payment.Split(new string[] { "##" }, StringSplitOptions.None);
                                DataGridView DGV  = (this.Owner as shop).payment_DGV;
                                DGV.Rows.Add(
                                    GF.payment_type[Convert.ToInt32(Item[0].ToString())],
                                    GF.formatNumber(Convert.ToInt32(Item[1].ToString())),
                                    (Item[2] ?? "").ToString(),
                                    (Item[3] ?? "").ToString(),
                                    Item[4].ToString(),
                                    GF.formatDBDateTime(Item[5].ToString()),
                                    Item[0].ToString()
                                    );
                            }

                            (this.Owner as shop).product_DGV.ClearSelection();
                            (this.Owner as shop).payment_DGV.ClearSelection();

                            (this.Owner as shop).bill_search_btn.Text = "เปิดบิลใหม่";
                            (this.Owner as shop).product_code.Enabled = false;
                            GF.disableBtn((this.Owner as shop).add_product_btn);
                            (this.Owner as shop).product_DGV.Enabled = false;
                            GF.disableBtn((this.Owner as shop).add_payment_btn);
                            (this.Owner as shop).payment_DGV.Enabled = false;
                            GF.disableBtn((this.Owner as shop).manage_btn);

                            (this.Owner as shop).print_btn.Visible = true;
                            (this.Owner as shop).print_btn.Left    = (this.Owner as shop).manage_btn.Left;
                            (this.Owner as shop).print_btn.Top     = (this.Owner as shop).manage_btn.Top;
                            (this.Owner as shop).print_btn.BringToFront();
                        }
                    }
                }

                GF.closeLoading();
                this.Close();
            }
        }