static void doPrint() { try { print_receipt.printerResolution = new PrinterResolution(); GF.printError("INIT PRINT DOCUMENT FOR 'SHOP RECEIPT' ..."); if (GF.Settings("receipt_printer") == "") { GF.Error("ไม่พบ PRINTER สำหรับออกใบเสร็จ !!"); GF.closeLoading(); } else if (GF.Settings("receipt_printer") == "ไม่มี") { GF.Error("ไม่สามารถพิมพ์ใบเสร็จได้ จนกว่าจะตั้งค่า PRINTER สำหรับออกใบเสร็จ !!"); GF.closeLoading(); return; } else { print_receipt.printerName = GF.Settings("receipt_printer"); GF.printError("PRINTER : " + print_receipt.printerName); } initPrintDocument(); } catch (Exception e) { GF.printError(e.Message + "\r\n\r\n" + e.StackTrace.ToString()); GF.Error(e.Message, "PRINTER ERROR !!"); GF.closeLoading(); } }
static void doPrint() { try { preview_bill_header.printerResolution = new PrinterResolution(); Console.WriteLine("INIT PRINT DOCUMENT FOR 'RECEIPT' ..."); if (GF.Settings("receipt_printer") == "") { GF.Error("ไม่พบ PRINTER สำหรับออกใบเสร็จ !!"); GF.closeLoading(); } else { preview_bill_header.printerName = GF.Settings("receipt_printer"); Console.WriteLine("PRINTER : " + preview_bill_header.printerName); } initPrintDocument(); } catch (Exception e) { GF.Error(e.Message, "PRINTER ERROR !!"); GF.closeLoading(); } }
private void branch_manage_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(branch_id)) { GF.showLoading(this); Dictionary <string, string> values = new() { { "branch_id", branch_id.Trim() } }; 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) { branch_name.Text = Item["branch_name"]?.ToString(); prefix.Text = Item["prefix"]?.ToString(); company_name.Text = Item["company_name"]?.ToString(); address.Text = Item["address"]?.ToString(); tax_id.Text = Item["tax_id"]?.ToString(); } } } GF.closeLoading(); } }
public history_payment(string member_id) { InitializeComponent(); _member_id = member_id; GF.showLoading(this); Dictionary <string, string> values = new() { { "user_id", GF.userID } }; Dictionary <string, object> Obj = DB.Post("Branch/BranchList/", values); if (Obj != null) { branch_id.Items.Add(new ComboItem(0, "ทุกสาขา")); if (Obj.ContainsKey("result")) { foreach (Dictionary <string, object> Item in GF.ToType <Dictionary <string, object>[]>(Obj["result"])) { branch_id.Items.Add(new ComboItem(GF.toInt(Item["branch_id"].ToString()), Item["branch_name"].ToString() + " (" + Item["prefix"].ToString() + ")")); } } branch_id.SelectedIndex = 0; GF.resizeComboBox(branch_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("detail", "รายละเอียด", DataGridViewContentAlignment.MiddleLeft)); DGVC.Add(new dgvColumn("branch_name", "สาขา")); DGVC.Add(new dgvColumn("cash", "เงินสด")); DGVC.Add(new dgvColumn("card", "บัตร")); DGVC.Add(new dgvColumn("card_no", "บัตรหมายเลข")); DGVC.Add(new dgvColumn("card_expiry_date", "วันหมดอายุบัตร")); DGVC.Add(new dgvColumn("by", "ผู้รับเงิน")); btn_dgv.initColumn(DGVC); GF.closeLoading(); this.Width = Screen.PrimaryScreen.WorkingArea.Width; this.Height = Screen.PrimaryScreen.WorkingArea.Height; this.CenterToScreen(); }
private void config_product_manage_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(product_id)) { GF.showLoading(this); Dictionary <string, string> values = new() { { "product_id", product_id.Trim() } }; Dictionary <string, object> Obj = DB.Post("Product/getProductData/", values); if (Obj != null) { if (Obj.ContainsKey("result")) { Dictionary <string, object> Item = GF.ToType <Dictionary <string, object> >(Obj["result"]); if (Item.Keys.Count > 0) { product_name.Text = Item["product_name"].ToString(); product_code.Text = (Item["product_code"] ?? "").ToString(); price.Text = Item["price"].ToString(); alert_amount.Text = Item["alert_amount"].ToString(); } } } GF.closeLoading(); } }
private void config_member_type_manage_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(member_type_id)) { GF.showLoading(this); Dictionary <string, string> values = new() { { "member_type_id", member_type_id.Trim() } }; Dictionary <string, object> Obj = DB.Post("MemberType/getMemberTypeData/", 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_type_name.Text = Item["member_type_name"].ToString(); month_amount.Text = Item["month_amount"].ToString(); price.Text = Item["price"].ToString(); } } } GF.closeLoading(); } }
public history_pt_usage(string member_id) { InitializeComponent(); _member_id = member_id; GF.showLoading(this); //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("pt_course", "คอร์ส PT", DataGridViewContentAlignment.MiddleLeft)); DGVC.Add(new dgvColumn("trainer", "เทรนเนอร์", DataGridViewContentAlignment.MiddleLeft)); DGVC.Add(new dgvColumn("amount_left", "คงเหลือ")); btn_dgv.initColumn(DGVC); GF.closeLoading(); this.Width = Screen.PrimaryScreen.WorkingArea.Width; this.Height = Screen.PrimaryScreen.WorkingArea.Height; this.CenterToScreen(); }
public history_drop(string member_id) { InitializeComponent(); _member_id = member_id; GF.showLoading(this); //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("drop_datetime", "ดรอปเมื่อ", DataGridViewContentAlignment.MiddleLeft)); DGVC.Add(new dgvColumn("drop_during", "ดรอประหว่างวันที่", DataGridViewContentAlignment.MiddleLeft)); DGVC.Add(new dgvColumn("drop_note", "สาเหตุการดรอป", DataGridViewContentAlignment.MiddleLeft)); DGVC.Add(new dgvColumn("drop_by", "ทำการดรอปโดย", DataGridViewContentAlignment.MiddleLeft)); DGVC.Add(new dgvColumn("branch_name", "ดรอปที่สาขา", DataGridViewContentAlignment.MiddleLeft)); DGVC.Add(new dgvColumn("drop_is_cancelled", "ถูกยกเลิก ?")); DGVC.Add(new dgvColumn("cancelled_by", "ยกเลิกการดรอปโดย", DataGridViewContentAlignment.MiddleLeft)); DGVC.Add(new dgvColumn("cancelled_datetime", "ยกเลิกการดรอปเมื่อ", DataGridViewContentAlignment.MiddleLeft)); btn_dgv.initColumn(DGVC); this.Width = Screen.PrimaryScreen.WorkingArea.Width; this.Height = Screen.PrimaryScreen.WorkingArea.Height; GF.closeLoading(); }
static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) { try { GF.closeLoading(); Exception ex = (Exception)e.Exception; GF.printError("********** THREAD FATAL ERROR **********"); GF.printError("[" + ex.TargetSite.ToString() + "]"); GF.printError(ex.ToString() + "\r\n"); GF.printError("FILE : " + new StackTrace(ex, true).GetFrame(0).GetFileName()); GF.printError("LINE : " + new StackTrace(ex, true).GetFrame(0).GetFileLineNumber()); GF.printError("STACK-TRACE : \r\n" + ex.StackTrace.ToString() + "\r\n"); waitHandle.WaitOne(); } finally { foreach (Process theProcess in Process.GetProcessesByName("EXCEL")) { theProcess.Kill(); } if (currentProcess != null) { foreach (Process theProcess in Process.GetProcessesByName("FAMS")) { theProcess.Kill(); } } System.Environment.Exit(0); } }
public history_card_no(string member_id) { InitializeComponent(); _member_id = member_id; GF.showLoading(this); //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("change_datetime", "วันที่", DataGridViewContentAlignment.MiddleLeft)); DGVC.Add(new dgvColumn("member_no", "เปลี่ยน เลขที่สมาชิก เป็น", DataGridViewContentAlignment.MiddleLeft)); DGVC.Add(new dgvColumn("note", "บันทึกเพิ่มเติม", DataGridViewContentAlignment.MiddleLeft)); DGVC.Add(new dgvColumn("change_by", "เปลี่ยนแปลงโดย", DataGridViewContentAlignment.MiddleLeft)); btn_dgv.initColumn(DGVC); this.Width = Screen.PrimaryScreen.WorkingArea.Width; this.Height = Screen.PrimaryScreen.WorkingArea.Height; GF.closeLoading(); }
private void trainer_job_manage_Load(object sender, EventArgs e) { if (isReadOnly) { trainer_emp_id.Enabled = false; job_date.Enabled = false; start_time.Enabled = false; end_time.Enabled = false; detail.Enabled = false; manage_btn.Enabled = false; } if (!string.IsNullOrEmpty(trainer_job_id.Trim())) { GF.showLoading(this); Dictionary <string, string> values = new() { { "trainer_job_id", trainer_job_id.Trim() } }; Dictionary <string, object> Obj = DB.Post("TrainerJob/getJobData/", values); if (Obj != null) { if (Obj.ContainsKey("result")) { Dictionary <string, object> Item = GF.ToType <Dictionary <string, object> >(Obj["result"]); foreach (ComboItem cb in trainer_emp_id.Items) { if (Item.ContainsKey("trainer_emp_id")) { if (cb.Key.ToString() == Item["trainer_emp_id"].ToString()) { trainer_emp_id.Text = cb.Value; break; } } } job_date.Text = Item["job_date"]?.ToString(); start_time.Text = Item["start_time"]?.ToString(); end_time.Text = Item["end_time"]?.ToString(); detail.Text = Item["detail"]?.ToString(); } } GF.closeLoading(); } }
public history_checkin(string member_id) { InitializeComponent(); _member_id = member_id; GF.showLoading(this); Dictionary <string, string> values = new() { { "user_id", GF.userID } }; Dictionary <string, object> Obj = DB.Post("Branch/BranchList/", values); if (Obj != null) { branch_id.Items.Add(new ComboItem(0, "ทุกสาขา")); if (Obj.ContainsKey("result")) { foreach (Dictionary <string, object> Item in GF.ToType <Dictionary <string, object>[]>(Obj["result"])) { branch_id.Items.Add(new ComboItem(GF.toInt(Item["branch_id"].ToString()), Item["branch_name"].ToString() + " (" + Item["prefix"].ToString() + ")")); } } branch_id.SelectedIndex = 0; GF.resizeComboBox(branch_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("checkin_datetime", "วันที่", DataGridViewContentAlignment.MiddleLeft)); DGVC.Add(new dgvColumn("branch_name", "สาขา", DataGridViewContentAlignment.MiddleLeft)); btn_dgv.initColumn(DGVC); GF.closeLoading(); }
private void month_range_ItemCheck(object sender, ItemCheckEventArgs e) { if (isReady) { isReady = false; GF.showLoading(this); if (e.NewValue == CheckState.Checked) { for (int i = 0; i < month_range.Items.Count; i++) { month_range.SetItemCheckState(i, CheckState.Unchecked); } } isReady = true; GF.closeLoading(); } }
private void employee_manage_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(emp_id.Trim())) { GF.showLoading(this); Dictionary <string, string> values = new() { { "emp_id", emp_id.Trim() } }; Dictionary <string, object> Obj = DB.Post("Employee/getEmployeeData/", values); if (Obj != null) { Dictionary <string, object> Item = GF.ToType <Dictionary <string, object> >(Obj["result"]); if (Item.Keys.Count > 0) { emp_code.Text = (Item["emp_code"] ?? "").ToString(); fullname.Text = Item["fullname"]?.ToString(); nickname.Text = Item["nickname"]?.ToString(); if (Item["is_trainer"]?.ToString() == "1") { is_trainer.Checked = true; } if (Item["can_get_commission"]?.ToString() == "1") { can_get_commission.Checked = true; } foreach (ComboItem cb in branch_id.Items) { if (cb.Key.ToString() == Item["branch_id"]?.ToString()) { branch_id.Text = cb.Value; break; } } } } GF.closeLoading(); } }
void DisableEvent(object sender, EventArgs e) { var values = new Dictionary <string, string> { { "branch_id", btn_dgv.DGV.SelectedRows[0].Cells["branch_id"]?.Value.ToString() } }; GF.showLoading(this); Dictionary <string, object> result = DB.Post("Branch/Suspend/", values); if (result == null) { GF.Error("เกิดความผิดพลาด !!"); GF.closeLoading(); return; } getData(); }
void EnableEvent(object sender, EventArgs e) { Dictionary <string, string> values = new() { { "product_id", btn_dgv.DGV.SelectedRows[0].Cells["product_id"].Value.ToString() } }; GF.showLoading(this); Dictionary <string, object> result = DB.Post("Product/Enable/", values); if (result == null) { GF.Error("เกิดความผิดพลาด !!"); GF.closeLoading(); return; } getData(); }
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { try { GF.closeLoading(); Exception ex = (Exception)e.ExceptionObject; GF.printError("********** FATAL UNHANDLED EXCEPTION ERROR *********"); GF.printError("[" + ex.TargetSite.ToString() + "]"); GF.printError(ex.ToString() + "\r\n"); GF.printError("FILE : " + new StackTrace(ex, true).GetFrame(0).GetFileName()); GF.printError("LINE : " + new StackTrace(ex, true).GetFrame(0).GetFileLineNumber()); GF.printError("STACK-TRACE : \r\n" + ex.StackTrace.ToString() + "\r\n"); waitHandle.WaitOne(); /*MessageBox.Show("Whoops! Please contact the developers with the following" + " information:\n\n" + ex.Message + ex.StackTrace, + "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);*/ } finally { foreach (Process theProcess in Process.GetProcessesByName("EXCEL")) { theProcess.Kill(); } if (currentProcess != null) { foreach (Process theProcess in Process.GetProcessesByName("FAMS")) { theProcess.Kill(); } } System.Environment.Exit(0); } }
private void save_btn_Click(object sender, EventArgs e) { GF.showLoading(this); string newFileName = (DateTime.Now.Year + 543).ToString() + "-" + DateTime.Now.Month.ToString("00") + "-" + DateTime.Now.Day.ToString("00") + "-" + DateTime.Now.Hour.ToString("00") + "-" + DateTime.Now.Minute.ToString("00") + "-" + DateTime.Now.Second.ToString("00") + ".jpg"; List <string> FileList = FTP.getFTPFileList("emp_card"); foreach (string FTPfilename in FileList) { if (!FTP.delete("emp_card", FTPfilename)) { GF.Error("เกิดความผิดพลาดในการลบไฟล์บน Server !!"); return; } } if (!FTP.upload("emp_card", targetFileName, newFileName)) { GF.closeLoading(); GF.Error("เกิดความผิดพลาดในการ upload ไฟล์รูปภาพไปยัง server !!"); return; } Dictionary <string, string> values = new() { { "filename", newFileName } }; Dictionary <string, object> result = DB.Post("Employee/manageEmpCard/", values); if (result == null) { GF.closeLoading(); GF.Error("เกิดความผิดพลาด !!"); return; } GF.closeLoading(); this.Close(); }
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 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(); } }
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(); }
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(); }
private void save_btn_Click(object sender, EventArgs e) { if (validateForm()) { var values = new Dictionary <string, string> { { "firstname_th", firstname_th.Text.Trim() }, { "lastname_th", lastname_th.Text.Trim() }, { "nickname_th", nickname_th.Text.Trim() }, { "martial_status", martial_status.Text.Trim() }, { "birthday", birthday.Text.Trim() }, { "document_type", document_type.Text.Trim() }, { "document_no", document_no.Text.Trim() }, { "gender", gender.Text.Trim() }, { "mobile_phone", mobile_phone.Text.Trim() }, { "create_by", GF.userID }, { "create_branch_id", GF.Settings("branch_id") }, { "member_prefix", GF.Settings("member_prefix") } }; if (!string.IsNullOrEmpty(firstname_en.Text.Trim())) { values.Add("firstname_en", firstname_en.Text.Trim()); } if (!string.IsNullOrEmpty(lastname_en.Text.Trim())) { values.Add("lastname_en", lastname_en.Text.Trim()); } if (!string.IsNullOrEmpty(nickname_en.Text.Trim())) { values.Add("nickname_en", nickname_en.Text.Trim()); } if (!string.IsNullOrEmpty(email.Text.Trim())) { values.Add("email", email.Text.Trim()); } if (!string.IsNullOrEmpty(occupation.Text.Trim())) { values.Add("occupation", occupation.Text.Trim()); } if (!string.IsNullOrEmpty(address.Text.Trim())) { values.Add("address", address.Text.Trim()); } if (!string.IsNullOrEmpty(company_name.Text.Trim())) { values.Add("company_name", company_name.Text.Trim()); } if (!string.IsNullOrEmpty(work_phone.Text.Trim())) { values.Add("work_phone", work_phone.Text.Trim()); } if (!string.IsNullOrEmpty(home_phone.Text.Trim())) { values.Add("home_phone", home_phone.Text.Trim()); } if (!string.IsNullOrEmpty(emergency_contact_name.Text.Trim())) { values.Add("emergency_contact_name", emergency_contact_name.Text.Trim()); } if (!string.IsNullOrEmpty(emergency_contact_phone.Text.Trim())) { values.Add("emergency_contact_phone", emergency_contact_phone.Text.Trim()); } if (!string.IsNullOrEmpty(emergency_contact_relationship.Text.Trim())) { values.Add("emergency_contact_relationship", emergency_contact_relationship.Text.Trim()); } if (!string.IsNullOrEmpty(weight.Text.Trim())) { values.Add("weight", weight.Text.Trim()); } if (!string.IsNullOrEmpty(height.Text.Trim())) { values.Add("height", height.Text.Trim()); } if (!string.IsNullOrEmpty(congenital_disease.Text.Trim())) { values.Add("congenital_disease", congenital_disease.Text.Trim()); } if (!string.IsNullOrEmpty(member_id)) { values.Add("member_id", member_id); } if (!string.IsNullOrEmpty(member_no.Text.Trim())) { values.Add("member_no", member_no.Text.Trim()); } if (!string.IsNullOrEmpty(member_no.Text.Trim())) { if (isPictureChanged) { if (!string.IsNullOrEmpty(pictureFilename)) { values.Add("image_file", member_no.Text.Trim() + ".jpg"); } if (!string.IsNullOrEmpty(pictureFilename.Trim())) { if (!FTP.upload("member_picture", GF.Settings("tmp_path") + pictureFilename, member_no.Text.Trim() + ".jpg")) { GF.Error("เกิดความผิดพลาดในการ upload ไฟล์รูปภาพไปยัง server !!"); return; } } } } GF.showLoading(this); Dictionary <string, object> result = DB.Post("Member/manageMember/", values); if (result == null) { GF.Error("เกิดความผิดพลาด !!"); GF.closeLoading(); return; } member_id = result["member_id"].ToString(); member_no.Text = (result["member_no"] ?? "").ToString(); ((member)this.Owner).getData(); this.Close(); } }
public trainer_job_list() { 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("datetime", "วันที่", DataGridViewContentAlignment.MiddleLeft)); DGVC.Add(new dgvColumn("during", "ระหว่างเวลา")); DGVC.Add(new dgvColumn("detail", "รายละเอียด", DataGridViewContentAlignment.MiddleLeft)); DGVC.Add(new dgvColumn("trainer_name", "เทรนเนอร์", DataGridViewContentAlignment.MiddleLeft)); DGVC.Add(new dgvColumn("confirm_by", "ยืนยันว่าเกิดขึ้นจริง โดย")); DGVC.Add(new dgvColumn("confirm_datetime", "วันเวลา ที่ยืนยันว่าเกิดขึ้นจริง")); DGVC.Add(new dgvColumn("create_by", "สร้าง โดย")); DGVC.Add(new dgvColumn("create_datetime", "สร้าง เมื่อ")); DGVC.Add(new dgvColumn("last_modified_by", "ปรับปรุงล่าสุด โดย")); DGVC.Add(new dgvColumn("last_modified_datetime", "ปรับปรุงล่าสุด เมื่อ")); DGVC.Add(new dgvColumn("trainer_job_id", "trainer_job_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(EditEvent)); if (string.IsNullOrEmpty((btn_dgv.DGV.SelectedRows[0].Cells["confirm_by"].Value ?? "").ToString())) { btn_dgv.theContextMenu.Items.Add("ยืนยันว่าเกิดขึ้นจริง", null, new EventHandler(ConfirmEvent)); } } } } }; GF.closeLoading(); this.Width = Screen.PrimaryScreen.WorkingArea.Width; this.Height = Screen.PrimaryScreen.WorkingArea.Height; this.CenterToScreen(); }
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; } }
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(); } } }
static void initPrintDocument() { using (pd = new PrintDocument()) { pd.DocumentName = "หัวใบเสร็จ"; pd.PrinterSettings.PrinterName = printerName; //checkPaperSize(pd); //checkPaperSource(pd); Console.WriteLine("THIS RAW KIND : " + rawKind); Console.WriteLine("THIS PAPER SIZE : " + paperSize); if (rawKind != 0) { pd.DefaultPageSettings.PaperSize.RawKind = rawKind; } if (paperSize != null) { pd.DefaultPageSettings.PaperSize = paperSize; } Console.WriteLine(pd.DefaultPageSettings.PaperSize.Width.ToString() + " x " + pd.DefaultPageSettings.PaperSize.Height.ToString()); Console.WriteLine("PD RAW KIND : " + pd.DefaultPageSettings.PaperSize.RawKind); Console.WriteLine("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) => { print_bill_header.draw(e, branch_id, out int 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; PPD.ShowDialog(); } } }
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(); }
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(); }