protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            string            actionName     = filterContext.RouteData.Values["action"].ToString();
            string            controllerName = filterContext.RouteData.Values["controller"].ToString();
            tbl_Customer_Main tcm            = new tbl_Customer_Main();
            var coockie = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerCode());

            if (coockie != null)
            {
                tcm = CoockieController.SayWhoIsHE(coockie.Value);
                var Id = tcm.id_Customer;
                int dd = 0;
                if (Int32.TryParse(Id, out dd))
                {
                    base.OnActionExecuting(filterContext);
                }
                else
                {
                    filterContext.Result = RedirectToAction("loginandregister", "CustomerSide_Register");
                }
            }
            else
            {
                filterContext.Result = RedirectToAction("loginandregister", "CustomerSide_Register");
            }
        }
        public ActionResult AddCustomerAddress(string CityId, string FullAddress, string CodePosti)
        {
            tbl_Customer_Main tcm = new tbl_Customer_Main();
            var coockie           = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerCode());

            if (coockie != null)
            {
                tcm = CoockieController.SayWhoIsHE(coockie.Value);
                var Id = tcm.id_Customer;

                PDBC db = new PDBC();
                List <ExcParameters> parss = new List <ExcParameters>();
                ExcParameters        par   = new ExcParameters()
                {
                    _KEY   = "@Id",
                    _VALUE = Id
                };
                parss.Add(par);

                par = new ExcParameters()
                {
                    _KEY   = "@CityId",
                    _VALUE = CityId
                };
                parss.Add(par);

                par = new ExcParameters()
                {
                    _KEY   = "@FullAddress",
                    _VALUE = FullAddress
                };
                parss.Add(par);

                par = new ExcParameters()
                {
                    _KEY   = "@CodePosti",
                    _VALUE = CodePosti
                };
                parss.Add(par);

                db.Connect();
                string result = db.Script("INSERT INTO [tbl_Customer_Address]([id_Customer],[ID_Shahr],[C_AddressHint],[C_FullAddress])VALUES(@Id,@CityId,@CodePosti,@FullAddress)", parss);


                db.DC();

                if (result == "1")
                {
                    return(Content("Success"));
                }
                else
                {
                    return(Content("Error"));
                }
            }
            else
            {
                return(Content("Error"));
            }
        }
Пример #3
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            string            actionName     = filterContext.RouteData.Values["action"].ToString();
            string            controllerName = filterContext.RouteData.Values["controller"].ToString();
            tbl_Customer_Main tcm            = new tbl_Customer_Main();
            var           coockie            = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerCode());
            AllowDisallow AA = new AllowDisallow()
            {
                BasketItemsCount = 0,
                ShoppingBasket   = new ShoppingBasket()
                {
                    Items = new List <ShoppingBasketItems>()
                }
            };
            ShoppingBasket model = new ShoppingBasket();

            if (HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerShoppingBasket()) != null)
            {
                model = JsonConvert.DeserializeObject <ShoppingBasket>(HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerShoppingBasket()).Value);
            }
            else
            {
                model = new ShoppingBasket()
                {
                    Items = new List <ShoppingBasketItems>()
                };
            }
            AA.ShoppingBasket        = model;
            AA.BasketItemsCount      = model.Items.Count;
            ViewBag.AllAllowDisallow = AA;
            if (coockie != null)
            {
                tcm = CoockieController.SayWhoIsHE(coockie.Value);
                var Id = tcm.id_Customer;
                int dd = 0;
                if (Int32.TryParse(Id, out dd))
                {
                    ViewBag.IsUserLogin = true;
                }
                else
                {
                    ViewBag.IsUserLogin = false;
                }
            }
            else
            {
                ViewBag.IsUserLogin = false;
            }


            base.OnActionExecuting(filterContext);
        }
        public ActionResult customerProfile()
        {
            CustomerModelFiller modelFiller = new CustomerModelFiller();
            tbl_Customer_Main   tcm         = new tbl_Customer_Main();
            var coockie = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerCode());

            if (coockie != null)
            {
                tcm = CoockieController.SayWhoIsHE(coockie.Value);
                var Id = tcm.id_Customer;
                return(View(modelFiller.customerDetail(Convert.ToInt32(Id))));
            }
            else
            {
                return(Content("Error"));
            }
        }
