private void login_btn_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(username.Text.Trim())) { GF.Error("PLEASE ENTER 'USERNAME' !!"); username.Select(); return; } if (string.IsNullOrEmpty(password.Text.Trim())) { GF.Error("PLEASE ENTER 'PASSWORD' !!"); password.Select(); return; } GF.mainPage = new main(); if (username.Text.Trim() == "admin" && password.Text.Trim() == "Cy{;yllN") { GF.userID = "-1"; GF.isAdmin = true; this.Hide(); Dictionary <string, string> values = new(); if (!string.IsNullOrEmpty(GF.Settings("branch_id"))) { values.Add("branch_id", GF.Settings("branch_id")); Dictionary <string, object> Obj = DB.Post("Branch/getBranchData/", values); if (Obj != null) { if (Obj.ContainsKey("result")) { Dictionary <string, object> Item = GF.ToType <Dictionary <string, object> >(Obj["result"]); if (Item.Keys.Count > 0) { GF.mainPage.branch_name.Text = Item["branch_name"].ToString(); } } } } GF.mainPage.MaximumSize = Screen.PrimaryScreen.WorkingArea.Size; GF.mainPage.current_user.Text = "Software Developer"; GF.mainPage.last_login.Text = ""; GF.mainPage.last_login_lbl.Visible = false; getVersion(); GF.mainPage.config_btn.Visible = GF.isAdmin; foreach (ToolStripMenuItem menu in GF.mainPage.main_menu.Items) { menu.Visible = true; } GF.mainPage.change_pwd_btn.Visible = false; GF.mainPage.ShowDialog(); return; } else { Dictionary <string, string> values = new() { { "branch_id", GF.Settings("branch_id") }, { "username", username.Text.Trim() },
private void config_employee_card_Load(object sender, EventArgs e) { GF.showLoading(this); Dictionary <string, string> values = new() { { "user_id", GF.userID } }; Dictionary <string, object> Obj = DB.Post("Employee/getEmpCardFileName/", values); if (Obj != null) { if (Obj.ContainsKey("result")) { Dictionary <string, object> Item = GF.ToType <Dictionary <string, object> >(Obj["result"]); if (Item.Keys.Count > 0) { if (string.IsNullOrEmpty(Item["filename"]?.ToString())) { this.Height = minHeight; } else { bool isFTPPicture = false; if (File.Exists(GF.Settings("emp_card") + Item["filename"]?.ToString())) { thePicture = Image.FromFile(GF.Settings("emp_card") + Item["filename"]?.ToString()); } else { isFTPPicture = true; thePicture = FTP.download("emp_card", Item["filename"]?.ToString()); } var destRect = new Rectangle(0, 0, 502, 325); var destImage = new Bitmap(502, 325); destImage.SetResolution(thePicture.HorizontalResolution, thePicture.VerticalResolution); using (var graphics = Graphics.FromImage(destImage)) { graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy; graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; using var wrapMode = new System.Drawing.Imaging.ImageAttributes(); wrapMode.SetWrapMode(System.Drawing.Drawing2D.WrapMode.TileFlipXY); graphics.DrawImage(thePicture, destRect, 0, 0, thePicture.Width, thePicture.Height, GraphicsUnit.Pixel, wrapMode); } if (isFTPPicture) { var downloadedMessageInfo = new DirectoryInfo(GF.Settings("emp_card")); foreach (FileInfo file in downloadedMessageInfo.GetFiles()) { file.Delete(); } destImage.Save(GF.Settings("emp_card") + Item["filename"]?.ToString(), System.Drawing.Imaging.ImageFormat.Jpeg); } pictureBox.Image = destImage; } } } } else { this.Height = minHeight; GF.closeLoading(); GF.Error("เกิดความผิดพลาดในการรับชื่อไฟล์จาก Server !"); } this.CenterToScreen(); GF.closeLoading(); }
static void initPrintDocument() { using (pd = new PrintDocument()) { pd.DocumentName = "ใบเสร็จค่าสินค้า"; pd.PrinterSettings.PrinterName = printerName; GF.checkPaperSize(pd); GF.checkPaperSource(pd); GF.printError("THIS RAW KIND : " + rawKind); GF.printError("THIS PAPER SIZE : " + paperSize); if (rawKind != 0) { pd.DefaultPageSettings.PaperSize.RawKind = rawKind; } if (paperSize != null) { pd.DefaultPageSettings.PaperSize = paperSize; } GF.printError(pd.DefaultPageSettings.PaperSize.Width.ToString() + " x " + pd.DefaultPageSettings.PaperSize.Height.ToString()); GF.printError("PD RAW KIND : " + pd.DefaultPageSettings.PaperSize.RawKind); GF.printError("PD PAPER SIZE : " + pd.DefaultPageSettings.PaperSize); if (printerResolution != null) { pd.DefaultPageSettings.PrinterResolution = printerResolution; } pd.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0); pd.PrintPage += (sender, e) => { int FontSize = 8; string FontName = "Calibri"; regular = new Font(FontName, FontSize); boldUnderline = new Font(FontName, FontSize, (FontStyle.Bold | FontStyle.Underline)); bold = new Font(FontName, FontSize, FontStyle.Bold); brush = new SolidBrush(Color.Black); alignRight = new StringFormat(); alignRight.Alignment = StringAlignment.Far; int width = e.MarginBounds.Width; string vat = ""; string net_price_before_vat = ""; string vat_amount = ""; string total_amount = ""; string cashier_name = ""; Dictionary <string, string> values = new() { { "bill_id", bill_id }, { "issue_vat", (hasVat ? "1" : "0") } }; Dictionary <string, object> Obj = DB.Post("Shop/getBillHeader/", values); int top = 10; if (Obj != null) { if (Obj.ContainsKey("result")) { Dictionary <string, object> item = GF.ToType <Dictionary <string, object> >(Obj["result"]); if (item.Keys.Count > 0) { bill_no = item["bill_no"].ToString(); print_bill_header.draw(e, item["branch_id"].ToString(), out top); top += 65; e.Graphics.DrawString("ใบเสร็จรับเงิน / ใบกำกับภาษีอย่างย่อ", boldUnderline, brush, new PointF((float)(((width - GF.margin_right) / 2) - (e.Graphics.MeasureString("ใบเสร็จรับเงิน / ใบกำกับภาษีอย่างย่อ", boldUnderline).Width / 2)), top)); top += 25; e.Graphics.DrawString("หมายเลขใบเสร็จ", bold, brush, new PointF((e.MarginBounds.Width) - e.Graphics.MeasureString(": " + bill_no, regular).Width - e.Graphics.MeasureString("หมายเลขใบเสร็จ", bold).Width - GF.margin_right + GF.margin_left, top)); e.Graphics.DrawString(": " + bill_no, regular, brush, new RectangleF(GF.margin_left, top, e.MarginBounds.Width - GF.margin_right, 15), alignRight); top += 20; e.Graphics.DrawString("วันที่", bold, brush, new PointF((e.MarginBounds.Width) - e.Graphics.MeasureString(": " + GF.formatDBDateTime(item["bill_datetime"].ToString()), regular).Width - e.Graphics.MeasureString("วันที่", bold).Width - GF.margin_right + GF.margin_left, top)); e.Graphics.DrawString(": " + GF.formatDBDateTime(item["bill_datetime"].ToString()), regular, brush, new RectangleF(GF.margin_left, top, e.MarginBounds.Width - GF.margin_right, 15), alignRight); vat = item["vat"].ToString(); vat_amount = item["vat_amount"].ToString(); net_price_before_vat = item["net_price_before_vat"].ToString(); total_amount = item["total_price"].ToString(); cashier_name = item["receive_by"].ToString(); } } } string seps = ""; while (e.Graphics.MeasureString(seps, regular).Width < e.MarginBounds.Width) { seps += "-"; } /*top += 25; * e.Graphics.DrawString(seps, regular, brush, new PointF(left, top));*/ values = new() { { "bill_no", bill_no } }; 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[] tmp_data = Product_Data.Split(new string[] { "!!" }, StringSplitOptions.None); foreach (string product in tmp_data) { string[] Item = product.Split(new string[] { "##" }, StringSplitOptions.None); top += 20; string item_name = Item[3].ToString() + " x " + Item[0].ToString() + " @" + Item[1].ToString() + ".00"; e.Graphics.DrawString(item_name, regular, brush, new RectangleF(GF.margin_left, top, e.MarginBounds.Width - e.Graphics.MeasureString(item_name, regular).Width - GF.margin_right, 15)); e.Graphics.DrawString(GF.formatNumber(Item[4].ToString()) + ".00", regular, brush, new RectangleF(GF.margin_left, top, e.MarginBounds.Width - GF.margin_right, 15), alignRight); } //======================================= SUB TOTAL ======================================// top += 20; e.Graphics.DrawString("ราคารวมก่อนภาษี", bold, brush, new PointF((e.MarginBounds.Width) - e.Graphics.MeasureString(": " + net_price_before_vat, bold).Width - e.Graphics.MeasureString("ราคารวมก่อนภาษี :", bold).Width - GF.margin_right + GF.margin_left, top)); e.Graphics.DrawString(": " + net_price_before_vat, bold, brush, new RectangleF(GF.margin_left, top, e.MarginBounds.Width - GF.margin_right, 15), alignRight); top += 20; e.Graphics.DrawString("ภาษี " + string.Format("{0:f2}", Convert.ToDouble(vat)) + "%", bold, brush, new PointF((e.MarginBounds.Width) - e.Graphics.MeasureString(": " + vat_amount, bold).Width - e.Graphics.MeasureString("ภาษี " + string.Format("{0:f2}", Convert.ToDouble(vat)) + "% : ", bold).Width - GF.margin_right + GF.margin_left, top)); e.Graphics.DrawString(": " + vat_amount, bold, brush, new RectangleF(GF.margin_left, top, e.MarginBounds.Width - GF.margin_right, 15), alignRight); top += 20; e.Graphics.DrawString("รวมเป็นเงิน", bold, brush, new PointF((e.MarginBounds.Width) - e.Graphics.MeasureString(": " + GF.formatNumber(total_amount) + ".00", bold).Width - e.Graphics.MeasureString("รวมเป็นเงิน :", bold).Width - GF.margin_right + GF.margin_left, top)); e.Graphics.DrawString(": " + GF.formatNumber(total_amount) + ".00", bold, brush, new RectangleF(GF.margin_left, top, e.MarginBounds.Width - GF.margin_right, 15), alignRight); top += 15; e.Graphics.DrawString(seps, regular, brush, new PointF(GF.margin_left, top)); //======================================= PAYMENT ======================================// string Payment_Data = item["payment_data"].ToString(); tmp_data = Payment_Data.Split(new string[] { "!!" }, StringSplitOptions.None); foreach (string payment in tmp_data) { string[] Item = payment.Split(new string[] { "##" }, StringSplitOptions.None); top += 20; if (Item[0].ToString() == "0") { // CASH e.Graphics.DrawString("เงินสด", bold, brush, new PointF((e.MarginBounds.Width) - e.Graphics.MeasureString(": " + GF.formatNumber(Item[1].ToString()) + ".00", bold).Width - e.Graphics.MeasureString("เงินสด", bold).Width - GF.margin_right + GF.margin_left, top)); } else if (Item[0].ToString() == "1") { // CARD string last4Digits = Item[2].ToString().Substring(Item[2].ToString().Length - 4, 4); e.Graphics.DrawString("บัตร XXXX-XXXX-XXXX-" + last4Digits, bold, brush, new PointF((e.MarginBounds.Width) - e.Graphics.MeasureString(": " + GF.formatNumber(Item[1].ToString()) + ".00", bold).Width - e.Graphics.MeasureString("บัตร XXXX-XXXX-XXXX-" + last4Digits, bold).Width - GF.margin_right + GF.margin_left, top)); } e.Graphics.DrawString(": " + GF.formatNumber(Item[1].ToString()) + ".00", bold, brush, new RectangleF(GF.margin_left, top, e.MarginBounds.Width - GF.margin_right, 15), alignRight); } } } } top += (13 * 3); e.Graphics.DrawString("ผู้รับเงิน : " + cashier_name, bold, brush, new PointF((float)(((width - GF.margin_right) / 2) - (e.Graphics.MeasureString("ผู้รับเงิน : " + cashier_name, bold).Width / 2)), top)); top += (20); string print_datetime = GF.NOW(); e.Graphics.DrawString("พิมพ์เมื่อ : " + print_datetime, bold, brush, new PointF((float)(((width - GF.margin_right) / 2) - (e.Graphics.MeasureString("พิมพ์เมื่อ : " + print_datetime, bold).Width / 2)), top)); top += (13 * 2); CreateBarcode(bill_no, e, top); e.Graphics.Dispose(); }; pd.EndPrint += (sender, e) => { if (e.PrintAction == PrintAction.PrintToPrinter) { if (PPD != null && !PPD.IsDisposed) { PPD.Close(); } Sender.Activate(); GF.closeLoading(); } }; GF.closeLoading(); using (PPD = new PrintPreviewDialog()) { ((Form)PPD).FormClosed += (ss, ee) => { Sender.Activate(); }; ((Form)PPD).TopMost = true; ((Form)PPD).WindowState = FormWindowState.Maximized; ((Form)PPD).FormBorderStyle = FormBorderStyle.None; PPD.Document = pd; PPD.PrintPreviewControl.Zoom = 1; PPD.PrintPreviewControl.UseAntiAlias = true; PPD.Document.OriginAtMargins = false; if (isPreview) { PPD.ShowDialog(); } else { pd.Print(); } } }
public user_manage() { InitializeComponent(); Dictionary <string, string> values = new() { { "user_id", GF.userID } }; Dictionary <string, object> Obj = DB.Post("Branch/BranchList/", values); if (Obj != null) { branch_TreeView.Nodes.Add("-1", "ทุกสาขา"); if (Obj.ContainsKey("result")) { foreach (Dictionary <string, object> Branch in GF.ToType <Dictionary <string, object>[]>(Obj["result"])) { branch_TreeView.Nodes.Add(Branch["branch_id"].ToString(), Branch["branch_name"].ToString()); } } } branch_TreeView.ExpandAll(); values = new() { { "user_id", GF.userID } }; Obj = DB.Post("User/getMenu/", values); if (Obj != null) { menu_TreeView.Nodes.Add("-1", "ทุกเมนู"); if (Obj.ContainsKey("result")) { foreach (Dictionary <string, object> menu in GF.ToType <Dictionary <string, object>[]>(Obj["result"])) // 1st level { menu_TreeView.Nodes.Add(menu["menu_id"].ToString(), menu["menu_name"].ToString()); } } } menu_TreeView.ExpandAll(); values = new() { { "user_id", GF.userID } }; Obj = DB.Post("User/getWebMenu/", values); if (Obj != null) { web_TreeView.Nodes.Add("-1", "ทุกเมนู"); if (Obj.ContainsKey("result")) { foreach (Dictionary <string, object> menu in GF.ToType <Dictionary <string, object>[]>(Obj["result"])) // 1st level { web_TreeView.Nodes.Add(menu["menu_web_id"].ToString(), menu["menu_web_name"].ToString()); } } } web_TreeView.ExpandAll(); web_TreeView.Enabled = false; }
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 user_manage_Load(object sender, EventArgs e) { GF.showLoading(this); Dictionary <string, string> values = new() { { "branch_id", GF.Settings("branch_id") } }; if (!string.IsNullOrEmpty(user_id)) { values.Add("user_id", user_id); } Dictionary <string, object> Obj = DB.Post("User/getUserOwner/", values); if (Obj != null) { emp_id.Items.Add(new ComboItem(0, "เลือก พนักงานเจ้าของบัญชี")); emp_id.Items.Add(new ComboItem(-1, "ไม่ใช่พนักงาน")); if (Obj.ContainsKey("result")) { foreach (Dictionary <string, object> Item in GF.ToType <Dictionary <string, object>[]>(Obj["result"])) { emp_id.Items.Add(new ComboItem(Convert.ToInt32(Item["emp_id"].ToString()), Item["owner_name"].ToString())); } } } else { emp_id.Items.Add(new ComboItem(0, "เกิดความผิดพลาด !!")); } emp_id.SelectedIndex = 0; if (!string.IsNullOrEmpty(user_id)) { values = new() { { "user_id", user_id.Trim() } }; Obj = DB.Post("User/getUserData/", values); if (Obj != null) { if (Obj.ContainsKey("result")) { Dictionary <string, object> Item = GF.ToType <Dictionary <string, object> >(Obj["result"]); if (Item.Keys.Count > 0) { username.Text = Item["username"].ToString(); manual_owner_name.Text = (Item["manual_owner_name"] ?? "").ToString(); if (Item["is_admin"].ToString() == "1") { is_admin.Checked = true; } if (Item["can_approve"].ToString() == "1") { can_approve.Checked = true; } if (Item["can_use_web"].ToString() == "1") { can_use_web.Checked = true; web_TreeView.Enabled = true; } else { web_TreeView.Enabled = false; } foreach (ComboItem cb in emp_id.Items) { if (cb.Key.ToString() == Item["emp_id"].ToString()) { emp_id.Text = cb.Value; break; } } string[] BranchList = Item["branch_list"].ToString().Split(new string[] { "!!" }, StringSplitOptions.None); foreach (string Branch in BranchList) { TreeNode[] Nodes = branch_TreeView.Nodes.Find(Branch, true); if (Nodes.Length == 1) { Nodes[0].Checked = true; } } string[] MenuList = Item["menu_list"].ToString().Split(new string[] { "!!" }, StringSplitOptions.None); foreach (string Menu in MenuList) { TreeNode[] Nodes = menu_TreeView.Nodes.Find(Menu, true); if (Nodes.Length == 1) { Nodes[0].Checked = true; } } string[] MenuWebList = Item["menu_web_list"].ToString().Split(new string[] { "!!" }, StringSplitOptions.None); foreach (string Menu in MenuWebList) { TreeNode[] Nodes = web_TreeView.Nodes.Find(Menu, true); if (Nodes.Length == 1) { Nodes[0].Checked = true; } } } } } } GF.closeLoading(); }
private void member_manage_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(member_id.Trim())) { GF.showLoading(this); Dictionary <string, string> values = new() { { "member_id", member_id.Trim() } }; Dictionary <string, object> Obj = DB.Post("Member/getMemberData/", values); if (Obj != null) { if (Obj.ContainsKey("result")) { Dictionary <string, object> Item = GF.ToType <Dictionary <string, object> >(Obj["result"]); if (Item.Keys.Count > 0) { member_no.Text = (Item["member_no"] ?? "").ToString(); current_member_type.Text = (Item["current_member_type"] ?? "").ToString(); during_date.Text = (Item["during_date"] ?? "").ToString(); first_date.Text = GF.formatDBDateTime((Item["create_date"] ?? "").ToString()); current_contract_no.Text = (Item["contract_no"] ?? "").ToString(); firstname_th.Text = (Item["firstname_th"] ?? "").ToString(); lastname_th.Text = (Item["lastname_th"] ?? "").ToString(); nickname_th.Text = (Item["nickname_th"] ?? "").ToString(); firstname_en.Text = (Item["firstname_en"] ?? "").ToString(); lastname_en.Text = (Item["lastname_en"] ?? "").ToString(); nickname_en.Text = (Item["nickname_en"] ?? "").ToString(); martial_status.Text = Item["martial_status"].ToString(); if (!string.IsNullOrEmpty((Item["birthday"] ?? "").ToString())) { birthday.Text = Item["birthday"].ToString(); current_age.Text = GF.calculateAge(Item["birthday"].ToString()); } if (!string.IsNullOrEmpty((Item["document_type"] ?? "").ToString())) { document_type.Text = Item["document_type"].ToString(); } document_no.Text = (Item["document_no"] ?? "").ToString(); email.Text = (Item["email"] ?? "").ToString(); occupation.Text = (Item["occupation"] ?? "").ToString(); gender.Text = Item["gender"].ToString(); address.Text = (Item["address"] ?? "").ToString(); company_name.Text = (Item["company_name"] ?? "").ToString(); work_phone.Text = (Item["work_phone"] ?? "").ToString(); home_phone.Text = (Item["home_phone"] ?? "").ToString(); mobile_phone.Text = (Item["mobile_phone"] ?? "").ToString(); emergency_contact_name.Text = (Item["emergency_contact_name"] ?? "").ToString(); emergency_contact_phone.Text = (Item["emergency_contact_phone"] ?? "").ToString(); emergency_contact_relationship.Text = (Item["emergency_contact_relationship"] ?? "").ToString(); weight.Text = (Item["weight"] ?? "").ToString(); height.Text = (Item["height"] ?? "").ToString(); congenital_disease.Text = (Item["congenital_disease"] ?? "").ToString(); pictureFilename = (Item["image_file"] ?? "").ToString(); if (!string.IsNullOrEmpty(pictureFilename.Trim())) { GF.getImage(pictureFilename, ref picture, "member_picture"); } } } } GF.closeLoading(); } else { picture.Visible = false; } }
public history_buy_member(string member_id) { InitializeComponent(); _member_id = member_id; GF.showLoading(this); Dictionary <string, string> values = new() { { "is_suspend", "0" } }; Dictionary <string, object> Obj = DB.Post("MemberType/getMemberType/", values); if (Obj != null) { member_type_id.Items.Add(new ComboItem(0, "ทุกประเภท")); if (Obj.ContainsKey("result")) { foreach (Dictionary <string, object> Item in GF.ToType <Dictionary <string, object>[]>(Obj["result"])) { member_type_id.Items.Add(new ComboItem(GF.toInt(Item["member_type_id"].ToString()), Item["member_type_name"].ToString())); } } member_type_id.SelectedIndex = 0; GF.resizeComboBox(member_type_id); } else { GF.closeLoading(); GF.Error("ไม่มีข้อมูล 'ประเภทสมาชิก' ในฐานข้อมูล !!\r\n\r\nกรุณาติดต่อผู้ดูแลระบบ !!"); } //PAGING DELEGATE btn_dgv.firstClick += doLoadGridData; btn_dgv.prevClick += doLoadGridData; btn_dgv.nextClick += doLoadGridData; btn_dgv.lastClick += doLoadGridData; btn_dgv.pageNumberChanged += doLoadGridData; List <dgvColumn> DGVC = new(); DGVC.Add(new dgvColumn("datetime", "วันที่", DataGridViewContentAlignment.MiddleLeft)); DGVC.Add(new dgvColumn("member_type", "ประเภท Member", DataGridViewContentAlignment.MiddleLeft)); DGVC.Add(new dgvColumn("allow_branch", "สาขาที่ใช้ได้", DataGridViewContentAlignment.MiddleCenter)); DGVC.Add(new dgvColumn("since", "เริ่มต้น")); DGVC.Add(new dgvColumn("until", "สิ้นสุด")); DGVC.Add(new dgvColumn("full_amount", "ราคาเต็ม")); DGVC.Add(new dgvColumn("discount_amount", "ส่วนลด")); DGVC.Add(new dgvColumn("discount_by", "อนุมัติส่วนลดโดย", DataGridViewContentAlignment.MiddleLeft)); DGVC.Add(new dgvColumn("discount_note", "รายละเอียดส่วนลด", DataGridViewContentAlignment.MiddleLeft)); DGVC.Add(new dgvColumn("void_by", "VOID โดย", DataGridViewContentAlignment.MiddleLeft)); DGVC.Add(new dgvColumn("void_datetime", "เมื่อ", DataGridViewContentAlignment.MiddleLeft)); DGVC.Add(new dgvColumn("void_reason", "สาเหตุ", DataGridViewContentAlignment.MiddleLeft)); DGVC.Add(new dgvColumn("member_id", "member_id", DataGridViewContentAlignment.MiddleLeft, false)); DGVC.Add(new dgvColumn("member_ext_id", "member_ext_id", DataGridViewContentAlignment.MiddleLeft, false)); DGVC.Add(new dgvColumn("is_import", "is_import", DataGridViewContentAlignment.MiddleLeft, false)); btn_dgv.initColumn(DGVC); btn_dgv.DGV.CellDoubleClick += (ss, ee) => { if (ee.RowIndex > -1 && ee.ColumnIndex > -1) { using member_ext ExtData = new(); ExtData.onlySee = true; ExtData.member_ext_id = btn_dgv.DGV.Rows[ee.RowIndex].Cells["member_ext_id"].Value.ToString(); ExtData.manage_btn.Visible = false; ExtData.print_btn.Left = ExtData.manage_btn.Right - ExtData.print_btn.Width; ExtData.branch_list.Enabled = false; ExtData.Owner = this; ExtData.ShowDialog(); this.Select(); } }; btn_dgv.DGV.MouseClick += (ss, ee) => { if (ee.Button == System.Windows.Forms.MouseButtons.Right) { if (btn_dgv.DGV.HitTest(ee.X, ee.Y).ColumnIndex > -1 && btn_dgv.DGV.HitTest(ee.X, ee.Y).RowIndex > -1) { btn_dgv.DGV.Rows[btn_dgv.DGV.HitTest(ee.X, ee.Y).RowIndex].Selected = true; btn_dgv.theContextMenu.Items.Clear(); if (btn_dgv.DGV.SelectedRows.Count == 1) { if (btn_dgv.DGV.Rows[btn_dgv.DGV.HitTest(ee.X, ee.Y).RowIndex].DefaultCellStyle.BackColor != Color.LightCoral) { btn_dgv.theContextMenu.Items.Add("แก้ไข สาขาที่เข้าใช้ได้", null, new EventHandler(ChangeBranchEvent)); if (GF.isAdmin) { btn_dgv.theContextMenu.Items.Add("-"); btn_dgv.theContextMenu.Items.Add("แก้ไขข้อมูลการซื้อสมาชิก โดยผู้มีอำนาจ", null, new EventHandler(ForceEditEvent)); btn_dgv.theContextMenu.Items.Add("VOID รายการ โดยผู้มีอำนาจ", null, new EventHandler(VoidEvent)); } } } } } }; GF.closeLoading(); this.Width = Screen.PrimaryScreen.WorkingArea.Width; this.Height = Screen.PrimaryScreen.WorkingArea.Height; this.CenterToScreen(); }
public trainer_list_member() { InitializeComponent(); GF.showLoading(this); Dictionary <string, string> values = new() { { "branch_id", GF.Settings("branch_id") } }; Dictionary <string, object> Obj = DB.Post("Employee/getTrainer/", values); if (Obj != null) { trainer_emp_id.Items.Add(new ComboItem(0, "เลือก เทรนเนอร์")); if (Obj.ContainsKey("result")) { foreach (Dictionary <string, object> Item in GF.ToType <Dictionary <string, object>[]>(Obj["result"])) { trainer_emp_id.Items.Add(new ComboItem(GF.toInt(Item["trainer_emp_id"].ToString()), Item["trainer_name"].ToString())); } } trainer_emp_id.SelectedIndex = 0; GF.resizeComboBox(trainer_emp_id); } //PAGING DELEGATE btn_dgv.firstClick += doLoadGridData; btn_dgv.prevClick += doLoadGridData; btn_dgv.nextClick += doLoadGridData; btn_dgv.lastClick += doLoadGridData; btn_dgv.pageNumberChanged += doLoadGridData; List <dgvColumn> DGVC = new(); DGVC.Add(new dgvColumn("member_no", "รหัสสมาชิก", DataGridViewContentAlignment.MiddleLeft)); DGVC.Add(new dgvColumn("member_name", "สมาชิก", DataGridViewContentAlignment.MiddleLeft)); DGVC.Add(new dgvColumn("pt_course_name", "คอร์ส", DataGridViewContentAlignment.MiddleLeft)); DGVC.Add(new dgvColumn("hours", "คงเหลือ", DataGridViewContentAlignment.MiddleCenter)); DGVC.Add(new dgvColumn("expiry_date", "วันหมดอายุ", DataGridViewContentAlignment.MiddleCenter)); DGVC.Add(new dgvColumn("seller", "ผู้ขาย", DataGridViewContentAlignment.MiddleLeft)); DGVC.Add(new dgvColumn("process_date", "วันที่ซื้อ", DataGridViewContentAlignment.MiddleCenter)); DGVC.Add(new dgvColumn("member_pt_id", "member_pt_id", DataGridViewContentAlignment.MiddleLeft, false)); btn_dgv.initColumn(DGVC); btn_dgv.DGV.MouseClick += (ss, ee) => { if (ee.Button == System.Windows.Forms.MouseButtons.Right) { if (btn_dgv.DGV.HitTest(ee.X, ee.Y).ColumnIndex > -1 && btn_dgv.DGV.HitTest(ee.X, ee.Y).RowIndex > -1) { btn_dgv.DGV.Rows[btn_dgv.DGV.HitTest(ee.X, ee.Y).RowIndex].Selected = true; btn_dgv.theContextMenu.Items.Clear(); if (btn_dgv.DGV.SelectedRows.Count == 1) { btn_dgv.theContextMenu.Items.Add("เปลี่ยนเทรนเนอร์", null, new EventHandler(ChangeTrainerEvent)); } } } }; GF.closeLoading(); this.Width = Screen.PrimaryScreen.WorkingArea.Width; this.Height = Screen.PrimaryScreen.WorkingArea.Height; this.CenterToScreen(); }
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(); } }