public void InsertForm()
        {
            Guid TicketID = new Guid(Request.QueryString["TicketID"].ToString());

            using (MashadCarpetEntities db = new MashadCarpetEntities())
            {
                TicketResponse t = new TicketResponse();

                t.TicketResponseID = Guid.NewGuid();
                t.fk_TicketID      = TicketID;
                t.ResponseText     = reResponseText.Content;
                t.ResponseDate     = DateTime.Now;

                //t.fk_UserID = new Guid(HttpContext.Current.User.Identity.Name);

                t.fk_UserID = new Guid("ee4edaf0-aad0-4140-a9fe-8b9bcaab6bd3");
                t.IsDelete  = false;

                db.TicketResponse.Add(t);
                db.SaveChanges();

                var m = (from u in db.Tickets where u.TicketID == TicketID select u).FirstOrDefault();
                m.Status = 2;
                db.SaveChanges();

                //SendMail(t.TicketResponseID);
            }
        }
        protected void btnYes_Click(object sender, EventArgs e)
        {
            Guid DiscountID = new Guid(ViewState["DiscountID"].ToString());

            using (MashadCarpetEntities db = new MashadCarpetEntities())
            {
                var n = (from u in db.Discounts where u.DiscountID == DiscountID select u).FirstOrDefault();

                n.IsDelete   = true;
                n.DeleteDate = DateTime.Now;
                db.SaveChanges();

                var nn = (from a in db.Rel_Discounts_Sizes
                          where a.fk_DiscountID == DiscountID
                          select a).ToList();

                foreach (var NItem in nn)
                {
                    db.Rel_Discounts_Sizes.Remove(NItem);
                    db.SaveChanges();
                }
            }
            LoadForm();
            pnlSuccess.Visible = true;
        }
        public void UpdateForm()
        {
            Guid userid     = new Guid(HttpContext.Current.User.Identity.Name);
            Guid DiscountID = new Guid(ViewState["DiscountID"].ToString());

            using (MashadCarpetEntities db = new MashadCarpetEntities())
            {
                var p = (from u in db.Discounts where u.DiscountID == DiscountID select u).FirstOrDefault();
                p.DiscountPercent = Convert.ToDouble(txtPercent.Text);
                p.fk_UserID       = userid;
                p.IsActive        = chbActive.Checked;
                p.Title           = txtTitle.Text;



                var nn = (from a in db.Rel_Discounts_Sizes
                          where a.fk_DiscountID == DiscountID
                          select a).ToList();

                foreach (var NItem in nn)
                {
                    db.Rel_Discounts_Sizes.Remove(NItem);
                    db.SaveChanges();
                }

                foreach (ListItem chk in chlSizes.Items)
                {
                    if (chk.Selected)
                    {
                        int size = Convert.ToInt32(chk.Value);

                        Rel_Discounts_Sizes RelEnter = new Rel_Discounts_Sizes();

                        RelEnter.Rel_Discount_SizesID = Guid.NewGuid();

                        RelEnter.fk_DiscountID = DiscountID;

                        RelEnter.fk_SizeID = size;


                        db.Rel_Discounts_Sizes.Add(RelEnter);
                        db.SaveChanges();
                    }
                }

                db.SaveChanges();
            }
        }
        //protected void btnIsFinilzed_Click(object sender, EventArgs e)
        //{
        //    if (HttpContext.Current.User.Identity.IsAuthenticated)
        //    {
        //        Guid UserID = new Guid(HttpContext.Current.User.Identity.Name);

        //        using (MashadCarpetEntities db = new MashadCarpetEntities())
        //        {
        //            var n = (from a in db.Orders
        //                     where a.fk_UserID == UserID && a.IsFinalized == false && a.IsDelete == false
        //                     select a).FirstOrDefault();

        //            n.IsFinalized = true;
        //            n.OrderDesc = txtOrderDesc.Text;
        //            n.FinalPrice = Convert.ToDecimal(OrderInfo.returnFinalPrice(n.OrderID));
        //            db.SaveChanges();

        //            //lblTrackingCode.Text = n.CustomerOrderID;
        //            Response.Redirect("~/FinlizingFactor.aspx?Code=" + n.CustomerOrderID);
        //        }
        //        pnlOrderDetails.Visible = false;

        //        // pnlIsFinilized.Visible = true;
        //        //SendMail(UserID);

        //    }
        //}

        protected void btnpay_Click(object sender, EventArgs e)
        {
            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                Guid UserID = new Guid(HttpContext.Current.User.Identity.Name);

                using (MashadCarpetEntities db = new MashadCarpetEntities())
                {
                    var n = (from a in db.Orders
                             where a.fk_UserID == UserID && a.IsFinalized == false && a.IsDelete == false
                             select a).FirstOrDefault();

                    n.OrderDesc = txtOrderDesc.Text;


                    //int finalPrice = Convert.ToInt32(n.FinalPrice);
                    //int newProductPrice=0 ;
                    //List<OrderDetails> orderDetails = db.OrderDetails.Where(current => current.fk_OrderID == n.OrderID && current.IsDelete==false).ToList();
                    //foreach(var detail in orderDetails)
                    //{
                    //    ProductColorSizes productColorSizes = db.ProductColorSizes.Where(current => current.IsDelete == false && current.ProductColorSizeID == detail.fk_ProductColorSizeID).FirstOrDefault();
                    //    newProductPrice = newProductPrice + (Convert.ToInt32(productColorSizes.ProductPrice)*detail.Count.Value);
                    //}
                    //if(finalPrice!=newProductPrice)
                    //{
                    //    n.FinalPrice = newProductPrice;
                    //}
                    db.SaveChanges();
                    Response.Redirect("~/bank.aspx?OID=" + n.OrderID.ToString() + "&&UID=" + UserID.ToString());
                }
            }
        }
        protected void btnUpdateBasket_Click(object sender, EventArgs e)
        {
            using (MashadCarpetEntities db = new MashadCarpetEntities())
            {
                foreach (RepeaterItem item in rptOrders.Items)
                {
                    HiddenField hfOrderDetailID = (HiddenField)item.FindControl("hfOrderDetailID");

                    TextBox txtCount = (TextBox)item.FindControl("txtCount");

                    Guid OrderDetailID = new Guid(hfOrderDetailID.Value);


                    var n = (from a in db.OrderDetails
                             where a.OrderDetailID == OrderDetailID
                             select a).FirstOrDefault();

                    n.Count = Convert.ToInt32(txtCount.Text);

                    var m = (from u in db.Orders where u.OrderID == n.fk_OrderID select u).FirstOrDefault();
                    m.OrderDesc = txtOrderDesc.Text;
                }
                db.SaveChanges();
                RptOrdersBind();
            }
        }
        public void InsertForm()
        {
            string new_filename = string.Empty;
            Guid   ID           = new Guid(ViewState["ID"].ToString());

            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/ProductGroup/" + new_filename);
                fuImage.PostedFile.SaveAs(new_filepath);
                ViewState["GImage"] = new_filename;
            }


            string new_filename_Slider = string.Empty;

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

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

                string new_filepath = Server.MapPath("~/Uploads/ProductGroup/" + new_filename);
                fuImage_Slider.PostedFile.SaveAs(new_filepath);
                ViewState["GImage_Slider"] = new_filename;
            }

            using (MashadCarpetEntities db = new MashadCarpetEntities())
            {
                ProductGroup pg = new ProductGroup();
                pg.ProductGroupID    = Guid.NewGuid();
                pg.ProductGroupTitle = txtTitle.Text;

                pg.ProductGroupName     = txtName.Text;
                pg.ProductGroupImage    = new_filename;
                pg.imgSliderImage       = new_filename_Slider;
                pg.ProductGroupDesc     = reDesc.Content;
                pg.IsDelete             = false;
                pg.EN_ProductGroupTitle = txtEN_Title.Text;

                pg.EN_ProductGroupDesc     = reEN_Desc.Content;
                pg.fk_ProductGroupID       = ID;
                pg.Rus_ProductGroupDesc    = reRus_Desc.Content;
                pg.Rus_ProductGroupTitle   = txtRus_Title.Text;
                pg.China_ProductGroupDesc  = reChina_Desc.Content;
                pg.China_ProductGroupTitle = txtChina_Title.Text;
                //  if (ddlProductGroups.SelectedValue != "-1")
                //           pg.fk_ProductGroupID = new Guid(ddlProductGroups.SelectedValue);

                db.ProductGroup.Add(pg);
                db.SaveChanges();
            }
        }
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            using (MashadCarpetEntities db = new MashadCarpetEntities())
            {
                if (HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    Guid UserID = new Guid(HttpContext.Current.User.Identity.Name);

                    var u = (from i in db.Users where i.UserID == UserID select i).FirstOrDefault();


                    u.UserName   = txtUserName.Text;
                    u.UserFamily = txtFamily.Text;
                    u.Address1   = txtAddress1.Text;
                    u.Address2   = txtAddress2.Text;
                    u.CityID     = int.Parse(ddlCity.SelectedValue.ToString());
                    u.ProvinceID = int.Parse(ddlProvince.SelectedValue.ToString());
                    u.PostalCode = txtPostalCode.Text;
                    u.Phone      = txtPhone.Text;
                    u.Mobile     = txtMobile.Text;
                    u.Email      = txtEmail.Text;
                    //u.Password = txtPass.Text;


                    db.SaveChanges();
                }
            }
        }
