public ActionResult TestKayit(FormCollection form, HttpPostedFileBase[] TestImage)
        {
            tbl_Test test = new tbl_Test();

            test.Test_Detay   = form["UygulamaAdi"];
            test.Kategori_ID  = int.Parse(form["kategori"].ToString());
            test.Test_Tarihi  = DateTime.Today;
            test.Sonuc_ID     = int.Parse(form["testsonuc"].ToString());
            test.UygulamaAdi  = form["UygulamaAdi"];
            test.Kullanici_ID = int.Parse(Session["UserID"].ToString());
            db.tbl_Test.Add(test);
            db.SaveChanges();


            if (TestImage != null)
            {
                tbl_Image testImage = new tbl_Image();
                foreach (var item in TestImage)
                {
                    string yol        = System.IO.Path.GetFileName(item.FileName);
                    string fileadress = Server.MapPath("~/Images/" + yol);
                    item.SaveAs(fileadress);
                    testImage.Image = (yol);


                    db.tbl_Image.Add(testImage);
                    db.SaveChanges();
                }
            }
            return(RedirectToAction("Home", "Default"));
        }
        public ActionResult Index(HttpPostedFileBase uploadfile)
        {
            UploadResponse response = new UploadResponse();

            if (uploadfile != null && uploadfile.ContentLength > 0)
            {
                ImageHandlerDBEntities db = new ImageHandlerDBEntities();
                tbl_Image img             = new tbl_Image();
                img.CreateDate = DateTime.Now;
                img.ImageId    = Guid.NewGuid();
                img.ImageName  = uploadfile.FileName;
                img.ImageType  = uploadfile.ContentType;
                using (BinaryReader br = new BinaryReader(uploadfile.InputStream))
                {
                    img.ImageData = br.ReadBytes((int)uploadfile.InputStream.Length);
                }
                db.tbl_Image.Add(img);
                db.SaveChanges();
                response.CreateDate = img.CreateDate;
                response.ImageId    = img.ImageId;
                response.ImageType  = img.ImageType;
                response.ImageName  = img.ImageName;
            }
            return(View(response));
        }
Example #3
0
        public static tbl_Image Map(Image img)
        {
            tbl_Image ret = new tbl_Image();

            ret.Active           = img.Active;
            ret.Category         = img.Category;
            ret.CreationTime     = img.CreationTime;
            ret.Description      = img.Description;
            ret.ID               = img.ID;
            ret.OwnerID          = img.OwnerID;
            ret.OwnerType        = Convert.ToInt32(img.OwnerType);
            ret.Title            = img.Title;
            ret.URL              = img.URL;
            ret.BackupOf         = img.BackupOf;
            ret.Extension        = img.GetExtension();
            ret.Height           = img.Height;
            ret.Name             = img.Name;
            ret.ResizeForDevices = img.ResizeForDevices;
            ret.ResizeOf         = img.ResizeOf;
            ret.TargetDevice     = img.TargetDevice;
            ret.ResizeDevice     = img.ResizeDevice;
            ret.Width            = img.Width;
            if (ret.ResizeDevice <= 0)
            {
                ret.ResizeDevice = null;                        //to prevent FOREIGN constraint conflicts
            }
            if (ret.TargetDevice <= 0)
            {
                ret.TargetDevice = null;
            }
            return(ret);
        }
Example #4
0
        public async Task <IHttpActionResult> Puttbl_Image(int id, tbl_Image tbl_Image)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tbl_Image.fld_Image_ID)
            {
                return(BadRequest());
            }

            db.Entry(tbl_Image).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!tbl_ImageExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #5
0
        public void ProcessRequest(HttpContext context)
        {
            string   filename     = context.Request.QueryString["filename"].ToString();
            int      Mag_ID       = int.Parse(context.Request.QueryString["Mag_id"].ToString());
            string   Mag_Issue    = context.Request.QueryString["Mag_Issue"].ToString();
            string   Shoot        = context.Request.QueryString["Shoot"].ToString();
            DateTime ShootDate    = DateTime.Parse(context.Request.QueryString["ShootDate"].ToString());
            string   keywords     = context.Request.QueryString["keywords"].ToString();
            string   description  = context.Request.QueryString["description"].ToString();
            string   photographer = context.Request.QueryString["photographer"].ToString();

            using (FileStream fs = File.Create(HttpContext.Current.Server.MapPath("~/photos/" + filename)))
            {
                SaveFile(context.Request.InputStream, fs);
            }

            IImageRepository db       = new ImageRepository();
            IUserRepository  userdb   = new UserRepository();
            tbl_Image        newImage = new tbl_Image();

            newImage.date_uploaded     = DateTime.Now;
            newImage.magazine_id       = Mag_ID;
            newImage.magazine_issue    = Mag_Issue;
            newImage.shoot_description = Shoot;
            newImage.shoot_date        = ShootDate;
            newImage.keywords          = keywords;
            newImage.description       = description;
            newImage.photographer      = userdb.getUserbyUsername(photographer).id;
            newImage.date_updated      = DateTime.Now;


            db.Add(newImage);
            db.Save();
        }
