Exemple #1
0
        public void UpdateForm()
        {
            int ImageID = int.Parse(ViewState["ImageID"].ToString());

            string new_filename = string.Empty;

            if (fuImage.PostedFile.ContentLength != 0)
            {
                string original_filename = Path.GetFileName(fuImage.PostedFile.FileName);

                new_filename =
                    Guid.NewGuid().ToString() +
                    Path.GetExtension(original_filename);

                string new_filepath = Server.MapPath("~/Uploads/Images/" + new_filename);
                fuImage.PostedFile.SaveAs(new_filepath);
                ViewState["GImage"] = new_filename;
            }

            using (VaranegarEntities db = new VaranegarEntities())
            {
                var n = (from u in db.Images where u.ImageID == ImageID select u).FirstOrDefault();

                n.ImageTitle        = txtTitle.Text;
                n.LastUpdateUserID  = FindUserInfo.OnlineUserID();
                n.ImgLastUpdateDate = DateTime.Now;
                n.ImgUrlAddress     = ViewState["GImage"].ToString();
                n.Priority          = Convert.ToInt32(txtPrio.Text);
                n.IsActive          = chkActive.Checked;
                db.SaveChanges();
            }
        }
        public void InsertForm()
        {
            string new_filename = string.Empty;

            if (fuImage.PostedFile.ContentLength != 0)
            {
                string original_filename = Path.GetFileName(fuImage.PostedFile.FileName);

                new_filename =
                    Guid.NewGuid().ToString() +
                    Path.GetExtension(original_filename);

                string new_filepath = Server.MapPath("~/Uploads/team/" + new_filename);
                fuImage.PostedFile.SaveAs(new_filepath);
                ViewState["GImage"] = new_filename;
            }

            using (VaranegarEntities db = new VaranegarEntities())
            {
                Managers p = new Managers();

                p.ManagerTitle    = txtTitle.Text;
                p.ManagerPost     = txtPost.Text;
                p.ManagerDesc     = txtDesc.Text;
                p.En_ManagerTitle = txtTitle_En.Text;
                p.En_ManagerPost  = txtPost_En.Text;
                p.En_ManagerDesc  = txtDesc_En.Text;
                p.SubmitDate      = DateTime.Now;
                p.UserSubmited    = FindUserInfo.OnlineUserID();
                p.IsDelete        = false;
                p.ManagerImg      = new_filename;
                p.Priority        = Convert.ToInt32(txtPrio.Text);
                p.LinkedinLink    = txtLinkedin.Text;
                p.EmailLink       = txtEmail.Text;

                db.Managers.Add(p);
                db.SaveChanges();
            }
        }
        public void UpdateForm()
        {
            string new_filename = string.Empty;

            if (fuImage.PostedFile.ContentLength != 0)
            {
                string original_filename = Path.GetFileName(fuImage.PostedFile.FileName);

                new_filename =
                    Guid.NewGuid().ToString() +
                    Path.GetExtension(original_filename);

                string new_filepath = Server.MapPath("~/Uploads/team/" + new_filename);
                fuImage.PostedFile.SaveAs(new_filepath);
                ViewState["GImage"] = new_filename;
            }

            int ManagerID = Convert.ToInt32(ViewState["ManagerID"].ToString());

            using (VaranegarEntities db = new VaranegarEntities())
            {
                var p = (from u in db.Managers where u.ManagerID == ManagerID select u).FirstOrDefault();

                p.ManagerTitle    = txtTitle.Text;
                p.ManagerPost     = txtPost.Text;
                p.ManagerDesc     = txtDesc.Text;
                p.En_ManagerTitle = txtTitle_En.Text;
                p.En_ManagerPost  = txtPost_En.Text;
                p.En_ManagerDesc  = txtDesc_En.Text;
                p.ManagerImg      = ViewState["GImage"].ToString();
                p.LastUpdateDate  = DateTime.Now;
                p.UserLastUpdated = FindUserInfo.OnlineUserID();
                p.Priority        = Convert.ToInt32(txtPrio.Text);
                p.LinkedinLink    = txtLinkedin.Text;
                p.EmailLink       = txtEmail.Text;
                db.SaveChanges();
            }
        }