Beispiel #8
0
        public void Update()
        {
            Guid UserID = new Guid(ViewState["UserID"].ToString());

            using (MashadCarpetEntities db = new MashadCarpetEntities())
            {
                var u = (from n in db.Users where n.UserID == UserID select n).FirstOrDefault();
                if (u.fk_RoleID == 2)
                {
                    u.Password = txtpass.Text;
                }
                u.UserName   = txtFirstName.Text;
                u.Email      = txtEmail.Text;
                u.Phone      = txtPhone.Text;
                u.Address1   = txtAddress1.Text;
                u.fk_RoleID  = Convert.ToInt32(ddlRoles.SelectedValue);
                u.Address2   = txtAddress2.Text;
                u.CityID     = int.Parse(ddlCity.SelectedValue);
                u.ProvinceID = int.Parse(ddlProvince.SelectedValue);
                u.PostalCode = txtPostalCode.Text;
                u.Mobile     = txtMobile.Text;
                u.UserFamily = txtFamily.Text;

                db.SaveChanges();
            }
        }
Beispiel #9
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Guid UserID = new Guid(HttpContext.Current.User.Identity.Name);

            //Guid UserID = new Guid("ee4edaf0-aad0-4140-a9fe-8b9bcaab6bd3");
            using (MashadCarpetEntities db = new MashadCarpetEntities())
            {
                var u = (from n in db.Users where n.UserID == UserID select n).FirstOrDefault();


                u.UserName   = txtFirstName.Text;
                u.Email      = txtEmail.Text;
                u.Phone      = txtPhone.Text;
                u.Password   = txtpass.Text;
                u.Address1   = txtAddress1.Text;
                u.Address2   = txtAddress2.Text;
                u.CityID     = int.Parse(ddlCity.SelectedValue);
                u.ProvinceID = int.Parse(ddlProvince.SelectedValue);
                u.PostalCode = txtPostalCode.Text;
                u.Mobile     = txtMobile.Text;
                u.UserFamily = txtFamily.Text;

                db.SaveChanges();
            }
            LoadForm();
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            ExcelPackage package = new ExcelPackage(FileUpload1.FileContent);

            DataTable datasource = package.ToDataTable();

            // List<string> newproList = new List<string>();

            foreach (DataRow dr in datasource.Rows)
            {
                using (MashadCarpetEntities db = new MashadCarpetEntities())
                {
                    string city    = dr["شهر"].ToString();
                    string address = dr["آدرس"].ToString();
                    string phone   = dr["تلفن"].ToString();

                    Stores sss = new Stores();
                    sss.StoreID      = Guid.NewGuid();
                    sss.StorePhone   = phone;
                    sss.StoreAddress = address;
                    sss.IsDelete     = false;
                    sss.StoreCity    = city;
                    sss.IsStore      = true;

                    db.Stores.Add(sss);
                    db.SaveChanges();
                }
            }
        }