Example #6
0
        public void SLUpload()
        {
            //Get all Values from Request
            string   filename     = HttpContext.Request.QueryString["filename"].ToString();
            int      Mag_ID       = int.Parse(HttpContext.Request.QueryString["Mag_id"].ToString());
            string   Mag_Issue    = HttpContext.Request.QueryString["Mag_Issue"].ToString();
            string   Shoot        = HttpContext.Request.QueryString["Shoot"].ToString();
            DateTime ShootDate    = DateTime.Parse(HttpContext.Request.QueryString["ShootDate"].ToString());
            string   keywords     = HttpContext.Request.QueryString["keywords"].ToString();
            string   description  = HttpContext.Request.QueryString["description"].ToString();
            string   photographer = HttpContext.Request.QueryString["photographer"].ToString();

            //Save image as tempImage in "photos" folder
            string tempFileName = System.Guid.NewGuid().ToString("N") + ".jpg";

            using (FileStream fs = System.IO.File.Create(HttpContext.Server.MapPath("~/photos/" + tempFileName)))
            {
                SaveFile(HttpContext.Request.InputStream, fs);
            }

            //Save image details to database
            tbl_Image newImage = new tbl_Image();

            newImage.date_uploaded     = DateTime.Now;
            newImage.magazine_id       = Mag_ID;
            newImage.magazine_issue    = Mag_Issue;
            newImage.shoot_description = Shoot;
            newImage.shoot_date        = ShootDate;
            newImage.keywords          = keywords;
            newImage.description       = description;
            newImage.photographer      = userdb.getUserbyUsername(photographer).id;
            newImage.date_updated      = DateTime.Now;
            newImage.name = tempFileName;
            imagedb.Add(newImage);
            imagedb.Save();


            //Create Thumbnail and Preview and Delete Temp
            string oldName = newImage.name;

            newImage.name = newImage.tbl_publication.name.Replace(' ', '_') +
                            "_" +
                            newImage.magazine_issue.Replace(' ', '_') +
                            "_" +
                            ((DateTime)newImage.shoot_date).ToString("dd_MMM_yyyy") +
                            "_" +
                            newImage.id.ToString() + ".jpg";
            newImage.preview_location = "pv_" + newImage.name;
            newImage.thumb_location   = "th_" + newImage.name;

            CreateThumbAndPreview("~/photos", oldName, newImage.name);

            DeleteCurrentFile("~/photos", oldName);
            imagedb.Save();
        }
Example #7
0
        public async Task <IHttpActionResult> Gettbl_Image(int id)
        {
            tbl_Image tbl_Image = await db.tbl_Image.FindAsync(id);

            if (tbl_Image == null)
            {
                return(NotFound());
            }

            return(Ok(tbl_Image));
        }
Example #8
0
        public void createBatch(string location)
        {
            string batchName = new DirectoryInfo(location).Name;
            var    fBatch    = new tbl_Batch
            {
                fBatchName   = batchName,
                fusercreate  = txt_UserCreate.Text,
                fdatecreated = DateTime.Now,
                fPathPicture = location,
                fLocation    = txt_Location.Text + "\\" + batchName + "\\",
                fSoLuongAnh  = Directory.GetFiles(location).Length.ToString(),
                LoaiBatch    = "Getsu"
            };

            Global.Db.tbl_Batches.InsertOnSubmit(fBatch);
            Global.Db.SubmitChanges();

            string searchFolder = txt_PathFolder.Text + "\\" + new DirectoryInfo(location).Name;
            var    filters      = new String[] { "jpg", "jpeg", "png", "gif", "tiff", "bmp" };

            string[] tmp  = GetFilesFrom(searchFolder, filters, false);
            string   temp = Global.StrPath + "\\" + batchName;

            Directory.CreateDirectory(temp);
            string imageJPG = "";

            var filters1 = new String[] { "jpg", "jpeg", "png", "gif", "tiff", "bmp" };

            string[] tmp1 = GetFilesFrom(location, filters1, false);
            foreach (string s in tmp1)
            {
                FileInfo  fi        = new FileInfo(location);
                tbl_Image tempImage = new tbl_Image
                {
                    fbatchname            = batchName,
                    idimage               = Path.GetFileName(fi.ToString()),
                    ReadImageDESo         = 0,
                    CheckedDESo           = 0,
                    TienDoDESO            = "Hình chưa nhập",
                    ReadImageDESO_Good    = 1,
                    ReadImageDESO_NotGood = 1
                };
                Global.Db.tbl_Images.InsertOnSubmit(tempImage);
                Global.Db.SubmitChanges();
                string des = location + @"\" + Path.GetFileName(fi.ToString());
                fi.CopyTo(des);
                progressBarControl1.PerformStep();
                progressBarControl1.Update();
            }
        }
Example #9
0
        public async Task <IHttpActionResult> Deletetbl_Image(int id)
        {
            tbl_Image tbl_Image = await db.tbl_Image.FindAsync(id);

            if (tbl_Image == null)
            {
                return(NotFound());
            }

            db.tbl_Image.Remove(tbl_Image);
            await db.SaveChangesAsync();

            return(Ok(tbl_Image));
        }
