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(); }
private void manage_btn_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(amount.Text.Trim())) { GF.Error("กรุณากรอก 'จำนวนเงิน' !!"); amount.Select(); return; } if (Convert.ToInt32(amount.Text.Trim()) <= 0) { GF.Error("'จำนวนเงิน' ต้องมากกว่า 0 !!"); amount.Select(); return; } if (payment_type.SelectedIndex == 1) { if (string.IsNullOrEmpty(card_no.Text.Trim().Replace("_", "").Replace(" ", ""))) { GF.Error("กรุณากรอก 'หมายเลขบัตร' !!"); card_no.Select(); return; } if (card_no.Text.Trim().Replace("_", "").Replace(" ", "").Length < 16) { GF.Error("กรุณากรอก 'หมายเลขบัตร' ให้ครบ 16 หลัก !!"); card_no.Select(); return; } if (string.IsNullOrEmpty(card_expiry_date.Text.Trim().Replace("_", "").Replace("/", "").Replace(" ", ""))) { GF.Error("กรุณากรอก 'วันหมดอายุบัตร' !!"); card_expiry_date.Select(); return; } if (card_expiry_date.Text.Trim().Replace("_", "").Replace("/", "").Replace(" ", "").Length < 4) { GF.Error("กรุณากรอก 'วันหมดอายุบัตร' ให้ครบ !!\r\n\r\n(หากเลขเดือนมีหลักเดียว ให้เติม 0 ข้างหน้า)"); card_expiry_date.Select(); return; } } string[] Data = { payment_type.Text, GF.formatNumber(Convert.ToInt32(amount.Text)), "", "", "", "", ((ComboItem)payment_type.SelectedItem).Key.ToString() }; if (payment_type.SelectedIndex == 1) { Data[2] = card_no.Text; Data[3] = card_expiry_date.Text; } if (isDeposit) { GF.addPaymentRow(((member_ext)this.Owner).deposit_DGV, Data, ((ComboItem)payment_type.SelectedItem).Key.ToString()); } else { GF.addPaymentRow(((member_ext)this.Owner).full_DGV, Data, ((ComboItem)payment_type.SelectedItem).Key.ToString()); } this.Close(); }