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();
            }
        }
示例#2
0
        private void picture_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(member_no.Text.Trim()) || string.IsNullOrEmpty(member_id.Trim()))
            {
                GF.Error("ต้องมี 'หมายเลขสมาชิก' ก่อน !!");
                return;
            }

            if (Global.Capture.List().Count > 0)
            {
                using var member_picture = new member_picture(member_no.Text.Trim());
                member_picture.Owner     = this;
                member_picture.ShowDialog();
                this.BringToFront();
                this.Activate();
            }
            else
            {
                GF.Error("ไม่พบ กล้อง WebCam !!\r\nกรุณาติดตั้ง กล้อง WebCam ก่อน !");
                return;
            }

            if (!string.IsNullOrEmpty(member_no.Text.Trim()) && !string.IsNullOrEmpty(pictureFilename.Trim()))
            {
                GF.getImage(GF.Settings("tmp_path") + pictureFilename, ref picture, "member_picture");
            }
        }
        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();
            }
        }
示例#4
0
        public trainer_job_manage()
        {
            InitializeComponent();

            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);
            }
        }
        private void manage_btn_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(ref_txt.Text.Trim()))
            {
                GF.Error("กรุณากรอก 'อ้างอิง' !!");
                return;
            }

            string product_list = "";

            foreach (DataGridViewRow DGVR in DGV.Rows)
            {
                product_list += DGVR.Cells["product_id"].Value.ToString() + "###" + prefixAmount + DGVR.Cells["amount"].Value.ToString() + "@@@";
            }

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

            if (string.IsNullOrEmpty(product_list.Trim()))
            {
                GF.Error("ยังไม่ได้เลือก สินค้า !!");
                return;
            }
            GF.showLoading(this);
            Dictionary <string, string> values = new()
            {
                { "branch_id", GF.Settings("branch_id") },
                { "ref", ref_txt.Text.Trim() },
示例#6
0
 private void change_trainer_Load(object sender, EventArgs e)
 {
     GF.showLoading(this);
     Dictionary <string, string> values = new()
     {
         { "branch_id", GF.Settings("branch_id") },
         { "only_active", "1" }
     };
示例#7
0
        public static Image download(string folderName, string fileName)
        {
            if (string.IsNullOrEmpty(folderName))
            {
                Console.WriteLine("\r\nระบุ folderName !!\r\n");
                GF.Error("เกิดความผิดพลาดในการ download ไฟล์จาก server !!\r\n\r\nกรุณาติดต่อผู้ดูแลเกี่ยวกับปัญหานี้ ...");
                return(null);
            }
            Console.WriteLine("folderName = " + folderName);

            if (fileName.IndexOf(GF.Settings("tmp_path")) != -1)
            {
                fileName = fileName.Replace(GF.Settings("tmp_path"), "");
            }

            if (string.IsNullOrEmpty(fileName))
            {
                Console.WriteLine("\r\nระบุ fileName !!\r\n");
                GF.Error("เกิดความผิดพลาดในการ download ไฟล์จาก server !!\r\n\r\nกรุณาติดต่อผู้ดูแลเกี่ยวกับปัญหานี้ ...");
                return(null);
            }
            Console.WriteLine("fileName = " + fileName);

            Image returnImage = null;

            try
            {
                FtpWebRequest request = open(WebRequestMethods.Ftp.DownloadFile, folderName, fileName);
                if (request != null)
                {
                    FtpWebResponse response = (FtpWebResponse)request.GetResponse();

                    Stream responseStream = response.GetResponseStream();

                    if (response.StatusCode == FtpStatusCode.OpeningData)
                    {
                        returnImage = Bitmap.FromStream(responseStream);
                    }
                    else
                    {
                        GF.Error("(" + response.StatusCode.ToString() + ") " + response.StatusDescription);
                        Console.WriteLine("FTP :: FILE [" + fileName + "] DOWNLOAD FAILED !! (" + response.StatusCode.ToString() + ") " + response.StatusDescription);
                        returnImage = null;
                    }

                    response.Close();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                GF.Error("เกิดความผิดพลาดในการดึงไฟล์รูปภาพสมาชิกจาก Server !");
                return(null);
            }
            Console.WriteLine("FTP :: FILE [" + fileName + "] DOWNLOAD SUCCEEDED !!");
            return(returnImage);
        }
 public static bool hasReceiptPrinter()
 {
     if (GF.Settings("receipt_printer") == "ไม่มี")
     {
         GF.Error("ใบเสร็จจะถูกพิมพ์ก็ต่อเมื่อมีการตั้งค่าเครื่องพิมพ์เท่านั้น !!");
         return(false);
     }
     return(true);
 }
示例#9
0
        static FtpWebRequest open(string Method, string folderName, string fileName)
        {
            // Get the object used to communicate with the server.
            FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://" + GF.Settings("host_url") + "/" + ftpPath + folderName + "/" + fileName);

            request.Method = Method;

            // This example assumes the FTP site uses anonymous logon.
            request.Credentials = new NetworkCredential("fitanswer", "9OeqLQfnI");
            Console.WriteLine("FTP :: CONNECTION IS OPENED TO " + request.RequestUri.AbsoluteUri);
            return(request);
        }
示例#10
0
 public static void printError(string debugText)
 {
     try
     {
         sw = new StreamWriter(GF.Settings("tmp_path") + "error.txt", true);
         sw.WriteLine("[ " + NOW() + " ] " + debugText);
         sw.Close();
     }
     catch (Exception e)
     {
         GF.Error(e.Message);
     }
 }
 private void use_pt_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Escape)
     {
         currentLabel.Text = "";
     }
     else if (e.KeyCode == Keys.Enter && !string.IsNullOrEmpty(card_no.Text.Trim()))
     {
         if (currentLabel == card_no && !string.IsNullOrEmpty(card_no.Text.Trim()))
         {
             // GET MEMBER DATA
             GF.showLoading(this);
             Dictionary <string, string> values = new()
             {
                 { "branch_id", GF.Settings("branch_id") },
                 { "card_no", card_no.Text.Trim() },
示例#12
0
        private void member_picture_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (cam != null)
            {
                cam.Dispose();
            }

            if (isCameraRunning)
            {
                return;
            }

            if (picture.Image != null)
            {
                var pictureFilename = member_no.Trim() + "_" + new Random().Next(100000, 999999).ToString("000000") + ".jpg";

                var destRect  = new Rectangle(0, 0, 240, 180);
                var destImage = new Bitmap(240, 180);

                destImage.SetResolution(picture.Image.HorizontalResolution, picture.Image.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;

                    var wrapMode = new ImageAttributes();
                    wrapMode.SetWrapMode(System.Drawing.Drawing2D.WrapMode.TileFlipXY);
                    graphics.DrawImage(picture.Image, destRect, 0, 0, picture.Image.Width, picture.Image.Height, GraphicsUnit.Pixel, wrapMode);
                    wrapMode.Dispose();
                }


                destImage.Save(GF.Settings("tmp_path") + pictureFilename, System.Drawing.Imaging.ImageFormat.Jpeg);

                (this.Owner as member_manage).picture.Image    = destImage;
                (this.Owner as member_manage).pictureFilename  = pictureFilename;
                (this.Owner as member_manage).isPictureChanged = true;
                this.Close();
            }
        }
 private void check_in_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Escape)
     {
         this.Height = 192;
         if (member_pic_pb.Image != null)
         {
             member_pic_pb.Image.Dispose();
             member_pic_pb.Image = null;
         }
         reset();
     }
     else if (e.KeyCode == Keys.Enter && !string.IsNullOrEmpty(member_card_no.Text.Trim()))
     {
         GF.showLoading(this);
         Dictionary <string, string> values = new()
         {
             { "card_no", member_card_no.Text.Trim() },
             { "branch_id", GF.Settings("branch_id") },
示例#14
0
        public static Dictionary <string, object> Post(string url, Dictionary <string, string> values = null)
        {
            string requestUri = "http://" + GF.Settings("host_url") + "/" + url;

            Console.WriteLine("URL : " + requestUri);

            string postData = string.Empty;

            byte[] postBytes = null;

            if (values != null)
            {
                foreach (KeyValuePair <string, string> obj in values)
                {
                    string theValue = (obj.Value ?? "").Replace("'", "''");
                    Console.WriteLine(obj.Key + " = " + theValue);
                    postData += obj.Key + "=" + theValue + "&";
                }
                if (postData.Trim().Length > 0)
                {
                    postData = postData[0..^ 1];
示例#15
0
        private void member_manage_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (picture.Image != null)
            {
                picture.Image.Dispose();
            }
            if (GF.tmpImg != null)
            {
                GF.tmpImg.Dispose();
            }

            var downloadedMessageInfo = new DirectoryInfo(GF.Settings("tmp_path"));

            foreach (FileInfo file in downloadedMessageInfo.GetFiles())
            {
                file.Delete();
            }

            /*if (!string.IsNullOrEmpty(pictureFilename.Trim()))
             *  if (File.Exists(GF.Settings("tmp_path + pictureFilename))
             *      File.Delete(GF.Settings("tmp_path + pictureFilename);*/
        }
示例#16
0
        public member_picture(string _member_no)
        {
            InitializeComponent();
            member_no = _member_no;

            hasCamera = !(string.IsNullOrEmpty(GF.Settings("capDevice")) || GF.Settings("capDevice") == "ไม่มี");

            if (!hasCamera)
            {
                GF.Error("ต้องเลือกกล้อง WebCam ก่อน !");
                return;
            }

            Rectangle screenRectangle = RectangleToScreen(this.ClientRectangle);
            int       titleHeight     = screenRectangle.Top - this.Top;

            this.Width  = Global.Capture.VIDEOWIDTH;
            this.Height = Global.Capture.VIDEOHEIGHT + titleHeight;

            //Console.WriteLine(manager.CurrentCamera.CaptureWidth.ToString() + " x " + manager.CurrentCamera.CaptureHeight.ToString());
            cam.Render(pb);
            isCameraRunning = true;
        }
示例#17
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();
        }
        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 member()
        {
            InitializeComponent();

            //PAGING DELEGATE
            btn_dgv.firstClick        += doLoadGridData;
            btn_dgv.prevClick         += doLoadGridData;
            btn_dgv.nextClick         += doLoadGridData;
            btn_dgv.lastClick         += doLoadGridData;
            btn_dgv.pageNumberChanged += doLoadGridData;

            gender.SelectedIndex = 0;
            filter.SelectedIndex = 0;

            Dictionary <string, string> values = new()
            {
                { "user_id", GF.userID }
            };

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

            if (Obj != null)
            {
                if (Obj.ContainsKey("result"))
                {
                    foreach (Dictionary <string, object> Branch in GF.ToType <Dictionary <string, object>[]>(Obj["result"]))
                    {
                        branch_id.Items.Add(new ComboItem(Convert.ToInt32(Branch["branch_id"].ToString()), Branch["branch_name"].ToString()));
                    }
                }
                GF.resizeComboBox(branch_id);
                int selectedIndex = 0;

                foreach (var cb in branch_id.Items)
                {
                    if ((cb as ComboItem).Key.ToString() == GF.Settings("branch_id"))
                    {
                        branch_id.SelectedIndex = selectedIndex;
                        break;
                    }
                    selectedIndex++;
                }
            }

            List <dgvColumn> DGVC = new();

            DGVC.Add(new dgvColumn("member_no", "รหัสสมาชิก"));
            DGVC.Add(new dgvColumn("card_no", "เลขบัตรสมาชิก"));
            DGVC.Add(new dgvColumn("fullname", "ชื่อ", DataGridViewContentAlignment.MiddleLeft));
            DGVC.Add(new dgvColumn("gender", "เพศ"));
            DGVC.Add(new dgvColumn("start_date", "บันทึกข้อมูลเมื่อ"));
            DGVC.Add(new dgvColumn("member_type", "ประเภทสมาชิก"));
            DGVC.Add(new dgvColumn("contract_no", "หมายเลขสัญญา"));
            DGVC.Add(new dgvColumn("during_date", "ระหว่างวันที่"));
            DGVC.Add(new dgvColumn("birthday", "วันเกิด"));
            DGVC.Add(new dgvColumn("age", "อายุ"));
            DGVC.Add(new dgvColumn("tel", "โทรศัพท์"));
            DGVC.Add(new dgvColumn("drop_during", "ใช้สิทธิ์ดรอประหว่างวันที่"));
            DGVC.Add(new dgvColumn("is_drop_active", "is_drop_active", DataGridViewContentAlignment.BottomCenter, false));
            DGVC.Add(new dgvColumn("suspend_since", "ระงับใช้เมื่อ"));
            DGVC.Add(new dgvColumn("suspend_reason", "สาเหตุ"));
            DGVC.Add(new dgvColumn("suspend_by", "ระงับโดย"));
            DGVC.Add(new dgvColumn("member_id", "member_id", DataGridViewContentAlignment.BottomCenter, false));
            DGVC.Add(new dgvColumn("member_drop_id", "member_drop_id", DataGridViewContentAlignment.BottomCenter, 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));
                            btn_dgv.theContextMenu.Items.Add("-");
                            btn_dgv.theContextMenu.Items.Add("ซื้อ MEMBER", null, new EventHandler(BuyMemberEvent));

                            if (!string.IsNullOrEmpty((btn_dgv.DGV.SelectedRows[0].Cells["member_no"].Value ?? "").ToString()))
                            {
                                if (!string.IsNullOrEmpty((btn_dgv.DGV.SelectedRows[0].Cells["member_type"].Value ?? "").ToString()))
                                {
                                    btn_dgv.theContextMenu.Items.Add("ซื้อ PT", null, new EventHandler(BuyPTEvent));
                                    btn_dgv.theContextMenu.Items.Add("-");
                                    btn_dgv.theContextMenu.Items.Add("ประวัติการซื้อ Member", null, new EventHandler(BuyMemberHistoryEvent));
                                    btn_dgv.theContextMenu.Items.Add("ประวัติการซื้อ PT", null, new EventHandler(BuyPTHistoryEvent));
                                    btn_dgv.theContextMenu.Items.Add("-");
                                    btn_dgv.theContextMenu.Items.Add("ประวัติการเข้าใช้", null, new EventHandler(CheckInHistoryEvent));
                                    btn_dgv.theContextMenu.Items.Add("ประวัติการชำระเงิน", null, new EventHandler(PaymentHistoryEvent));
                                    btn_dgv.theContextMenu.Items.Add("ประวัติการใช้ PT", null, new EventHandler(PTUsageHistoryEvent));
                                    btn_dgv.theContextMenu.Items.Add("ประวัติการดรอป", null, new EventHandler(DropHistoryEvent));

                                    if ((btn_dgv.DGV.SelectedRows[0].Cells["member_type"].Value ?? "").ToString() != "หมดอายุแล้ว" && (btn_dgv.DGV.SelectedRows[0].Cells["member_type"].Value ?? "").ToString() != "ยังไม่ถึงวันเริ่มต้น")
                                    {
                                        if (string.IsNullOrEmpty((btn_dgv.DGV.SelectedRows[0].Cells["drop_during"].Value ?? "").ToString()) || (btn_dgv.DGV.SelectedRows[0].Cells["is_drop_active"].Value ?? "").ToString() == "NO")
                                        {
                                            btn_dgv.theContextMenu.Items.Add("-");
                                            btn_dgv.theContextMenu.Items.Add("ดรอป", null, new EventHandler(DropEvent));
                                        }
                                        else if (btn_dgv.DGV.SelectedRows[0].Cells["is_drop_active"].Value.ToString() == "YES")
                                        {
                                            btn_dgv.theContextMenu.Items.Add("-");
                                            btn_dgv.theContextMenu.Items.Add("ยกเลิกดรอป", null, new EventHandler(CancelDropEvent));
                                        }
                                    }

                                    btn_dgv.theContextMenu.Items.Add("-");
                                    btn_dgv.theContextMenu.Items.Add("บันทึก / เปลี่ยนแปลง บัตรสมาชิก", null, new EventHandler(CardNoEvent));
                                    btn_dgv.theContextMenu.Items.Add("ประวัติ การเปลี่ยนแปลง บัตรสมาชิก", null, new EventHandler(CardNoHistoryEvent));

                                    btn_dgv.theContextMenu.Items.Add("-");
                                    if (string.IsNullOrEmpty((btn_dgv.DGV.SelectedRows[0].Cells["suspend_since"].Value ?? "").ToString()))
                                    {
                                        btn_dgv.theContextMenu.Items.Add("ระงับการใช้งาน", null, new EventHandler(SuspendEvent));
                                    }
                                    else
                                    {
                                        btn_dgv.theContextMenu.Items.Add("ยกเลิก การระงับการใช้งาน", null, new EventHandler(CancelSuspendEvent));
                                    }
                                    btn_dgv.theContextMenu.Items.Add("ประวัติการระงับการใช้", null, new EventHandler(SuspendHistoryEvent));
                                }
                            }
                        }
                    }
                }
            };
        }
        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();
        }
示例#21
0
        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() },