Example #10
0
        public ActionResult Create2([Bind(Exclude = "id")] tbl_Image myImage)
        {
            ViewData["Magazines"] = new SelectList(magdb.GetMagazines(), "id", "name");
            ViewData["Users"]     = new SelectList(userdb.GetUsers(), "id", "username", userdb.getUserbyUsername(HttpContext.User.Identity.Name.ToString()).id);

            HttpPostedFileBase hpf          = Request.Files["FileUp"] as HttpPostedFileBase;
            string             tempFileName = System.Guid.NewGuid().ToString("N") + ".jpg";
            string             filePath     = "";

            #region Validation
            if (hpf.ContentLength > 0)
            {
                filePath = Path.Combine(HttpContext.Server.MapPath("~/Photos"), Path.GetFileName(tempFileName));
                hpf.SaveAs(filePath);
            }

            #endregion


            myImage.date_uploaded = DateTime.Now;
            myImage.date_updated  = DateTime.Now;
            imagedb.Add(myImage);
            imagedb.Save();

            string oldName = tempFileName;
            myImage.name = myImage.tbl_publication.name.Replace(' ', '_') +
                           "_" +
                           myImage.magazine_issue.Replace(' ', '_') +
                           "_" +
                           ((DateTime)myImage.shoot_date).ToString("dd_MMM_yyyy") +
                           "_" +
                           myImage.id.ToString() + ".jpg";
            myImage.preview_location = "pv_" + myImage.name;
            myImage.thumb_location   = "th_" + myImage.name;

            CreateThumbAndPreview("~/photos", oldName, myImage.name);

            DeleteCurrentFile("~/photos", oldName);
            imagedb.Save();

            if (Request.Form["Create"] != null)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("Create2"));
            }
        }
Example #11
0
 public ActionResult Delete(int id)
 {
     try
     {
         tbl_Image dbItem = imagedb.GetImageByID(id);
         string    name   = dbItem.name;
         imagedb.Delete(dbItem);
         imagedb.Save();
         DeleteCurrentFile("~/photos/thumb", "th_" + name);
         DeleteCurrentFile("~/photos/preview", "pv_" + name);
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         return(RedirectToAction("Details", new { id = id, Error = "Error deleting Image!" }));
     }
 }
Example #12
0
        //  [Authorize(Roles = "Admin")]
        public ActionResult Edit(int id, string Error)
        {
            ViewData["Magazines"] = new SelectList(magdb.GetMagazines(), "id", "name");
            ViewData["Users"]     = new SelectList(userdb.GetUsers(), "id", "username", userdb.getUserbyUsername(HttpContext.User.Identity.Name.ToString()).id);
            tbl_Image myImage    = imagedb.GetImageByID(id);
            string    UploadedBy = myImage.tbl_user.UserName.ToUpper();

            ViewData["UploadedBy"] = UploadedBy;

            try
            {
                ViewData["Error"] = Error;
                return(View(myImage));
            }
            catch
            {
                return(RedirectToAction("Index"));
            }
        }
Example #13
0
 public Image Map(tbl_Image img)
 {
     this.CreationTime     = Convert.ToDateTime(img.CreationTime);
     this.Description      = img.Description;
     this.ID               = Convert.ToInt64(img.ID);
     this.OwnerID          = Convert.ToInt64(img.OwnerID);
     this.OwnerType        = Convert.ToInt32(img.OwnerType);
     this.URL              = img.URL;
     this.Active           = Convert.ToBoolean(img.Active);
     this.Category         = img.Category;
     this.Title            = img.Title;
     this.BackupOf         = img.BackupOf;
     this.Extension        = img.Extension;
     this.Height           = img.Height;
     this.Name             = img.Name;
     this.ResizeForDevices = img.ResizeForDevices;
     this.ResizeOf         = img.ResizeOf;
     this.TargetDevice     = Convert.ToInt32(img.TargetDevice);
     this.ResizeDevice     = Convert.ToInt32(img.ResizeDevice);
     this.Width            = img.Width;
     return(this);
 }