Beispiel #11
0
        public void Insert()
        {
            using (MashadCarpetEntities db = new MashadCarpetEntities())
            {
                Users u = new Users();
                u.UserID       = Guid.NewGuid();
                u.UserName     = txtFirstName.Text;
                u.Email        = txtEmail.Text;
                u.Phone        = txtPhone.Text;
                u.RegisterDate = DateTime.Now;
                u.Password     = txtpass.Text;
                u.fk_RoleID    = Convert.ToInt32(ddlRoles.SelectedValue);
                u.RegisterIP   = Request.UserHostAddress;
                u.Address1     = txtAddress1.Text;
                u.Address2     = txtAddress2.Text;
                u.CityID       = int.Parse(ddlCity.SelectedValue);
                u.ProvinceID   = int.Parse(ddlProvince.SelectedValue);
                u.PostalCode   = txtPostalCode.Text;
                u.Mobile       = txtMobile.Text;
                u.IsDelete     = false;
                u.UserFamily   = txtFamily.Text;


                db.Users.Add(u);
                db.SaveChanges();
            }
        }
        protected void btnSend_Click(object sender, EventArgs e)
        {
            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                Guid UserID = new Guid(HttpContext.Current.User.Identity.Name.ToString());

                using (MashadCarpetEntities db = new MashadCarpetEntities())
                {
                    Tickets t = new Tickets();

                    t.TicketID      = Guid.NewGuid();
                    t.fk_UserID     = UserID;
                    t.TicketSubject = txtTicketSubject.Text;
                    t.TicketMessage = txtTicketMessage.Text;
                    t.TicketDate    = DateTime.Now;
                    t.IsDelete      = false;
                    t.IsValid       = false;
                    t.Status        = 1;

                    db.Tickets.Add(t);
                    db.SaveChanges();

                    txtTicketMessage.Text = string.Empty;
                    txtTicketSubject.Text = string.Empty;
                }
                pnlSuccess.Visible = true;
            }
        }