Пример #5
0
        public ActionResult customershoppingCart()
        {
            CustomerModelFiller modelFiller = new CustomerModelFiller();
            tbl_Customer_Main   tcm         = new tbl_Customer_Main();

            if (HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerCode()) != null)
            {
                var coockie = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerCode());
                tcm = CoockieController.SayWhoIsHE(coockie.Value);
            }
            else
            {
                return(RedirectToAction("loginandregister", "CustomerSide_Register"));
            }
            int CustomerId = Convert.ToInt32(tcm.id_Customer);

            if (HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerShoppingBasket()) != null)
            {
                var coockie = JsonConvert.DeserializeObject <ShoppingBasket>(HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerShoppingBasket()).Value);
                var model   = new ShoppingCartModelView()
                {
                    FactorModel = modelFiller.shoppingCart(coockie),
                    Ostan       = modelFiller.Ostanha(),
                    Adresses    = modelFiller.CustomerAddresses(CustomerId),
                    Customer    = modelFiller.customerDetail(CustomerId)
                };

                FactorPopUpModel fpm = model.FactorModel;
                var userCookieIDV    = new HttpCookie(ProjectProperies.CustomerShoppingFactor());
                userCookieIDV.Value   = CoockieController.SetCustomerShopFactorCookie(fpm);
                userCookieIDV.Expires = DateTime.Now.AddDays(2);
                Response.SetCookie(userCookieIDV);
                return(View(model));
            }
            else
            {
                return(RedirectToAction("index", "CustomerSide_Pages"));
            }
        }
        public ActionResult customerProfileAddress()
        {
            CustomerModelFiller modelFiller = new CustomerModelFiller();
            tbl_Customer_Main   tcm         = new tbl_Customer_Main();
            var coockie = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerCode());

            if (coockie != null)
            {
                tcm = CoockieController.SayWhoIsHE(coockie.Value);
                var Id    = tcm.id_Customer;
                var model = new customerAddressModelView()
                {
                    City      = modelFiller.Ostanha(),
                    Addresses = modelFiller.CustomerAddresses(Convert.ToInt32(Id))
                };


                return(View(model));
            }
            else
            {
                return(Content("Error"));
            }
        }
        public ActionResult customerProfileHistory()
        {
            historyProductItemsModelView model = new historyProductItemsModelView()
            {
                History = new List <historyProductCardItemsModel>()
            };
            tbl_Customer_Main tcm = new tbl_Customer_Main();

            if (HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerCode()) != null)
            {
                var coockie = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerCode());
                tcm = CoockieController.SayWhoIsHE(coockie.Value);
            }
            else
            {
                return(RedirectToAction("loginandregister", "CustomerSide_Register"));
            }
            PDBC db = new PDBC();

            db.Connect();
            using (DataTable dt = db.Select("SELECT [id_MainFactor],[MainFactor_CreateDate],[MainFactor_Code],[MainFactor_Price],[MainFactor_IsPay],[MainFactor_Tax],[MainFactor_TotalOff],[PayType] FROM [v_Factor_Main] WHERE [id_Customer] = " + tcm.id_Customer))
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    using (DataTable dt2 = db.Select("SELECT [id_MPC],[id_MainFactor],[id_ChildFactor],[Title],[MoneyTypeName],[PQT_Demansion],[ChildFactor_PurePrice],[ChildFactor_QBuy],[MultyPriceStartFromQ],[MultyPrice],[PriceXquantity]  FROM [v_ChildFactorToProduct] WHERE [id_MainFactor] = " + dt.Rows[i]["id_MainFactor"].ToString()))
                    {
                        db.DC();
                        historyProductCardItemsModel df = new historyProductCardItemsModel()
                        {
                            WhenCreated     = new PersianDateTime(DateTime.Parse(dt.Rows[i]["MainFactor_CreateDate"].ToString())).ToLongDateTimeString(),
                            Ispay           = (dt.Rows[i]["MainFactor_IsPay"].ToString()),
                            OffPrice        = 0,
                            PeygiriCode     = dt.Rows[i]["MainFactor_Code"].ToString(),
                            TaxPrice        = 0,
                            PayMentTypeName = dt.Rows[i]["PayType"].ToString(),
                            PayPrice        = Convert.ToInt64(dt.Rows[i]["MainFactor_Price"].ToString()),
                            TotalPrice      = Convert.ToInt64(dt.Rows[i]["MainFactor_Price"].ToString())
                        };
                        df.AllItems = new List <historyProductTableItemsModel>();
                        for (int j = 0; j < dt2.Rows.Count; j++)
                        {
                            historyProductTableItemsModel ai = new historyProductTableItemsModel()
                            {
                                Countof = dt2.Rows[j]["ChildFactor_QBuy"].ToString(),
                                id_MPC  = dt2.Rows[j]["id_MPC"].ToString(),
                                ProductDimensionName = dt2.Rows[j]["PQT_Demansion"].ToString(),
                                ProductName          = dt2.Rows[j]["Title"].ToString(),
                                scoknameandvalue     = "",
                                ImagePath            = UploaderGeneral.imageFinderfromIDMPC(dt2.Rows[j]["id_MPC"].ToString(), ImageSizeEnums.Thumbnail),
                            };
                            if (Convert.ToInt64(dt2.Rows[j]["ChildFactor_QBuy"].ToString()) > Convert.ToInt64(dt2.Rows[j]["MultyPriceStartFromQ"].ToString()))
                            {
                                ai.pricebperQ = dt2.Rows[j]["MultyPrice"].ToString();
                                ai.TotalPrice = (Convert.ToInt64(ai.pricebperQ) * Convert.ToInt64(dt2.Rows[j]["ChildFactor_QBuy"].ToString())).ToString();
                            }
                            else
                            {
                                ai.pricebperQ = dt2.Rows[j]["PriceXquantity"].ToString();
                                ai.TotalPrice = (Convert.ToInt64(ai.pricebperQ) * Convert.ToInt64(dt2.Rows[j]["ChildFactor_QBuy"].ToString())).ToString();
                            }

                            df.AllItems.Add(ai);
                        }


                        model.History.Add(df);
                        db.Connect();
                    }
                }
                db.DC();
            }


            return(View(model));
        }
        public ActionResult UpdateCustomerPass(string PrePass, string Pass)
        {
            EncDec            enc = new EncDec();
            tbl_Customer_Main tcm = new tbl_Customer_Main();
            var coockie           = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerCode());

            if (coockie != null)
            {
                tcm = CoockieController.SayWhoIsHE(coockie.Value);
                var Id = tcm.id_Customer;


                PDBC db = new PDBC();
                List <ExcParameters> parss = new List <ExcParameters>();
                ExcParameters        par   = new ExcParameters()
                {
                    _KEY   = "@Id",
                    _VALUE = Id
                };
                parss.Add(par);

                par = new ExcParameters()
                {
                    _KEY   = "@PrePass",
                    _VALUE = enc.HMACMD5Generator(PrePass)
                };
                parss.Add(par);

                par = new ExcParameters()
                {
                    _KEY   = "@Pass",
                    _VALUE = enc.HMACMD5Generator(Pass)
                };
                parss.Add(par);


                db.Connect();

                int Count = Convert.ToInt32(db.Select("SELECT COUNT(*) FROM [tbl_Customer_Main] WHERE id_Customer=@Id AND C_Password LIKE @PrePass", parss).Rows[0][0]);

                if (Count > 0)
                {
                    string result = db.Script("UPDATE [tbl_Customer_Main] SET [C_Password]=@Pass WHERE [id_Customer]=@Id", parss);
                    db.DC();
                    if (result == "1")
                    {
                        return(Content("Success"));
                    }
                    else
                    {
                        return(Content("ErrorSQL"));
                    }
                }
                else
                {
                    db.DC();
                    return(Content("pre_Pass"));
                }
            }
            else
            {
                return(Content("Error"));
            }
        }