Example #14
0
        public ActionResult AddNewHouse(FormCollection fc)
        {
            string sEmail = fc["txtEmailAdmin"].ToString().Trim();

            string sPrice = fc["txtPrice"].ToString().Trim();
            float  Price  = float.Parse(sPrice);

            string sRoomNumber = fc["txtRoomNumber"].ToString().Trim();
            int    RoomNumber  = int.Parse(sRoomNumber);

            string sAcreage = fc["txtAcreage"].ToString().Trim();
            float  Acreage  = float.Parse(sAcreage);

            string sFloor = fc["txtFloor"].ToString().Trim();
            int    Floor  = int.Parse(sFloor);

            string sHouseNumber = fc["txtHouseNumber"].ToString().Trim();

            string sHouseStreet = fc["txtHouseStreet"].ToString().Trim();

            var sFurniture = fc["cbFurniture"];

            var sRentStatus = fc["cbRentStatus"];

            string sOrderDetails = fc["txtOrderDetails"].ToString().Trim();

            string sAreaID = fc["areaID"].ToString().Trim();
            int    AreaID  = int.Parse(sAreaID);

            string surl1 = fc["Image1"].ToString();
            string surl2 = fc["Image2"].ToString();
            string surl3 = fc["Image3"].ToString();

            tbl_House house = new tbl_House();

            house.emailAdmin = sEmail;
            house.price      = Price;
            house.roomNumber = RoomNumber;

            if (sFurniture != null)
            {
                house.furniture = true;
            }
            else
            {
                house.furniture = false;
            }

            house.acreage = Acreage;
            house.floor   = Floor;

            if (sRentStatus != null)
            {
                house.rentStatus = true;
            }
            else
            {
                house.rentStatus = false;
            }

            house.areaID       = AreaID;
            house.houseNumber  = sHouseNumber;
            house.houseStreet  = sHouseStreet;
            house.otherDetails = sOrderDetails;

            db.tbl_House.Add(house);
            db.SaveChanges();

            //lấy nhà vừa được thêm
            List <tbl_House> listHouseAdded = db.tbl_House.Where(n => n.emailAdmin == house.emailAdmin &&
                                                                 n.price == house.price && n.roomNumber == house.roomNumber && n.furniture == house.furniture &&
                                                                 n.acreage == house.acreage && n.floor == house.floor && n.rentStatus == house.rentStatus &&
                                                                 n.areaID == house.areaID && n.houseNumber == house.houseNumber && n.houseStreet == house.houseStreet &&
                                                                 n.otherDetails == house.otherDetails).ToList();

            tbl_House houseAdded = (tbl_House)listHouseAdded[listHouseAdded.Count - 1];

            tbl_Image image = new tbl_Image();

            image.houseID = houseAdded.houseID;
            image.url     = surl1;
            db.tbl_Image.Add(image);
            db.SaveChanges();

            image.url = surl2;
            db.tbl_Image.Add(image);
            db.SaveChanges();

            image.url = surl3;
            db.tbl_Image.Add(image);
            db.SaveChanges();


            return(RedirectToAction("GetListHouseByAdmin", "Login"));
        }
Example #15
0
 public void Add(tbl_Image image)
 {
     db.tbl_Images.InsertOnSubmit(image);
 }
Example #16
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 #17
0
        public void createBatch(string location, string server, string batch, string excellocation)
        {
            string batchName = new DirectoryInfo(location).Name;
            var    fBatch    = new tbl_Batch
            {
                fBatchName    = batch,
                fusercreate   = txt_UserCreate.Text,
                fdatecreated  = DateTime.Now,
                fPathPicture  = location,
                fLocation     = excellocation,
                fSoLuongAnh   = Directory.GetFiles(location).Length.ToString(),
                LoaiBatch     = "Getsu",
                ChiaUser      = ck_ChiaUser.Checked,
                CongKhaiBatch = false
            };

            Global.Db.tbl_Batches.InsertOnSubmit(fBatch);
            Global.Db.SubmitChanges();
            string imageJPG = "";

            var filters1 = new String[] { "jpg", "jpeg", "png", "gif", "tiff", "bmp" };

            string[] tmp1 = GetFilesFrom(location, filters1, false);
            progressBarControl1.EditValue              = 0;
            progressBarControl1.Properties.Step        = 1;
            progressBarControl1.Properties.PercentView = true;
            progressBarControl1.Properties.Maximum     = tmp1.Length;
            progressBarControl1.Properties.Minimum     = 0;
            foreach (string s in tmp1)
            {
                FileInfo fi = new FileInfo(s);
                if (ck_ChiaUser.Checked)
                {
                    tbl_Image tempImage = new tbl_Image
                    {
                        fbatchname            = batch,
                        idimage               = Path.GetFileName(fi.ToString()),
                        ReadImageDESo         = 0,
                        CheckedDESo           = 0,
                        TienDoDESO            = "Hình chưa nhập",
                        ReadImageDESO_Good    = 0,
                        ReadImageDESO_NotGood = 0
                    };
                    Global.Db.tbl_Images.InsertOnSubmit(tempImage);
                    Global.Db.SubmitChanges();
                }
                else
                {
                    tbl_Image tempImage = new tbl_Image
                    {
                        fbatchname            = batch,
                        idimage               = Path.GetFileName(fi.ToString()),
                        ReadImageDESo         = 0,
                        CheckedDESo           = 0,
                        TienDoDESO            = "Hình chưa nhập",
                        ReadImageDESO_Good    = 1,
                        ReadImageDESO_NotGood = 1
                    };
                    Global.Db.tbl_Images.InsertOnSubmit(tempImage);
                    Global.Db.SubmitChanges();
                }
                string des = server + @"\" + Path.GetFileName(fi.ToString());
                fi.CopyTo(des);
                progressBarControl1.PerformStep();
                progressBarControl1.Update();
            }
        }
Example #18
0
 public void Delete(tbl_Image image)
 {
     db.tbl_Images.DeleteOnSubmit(image);
 }
Example #19
0
        private void UpLoadSingle()
        {
            progressBarControl1.EditValue              = 0;
            progressBarControl1.Properties.Step        = 1;
            progressBarControl1.Properties.PercentView = true;
            progressBarControl1.Properties.Maximum     = _lFileNames.Length;
            progressBarControl1.Properties.Minimum     = 0;
            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(),
                        LoaiBatch    = rg_LoaiBatch.Properties.Items[rg_LoaiBatch.SelectedIndex].Description
                    };
                    Global.db.tbl_Batches.InsertOnSubmit(fBatch);
                    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,
                    TienDoDESO            = "Hình chưa nhập",
                    ReadImageDESO_Good    = 1,
                    ReadImageDESO_NotGood = 1
                };
                Global.db.tbl_Images.InsertOnSubmit(tempImage);
                Global.db.SubmitChanges();


                string des = temp + @"\" + Path.GetFileName(fi.ToString());
                fi.CopyTo(des);
                progressBarControl1.PerformStep();
                progressBarControl1.Update();
            }
            MessageBox.Show("Tạo batch mới thành công!");
            progressBarControl1.EditValue = 0;
            txt_BatchName.Text            = "";
            txt_ImagePath.Text            = "";
            lb_SoLuongHinh.Text           = "";
        }