示例#22
0
        public static List <string> getFTPFileList(string folderName)
        {
            var          result   = new StringBuilder();
            WebResponse  response = null;
            StreamReader reader   = null;

            try
            {
                Console.WriteLine("[" + folderName + "] connecting to ftp://" + GF.Settings("host_url") + "/public_html/fams/" + folderName + "/");
                FtpWebRequest reqFTP;
                reqFTP             = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + GF.Settings("host_url") + "/public_html/fams/" + folderName + "/"));
                reqFTP.UseBinary   = true;
                reqFTP.Credentials = new NetworkCredential("fitanswer", "9OeqLQfnI");
                reqFTP.Method      = WebRequestMethods.Ftp.ListDirectory;
                reqFTP.Proxy       = null;
                reqFTP.KeepAlive   = true;
                reqFTP.UsePassive  = true;
                using (response = reqFTP.GetResponse())
                {
                    using (reader = new StreamReader(response.GetResponseStream()))
                    {
                        string line = reader.ReadLine();
                        while (line != null)
                        {
                            result.Append(line);
                            result.Append('\n');
                            line = reader.ReadLine();
                        }
                        // to remove the trailing '\n'
                        result.Remove(result.ToString().LastIndexOf('\n'), 1);
                        result.Replace("version.txt\n", "");
                        string[] tmp = result.ToString().Split('\n');
                        Console.WriteLine("\r\n[" + folderName + "] ========== FTP FILE ==========");
                        var FTPFiles = new List <string>();
                        foreach (string tmpStr in tmp)
                        {
                            if (tmpStr != "." && tmpStr != "..")
                            {
                                FTPFiles.Add(tmpStr);
                                Console.WriteLine("- " + tmpStr);
                            }
                        }
                        Console.WriteLine("\r\n");
                        return(FTPFiles);
                    }
                }
            }
            catch (Exception ex)
            {
                if (reader != null)
                {
                    reader.Close();
                }
                if (response != null)
                {
                    response.Close();
                }
                Console.WriteLine("[" + folderName + "] [ GET FILE LIST :: ERROR ] >>> " + ex.Message);
                return(null);
            }
        }