Пример #9
0
        public JsonResult AddproductToBasket(string idp, string Number_inp)
        {
            var ModelSender = new ErrorReporterModel();

            if (string.IsNullOrEmpty(Number_inp) || Convert.ToInt32(Number_inp) < 1)
            {
                ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "EX186763",
                    Errormessage = $"تعداد محصول خریداری شده معتبر نمیباشد!",
                    Errortype    = "Error"
                };
                return(Json(ModelSender));
            }
            PDBC db = new PDBC();

            tbl_Customer_Main tcm = new tbl_Customer_Main();
            var coockie           = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerCode());

            if (coockie != null)
            {
                tcm = CoockieController.SayWhoIsHE(coockie.Value);
            }
            else
            {
                ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "EX186763",
                    Errormessage = $"ابتدا وارد اکانت کاربری خود شوید!",
                    Errortype    = "Error"
                };
                return(Json(ModelSender));
            }
            var coockie2 = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerShoppingBasket());

            if (coockie2 != null)
            {
                var coockie3 = JsonConvert.DeserializeObject <ShoppingBasket>(HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerShoppingBasket()).Value);
                var KK       = coockie3.Items.Find(x => x.idmpc == idp);
                if (KK != null)
                {
                    coockie3.Items.Remove(KK);
                }
                List <ExcParameters> pars = new List <ExcParameters>();
                ExcParameters        par  = new ExcParameters()
                {
                    _KEY   = "@id_MPC",
                    _VALUE = idp
                };
                pars.Add(par);
                db.Connect();
                using (DataTable dt = db.Select("SELECT [Quantity],[Title] ,[PriceXquantity] ,[PricePerquantity] ,[MultyPriceStartFromQ] ,[MultyPrice] FROM [v_Connector_MainProductConnectorToProduct] WHERE [id_MPC] = @id_MPC AND [tlb_Product_MainProductConnector_ISDELETE] = 0 ", pars))
                {
                    db.DC();
                    if (dt.Rows.Count > 0)
                    {
                        ShoppingBasketItems ssd = new ShoppingBasketItems()
                        {
                            idmpc     = idp,
                            CountOf   = Convert.ToInt32(Number_inp),
                            ImagePath = UploaderGeneral.imageFinderfromIDMPC(idp, ImageSizeEnums.Thumbnail),
                            Title     = dt.Rows[0]["Title"].ToString()
                        };
                        int assd = Convert.ToInt32(dt.Rows[0]["MultyPriceStartFromQ"].ToString());
                        if (Convert.ToInt32(dt.Rows[0]["MultyPriceStartFromQ"].ToString()) < Convert.ToInt32(Number_inp))
                        {
                            ssd.PriceXQ = Convert.ToInt64(dt.Rows[0]["MultyPrice"].ToString());
                        }
                        else
                        {
                            ssd.PriceXQ = Convert.ToInt64(dt.Rows[0]["PriceXquantity"].ToString());
                        }
                        ssd.Totals = ssd.PriceXQ * ssd.CountOf;
                        coockie3.Items.Add(ssd);
                    }
                    else
                    {
                        ModelSender = new ErrorReporterModel
                        {
                            ErrorID      = "EX567763",
                            Errormessage = $"محصول یافت نشد!",
                            Errortype    = "Error"
                        };
                        return(Json(ModelSender));
                    }
                }



                var userCookieIDV = new HttpCookie(ProjectProperies.AuthCustomerShoppingBasket());
                userCookieIDV.Value   = JsonConvert.SerializeObject(coockie3);
                userCookieIDV.Expires = DateTime.Now.AddDays(2);
                Response.SetCookie(userCookieIDV);
                ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "SX106",
                    Errormessage = $"با موفقیت افزوده شد!",
                    Errortype    = "Success"
                };
                return(Json(ModelSender));
            }
            else
            {
                ShoppingBasket SB = new ShoppingBasket()
                {
                    Items = new List <ShoppingBasketItems>()
                };
                List <ExcParameters> pars = new List <ExcParameters>();
                ExcParameters        par  = new ExcParameters()
                {
                    _KEY   = "@id_MPC",
                    _VALUE = idp
                };
                pars.Add(par);
                db.Connect();
                using (DataTable dt = db.Select("SELECT [Quantity] ,[Title],[PriceXquantity] ,[PricePerquantity]   ,[MultyPriceStartFromQ] ,[MultyPrice] FROM [v_Connector_MainProductConnectorToProduct] WHERE [id_MPC] = @id_MPC AND [tlb_Product_MainProductConnector_ISDELETE] = 0 ", pars))
                {
                    db.DC();
                    if (dt.Rows.Count > 0)
                    {
                        ShoppingBasketItems ssd = new ShoppingBasketItems()
                        {
                            idmpc     = idp,
                            CountOf   = Convert.ToInt32(Number_inp),
                            ImagePath = UploaderGeneral.imageFinderfromIDMPC(idp, ImageSizeEnums.Thumbnail),
                            Title     = dt.Rows[0]["Title"].ToString()
                        };
                        if (Convert.ToInt32(dt.Rows[0]["MultyPriceStartFromQ"].ToString()) < Convert.ToInt32(Number_inp))
                        {
                            ssd.PriceXQ = Convert.ToInt64(dt.Rows[0]["MultyPrice"].ToString());
                        }
                        else
                        {
                            ssd.PriceXQ = Convert.ToInt64(dt.Rows[0]["PriceXquantity"].ToString());
                        }
                        ssd.Totals = ssd.PriceXQ * ssd.CountOf;
                        SB.Items.Add(ssd);
                    }
                    else
                    {
                        ModelSender = new ErrorReporterModel
                        {
                            ErrorID      = "EX567763",
                            Errormessage = $"محصول یافت نشد!",
                            Errortype    = "Error"
                        };
                        return(Json(ModelSender));
                    }
                }
                var userCookieIDV = new HttpCookie(ProjectProperies.AuthCustomerShoppingBasket());
                userCookieIDV.Value   = JsonConvert.SerializeObject(SB);
                userCookieIDV.Expires = DateTime.Now.AddDays(2);
                Response.SetCookie(userCookieIDV);
                ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "SX106",
                    Errormessage = $"با موفقیت افزوده شد!",
                    Errortype    = "Success"
                };
                return(Json(ModelSender));
            }
        }