Example #20
0
        private void saveImage(ref tbl_Image myImage)
        {
            string oldName = myImage.name;

            myImage.name = myImage.tbl_publication.name.Replace(' ', '_') +
                           "_" +
                           myImage.magazine_issue.Replace(' ', '_') +
                           "_" +
                           ((DateTime)myImage.shoot_date).ToString("dd_MMM_yyyy") +
                           "_" +
                           myImage.id.ToString() + ".jpg";
            myImage.preview_location = "pv_" + myImage.name;
            myImage.thumb_location   = "th_" + myImage.name;
            try
            {
                using (System.Drawing.Image image = System.Drawing.Image.FromFile(Path.Combine(HttpContext.Server.MapPath("~/photos"), Path.GetFileName(oldName))))
                {
                    var fileWidth  = image.Width;
                    var fileHeight = image.Height;

                    //Create Thumbnail
                    int ThumbHeight = 110;
                    int ThumbWidth  = 110;

                    if (fileWidth > fileHeight)
                    {
                        ThumbHeight = imagedb.GetProportionalImageHeight(ThumbWidth, fileHeight, fileWidth);
                    }
                    else if (fileWidth < fileHeight)
                    {
                        ThumbWidth = imagedb.GetProportionalImageWidth(ThumbHeight, fileWidth, fileHeight);
                    }

                    using (Bitmap bitmapThumb = new Bitmap(image, ThumbWidth, ThumbHeight))
                    {
                        bitmapThumb.Save(Server.MapPath("~/photos/thumb/" + myImage.thumb_location), image.RawFormat);
                    }

                    //Create Preview
                    int destinationHeight = 380;
                    int destinationWidth  = 380;

                    if (fileWidth > fileHeight)
                    {
                        destinationHeight = imagedb.GetProportionalImageHeight(destinationWidth, fileWidth, fileWidth);
                    }
                    else if (fileWidth < fileHeight)
                    {
                        destinationWidth = imagedb.GetProportionalImageWidth(destinationHeight, fileWidth, fileHeight);
                    }



                    using (Bitmap bitmapPreview = new Bitmap(image, destinationWidth, destinationHeight))
                    {
                        Graphics g         = Graphics.FromImage(bitmapPreview);
                        Color    WaterMark = Color.FromArgb(80, Color.Gray);
                        Pen      p         = new Pen(WaterMark, 5);
                        g.DrawString("ImageBank Preview", new Font("Arial", 15), new SolidBrush(Color.DarkGray), new Point((bitmapPreview.Size.Width / 2) - 85, (bitmapPreview.Size.Height / 2) - 10));
                        g.DrawLine(p, new Point(0, 0), new Point((bitmapPreview.Size.Width / 2) - 50, (bitmapPreview.Size.Height / 2) - 50));
                        g.DrawLine(p, new Point((bitmapPreview.Size.Width / 2) + 50, (bitmapPreview.Size.Height / 2) + 50), new Point(bitmapPreview.Size.Width, bitmapPreview.Size.Height));
                        g.DrawLine(p, new Point((bitmapPreview.Size.Width / 2) - 50, (bitmapPreview.Size.Height / 2) + 50), new Point(0, bitmapPreview.Size.Height));
                        g.DrawLine(p, new Point((bitmapPreview.Size.Width / 2) + 50, (bitmapPreview.Size.Height / 2) - 50), new Point(bitmapPreview.Size.Width, 0));
                        bitmapPreview.Save(Server.MapPath("~/photos/preview/" + myImage.preview_location), image.RawFormat);
                    }
                }
                DeleteCurrentFile("~/photos", oldName);
            }
            catch (Exception ex)
            {
                throw new Exception("Error: " + ex.Message);
            }
        }
