Example #1
0
        private void UpLoadMulti()
        {
            btn_Browser.Enabled    = false;
            txt_PathFolder.Enabled = false;
            txt_Location.Enabled   = false;
            List <string> lStrBath = new List <string>();

            lStrBath.AddRange(Directory.GetDirectories(txt_PathFolder.Text));
            int    countBatchExists = 0;
            string listBatchExxists = "";

            for (int i = 0; i < lStrBath.Count; i++)
            {
                var batchExists = (from w in Global.db.tbl_Batches where w.fBatchName == new DirectoryInfo(lStrBath[i]).Name select w.fBatchName).ToList();
                if (batchExists.Count > 0)
                {
                    countBatchExists += 1;
                    listBatchExxists += batchExists[0] + "\r\n";
                }
            }
            if (countBatchExists > 0)
            {
                MessageBox.Show("Batch đã tồn tại :\r\n" + listBatchExxists);
                btn_Browser.Enabled    = true;
                txt_PathFolder.Enabled = true;
                txt_Location.Enabled   = true;
                return;
            }
            int n = 0;

            foreach (string itemBatch in lStrBath)
            {
                string batchName = "", loaiPhieu = "", pathPicture = "";
                int    m = 0;
                batchName = new DirectoryInfo(itemBatch).Name;
                if (batchName.IndexOf("AEON", StringComparison.Ordinal) >= 0 || batchName.IndexOf("aeon", StringComparison.Ordinal) >= 0)
                {
                    loaiPhieu = "AEON";
                }
                else if (batchName.IndexOf("ASAHI", StringComparison.Ordinal) >= 0 || batchName.IndexOf("asahi", StringComparison.Ordinal) >= 0)
                {
                    loaiPhieu = "ASAHI";
                }
                else if (batchName.IndexOf("EIZEN", StringComparison.Ordinal) >= 0 || batchName.IndexOf("eizen", StringComparison.Ordinal) >= 0)
                {
                    loaiPhieu = "EIZEN";
                }
                else if (batchName.IndexOf("YAMAMOTO", StringComparison.Ordinal) >= 0 || batchName.IndexOf("yamamoto", StringComparison.Ordinal) >= 0)
                {
                    loaiPhieu = "YAMAMOTO";
                }
                else if (batchName.IndexOf("YASUDA", StringComparison.Ordinal) >= 0 || batchName.IndexOf("yasuda", StringComparison.Ordinal) >= 0)
                {
                    loaiPhieu = "YASUDA";
                }
                else if (batchName.IndexOf("TAIYO", StringComparison.Ordinal) >= 0 || batchName.IndexOf("taiyo", StringComparison.Ordinal) >= 0)
                {
                    loaiPhieu = "TAIYO";
                }
                else
                {
                    continue;
                }

                n += 1;
                lb_SobatchHoanThanh.Text = n + @" :";

                pathPicture = itemBatch + @"\入力画像";
                var fBatch = new tbl_Batch
                {
                    fBatchName   = batchName,
                    fUserCreate  = txt_UserCreate.Text,
                    fDateCreated = DateTime.Now,
                    fPathPicture = pathPicture,
                    fLocation    = txt_Location.Text,
                    fSoLuongAnh  = Directory.GetFiles(pathPicture).Length.ToString(),
                    fLoaiPhieu   = loaiPhieu
                };
                Global.db.tbl_Batches.InsertOnSubmit(fBatch);
                Global.db.SubmitChanges();

                var      filters           = new String[] { "jpg", "jpeg", "png", "gif", "tif", "bmp" };
                string[] pathImageLocation = GetFilesFrom(pathPicture, filters, false);
                string   pathImageServer   = Global.StrPath + "\\" + new DirectoryInfo(itemBatch).Name;
                Directory.CreateDirectory(pathImageServer);
                string imageJPG = "";

                progressBar1.Step    = 1;
                progressBar1.Value   = 1;
                progressBar1.Maximum = pathImageLocation.Length;
                progressBar1.Minimum = 0;
                ModifyProgressBarColor.SetState(progressBar1, 1);

                foreach (string i in pathImageLocation)
                {
                    FileInfo  fi        = new FileInfo(i);
                    tbl_Image tempImage = new tbl_Image
                    {
                        fbatchname    = batchName,
                        idimage       = Path.GetFileName(fi.ToString()),
                        ReadImageDESo = 0,
                        CheckedDESo   = 0,
                        Checked_QC    = 0,
                        TienDoDESO    = "Hình chưa nhập",
                        CheckQC       = false
                    };

                    Global.db.tbl_Images.InsertOnSubmit(tempImage);
                    Global.db.SubmitChanges();
                    //tbl_TienDo tempTblTienDo = new tbl_TienDo
                    //{
                    //    IDProject = "JEMS",
                    //    fBatchName = txt_BatchName.Text,
                    //    Idimage = Path.GetFileName(fi.ToString()),
                    //    TienDoDeSo = "Hình chưa nhập",
                    //    UserCheckDeSo = "",
                    //    DateCreate = DateTime.Now
                    //};
                    //Global.db_BPO.tbl_TienDos.InsertOnSubmit(tempTblTienDo);
                    //Global.db_BPO.SubmitChanges();

                    string des = pathImageServer + @"\" + Path.GetFileName(fi.ToString());
                    fi.CopyTo(des);
                    m += 1;
                    lb_SoImageDaHoanThanh.Text = m + @"/" + pathImageLocation.Length;
                    progressBar1.PerformStep();
                }
            }
            MessageBox.Show(@"Tạo batch mới thành công!");
            txt_BatchName.Text          = "";
            txt_ImagePath.Text          = "";
            lb_SoLuongHinh.Text         = "";
            txt_PathFolder.Text         = "";
            txt_LoaiPhieu.SelectedIndex = 0;

            //btn_CreateBatch.Enabled = true;
            btn_Browser.Enabled    = true;
            txt_PathFolder.Enabled = true;
            txt_Location.Enabled   = true;
        }