Beispiel #13
0
        public void Insert_Log_LoginAttemp(Boolean IsSuccess)
        {
            using (MashadCarpetEntities db = new MashadCarpetEntities())
            {
                Log_LoginAttemps lmEnter = new Log_LoginAttemps();

                lmEnter.IP        = Request.UserHostAddress;
                lmEnter.VisitDate = DateTime.Now;

                if (Request.UrlReferrer != null)
                {
                    lmEnter.RefrallPage = Request.UrlReferrer.ToString();
                }
                else
                {
                    lmEnter.RefrallPage = "ورود مستقیم";
                }
                System.Web.HttpBrowserCapabilities browser = Request.Browser;
                lmEnter.Browser   = browser.Type;
                lmEnter.OS        = OSIdentify.OSName();
                lmEnter.Username  = txtEmail.Text;
                lmEnter.Password  = txtPass.Text;
                lmEnter.IsSuccess = IsSuccess;

                db.Log_LoginAttemps.Add(lmEnter);
                db.SaveChanges();
            }
        }
Beispiel #14
0
        public void InserForm()
        {
            using (MashadCarpetEntities db = new MashadCarpetEntities())
            {
                Tickets p = new Tickets();

                p.TicketID = Guid.NewGuid();
                //p.fk_TicketGroupID = new Guid(ddlTicketGroup.SelectedValue);
                p.TicketSubject = txtSubject.Text;
                //p.TicketPriority = int.Parse(ddlPriority.SelectedValue);
                p.TicketMessage = txtMessage.Text;
                p.TicketDate    = DateTime.Now;
                p.IsDelete      = false;
                p.fk_UserID     = new Guid(ddlUser.SelectedValue);
                if (Request.QueryString["StatusID"] != null)
                {
                    int StatusID = int.Parse(Request.QueryString["StatusID"].ToString());
                    p.Status = Convert.ToByte(StatusID);
                }
                else
                {
                    p.Status = 1;
                }

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

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

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

                string new_filepath = Server.MapPath("~/Uploads/Sliders/" + new_filename);
                fuImg.PostedFile.SaveAs(new_filepath);
                ViewState["NewImg"] = new_filename;
            }

            using (MashadCarpetEntities db = new MashadCarpetEntities())
            {
                Slider s = new Slider();


                s.SliderTitle = txtTitle.Text;

                s.SliderImage = new_filename;

                db.Slider.Add(s);
                db.SaveChanges();
            }
        }
        public void InsertForm()
        {
            string new_filename = string.Empty;

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

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

                string new_filepath = Server.MapPath("~/Uploads/Blogs/" + new_filename);
                fuImg.PostedFile.SaveAs(new_filepath);
                ViewState["NewImg"] = new_filename;
            }
            using (MashadCarpetEntities db = new MashadCarpetEntities())
            {
                Links p = new Links();

                p.id = Guid.NewGuid();

                p.IsDelete   = false;
                p.title      = txtTitle.Text;
                p.LinkAddres = txtLink.Text;

                p.imgFile  = ViewState["NewImg"].ToString();
                p.title_En = txtEN_Title.Text;
                p.title_Ru = txtRus_Title.Text;
                p.title_Ch = txtChina_Title.Text;

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

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

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

                string new_filepath = Server.MapPath("~/Uploads/Blogs/" + new_filename);
                fuImg.PostedFile.SaveAs(new_filepath);
                ViewState["NewImg"] = new_filename;
            }

            Guid id = new Guid(ViewState["id"].ToString());

            using (MashadCarpetEntities db = new MashadCarpetEntities())
            {
                var p = (from u in db.Links where u.id == id select u).FirstOrDefault();

                p.title      = txtTitle.Text;
                p.LinkAddres = txtLink.Text;
                p.imgFile    = ViewState["NewImg"].ToString();
                p.title_En   = txtEN_Title.Text;
                p.title_Ru   = txtRus_Title.Text;
                p.title_Ch   = txtChina_Title.Text;

                db.SaveChanges();
            }
        }
        public void Update()
        {
            Guid id = new Guid(ViewState["StoreID"].ToString());

            using (MashadCarpetEntities db = new MashadCarpetEntities())
            {
                var n = (from u in db.Stores
                         where u.StoreID == id
                         select u).FirstOrDefault();



                //  n.StoreName = txtName.Text;
                n.StorePhone   = txtPhone.Text;
                n.StoreCity    = txtCity.Text;
                n.StoreAddress = txtAddress.Text;
                //   n.Prov = txtPov.Text;
                //  n.StoreDesc = txtDesc.Text;


                db.SaveChanges();
                Loadgrd();
                mvStores.SetActiveView(vwlist);
            }
        }