Example #21
0
        public ActionResult Edit(tbl_Image postedmImage)
        {
            var returnUrl = Request["hdnReturnurl"];
            //Get image from the database
            tbl_Image myImage = imagedb.GetImageByID(postedmImage.id);

            //Get collections for dropdowns
            ViewData["Magazines"] = new SelectList(magdb.GetMagazines(), "id", "name");
            ViewData["Users"]     = new SelectList(userdb.GetUsers(), "id", "username", userdb.getUserbyUsername(HttpContext.User.Identity.Name.ToString()).id);


            #region Validation of Input fields
            HttpPostedFileBase hpf = Request.Files["FileUp"] as HttpPostedFileBase;
            if (hpf.ContentLength > 0)
            {
                //Save updated file in photos folder as temp file
                if (hpf.ContentType != "image/jpeg")
                {
                    ModelState.AddModelError("", "Wrong File Type");
                }
            }

            if (postedmImage.magazine_issue.Trim().Length == 0)
            {
                ModelState.AddModelError("magazine_issue", "Magazine issue missing");
            }
            if (postedmImage.shoot_description.Trim().Length == 0)
            {
                ModelState.AddModelError("shoot_description", "Shoot description missing");
            }
            try { DateTime testDate = (DateTime)postedmImage.shoot_date.Value; }
            catch { ModelState.AddModelError("shoot_date", "Invalid Shoot Date"); }
            if (postedmImage.description.Trim().Length == 0)
            {
                ModelState.AddModelError("description", "Description issue missing");
            }
            if (postedmImage.keywords.Trim().Length == 0)
            {
                ModelState.AddModelError("keywords", "Keywords issue missing");
            }

            if (!ModelState.IsValid)
            {
                return(View(postedmImage));
            }
            #endregion

            //if validation is OK then execute the following

            string tempFileName = System.Guid.NewGuid().ToString("N") + ".jpg";
            if (hpf.ContentLength > 0)
            {
                //Save updated file in photos folder as temp file
                string filePath = "";
                filePath = Path.Combine(HttpContext.Server.MapPath("~/Photos"), Path.GetFileName(tempFileName));
                hpf.SaveAs(filePath);
            }

            //Update Image Object
            myImage.magazine_id       = postedmImage.magazine_id;
            myImage.magazine_issue    = postedmImage.magazine_issue;
            myImage.shoot_description = postedmImage.shoot_description;
            myImage.shoot_date        = postedmImage.shoot_date;
            myImage.date_updated      = DateTime.Now;
            myImage.keywords          = postedmImage.keywords;

            string oldName = tempFileName;
            myImage.name = myImage.tbl_publication.name.Replace(' ', '_') +
                           "_" +
                           myImage.magazine_issue.Replace(' ', '_') +
                           "_" +
                           ((DateTime)myImage.shoot_date).ToString("dd_MMM_yyyy") +
                           "_" +
                           myImage.id.ToString() + ".jpg";
            myImage.preview_location = "pv_" + myImage.name;
            myImage.thumb_location   = "th_" + myImage.name;
            myImage.thumb_location   = "th_" + myImage.name;
            myImage.preview_location = "pv_" + myImage.name;

            if (hpf.ContentLength > 0)
            {
                CreateThumbAndPreview("~/photos", oldName, myImage.name);
                DeleteCurrentFile("~/photos", oldName);
            }
            else
            {
                RenameFile(myImage.thumb_location, "th_" + myImage.name, "~/photos/thumb");
                RenameFile(myImage.preview_location, "pv_" + myImage.name, "~/photos/preview");
            }

            imagedb.Save();
            return(Redirect(returnUrl));
        }
Example #22
0
        private void UpLoadMulti()
        {
            List <string> lStrBath = new List <string>();

            lStrBath.AddRange(Directory.GetDirectories(txt_PathFolder.Text));
            progressBarControl1.EditValue              = 0;
            progressBarControl1.Properties.Step        = 1;
            progressBarControl1.Properties.PercentView = true;
            progressBarControl1.Properties.Maximum     = lStrBath.Count;
            progressBarControl1.Properties.Minimum     = 0;

            foreach (string item in lStrBath)
            {
                var fBatch = new tbl_Batch
                {
                    fBatchName   = new DirectoryInfo(item).Name,
                    fUserCreate  = txt_UserCreate.Text,
                    fDateCreated = DateTime.Now,
                    fPathPicture = item,
                    fLocation    = txt_Location.Text,
                    fSoLuongAnh  = Directory.GetFiles(item).Length.ToString()
                };
                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();


                string   searchFolder = txt_PathFolder.Text + "\\" + new DirectoryInfo(item).Name;
                var      filters      = new String[] { "jpg", "jpeg", "png", "gif", "tiff", "bmp" };
                string[] tmp          = GetFilesFrom(searchFolder, filters, false);
                string   temp         = Global.StrPath + "\\" + new DirectoryInfo(item).Name;
                Directory.CreateDirectory(temp);
                string imageJPG = "";
                foreach (string i in tmp)
                {
                    FileInfo  fi        = new FileInfo(i);
                    tbl_Image tempImage = new tbl_Image
                    {
                        fbatchname    = new DirectoryInfo(item).Name,
                        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);
                    progressBarControl1.PerformStep();
                    progressBarControl1.Update();
                }
                progressBarControl1.PerformStep();
                progressBarControl1.Update();
            }
            MessageBox.Show("Tạo batch mới thành công!");
            progressBarControl1.EditValue = 0;
            txt_BatchName.Text            = "";
            txt_ImagePath.Text            = "";
            lb_SoLuongHinh.Text           = "";
            txt_LoaiPhieu.SelectedIndex   = 0;
        }
 private void UpLoadSingle()
 {
     try
     {
         progressBarControl1.EditValue              = 0;
         progressBarControl1.Properties.Step        = 1;
         progressBarControl1.Properties.PercentView = true;
         progressBarControl1.Properties.Maximum     = _lFileNames.Length;
         progressBarControl1.Properties.Minimum     = 0;
         var batch = (from w in Global.db_BCL.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(),
                     ChiaUser        = chk_ChiaUser.Checked ? true : false,
                     CongKhaiBatch   = false,
                     GiaTriTruongSo4 = txt_TruongSo4.Text,
                     TeninhThu2      = txt_TenHinhThu2.Text
                 };
                 Global.db_BCL.tbl_Batches.InsertOnSubmit(fBatch);
                 Global.db_BCL.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,
                 ReadImageDEJP        = 0,
                 CheckedDESo          = 0,
                 CheckedDEJP          = 0,
                 FlagReadDeSo_Good    = chk_ChiaUser.Checked ? 0 : 1,
                 FlagReadDeSo_NotGood = chk_ChiaUser.Checked ? 0 : 1,
                 TienDoDESO           = "Hình chưa nhập",
                 TienDoDEJP           = "Hình chưa nhập"
             };
             Global.db_BCL.tbl_Images.InsertOnSubmit(tempImage);
             Global.db_BCL.SubmitChanges();
             string des = temp + @"\" + Path.GetFileName(fi.ToString());
             fi.CopyTo(des);
             progressBarControl1.PerformStep();
             progressBarControl1.Update();
         }
         MessageBox.Show("Tạo batch mới thành công!");
         progressBarControl1.EditValue = 0;
         txt_BatchName.Text            = "";
         txt_ImagePath.Text            = "";
         lb_SoLuongHinh.Text           = "";
     }
     catch (Exception ex)
     {
         MessageBox.Show("Lỗi: \r\n" + ex.Message);
     }
     finally
     {
         chk_ChiaUser.Enabled = true;
     }
 }