Example #2
0
        private void UpLoadSingle()
        {
            progressBar1.Step    = 1;
            progressBar1.Value   = 1;
            progressBar1.Maximum = _lFileNames.Length;
            progressBar1.Minimum = 0;
            ModifyProgressBarColor.SetState(progressBar1, 1);
            var batch = (from w in Global.db.tbl_Batches.Where(w => w.fBatchName == txt_BatchName.Text) select w.fBatchName).FirstOrDefault();

            if (!string.IsNullOrEmpty(txt_ImagePath.Text))
            {
                if (string.IsNullOrEmpty(batch))
                {
                    var fBatch = new tbl_Batch
                    {
                        fBatchName   = txt_BatchName.Text,
                        fUserCreate  = txt_UserCreate.Text,
                        fDateCreated = DateTime.Now,
                        fPathPicture = txt_ImagePath.Text,
                        fLocation    = txt_Location.Text,
                        fSoLuongAnh  = soluonghinh.ToString(),
                        fLoaiPhieu   = txt_LoaiPhieu.Text
                    };
                    Global.db.tbl_Batches.InsertOnSubmit(fBatch);
                    Global.db.SubmitChanges();


                    //DateTime timeStart = new DateTime(dateEdit_ngaybatdau.DateTime.Year,
                    //                            dateEdit_ngaybatdau.DateTime.Month,
                    //                            dateEdit_ngaybatdau.DateTime.Day,
                    //                            timeEdit_ngaybatdau.Time.Hour,
                    //                            timeEdit_ngaybatdau.Time.Minute,
                    //                            timeEdit_ngaybatdau.Time.Second);
                    //DateTime timeEnd = new DateTime(dateEdit_ngayketthuc.DateTime.Year,
                    //                                    dateEdit_ngayketthuc.DateTime.Month,
                    //                                    dateEdit_ngayketthuc.DateTime.Day,
                    //                                    timeEdit_ngayketthuc.Time.Hour,
                    //                                    timeEdit_ngayketthuc.Time.Minute,
                    //                                    timeEdit_ngayketthuc.Time.Second);
                    //int timeNotificationdeadline = 0;
                    //if (cbb_loaithoigian.Text == "Ngày")
                    //{
                    //    timeNotificationdeadline = Convert.ToInt32(nud_thoigiandeadline.Value * 24 * 60);
                    //}
                    //else if (cbb_loaithoigian.Text == "Giờ")
                    //{
                    //    timeNotificationdeadline = Convert.ToInt32(nud_thoigiandeadline.Value * 60);
                    //}
                    //else if (cbb_loaithoigian.Text == "Phút")
                    //{
                    //    timeNotificationdeadline = Convert.ToInt32(nud_thoigiandeadline.Value);
                    //}
                    //var fBatchEntry = new tbl_Batch_Entry()
                    //{
                    //    fIDProject = Global.StrIdProject,
                    //    fBatchName = txt_BatchName.Text,
                    //    fUserCreate = txt_UserCreate.Text,
                    //    fDateCreated = DateTime.Now,
                    //    fPathPicture = txt_ImagePath.Text,
                    //    fLocation = txt_Location.Text,
                    //    fSoLuongAnh = soluonghinh.ToString(),
                    //    fLoaiPhieu = txt_LoaiPhieu.Text,
                    //    fTimeStart = timeStart,
                    //    fTimeEnd = timeEnd,
                    //    fDeadlineNotificationTime = timeNotificationdeadline
                    //};
                    //Global.db_BPO.tbl_Batch_Entries.InsertOnSubmit(fBatchEntry);
                    //Global.db.SubmitChanges();
                }
                else
                {
                    MessageBox.Show("Batch đã tồn tại vui lòng điền tên batch khác!");
                    return;
                }
            }
            else
            {
                MessageBox.Show("Bạn chưa chọn hình ảnh!");
                return;
            }
            string temp = Global.StrPath + "\\" + txt_BatchName.Text;

            if (!Directory.Exists(temp))
            {
                Directory.CreateDirectory(temp);
            }
            else
            {
                MessageBox.Show("Bị trùng tên batch!");
                return;
            }
            foreach (string i in _lFileNames)
            {
                FileInfo  fi        = new FileInfo(i);
                tbl_Image tempImage = new tbl_Image
                {
                    fbatchname    = txt_BatchName.Text,
                    idimage       = Path.GetFileName(fi.ToString()),
                    ReadImageDESo = 0,
                    CheckedDESo   = 0,
                    Checked_QC    = 0,
                    TienDoDESO    = "Hình chưa nhập",
                    CheckQC       = false
                };
                Global.db.tbl_Images.InsertOnSubmit(tempImage);
                Global.db.SubmitChanges();

                tbl_TienDo tempTblTienDo = new tbl_TienDo
                {
                    IDProject     = "JEMS",
                    fBatchName    = txt_BatchName.Text,
                    Idimage       = Path.GetFileName(fi.ToString()),
                    TienDoDeSo    = "Hình chưa nhập",
                    UserCheckDeSo = "",
                    DateCreate    = DateTime.Now
                };
                Global.db_BPO.tbl_TienDos.InsertOnSubmit(tempTblTienDo);
                Global.db_BPO.SubmitChanges();

                string des = temp + @"\" + Path.GetFileName(fi.ToString());
                fi.CopyTo(des);
                progressBar1.PerformStep();
            }
            MessageBox.Show("Tạo batch mới thành công!");
            txt_BatchName.Text          = "";
            txt_ImagePath.Text          = "";
            lb_SoLuongHinh.Text         = "";
            txt_LoaiPhieu.SelectedIndex = 0;
        }