示例#23
0
        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();
        }
示例#24
0
        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();
            }
        }
示例#25
0
        private void save_btn_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(hours.Text.Trim()))
            {
                GF.Error("กรุณาระบุ 'จำนวน ชั่วโมง' !!");
                hours.Select();
                return;
            }

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

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

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

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

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

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

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

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

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

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

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

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

            string payment_list = "";

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

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

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

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

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

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

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

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

            Dictionary <string, string> values = new()
            {
                { "branch_id", GF.Settings("branch_id") },
                { "member_id", member_id },
示例#26
0
        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();
        }
示例#27
0
        static void Main()
        {
            try
            {
                waitHandle = new AutoResetEvent(false);
                foreach (Process theProcess in Process.GetProcessesByName("EXCEL"))
                {
                    theProcess.Kill();
                }

                if (Process.GetProcessesByName("FAMS").Length > 1)
                {
                    foreach (Process theProcess in Process.GetProcessesByName("FAMS"))
                    {
                        theProcess.Kill();
                    }
                }

#if !DEBUG
                //if (!IsRunningAsAdministrator()) { Restart(); return; }
#endif

                using (Microsoft.Win32.RegistryKey rkey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Control Panel\International", true))
                {
                    rkey.SetValue("sShortDate", "dd/MM/yyyy");
                    rkey.Close();
                }

                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
                Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
                Application.ApplicationExit += (ss, ee) =>
                {
                    foreach (Process theProcess in Process.GetProcessesByName("EXCEL"))
                    {
                        theProcess.Kill();
                    }

                    foreach (Process theProcess in Process.GetProcessesByName("FAMS"))
                    {
                        theProcess.Kill();
                    }
                };

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                /*GF.Settings("Reset();
                 * GF.Settings("Save();*/

                Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("FAMS_Settings", true);
                if (key == null)
                {
                    key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("FAMS_Settings");
                    key.SetValue("host_url", "fams.fit-answer.com");
                    key.SetValue("branch_id", "");
                    key.SetValue("tmp_path", "C:\\FAMS\\TMP\\");
                    key.SetValue("member_prefix", "");
                    key.SetValue("localCardPath", "C:\\FAMS\\MEMBERCARD\\");
                    key.SetValue("card_printer", "");
                    key.SetValue("receipt_printer", "");
                    key.SetValue("vat", "");
                    key.SetValue("emp_card", "C:\\FAMS\\EMPCARD\\");
                }
                else
                {
                    if (key.GetValue("host_url") == null)
                    {
                        key.SetValue("host_url", "fams.fit-answer.com");
                    }
                    if (key.GetValue("branch_id") == null)
                    {
                        key.SetValue("branch_id", "");
                    }
                    if (key.GetValue("tmp_path") == null)
                    {
                        key.SetValue("tmp_path", "C:\\FAMS\\TMP\\");
                    }
                    if (key.GetValue("member_prefix") == null)
                    {
                        key.SetValue("member_prefix", "");
                    }
                    if (key.GetValue("localCardPath") == null)
                    {
                        key.SetValue("localCardPath", "C:\\FAMS\\MEMBERCARD\\");
                    }
                    if (key.GetValue("card_printer") == null)
                    {
                        key.SetValue("card_printer", "");
                    }
                    if (key.GetValue("receipt_printer") == null)
                    {
                        key.SetValue("receipt_printer", "");
                    }
                    if (key.GetValue("vat") == null)
                    {
                        key.SetValue("vat", "");
                    }
                    if (key.GetValue("emp_card") == null)
                    {
                        key.SetValue("emp_card", "C:\\FAMS\\EMPCARD\\");
                    }
                }

                //key.SetValue("host_url", "fams.topladyshop.net");
                key.SetValue("host_url", "fams.fit-answer.com");

                bool nullConfig = false;
                foreach (string valueName in key.GetValueNames())
                {
                    Console.WriteLine(valueName + " = " + key.GetValue(valueName));
                }

                foreach (string valueName in key.GetValueNames())
                {
                    if (string.IsNullOrEmpty((key.GetValue(valueName) ?? "").ToString()))
                    {
                        nullConfig = true;
                        break;
                    }
                }
                key.Close();
                key.Dispose();

                GF.cultureList = new List <string>();

                CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures);

                foreach (CultureInfo culture in cultures)
                {
                    var region = new RegionInfo(culture.LCID);

                    if (!(GF.cultureList.Contains(region.EnglishName)))
                    {
                        GF.cultureList.Add(region.EnglishName);
                    }
                }

                string tmp_path = GF.Settings("tmp_path");

                if (!Directory.Exists(tmp_path))
                {
                    Directory.CreateDirectory(tmp_path);
                }
                else
                {
                    var di = new DirectoryInfo(tmp_path);

                    foreach (var file in di.GetFiles("*", SearchOption.AllDirectories))
                    {
                        file.Attributes &= ~FileAttributes.ReadOnly;
                    }
                }

                var downloadedMessageInfo = new DirectoryInfo(tmp_path);

                foreach (FileInfo file in downloadedMessageInfo.GetFiles())
                {
                    file.Delete();
                }
                foreach (DirectoryInfo dir in downloadedMessageInfo.GetDirectories())
                {
                    dir.Delete(true);
                }

                GF.CreateDirectoryWithEveryonePermission(tmp_path);

                Thread.CurrentThread.CurrentCulture   = new CultureInfo("en-GB");
                Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-GB");

                if (nullConfig)
                {
                    Console.WriteLine("!! NULL CONFIG !!");
                }
                else
                {
                    Console.WriteLine("^^ HAS CONFIG ^^");
                }

                Global.Capture.StartupCheck();

                if (DB.IsServerAlive())
                {
                    if (DB.IsDBAlive())
                    {
                        if (nullConfig)
                        {
                            Application.Run(new init_config());
                        }
                        else
                        {
                            Application.Run(new Login());
                        }
                    }
                }

                return;
            }
            catch (Win32Exception e)
            {
                GF.printError("********** APPLICATION EXIT WITH CODE (" + e.ErrorCode + ") **********");
                GF.printError(e.Message + "\r\n");

                GF.printError("FILE : " + new StackTrace(e, true).GetFrame(0).GetFileName());
                GF.printError("LINE : " + new StackTrace(e, true).GetFrame(0).GetFileLineNumber());

                GF.printError("STACK-TRACE : \r\n" + e.StackTrace.ToString() + "\r\n");

                if (currentProcess != null)
                {
                    currentProcess.Kill();
                }
                System.Environment.Exit(0);
            }
        }