Example #24
0
 public void Add(tbl_Image image)
 {
     db.tbl_Images.InsertOnSubmit(image);
 }
        private void UpLoadMulti()
        {
            try
            {
                List <string> lStrBath = new List <string>();
                lStrBath.AddRange(Directory.GetDirectories(txt_PathFolder.Text));
                progressBarControl1.EditValue              = 0;
                progressBarControl1.Properties.Step        = 1;
                progressBarControl1.Properties.PercentView = true;
                progressBarControl1.Properties.Maximum     = lStrBath.Count;
                progressBarControl1.Properties.Minimum     = 0;
                foreach (string item in lStrBath)
                {
                    var fBatch = new tbl_Batch
                    {
                        fBatchName    = new DirectoryInfo(item).Name,
                        fusercreate   = txt_UserCreate.Text,
                        fdatecreated  = DateTime.Now,
                        fPathPicture  = item,
                        fLocation     = txt_Location.Text,
                        fSoLuongAnh   = Directory.GetFiles(item).Length.ToString(),
                        ChiaUser      = chk_ChiaUser.Checked ? true : false,
                        CongKhaiBatch = false
                    };
                    Global.db_BCL.tbl_Batches.InsertOnSubmit(fBatch);
                    Global.db_BCL.SubmitChanges();

                    string   searchFolder = txt_PathFolder.Text + "\\" + new DirectoryInfo(item).Name;
                    var      filters      = new String[] { "jpg", "jpeg", "png", "gif", "tiff", "bmp" };
                    string[] tmp          = GetFilesFrom(searchFolder, filters, false);
                    string   temp         = Global.StrPath + "\\" + new DirectoryInfo(item).Name;
                    Directory.CreateDirectory(temp);
                    string imageJPG = "";
                    foreach (string i in tmp)
                    {
                        FileInfo  fi        = new FileInfo(i);
                        tbl_Image tempImage = new tbl_Image
                        {
                            fbatchname           = new DirectoryInfo(item).Name,
                            idimage              = Path.GetFileName(fi.ToString()),
                            ReadImageDESo        = 0,
                            ReadImageDEJP        = 0,
                            CheckedDESo          = 0,
                            CheckedDEJP          = 0,
                            FlagReadDeSo_Good    = chk_ChiaUser.Checked ? 0 : 1,
                            FlagReadDeSo_NotGood = chk_ChiaUser.Checked ? 0 : 1,
                            TienDoDESO           = "Hình chưa nhập",
                            TienDoDEJP           = "Hình chưa nhập"
                        };
                        Global.db_BCL.tbl_Images.InsertOnSubmit(tempImage);
                        Global.db_BCL.SubmitChanges();
                        string des = temp + @"\" + Path.GetFileName(fi.ToString());
                        fi.CopyTo(des);
                        progressBarControl1.PerformStep();
                        progressBarControl1.Update();
                    }
                    progressBarControl1.PerformStep();
                    progressBarControl1.Update();
                }
                MessageBox.Show("Tạo batch mới thành công!");
                progressBarControl1.EditValue = 0;
                txt_BatchName.Text            = "";
                txt_ImagePath.Text            = "";
                lb_SoLuongHinh.Text           = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi: \r\n" + ex.Message);
            }
            finally
            {
                chk_ChiaUser.Enabled = true;
            }
        }