Beispiel #19
0
        //  public Nullable<Boolean> ReturnThumb()
        //  {
        //      if (ddlThumbImg.SelectedValue == "0")
        //          return null;
        //      else if (ddlThumbImg.SelectedValue == "1")
        //          return true;
        //      else
        //          return false;
        //  }
        public void InsertForm()
        {
            Guid   ProductID    = new Guid(ViewState["ID"].ToString());
            string new_filename = string.Empty;

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

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

                string new_filepath = Server.MapPath("~/Uploads/Products/" + new_filename);
                fuImg.PostedFile.SaveAs(new_filepath);
                ViewState["NewImg"] = new_filename;
            }
            using (MashadCarpetEntities db = new MashadCarpetEntities())
            {
                ProductColors p = new ProductColors();

                p.ProductColorID = Guid.NewGuid();
                p.IsDelete       = false;
                p.ProductImage   = new_filename;
                p.fk_ColorID     = int.Parse(ddlColors.SelectedValue);

                p.fk_ProductID = ProductID;


                db.ProductColors.Add(p);
                db.SaveChanges();
            }
        }
Beispiel #20
0
        public void UpdateForm()
        {
            string new_filename = string.Empty;

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

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

                string new_filepath = Server.MapPath("~/Uploads/Products/" + new_filename);
                fuImg.PostedFile.SaveAs(new_filepath);
                ViewState["NewImg"] = new_filename;
            }

            Guid ID = new Guid(ViewState["ProductColorID"].ToString());

            using (MashadCarpetEntities db = new MashadCarpetEntities())
            {
                var p = (from u in db.ProductColors where u.ProductColorID == ID select u).FirstOrDefault();

                p.ProductImage = ViewState["NewImg"].ToString();
                p.fk_ColorID   = int.Parse(ddlColors.SelectedValue);


                db.SaveChanges();
            }
        }
