private void frm_DrawHide_Load(object sender, EventArgs e)
        {
            var ListToaDo = (from w in Global.Db.GetToaDo(fbatchname + "") select w).ToList();

            for (int i = 0; i < ListToaDo.Count; i++)
            {
                point_rectangle a = new point_rectangle
                {
                    _x1 = int.Parse(ListToaDo[i].x1 + ""),
                    _x2 = int.Parse(ListToaDo[i].x2 + ""),
                    _y1 = int.Parse(ListToaDo[i].y1 + ""),
                    _y2 = int.Parse(ListToaDo[i].y2 + "")
                };
                pr1.Add(a);
                pr.Add(a);
            }
        }
        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
        {
            try
            {
                if (pictureBox1.Image == null)
                {
                    MessageBox.Show("Bạn chưa chọn hình ảnh");
                    return;
                }
                x2 = e.Location.X;
                y2 = e.Location.Y;

                shiftSelecting = false;
                point_rectangle a = new point_rectangle
                {
                    _x1 = x1,
                    _x2 = x2,
                    _y1 = y1,
                    _y2 = y2
                };
                pr.Add(a);

                for (int i = 0; i < pr.Count; i++)
                {
                    int temp_x1 = 0, temp_y1 = 0, temp_x2 = 0, temp_y2 = 0;
                    if (pr[i]._x2 < pr[i]._x1)
                    {
                        temp_x1 = pr[i]._x2;
                        temp_x2 = pr[i]._x1;
                    }
                    else
                    {
                        temp_x1 = pr[i]._x1;

                        temp_x2 = pr[i]._x2;
                    }
                    if (pr[i]._y2 < pr[i]._y1)
                    {
                        temp_y1 = pr[i]._y2;
                        temp_y2 = pr[i]._y1;
                    }
                    else
                    {
                        temp_y1 = pr[i]._y1;
                        temp_y2 = pr[i]._y2;
                    }
                    Bitmap bmap   = new Bitmap(pictureBox1.Image);
                    Bitmap newmap = bmap.Clone(new Rectangle(0, 0, bmap.Width, bmap.Height), System.Drawing.Imaging.PixelFormat.DontCare);

                    Graphics g1 = Graphics.FromImage(newmap);
                    g1.FillRectangle(Brushes.WhiteSmoke, new Rectangle(temp_x1, temp_y1, temp_x2 - temp_x1, temp_y2 - temp_y1));
                    pictureBox1.Image = null;
                    pictureBox1.Image = newmap;
                }
            }
            catch (Exception)
            {
                pr.Clear();
                Global.Db.Xoa_drawhide(fbatchname);
                pictureBox1.Image = null;
            }
        }
        private void btn_TaoBatch_Click(object sender, EventArgs e)
        {
            if (rdo_Server.Checked)
            {
                //Global.StrPath = @"E:\test";
                Global.StrPath = @"E:\WebservicesBPO\PhieuKiemDinh";
            }
            else if (rdo_Client.Checked)
            {
                Global.StrPath = @"\\10.10.10.248\phieukiemdinh$";
            }

            if (backgroundWorker1.IsBusy)
            {
                MessageBox.Show("Quá trình tạo batch đang diễn ra, Bạn hãy chờ quá trình tạo batch kết thúc mới tiếp tục tạo batch mới !");
                return;
            }
            if (!Directory.Exists(Global.StrPath))
            {
                MessageBox.Show("Không thể mở thư mục lưu trữ hình ảnh.\r\nBạn hãy kiểm tra lại tài khoản đăng nhập hoặc kết nối internet");
                return;
            }
            else
            {
                try
                {
                    string path = Global.StrPath + @"\MyTest.txt";
                    using (StreamWriter sw = File.CreateText(path))
                    {
                        sw.WriteLine("Hello");
                        sw.WriteLine("And");
                        sw.WriteLine("Welcome");
                    }
                    File.Delete(path);
                }
                catch { MessageBox.Show("Bạn chưa được cấp quyền để tạo thư mục lưu trữ hình ảnh."); }
            }
            if (string.IsNullOrEmpty(txt_fBatchName.Text) && string.IsNullOrEmpty(txt_folder_Multiline.Text))
            {
                MessageBox.Show("Hãy nhập tên batch hoặc chọn folder hình ảnh !");
                return;
            }
            if (string.IsNullOrEmpty(txt_ImagePath.Text) && !string.IsNullOrEmpty(txt_fBatchName.Text))
            {
                MessageBox.Show("Chưa chọn hình ảnh!");
                return;
            }
            if (string.IsNullOrEmpty(comboBox1.Text))
            {
                MessageBox.Show("Bạn chưa chọn tọa độ !");
                return;
            }
            string temp = Global.StrPath + "\\" + txt_fBatchName.Text;

            if (Directory.Exists(temp) && !string.IsNullOrEmpty(txt_fBatchName.Text))
            {
                MessageBox.Show("Thư mục đã tồn tại!");
                Process.Start(Global.StrPath);
                return;
            }
            if (!Directory.Exists(temp) & !string.IsNullOrEmpty(txt_fBatchName.Text))
            {
                Directory.CreateDirectory(temp);
            }
            TimeBeginCreateBatch          = DateTime.Now;
            txt_fBatchName.ReadOnly       = true;
            txt_ImagePath.ReadOnly        = true;
            txt_folder_Multiline.ReadOnly = true;
            btn_Browser.Enabled           = false;
            comboBox1.Enabled             = false;
            btn_ChonAnh.Enabled           = false;
            btn_drawhide.Enabled          = false;
            btn_ShowPoint.Enabled         = false;
            lb_SobatchHoanThanh.Text      = "";
            lb_SoBatch.Text = "";
            var ListToaDo = (from w in Global.Db.GetToaDo(comboBox1.Text + "") select w).ToList();

            for (int i = 0; i < ListToaDo.Count; i++)
            {
                point_rectangle a = new point_rectangle
                {
                    _x1 = int.Parse(ListToaDo[i].x1 + ""),
                    _x2 = int.Parse(ListToaDo[i].x2 + ""),
                    _y1 = int.Parse(ListToaDo[i].y1 + ""),
                    _y2 = int.Parse(ListToaDo[i].y2 + "")
                };
                pr.Add(a);
            }
            multiline = -1;
            if (!string.IsNullOrEmpty(txt_fBatchName.Text) & string.IsNullOrEmpty(txt_folder_Multiline.Text))
            {
                multiline = 0;
            }
            else if (string.IsNullOrEmpty(txt_fBatchName.Text) & !string.IsNullOrEmpty(txt_folder_Multiline.Text))
            {
                multiline = 1;
            }
            soluonganh     = 0;
            timer1.Enabled = true;

            backgroundWorker1.RunWorkerAsync();
        }