Пример #10
0
        public JsonResult SubmitFactor(string ABC)
        {
            var  ModelSender         = new ErrorReporterModel();
            PDBC db                  = new PDBC();
            List <ExcParameters> pas = new List <ExcParameters>();
            tbl_Customer_Main    tcm = new tbl_Customer_Main();
            var coockie              = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerCode());

            tcm = CoockieController.SayWhoIsHE(coockie.Value);
            FactorPopUpModel fpm       = CoockieController.GetCustomerShopFactorCookie(HttpContext.Request.Cookies.Get(ProjectProperies.CustomerShoppingFactor()).Value);
            string           DeleteAns = "خرید با موفقیت انجام شد!";
            var c = new HttpCookie(ProjectProperies.CustomerShoppingFactor());

            c.Expires = DateTime.Now.AddDays(-1);
            Response.Cookies.Add(c);
            var d = new HttpCookie(ProjectProperies.AuthCustomerShoppingBasket());

            d.Expires = DateTime.Now.AddDays(-1);
            Response.Cookies.Add(d);
            AmountOfProductsLeft itemRemains = new AmountOfProductsLeft();

            for (int i = 0; i < fpm.items.Count; i++)
            {
                if (itemRemains.CanBuyThisProductFromThisShop(fpm.items[i].Id.ToString(), "1", fpm.items[i].number) <= 0)
                {
                    DeleteAns = "متاسفانه موجودی برخی کالا ها برای خرید شما کافی نمیباشد ";
                    fpm.items.RemoveAt(i);
                }
            }
            if (fpm.items.Count == 0)
            {
                ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "SX-fa3432",
                    Errormessage = DeleteAns,
                    Errortype    = "Success"
                };
                return(Json(ModelSender));
            }
            Int64 totals = 0;

            for (int i = 0; i < fpm.items.Count; i++)
            {
                totals += fpm.items[i].total;
            }
            fpm.totality = totals.ToString();
            ExcParameters pa = new ExcParameters()
            {
                _KEY   = "@id_Customer",
                _VALUE = tcm.id_Customer
            };

            pas.Add(pa);
            pa = new ExcParameters()
            {
                _KEY   = "@MainFactor_Code",
                _VALUE = "FM-" + DateTime.Now.Ticks
            };
            pas.Add(pa);
            pa = new ExcParameters()
            {
                _KEY   = "@MainFactor_Price",
                _VALUE = fpm.totality
            };
            pas.Add(pa);
            pa = new ExcParameters()
            {
                _KEY   = "@MainFactor_PaymentCode",
                _VALUE = "FMpc-" + DateTime.Now.Ticks
            };
            pas.Add(pa);
            pa = new ExcParameters()
            {
                _KEY   = "@MainFactor_CreatorID",
                _VALUE = tcm.id_Customer
            };
            pas.Add(pa);
            pa = new ExcParameters()
            {
                _KEY   = "@id_CAddress",
                _VALUE = "4003"
            };
            pas.Add(pa);
            db.Connect();
            string ReturnedID = db.Script("INSERT INTO [tbl_Factor_Main]([id_Customer],[MainFactor_Code],[MainFactor_Price],[MainFactor_IsPay],[MainFactor_PayMessage],[MainFactor_PaymentCode],[MainFactor_Tax],[MainFactor_TotalOff],[MainFactor_CreatedByUserType],[MainFactor_CreatorID],[MainFactor_ISEDITED],[MainFactor_EditedByAdminID],[MainFactor_EditedTo_id_MainFactor],[MainFactor_IsDeleted],[MainFactor_IsReturnedMoney],[MainFactor_PayType],[ChildFactor_DeleteTypeID],[id_CAddress]) output inserted.[id_MainFactor]     VALUES(@id_Customer ,@MainFactor_Code ,@MainFactor_Price ,1,N'NOMessage',@MainFactor_PaymentCode,0,0,2,@MainFactor_CreatorID ,0,0,0,0,0,1,0,@id_CAddress )", pas);

            db.DC();
            int idmf = 0;

            if (Int32.TryParse(ReturnedID, out idmf))
            {
                string flag = "";
                pas = new List <ExcParameters>();
                string res = "";
                db.Connect();
                for (int i = 0; i < fpm.items.Count; i++)
                {
                    pa = new ExcParameters()
                    {
                        _KEY   = "@id_MainFactor",
                        _VALUE = ReturnedID
                    };
                    pas.Add(pa);
                    pa = new ExcParameters()
                    {
                        _KEY   = "@ChildFactor_CreatorID",
                        _VALUE = tcm.id_Customer
                    };
                    pas.Add(pa);
                    pa = new ExcParameters()
                    {
                        _KEY   = "@ChildFactor_ProductID",
                        _VALUE = fpm.items[i].Id
                    };
                    pas.Add(pa);
                    pa = new ExcParameters()
                    {
                        _KEY   = "@ChildFactor_PurePrice",
                        _VALUE = fpm.items[i].total
                    };
                    pas.Add(pa);
                    pa = new ExcParameters()
                    {
                        _KEY   = "@ChildFactor_PurePricee",
                        _VALUE = fpm.items[i].total
                    };
                    pas.Add(pa);
                    pa = new ExcParameters()
                    {
                        _KEY   = "@ChildFactor_QBuy",
                        _VALUE = fpm.items[i].number
                    };
                    pas.Add(pa);

                    string idd = db.Script("INSERT INTO [tbl_Factor_ChildFactor]([id_MainFactor],[ChildFactor_DeleteTypeID],[ChildFactor_DeletedByAdminID],[ChildFactor_ISDELETED],[ChildFactor_CreateDate],[ChildFactor_CreatedByUserTypeID],[ChildFactor_CreatorID],[ChildFactor_ProductModuleType],[ChildFactor_ProductID],[ChildFactor_PastProductHistoryID],[ChildFactor_HasOff],[ChildFactor_OffID],[ChildFactor_OffCode],[ChildFactor_OffPrice],[ChildFactor_PurePrice],[ChildFactor_PriceAfterOff],[ChildFactor_ProductReturnTypeID],[ChildFactor_ISCERTIFIED],[ChildFactor_ISEDITED],[ChildFactor_EditedByAdminID],[ChildFactor_EditedTo_id_ChildFactor],[ChildFactor_QBuy]) OUTPUT inserted.[id_ChildFactor] VALUES(@id_MainFactor,0,0,0,GETDATE(),2,@ChildFactor_CreatorID ,1,@ChildFactor_ProductID ,0,0,0,N' ',0,@ChildFactor_PurePrice ,@ChildFactor_PurePricee,0,1,0,0,0,@ChildFactor_QBuy )", pas);

                    res  += db.Script("INSERT INTO  [tbl_Factor_FactorInStock]([id_ChildFactor],[FactorInStock_FirstShopID],[FactorInStock_SecondShopID],[FactorInStock_CreatedDate],[FactorInStock_TransActionByAdminID],[FactorInStock_HasTransAction]) VALUES(" + idd + " ,1 ,0,GETDATE(),0,0)");
                    flag += "1";
                }
                db.DC();
                if (flag == res)
                {
                    ModelSender = new ErrorReporterModel
                    {
                        ErrorID      = "SX-fa3432",
                        Errormessage = DeleteAns,
                        Errortype    = "Success"
                    };
                    return(Json(ModelSender));
                }
                else
                {
                    ModelSender = new ErrorReporterModel
                    {
                        ErrorID      = "EX15779455",
                        Errormessage = $"خرید انجام نشد!",
                        Errortype    = "Error"
                    };
                    return(Json(ModelSender));
                }
            }
            else
            {
                ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "EX785673455",
                    Errormessage = $"خرید انجام نشد!!",
                    Errortype    = "Error"
                };
                return(Json(ModelSender));
            }
        }