Beispiel #21
0
        protected void grdTable_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Details")
            {
                Guid ProductID = new Guid(e.CommandArgument.ToString());
                ViewState["ProductID"] = ProductID;
                ViewState["btn"]       = "Update";
                DropDownBind();
                FillViewEdit(ProductID);
            }
            else if (e.CommandName == "Restore")
            {
                Guid ProductID = new Guid(e.CommandArgument.ToString());
                ViewState["ProductID"] = ProductID;
                using (MashadCarpetEntities db = new MashadCarpetEntities())
                {
                    var n = (from u in db.Products where u.ProductID == ProductID select u).FirstOrDefault();
                    n.IsDelete   = false;
                    n.DeleteDate = null;
                    db.SaveChanges();

                    LoadForm();
                }
            }
        }
        public void InsertIntoPaymentLogs(string RefID, Guid OrderID, long?SaleRefrenceID, int ResCode_Request, Nullable <int> ResCode_Payment, Nullable <int> ResCode_Verify, Nullable <int> ResCode_Settle, string ErrorrText, Boolean IsSiccess)
        {
            using (MashadCarpetEntities db = new MashadCarpetEntities())
            {
                PaymentLogs a = new PaymentLogs();

                a.PaymentLogID    = Guid.NewGuid();
                a.fk_OrderID      = OrderID;
                a.RefID           = RefID;
                a.SaleReferenceId = SaleRefrenceID;

                a.ResCode_Request = ResCode_Request;
                a.ResCode_Payment = ResCode_Payment;
                a.ResCode_Settle  = ResCode_Settle;
                a.ResCode_Verify  = ResCode_Verify;

                a.ErrorMessage = ErrorrText;
                a.PaymentDate  = DateTime.Now;
                a.PaymentIP    = Request.UserHostName;
                a.IsSuccess    = false;

                db.PaymentLogs.Add(a);
                db.SaveChanges();
            }
        }