Example #26
0
        private void UpLoadMulti()
        {
            List <string> lStrBath = new List <string>();

            lStrBath.AddRange(Directory.GetDirectories(txt_PathFolder.Text));
            progressBarControl1.EditValue              = 0;
            progressBarControl1.Properties.Step        = 1;
            progressBarControl1.Properties.PercentView = true;
            progressBarControl1.Properties.Maximum     = lStrBath.Count;
            progressBarControl1.Properties.Minimum     = 0;
            foreach (string item in lStrBath)
            {
                string batchName = new DirectoryInfo(item).Name;
                var    fBatch    = new tbl_Batch
                {
                    fBatchName   = batchName,
                    fusercreate  = txt_UserCreate.Text,
                    fdatecreated = DateTime.Now,
                    fPathPicture = item,
                    fLocation    = txt_Location.Text + "\\" + batchName + "\\",
                    fSoLuongAnh  = Directory.GetFiles(item).Length.ToString(),
                    LoaiBatch    = "Getsu"
                };
                Global.Db.tbl_Batches.InsertOnSubmit(fBatch);
                Global.Db.SubmitChanges();

                string   searchFolder = txt_PathFolder.Text + "\\" + new DirectoryInfo(item).Name;
                var      filters      = new String[] { "jpg", "jpeg", "png", "gif", "tiff", "bmp" };
                string[] tmp          = GetFilesFrom(searchFolder, filters, false);
                string   temp         = Global.StrPath + "\\" + batchName;
                Directory.CreateDirectory(temp);
                string imageJPG = "";
                foreach (string i in tmp)
                {
                    FileInfo  fi        = new FileInfo(i);
                    tbl_Image tempImage = new tbl_Image
                    {
                        fbatchname            = batchName,
                        idimage               = Path.GetFileName(fi.ToString()),
                        ReadImageDESo         = 0,
                        CheckedDESo           = 0,
                        TienDoDESO            = "Hình chưa nhập",
                        ReadImageDESO_Good    = 1,
                        ReadImageDESO_NotGood = 1
                    };
                    Global.Db.tbl_Images.InsertOnSubmit(tempImage);
                    Global.Db.SubmitChanges();
                    string des = temp + @"\" + Path.GetFileName(fi.ToString());
                    fi.CopyTo(des);
                    progressBarControl1.PerformStep();
                    progressBarControl1.Update();
                }
                progressBarControl1.PerformStep();
                progressBarControl1.Update();
            }
            MessageBox.Show(@"Create a new batch successfully!");
            progressBarControl1.EditValue = 0;
            txt_BatchName.Text            = "";
            txt_ImagePath.Text            = "";
            lb_SoLuongHinh.Text           = "";
        }
Example #27
0
 public void Delete(tbl_Image image)
 {
     db.tbl_Images.DeleteOnSubmit(image);
 }
Example #28
0
        private void UpLoadSingle()
        {
            progressBarControl1.EditValue              = 0;
            progressBarControl1.Properties.Step        = 1;
            progressBarControl1.Properties.PercentView = true;
            progressBarControl1.Properties.Maximum     = _lFileNames.Length;
            progressBarControl1.Properties.Minimum     = 0;
            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 + "\\" + txt_BatchName.Text + "\\",
                        fSoLuongAnh   = _soluonghinh.ToString(),
                        LoaiBatch     = "Getsu",
                        ChiaUser      = ck_ChiaUser.Checked,
                        CongKhaiBatch = false
                                        //LoaiBatch = rg_LoaiBatch.Properties.Items[rg_LoaiBatch.SelectedIndex].Description
                    };
                    Global.Db.tbl_Batches.InsertOnSubmit(fBatch);
                    Global.Db.SubmitChanges();
                }
                else
                {
                    MessageBox.Show(@"Batch exists please enter another batch name!");
                    return;
                }
            }
            else
            {
                MessageBox.Show(@"You have not selected an image yet!");
                return;
            }
            string temp = Global.StrPath + "\\" + txt_BatchName.Text;

            if (!Directory.Exists(temp))
            {
                Directory.CreateDirectory(temp);
            }
            else
            {
                MessageBox.Show(@"Batch named batch!");
                return;
            }
            foreach (string i in _lFileNames)
            {
                FileInfo fi = new FileInfo(i);

                if (ck_ChiaUser.Checked)
                {
                    tbl_Image tempImage = new tbl_Image
                    {
                        fbatchname            = txt_BatchName.Text,
                        idimage               = Path.GetFileName(fi.ToString()),
                        ReadImageDESo         = 0,
                        CheckedDESo           = 0,
                        TienDoDESO            = "Hình chưa nhập",
                        ReadImageDESO_Good    = 0,
                        ReadImageDESO_NotGood = 0
                    };
                    Global.Db.tbl_Images.InsertOnSubmit(tempImage);
                    Global.Db.SubmitChanges();
                }
                else
                {
                    tbl_Image tempImage = new tbl_Image
                    {
                        fbatchname            = txt_BatchName.Text,
                        idimage               = Path.GetFileName(fi.ToString()),
                        ReadImageDESo         = 0,
                        CheckedDESo           = 0,
                        TienDoDESO            = "Hình chưa nhập",
                        ReadImageDESO_Good    = 1,
                        ReadImageDESO_NotGood = 1
                    };
                    Global.Db.tbl_Images.InsertOnSubmit(tempImage);
                    Global.Db.SubmitChanges();
                }

                string des = temp + @"\" + Path.GetFileName(fi.ToString());
                fi.CopyTo(des);
                progressBarControl1.PerformStep();
                progressBarControl1.Update();
            }
            MessageBox.Show(@"Create a new batch successfully!");
            progressBarControl1.EditValue = 0;
            txt_BatchName.Text            = "";
            txt_ImagePath.Text            = "";
            lb_SoLuongHinh.Text           = "";
        }
Example #29
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;
        }