Beispiel #23
0
        protected void btnSend_Click(object sender, EventArgs e)
        {
            Guid TicketID = new Guid(ViewState["TicketID"].ToString());

            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                Guid UserID = new Guid(HttpContext.Current.User.Identity.Name);
                using (MashadCarpetEntities db = new MashadCarpetEntities())
                {
                    TicketResponse t = new TicketResponse();

                    t.TicketResponseID = Guid.NewGuid();
                    t.fk_TicketID      = TicketID;
                    t.fk_UserID        = UserID;
                    t.ResponseText     = txtAnswerText.Text;
                    t.ResponseDate     = DateTime.Now;
                    t.IsDelete         = false;

                    db.TicketResponse.Add(t);
                    db.SaveChanges();
                }
                rptAnswersBind(TicketID);
                txtAnswerText.Text = string.Empty;
            }
        }
        public List <string> ReturnPaymentLogID(Guid OrderID)
        {
            using (MashadCarpetEntities db = new MashadCarpetEntities())
            {
                List <string> returnList = new List <string>();

                PaymentUniqeCodes puc = new PaymentUniqeCodes();
                puc.fk_OrderID = OrderID;

                db.PaymentUniqeCodes.Add(puc);
                db.SaveChanges();
                returnList.Add(puc.PayementUniqeCodeID.ToString());

                //var m = (from a in db.Orders
                //         where a.IsDelete == false && a.OrderID == OrderID
                //         select a).FirstOrDefault();

                Nullable <double> Price = 0;
                var od = (from a in db.OrderDetails
                          where a.IsDelete == false && a.fk_OrderID == OrderID
                          select a).ToList();
                foreach (var item in od)
                {
                    var n = (from a in db.ProductColorSizes
                             where a.ProductColorSizeID == item.fk_ProductColorSizeID &&
                             a.IsDelete == false
                             select a).FirstOrDefault();

                    Price = Price + Convert.ToDouble(n.ProductPrice) * item.Count;
                }
                returnList.Add(Price.ToString());
                return(returnList);
            }
        }
        public void Update()
        {
            string new_filename = string.Empty;

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

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

                string new_filepath = Server.MapPath("~/Uploads/Sliders/" + new_filename);
                fuImg.PostedFile.SaveAs(new_filepath);
                ViewState["NewImg"] = new_filename;
            }


            int SLiderID = int.Parse(ViewState["SliderID"].ToString());

            using (MashadCarpetEntities db = new MashadCarpetEntities())
            {
                var n = (from u in db.Slider where u.SliderID == SLiderID select u).FirstOrDefault();


                n.SliderTitle = txtTitle.Text;
                n.SliderImage = ViewState["NewImg"].ToString();

                db.SaveChanges();
            }
        }
        public void FindRefrall(int TodayTotal)
        {
            using (MashadCarpetEntities db = new MashadCarpetEntities())
            {
                VisitCounter c = new VisitCounter();
                TodayTotal = TodayTotal + 1;

                c.ClientIP   = Request.UserHostAddress;
                c.VisitDate  = DateTime.Now;
                c.VisitCount = 1;
                c.TotalVisit = TodayTotal;
                if (Request.UrlReferrer != null)
                {
                    c.RefrallPage = Request.UrlReferrer.ToString();
                }
                else
                {
                    c.RefrallPage = "ورود مستقیم";
                }
                System.Web.HttpBrowserCapabilities browser = Request.Browser;
                c.Browser = browser.Type;
                c.OS      = ReturnOS();

                db.VisitCounter.Add(c);
                db.SaveChanges();
            }
        }
        protected void rptAnswers_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            Guid TicketResponseID = new Guid(e.CommandArgument.ToString());

            ViewState["TicketResponseID"] = TicketResponseID;
            switch (e.CommandName)
            {
            case "DoEdit":
            {
                using (MashadCarpetEntities db = new MashadCarpetEntities())
                {
                    var n = (from u in db.TicketResponse where u.TicketResponseID == TicketResponseID select u).FirstOrDefault();

                    reResponseText.Content = n.ResponseText;
                }
                mvSetting.SetActiveView(vwEdit);
                ViewState["btn"]        = "Update";
                pnlSubmitAnswer.Visible = true;
                break;
            }

            case "DoDelete":
            {
                using (MashadCarpetEntities db = new MashadCarpetEntities())
                {
                    var n = (from u in db.TicketResponse where u.TicketResponseID == TicketResponseID select u).FirstOrDefault();

                    n.IsDelete   = true;
                    n.DeleteDate = DateTime.Now;

                    db.SaveChanges();
                }
                RptAnswersBind();
                break;
            }

            case "Show":
            {
                using (MashadCarpetEntities db = new MashadCarpetEntities())
                {
                    var n = (from u in db.TicketResponse
                             join i in db.Users.AsEnumerable() on u.fk_UserID equals i.UserID
                             where u.TicketResponseID == TicketResponseID
                             select new
                        {
                            u.ResponseText,
                            Name = i.UserName + " " + i.UserFamily,
                            u.ResponseDate
                        }).FirstOrDefault();
                    lblAnswer.Text         = n.ResponseText;
                    lblUserAnswerName.Text = n.Name;
                    lblAnswerDate.Text     = string.Format("{0:d}", n.ResponseDate);
                }

                mvSetting.SetActiveView(vwShow);
                break;
            }
            }
        }
        public void UpdateForm()
        {
            Guid   ProductGroupID = new Guid(ViewState["ProductGroupID"].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/ProductGroup/" + new_filename);
                fuImage.PostedFile.SaveAs(new_filepath);
                ViewState["GImage"] = new_filename;
            }
            string  new_filename_Slider = string.Empty;
            Boolean temp = false;

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

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

                string new_filepath = Server.MapPath("~/Uploads/ProductGroup/" + new_filename_Slider);
                fuImage_Slider.PostedFile.SaveAs(new_filepath);
                ViewState["GImage_Slider"] = new_filename_Slider;
                temp = true;
            }
            using (MashadCarpetEntities db = new MashadCarpetEntities())
            {
                var n = (from u in db.ProductGroup where u.ProductGroupID == ProductGroupID select u).FirstOrDefault();

                n.ProductGroupTitle    = txtTitle.Text;
                n.ProductGroupName     = txtName.Text;
                n.ProductGroupImage    = ViewState["GImage"].ToString();
                n.ProductGroupDesc     = reDesc.Content;
                n.EN_ProductGroupTitle = txtEN_Title.Text;
                n.EN_ProductGroupDesc  = reEN_Desc.Content;
                if (temp == true)
                {
                    n.imgSliderImage = ViewState["GImage_Slider"].ToString();
                }
                n.Rus_ProductGroupDesc  = reRus_Desc.Content;
                n.Rus_ProductGroupTitle = txtRus_Title.Text;
                n.Priority = Convert.ToInt32(txtPrio.Text);
                n.China_ProductGroupDesc  = reChina_Desc.Content;
                n.China_ProductGroupTitle = txtChina_Title.Text;
                n.IsAlienCulture          = chkAlienPro.Checked;

                db.SaveChanges();
            }
        }
        public void UpdateForm()
        {
            Guid   ProductGroupID = new Guid(ViewState["ProductGroupID"].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/ProductGroup/" + new_filename);
                fuImage.PostedFile.SaveAs(new_filepath);
                ViewState["GImage"] = new_filename;
            }
            string new_filename_Slider = string.Empty;

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

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

                string new_filepath = Server.MapPath("~/Uploads/ProductGroup/" + new_filename);
                fuImage_Slider.PostedFile.SaveAs(new_filepath);
                ViewState["GImage_Slider"] = new_filename;
            }

            using (MashadCarpetEntities db = new MashadCarpetEntities())
            {
                var n = (from u in db.ProductGroup where u.ProductGroupID == ProductGroupID select u).FirstOrDefault();

                n.ProductGroupTitle = txtTitle.Text;

                n.ProductGroupName  = txtName.Text;
                n.ProductGroupImage = ViewState["GImage"].ToString();
                n.imgSliderImage    = ViewState["GImage_Slider"].ToString();

                n.ProductGroupDesc        = reDesc.Content;
                n.EN_ProductGroupTitle    = txtEN_Title.Text;
                n.EN_ProductGroupDesc     = reEN_Desc.Content;
                n.Rus_ProductGroupDesc    = reRus_Desc.Content;
                n.Rus_ProductGroupTitle   = txtRus_Title.Text;
                n.China_ProductGroupDesc  = reChina_Desc.Content;
                n.China_ProductGroupTitle = txtChina_Title.Text;
                //n.fk_ProductGroupID = new Guid(ddlProductGroup.SelectedValue);
                //  n.fk_ProductGroupID = new Guid(ddlProductGroups.SelectedValue);

                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/ProductGroup/" + new_filename);
                fuImage.PostedFile.SaveAs(new_filepath);
                ViewState["GImage"] = new_filename;
            }
            string new_filename_Slider = string.Empty;

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

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

                string new_filepath = Server.MapPath("~/Uploads/ProductGroup/" + new_filename_Slider);
                fuImage_Slider.PostedFile.SaveAs(new_filepath);
                ViewState["GImage_Slider"] = new_filename_Slider;
            }

            using (MashadCarpetEntities db = new MashadCarpetEntities())
            {
                ProductGroup pg = new ProductGroup();
                pg.ProductGroupID          = Guid.NewGuid();
                pg.ProductGroupTitle       = txtTitle.Text;
                pg.ProductGroupName        = txtName.Text;
                pg.ProductGroupImage       = new_filename;
                pg.ProductGroupDesc        = reDesc.Content;
                pg.IsDelete                = false;
                pg.EN_ProductGroupTitle    = txtEN_Title.Text;
                pg.EN_ProductGroupDesc     = reEN_Desc.Content;
                pg.imgSliderImage          = new_filename_Slider;
                pg.Priority                = Convert.ToInt32(txtPrio.Text);
                pg.Rus_ProductGroupDesc    = reRus_Desc.Content;
                pg.Rus_ProductGroupTitle   = txtRus_Title.Text;
                pg.China_ProductGroupDesc  = reChina_Desc.Content;
                pg.China_ProductGroupTitle = txtChina_Title.Text;
                pg.IsAlienCulture          = chkAlienPro.Checked;

                db.ProductGroup.Add(pg);
                db.SaveChanges();
            }
        }