Ejemplo n.º 1
0
        public List <Id_ValueModel> C_AllTags_Filler()
        {
            PDBC db = new PDBC("PandaMarketCMS", true);

            db.Connect();
            var res = new List <Id_ValueModel>();

            DataTable dt = db.Select("SELECT [G_Id],[name] FROM [tbl_BLOG_Groups] WHERE [Is_Deleted]=0 AND [Is_Disabled]=0 ");

            db.DC();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                var model = new Id_ValueModel()
                {
                    Id    = Convert.ToInt32(dt.Rows[i]["G_Id"]),
                    Value = dt.Rows[i]["name"].ToString()
                };
                res.Add(model);
            }

            return(res);
        }
Ejemplo n.º 2
0
        public ActionResult Index()
        {
            List <postpage> obj = new List <postpage>();
            PDBC            db  = new PDBC("webmvc", true);

            db.Connect();
            using (DataTable dt = db.Select("SELECT [id],[name],[text],[image] FROM [dbo].[postpage] order by [id]  desc"))
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    postpage ad = new postpage();
                    ad.id    = dt.Rows[i]["id"].ToString();
                    ad.name  = dt.Rows[i]["name"].ToString();
                    ad.image = dt.Rows[i]["image"].ToString();
                    ad.text  = dt.Rows[i]["text"].ToString();
                    obj.Add(ad);
                }
                ViewBag.Tit = obj;
                db.DC();
            }
            return(View());
        }
Ejemplo n.º 3
0
        public ActionResult ContactUsMessage(string Name, string Email, string Subject, string Message)
        {
            PDBC db = new PDBC("PandaMarketCMS", true);
            List <ExcParameters> parss = new List <ExcParameters>();
            ExcParameters        par   = new ExcParameters()
            {
                _KEY   = "@Name",
                _VALUE = Name
            };

            parss.Add(par);

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

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

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

            db.Connect();
            db.Script("INSERT INTO [tbl_CotactUs]VALUES(@Email,@Name,@Subject,@Message)", parss);
            db.DC();
            return(Content("Success"));
        }
Ejemplo n.º 4
0
        public List <CustomerSidePostModel> UserPostModels(string Cat, int Page, int Id, string search, string DateType = "Date")
        {
            var  res = new List <CustomerSidePostModel>();
            PDBC db  = new PDBC();

            db.Connect();
            DataTable dt = db.Select(QueryMaker_BlogPost(Cat, Page, Id, search));

            db.DC();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                var model = new CustomerSidePostModel()
                {
                    Id              = Convert.ToInt32(dt.Rows[i]["Id"]),
                    by              = dt.Rows[i]["adminName"].ToString(),
                    Category        = dt.Rows[i]["Category"].ToString(),
                    InGroup         = dt.Rows[i]["GroupName"].ToString(),
                    GPIDforPostPAge = dt.Rows[i]["GroupId"].ToString(),
                    ImagePath       = dt.Rows[i]["Pic"].ToString(),
                    IsDeleted       = Convert.ToInt32(dt.Rows[i]["Is_Deleted"]),
                    IsDisabled      = Convert.ToInt32(dt.Rows[i]["Is_Disabled"]),
                    text            = dt.Rows[i]["Text"].ToString(),
                    title           = dt.Rows[i]["Title"].ToString(),
                    text_min        = dt.Rows[i]["Text_min"].ToString(),
                    date            = DateConvert.DateReturner(dt.Rows[i]["Date"].ToString(), DateType),
                    AdminPic        = dt.Rows[i]["AdminPic"].ToString()
                };

                if (string.IsNullOrEmpty(model.ImagePath))
                {
                    model.ImagePath = NoImage;
                }


                res.Add(model);
            }
            return(res);
        }
Ejemplo n.º 5
0
        public string insertsToTUBUSER(string posted)
        {
            user_login obj = JsonConvert.DeserializeObject <user_login>(posted);

            sessionCaptcha = obj.captcha;

            string str   = "";
            bool   is_ok = false;
            int    j     = 0;
            PDBC   db    = new PDBC("honarjoo");

            db.Connect();
            using (DataTable dt = db.Select("SELECT [id],[name],[us],[pass] FROM [dbo].[login]"))
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    while (j == i)
                    {
                        if (dt.Rows[j].ItemArray[2].ToString() == obj.us && dt.Rows[j].ItemArray[3].ToString() == obj.pass)
                        {
                            str   = dt.Rows[j].ItemArray[1].ToString();
                            is_ok = true;
                            break;
                        }
                        j++;
                        db.DC();
                    }
                }
                if (is_ok == true)
                {
                    return(str);
                }
                else
                {
                    return("-1");
                }
            }
        }
        public ActionResult Uploader_Image()
        {
            PDBC db = new PDBC();

            db.Connect();
            UploaderAlertModelView model = new UploaderAlertModelView();

            model.Alerts = new List <UploaderModelToAlertSizes>();
            using (DataTable dt = db.Select("SELECT [picSizeTypeWidth] ,[picSizeTypeHeight]  FROM [tbl_ADMIN_UploaderStructure_ImageSize]"))
            {
                db.DC();
                for (int idPT = 0; idPT < dt.Rows.Count; idPT++)
                {
                    model.Alerts.Add(new UploaderModelToAlertSizes()
                    {
                        Height = dt.Rows[idPT]["picSizeTypeHeight"].ToString(),
                        Width  = dt.Rows[idPT]["picSizeTypeWidth"].ToString()
                    });
                }
            }
            TempData["SizesToaler"] = model;
            return(View());
        }
Ejemplo n.º 7
0
        public List <TableModel> SearchResult(string search)
        {
            PDBC db = new PDBC("PandaMarketCMS", true);

            db.Connect();

            DataTable dt = db.Select("SELECT top 100 [Id],[Title],(SELECT top 1 B.PicAddress FROM [tbl_BLOG_Pic_Connector] as A inner join [tbl_ADMIN_UploadStructure_ImageAddress] as B on A.[PicId]=B.PicID where A.PostId=Id)as Pic FROM [tbl_BLOG_Post] where Is_Deleted=0 AND Is_Disabled=0 AND Title Like N'%" + search + "%' OR Text_min Like N'%" + search + "%' OR [Text] Like N'%" + search + "%' order by([weight])DESC,[date] DESC");

            db.DC();
            var res = new List <TableModel>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                var model = new TableModel()
                {
                    Group1 = AppendServername(dt.Rows[i]["Pic"].ToString()),
                    Group2 = dt.Rows[i]["Title"].ToString(),
                    Id     = Convert.ToInt32(dt.Rows[i]["Id"])
                };
                res.Add(model);
            }
            return(res);
        }
Ejemplo n.º 8
0
        public ActionResult ProductTag_Actions(string ActToDo, int id)
        {
            string SSSession = ""; if (HttpContext.Request.Cookies["TSHPANDAControll" + StaticLicense.LicName] != null)

            {
                HttpCookie cookie = HttpContext.Request.Cookies.Get("TSHPANDAControll" + StaticLicense.LicName); if (cookie != null)
                {
                    SSSession = cookie.Value;
                }
                else
                {
                    SSSession = "N.A";
                }
            }
            else
            {
                SSSession = "N.A";
            }
            CheckAccess check = new CheckAccess(SSSession);

            if (check.HasAccess)
            {
                PDBC db = new PDBC("PandaMarketCMS", true);
                db.Connect();
                if (ActToDo == "Delete")
                {
                    db.Script("DELETE FROM [tbl_Product_tagConnector] WHERE id_TE=" + id);
                    db.Script("DELETE FROM [tbl_Product_TagEnums] WHERE id_TE=" + id);
                }
                db.DC();
                return(Content("Success"));
            }
            else
            {
                return(Content("NotAccess"));
            }
        }
Ejemplo n.º 9
0
        public ActionResult Factor_Actions(string ActToDo, int id)
        {
            string SSSession = ""; if (HttpContext.Request.Cookies["TSHPANDAControll" + StaticLicense.LicName] != null)

            {
                HttpCookie cookie = HttpContext.Request.Cookies.Get("TSHPANDAControll" + StaticLicense.LicName); if (cookie != null)
                {
                    SSSession = cookie.Value;
                }
                else
                {
                    SSSession = "N.A";
                }
            }
            else
            {
                SSSession = "N.A";
            }
            CheckAccess check = new CheckAccess(SSSession);

            if (check.HasAccess)
            {
                PDBC db = new PDBC("PandaMarketCMS", true);
                db.Connect();
                if (ActToDo == "Delete")
                {
                    ///userType --> 1=Admin  ,0=user
                    db.Script("UPDATE [dbo].[tbl_FACTOR_Main] SET [IsDeleted] = 1 ,[delete_by_Id] = 1 ,[delete_UserType] = 2 WHERE Factor_Id=" + id);
                }
                db.DC();
                return(Content("Success"));
            }
            else
            {
                return(Content("NotAccess"));
            }
        }
Ejemplo n.º 10
0
        //////////////////////////////////////////////BlogPost      tbl_BLOG
        public tbl_BLOG BLOGPOST(string id)
        {
            PDBC   db    = new PDBC("PandaMarketCMS", true);
            string query = "";

            query += " SELECT  [tbl_BLOG_Post].[Id], [Title],[Text_min],[Text],[Date]  ,[name] as'Cat_Id' ";
            query += " ,(SELECT [ad_firstname]FROM  [tbl_ADMIN_main] where[id_Admin]= [tbl_BLOG_Post].[WrittenBy_AdminId]) as'firstname'";
            query += " ,(SELECT [ad_lastname]FROM  [tbl_ADMIN_main] where[id_Admin]= [tbl_BLOG_Post].[WrittenBy_AdminId]) as'lastname'";
            query += " ,(SELECT count([Id])FROM  [tbl_BLOG_Comment]where [PostId] = [tbl_BLOG_Post].[Id] )as'Comments'";
            query += " FROM  [tbl_BLOG_Post]";
            query += " inner join  [tbl_BLOG_Categories] on  [tbl_BLOG_Post].[Cat_Id] =  [tbl_BLOG_Categories].[Id] ";
            query += " where  [tbl_BLOG_Post].[Is_Deleted]  like 0 AND   [tbl_BLOG_Post].[Is_Disabled] like 0";
            query += " And  [tbl_BLOG_Categories].[Is_Deleted]  like 0 AND   [tbl_BLOG_Categories].[Is_Disabled] like 0";
            query += " And [tbl_BLOG_Post].[Id]=" + id;

            db.Connect();
            DataTable dt = db.Select(query);

            db.DC();
            var tbg = new tbl_BLOG
            {
                Id                = Convert.ToInt32(dt.Rows[0]["Id"]),
                Title             = dt.Rows[0]["Title"].ToString(),
                Text_min          = dt.Rows[0]["Text_min"].ToString(),
                Text              = dt.Rows[0]["Text"].ToString(),
                Date              = dt.Rows[0]["Date"].ToString(),
                Cat_Id            = dt.Rows[0]["Cat_Id"].ToString(),
                Comments          = dt.Rows[0]["Comments"].ToString(),
                WrittenBy_AdminId = dt.Rows[0]["firstname"].ToString() + " " + dt.Rows[0]["lastname"].ToString(),
                list_pic          = Pic_BLOG(dt.Rows[0]["Id"].ToString()),
                list_cat          = BLOG_Categories(dt.Rows[0]["Cat_Id"].ToString(), true),
                list_comment      = list_comm(dt.Rows[0]["Id"].ToString())
            };

            return(tbg);
        }
Ejemplo n.º 11
0
        public ActionResult post(int id)
        {
            List <postpage> obj = new List <postpage>();
            PDBC            db  = new PDBC("webmvc", true);

            db.Connect();
            using (DataTable dt = db.Select($"SELECT [name],[text],[image]FROM [dbo].[postpage] where id ='{id}'"))
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    postpage ad = new postpage();
                    ad.id    = Convert.ToString(id);
                    ad.name  = dt.Rows[i]["name"].ToString();
                    ad.image = dt.Rows[i]["image"].ToString();
                    ad.text  = dt.Rows[i]["text"].ToString();
                    obj.Add(ad);
                }
                ID             = Convert.ToInt32(obj[0].id);
                Session["idd"] = ID;
                ViewBag.post   = obj;
                db.DC();
            }
            return(View());
        }
 public static string imageFinder(string id, ImageSizeEnums imageSize = ImageSizeEnums.AllSize)
 {
     if (string.IsNullOrEmpty(id))
     {
         return("/CustomerSide_desinerResource/images/shop/imgNotFount.jpg");
     }
     else
     {
         PDBC db = new PDBC();
         db.Connect();
         using (DataTable dt = db.Select("SELECT [orgUploadAddress] FROM [v_tblProduct_Image] WHERE [PicID] = " + id))
         {
             db.DC();
             if (dt.Rows.Count > 0)
             {
                 return(dt.Rows[0]["orgUploadAddress"].ToString());
             }
             else
             {
                 return("/CustomerSide_desinerResource/images/shop/imgNotFount.jpg");
             }
         }
     }
 }
Ejemplo n.º 13
0
        public string Add_Update_Group(string Action, string Name, string Token, int id = 0)
        {
            PDBC db = new PDBC("PandaMarketCMS", true);

            db.Connect();
            string resultPost = "";

            if (string.IsNullOrEmpty(Token))
            {
                return("پرکردن فیلد توکن اجباری میباشد");
            }
            if (string.IsNullOrEmpty(Name))
            {
                return("پرکردن فیلد نام گروه اجباری میباشد");
            }
            List <ExcParameters> paramss = new List <ExcParameters>();

            if (Action == "insert")
            {
                ExcParameters par = new ExcParameters()
                {
                    _KEY   = "@Tok",
                    _VALUE = Token
                };
                paramss.Add(par);
                using (DataTable dt = db.Select("SELECT COUNT(*) FROM [tbl_BLOG_Groups] WHERE GpToken LIKE @Tok", paramss))
                {
                    paramss = new List <ExcParameters>();
                    if (dt.Rows[0][0].ToString() == "0")
                    {
                        par = new ExcParameters()
                        {
                            _KEY   = "@Name",
                            _VALUE = Name
                        };
                        paramss.Add(par);
                        par = new ExcParameters()
                        {
                            _KEY   = "@Token",
                            _VALUE = Token
                        };
                        paramss.Add(par);
                        resultPost = db.Script("INSERT INTO [tbl_BLOG_Groups] VALUES (@Name,0,0,@Token)", paramss);
                        if (resultPost != "1")
                        {
                            resultPost = "عدم توانایی در ایجاد گروه";
                        }
                    }
                    else
                    {
                        resultPost = "این توکن در پایگاه داده موجود میباشد!";
                    }
                }
            }
            else if (Action == "Update")
            {
                paramss = new List <ExcParameters>();
                ExcParameters par = new ExcParameters()
                {
                    _KEY   = "@Name",
                    _VALUE = Name
                };
                paramss.Add(par);
                par = new ExcParameters()
                {
                    _KEY   = "@Token",
                    _VALUE = Token
                };
                paramss.Add(par);
                par = new ExcParameters()
                {
                    _KEY   = "@G_Id",
                    _VALUE = id
                };
                paramss.Add(par);
                resultPost = db.Script("UPDATE [tbl_BLOG_Groups] SET [name] = @Name , [GpToken] = @Token WHERE G_Id= @G_Id", paramss);
                if (resultPost != "1")
                {
                    resultPost = "عدم توانایی در بروز رسانی";
                }
            }
            if (resultPost == "1")
            {
                db.DC();
                return("Success");
            }
            else
            {
                db.DC();
                return(resultPost);
            }
        }
Ejemplo n.º 14
0
        public string Post_Action(string Action, int WrittenBy_AdminId, string Title, string Text_min, string Text, int weight, int Cat_Id, int IsImportant, int GroupId, string Pictures, string Blog_Tags, int TypeId, int id_pr = 0)
        {
            List <ExcParameters> paramss = new List <ExcParameters>();
            PDBC db = new PDBC("PandaMarketCMS", true);

            var parameters = new ExcParameters()
            {
                _KEY   = "@Title",
                _VALUE = Title
            };

            paramss.Add(parameters);

            parameters = new ExcParameters()
            {
                _KEY   = "@Text_min",
                _VALUE = Text_min
            };
            paramss.Add(parameters);

            parameters = new ExcParameters()
            {
                _KEY   = "@Text",
                _VALUE = Text
            };
            paramss.Add(parameters);

            parameters = new ExcParameters()
            {
                _KEY   = "@WrittenBy_AdminId",
                _VALUE = WrittenBy_AdminId
            };
            paramss.Add(parameters);

            parameters = new ExcParameters()
            {
                _KEY   = "@weight",
                _VALUE = weight
            };
            paramss.Add(parameters);

            parameters = new ExcParameters()
            {
                _KEY   = "@IsImportant",
                _VALUE = IsImportant
            };
            paramss.Add(parameters);

            parameters = new ExcParameters()
            {
                _KEY   = "@Cat_Id",
                _VALUE = Cat_Id
            };
            paramss.Add(parameters);

            parameters = new ExcParameters()
            {
                _KEY   = "@GroupId",
                _VALUE = GroupId
            };
            paramss.Add(parameters);

            parameters = new ExcParameters()
            {
                _KEY   = "@TypeId",
                _VALUE = TypeId
            };
            paramss.Add(parameters);
            string query = "";

            if (Action.Equals("insert"))
            {
                query = "INSERT INTO [tbl_BLOG_Post] output inserted.Id VALUES(@Title, @Text_min ,@Text, @WrittenBy_AdminId, GETDATE(), @weight, @IsImportant, 0, 1, @Cat_Id, @GroupId,@TypeId)";
            }
            else if (Action == "update")
            {
                query = "UPDATE [tbl_BLOG_Post] SET [Title] = @Title ,[Text_min] = @Text_min ,[Text] = @Text ,[weight] = @weight ,[IsImportant] = @IsImportant ,[Cat_Id] = @Cat_Id ,[GroupId] = @GroupId , [TypeId]=@TypeId WHERE Id=" + id_pr;
            }

            string id = "0";

            db.Connect();
            if (query != "")
            {
                id = db.Script(query, paramss);
            }
            if (id != "0" && Action.Equals("insert"))
            {
                var Post_picturse = Pictures.Split(',');
                for (int i = 0; i < Post_picturse.Length; i++)
                {
                    db.Script("INSERT INTO [tbl_BLOG_Pic_Connector]VALUES(" + id + "," + Post_picturse[i] + ")");
                }

                var Tags = Blog_Tags.Split(',');
                for (int j = 0; j < Tags.Length; j++)
                {
                    db.Script("INSERT INTO [tbl_BLOG_TagConnector] VALUES(" + id + "," + Tags[j] + ")");
                }
            }
            else if (Action == "update")
            {
                db.Script("DELETE FROM [tbl_BLOG_Pic_Connector] WHERE PostId=" + id_pr);
                var Post_picturse = Pictures.Split(',');
                for (int i = 0; i < Post_picturse.Length; i++)
                {
                    db.Script("INSERT INTO [tbl_BLOG_Pic_Connector]VALUES(" + id_pr + "," + Post_picturse[i] + ")");
                }

                db.Script("DELETE FROM [tbl_BLOG_TagConnector] WHERE Post_Id=" + id_pr);//delete
                var Tags = Blog_Tags.Split(',');
                for (int j = 0; j < Tags.Length; j++)
                {
                    db.Script("INSERT INTO [tbl_BLOG_TagConnector] VALUES(" + id_pr + "," + Tags[j] + ")");
                }
            }
            db.DC();

            return("Success");
        }
        public ActionResult ProductInStockpile(int PSID)
        {
            ProductInStockpileModelView model = new ProductInStockpileModelView();
            PDBC          db  = new PDBC();
            ExcParameters par = new ExcParameters()
            {
                _KEY   = "@id_MPC",
                _VALUE = PSID
            };
            List <ExcParameters> pars = new List <ExcParameters>();

            pars.Add(par);
            string id_MProductReal = "";

            db.Connect();
            using (DataTable dtproduct = db.Select("SELECT [MoneyTypeName],[PQT_Demansion], [id_MProduct],[MultyPriceStartFromQ],[code_Stockpile],[Description],[MultyPrice],[Title],[PricePerquantity] FROM [v_Connector_MainProductConnectorToProduct] WHERE [id_MPC] = @id_MPC", pars))
            {
                db.DC();
                if (dtproduct.Rows.Count > 0)
                {
                    id_MProductReal = dtproduct.Rows[0]["id_MProduct"].ToString();

                    model.ShowPSIDs = new ShowPSID()
                    {
                        id_MPC = PSID.ToString(),
                        MultyPriceStartFromQ = dtproduct.Rows[0]["MultyPriceStartFromQ"].ToString(),
                        PicList                   = new List <string>(),
                        ProductCode               = dtproduct.Rows[0]["code_Stockpile"].ToString(),
                        ProductDescription        = dtproduct.Rows[0]["Description"].ToString(),
                        ProductMultyPrice         = dtproduct.Rows[0]["MultyPrice"].ToString(),
                        ProductName               = dtproduct.Rows[0]["Title"].ToString(),
                        ProductPurePrice          = dtproduct.Rows[0]["PricePerquantity"].ToString(),
                        ShopAvailable4Transaction = new List <Key_ValueModel>(),
                        ShopList                  = new List <Shops>(),
                        socKandSockvlList         = new List <ProductViewDetails_ProductSOCKandSOCKVLList>(),
                        STHList                   = new List <StockpileTransactionHistoryModel>(),
                        MoneyType                 = dtproduct.Rows[0]["MoneyTypeName"].ToString(),
                        demansion                 = dtproduct.Rows[0]["PQT_Demansion"].ToString(),
                    };
                }
                else
                {
                    return(RedirectToAction("Index"));
                }
            }
            //===========================pics
            db.Connect();
            using (DataTable dt = db.Select("SELECT [orgUploadAddress] FROM [v_tblProduct_Image] WHERE [id_MProduct]=" + id_MProductReal))
            {
                db.DC();
                int dtrows = dt.Rows.Count;
                for (int i = 0; i < dtrows; i++)
                {
                    model.ShowPSIDs.PicList.Add(dt.Rows[i]["orgUploadAddress"].ToString());
                }
            }
            if (model.ShowPSIDs.PicList.Count == 0)
            {
                model.ShowPSIDs.PicList.Add("/AdminDesignResource/app/media/img/users/user4.jpg");
            }
            //==============================Shops
            db.Connect();
            using (DataTable dtstock = db.Select("SELECT  [id_Stockpile]  ,[id_Stockpile_AllowType] ,[shop_id] ,[shop_name] ,[shop_IsAvailable] ,[shop_IsDelete]  FROM [v_Stockpile_MainView] WHERE [id_MPC] = " + PSID))
            {
                db.DC();
                AmountOfProductsLeft AOPL = new AmountOfProductsLeft();
                for (int i = 0; i < dtstock.Rows.Count; i++)
                {
                    bool CalCulatingFromShops = false;
                    if (dtstock.Rows[i]["id_Stockpile_AllowType"].ToString() == "1")
                    {
                        CalCulatingFromShops = true;
                    }
                    bool ISActivate = false;
                    if (dtstock.Rows[i]["shop_IsDelete"].ToString() == "0" && dtstock.Rows[i]["shop_IsAvailable"].ToString() == "1")
                    {
                        ISActivate = true;
                    }
                    //ProductCALCULATOR
                    Int64  ProductAvailableCount = AOPL.CanBuyThisProductFromThisShop(PSID.ToString(), dtstock.Rows[i]["shop_id"].ToString(), -1);
                    string BootstrapColor        = "";
                    if (ProductAvailableCount > 200)
                    {
                        BootstrapColor = BootstrapColorPicker.GetbootstrapColorByTag(BootstrapColorEnums.success);
                    }
                    else if (ProductAvailableCount > 100)
                    {
                        BootstrapColor = BootstrapColorPicker.GetbootstrapColorByTag(BootstrapColorEnums.warning);
                    }
                    else
                    {
                        BootstrapColor = BootstrapColorPicker.GetbootstrapColorByTag(BootstrapColorEnums.danger);
                    }
                    model.ShowPSIDs.ShopList.Add(new Shops()
                    {
                        ShopName              = dtstock.Rows[i]["shop_name"].ToString(),
                        CalCulatingFromShop   = CalCulatingFromShops,
                        ISActivate            = ISActivate,
                        ProductAvailableCount = String.Format("{0:n0}", ProductAvailableCount),
                        BootstrapColor        = BootstrapColor
                    });
                }
            }

            //===================================socKandSockvlList
            db.Connect();
            using (DataTable dtproduct = db.Select("SELECT [PTname], [MCName],[SCName]  FROM [v_Connector_MainProductConnectorToProduct] WHERE [id_MPC] = " + PSID))
            {
                using (DataTable dt = db.Select("SELECT [id_MPC] ,[SCOKName] ,[SCOVValueName] FROM [v_ConnectorTheProductConnectorViewToSCOVandSCOKV_s] WHERE [id_MProduct] = " + id_MProductReal + " ORDER BY [id_MPC] DESC"))
                {
                    db.DC();
                    if (dt.Rows.Count > 0)
                    {
                        int dtrows = dt.Rows.Count;
                        ProductViewDetails_ProductSOCKandSOCKVLList products = new ProductViewDetails_ProductSOCKandSOCKVLList();
                        products.ProductSOCKSOCKVList = new List <ProductViewDetails_ProductSOCKandSOCKVL>();
                        string id_MPC = "";
                        products.ProductSOCKSOCKVList.Add(new ProductViewDetails_ProductSOCKandSOCKVL()
                        {
                            BootstrapColor = BootstrapColorPicker.GetbootstrapColorByTag(BootstrapColorEnums.primary),
                            SOCKName       = "سردسته بندی اصلی",
                            SOCKVName      = dtproduct.Rows[0]["PTname"].ToString()
                        });
                        products.ProductSOCKSOCKVList.Add(new ProductViewDetails_ProductSOCKandSOCKVL()
                        {
                            BootstrapColor = BootstrapColorPicker.GetbootstrapColorByTag(BootstrapColorEnums.primary),
                            SOCKName       = "گروه اصلی",
                            SOCKVName      = dtproduct.Rows[0]["MCName"].ToString()
                        });
                        products.ProductSOCKSOCKVList.Add(new ProductViewDetails_ProductSOCKandSOCKVL()
                        {
                            BootstrapColor = BootstrapColorPicker.GetbootstrapColorByTag(BootstrapColorEnums.primary),
                            SOCKName       = "گروه محصول",
                            SOCKVName      = dtproduct.Rows[0]["SCName"].ToString()
                        });
                        for (int i = 0; i < dtrows; i++)
                        {
                            if (id_MPC != dt.Rows[i]["id_MPC"].ToString())
                            {
                                if (!string.IsNullOrEmpty(id_MPC))
                                {
                                    products.id_MPC = id_MPC;
                                    model.ShowPSIDs.socKandSockvlList.Add(products);
                                    products = new ProductViewDetails_ProductSOCKandSOCKVLList();
                                    products.ProductSOCKSOCKVList = new List <ProductViewDetails_ProductSOCKandSOCKVL>();
                                    products.id_MPC = dt.Rows[i]["id_MPC"].ToString();
                                    products.ProductSOCKSOCKVList.Add(new ProductViewDetails_ProductSOCKandSOCKVL()
                                    {
                                        BootstrapColor = BootstrapColorPicker.GetbootstrapColorByTag(BootstrapColorEnums.primary),
                                        SOCKName       = "سردسته بندی اصلی",
                                        SOCKVName      = dtproduct.Rows[0]["PTname"].ToString()
                                    });
                                    products.ProductSOCKSOCKVList.Add(new ProductViewDetails_ProductSOCKandSOCKVL()
                                    {
                                        BootstrapColor = BootstrapColorPicker.GetbootstrapColorByTag(BootstrapColorEnums.primary),
                                        SOCKName       = "گروه اصلی",
                                        SOCKVName      = dtproduct.Rows[0]["MCName"].ToString()
                                    });
                                    products.ProductSOCKSOCKVList.Add(new ProductViewDetails_ProductSOCKandSOCKVL()
                                    {
                                        BootstrapColor = BootstrapColorPicker.GetbootstrapColorByTag(BootstrapColorEnums.primary),
                                        SOCKName       = "گروه محصول",
                                        SOCKVName      = dtproduct.Rows[0]["SCName"].ToString()
                                    });
                                }
                            }
                            products.ProductSOCKSOCKVList.Add(new ProductViewDetails_ProductSOCKandSOCKVL()
                            {
                                BootstrapColor = BootstrapColorPicker.GetbootstrapColorRandomByCounter(i),
                                SOCKName       = dt.Rows[i]["SCOKName"].ToString(),
                                SOCKVName      = dt.Rows[i]["SCOVValueName"].ToString()
                            });
                            id_MPC = dt.Rows[i]["id_MPC"].ToString();
                            if (i == dtrows - 1)
                            {
                                products.id_MPC = id_MPC;
                                model.ShowPSIDs.socKandSockvlList.Add(products);
                            }
                        }
                    }
                    else
                    {
                        return(RedirectToAction("index"));
                    }
                }
            }

            //=-=======================================StockpileTransactionHistoryModel

            db.Connect();
            using (DataTable dt = db.Select("SELECT [shop_id], [id_TransactionType], [PQT_Demansion],[PQTValueOf_Transaction],[PriceOf_Transaction],[shop_name],[StockpileDate_Transaction],[StockpileTime_Transaction],[MoneyTypeName] FROM  [v_Stockpile_Transactions] WHERE [id_MPC] = " + PSID + " ORDER BY [id_Transaction] DESC"))
            {
                db.DC();
                int dtcount = dt.Rows.Count;
                if (dtcount > 0)
                {
                    for (int i = 0; i < dtcount; i++)
                    {
                        StockpileTransactionHistoryModel historyModel = new StockpileTransactionHistoryModel();
                        // {
                        //     BootstrapColor = BootstrapColorPicker.GetbootstrapColorByTag(BootstrapColorEnums.danger),
                        //     Dimension = "موردی یافت نشد",
                        //     HajmSadere = "موردی یافت نشد",x
                        //     HajmVarede = "موردی یافت نشد",x
                        //     MiyanginGheymateSadere = "موردی یافت نشد"x
                        //,
                        //     MiyanginGheymateVarede = "موردی یافت نشد",x
                        //     Mojoodi = "موردی یافت نشد",x
                        //     ShopID = "موردی یافت نشد",x
                        //     ShopName = "موردی یافت نشد",x
                        //     TotalPriceOfsadere = "موردی یافت نشد",x
                        //     TotalPriceOfVarede = "موردی یافت نشد",x
                        //     TransActionDate = "موردی یافت نشد",x
                        // };
                        historyModel.ShopID   = dt.Rows[i]["shop_id"].ToString();
                        historyModel.ShopName = dt.Rows[i]["shop_name"].ToString();
                        historyModel.Mojoodi  = "0";
                        PersianDateTime pdt = new PersianDateTime(DateTime.Parse(dt.Rows[i]["StockpileDate_Transaction"].ToString()));
                        historyModel.TransActionDate = pdt.ToLongDateString() + " " + dt.Rows[i]["StockpileTime_Transaction"].ToString();
                        historyModel.Dimension       = dt.Rows[i]["PQT_Demansion"].ToString();

                        if (dt.Rows[i]["id_TransactionType"].ToString() == "1")
                        {
                            historyModel.BootstrapColor         = BootstrapColorPicker.GetbootstrapColorByTag(BootstrapColorEnums.success);
                            historyModel.HajmSadere             = "0";
                            historyModel.MiyanginGheymateSadere = "0";
                            historyModel.TotalPriceOfsadere     = "0";
                            historyModel.HajmVarede             = String.Format("{0:n0}", dt.Rows[i]["PQTValueOf_Transaction"].ToString());
                            historyModel.MiyanginGheymateVarede = "0";
                            historyModel.TotalPriceOfVarede     = String.Format("{0:n0}", dt.Rows[i]["PriceOf_Transaction"].ToString()) + " " + dt.Rows[i]["PQT_Demansion"].ToString();
                        }
                        else
                        {
                            historyModel.BootstrapColor         = BootstrapColorPicker.GetbootstrapColorByTag(BootstrapColorEnums.danger);
                            historyModel.HajmVarede             = "0";
                            historyModel.MiyanginGheymateVarede = "0";
                            historyModel.TotalPriceOfVarede     = "0";
                            historyModel.HajmSadere             = String.Format("{0:n0}", dt.Rows[i]["PQTValueOf_Transaction"].ToString());
                            historyModel.MiyanginGheymateSadere = "0";
                            historyModel.TotalPriceOfsadere     = String.Format("{0:n0}", dt.Rows[i]["PriceOf_Transaction"].ToString()) + " " + dt.Rows[i]["PQT_Demansion"].ToString();
                        }



                        model.ShowPSIDs.STHList.Add(historyModel);
                    }
                }
                else
                {
                    StockpileTransactionHistoryModel historyModel = new StockpileTransactionHistoryModel()
                    {
                        BootstrapColor         = BootstrapColorPicker.GetbootstrapColorByTag(BootstrapColorEnums.danger),
                        Dimension              = "موردی یافت نشد",
                        HajmSadere             = "موردی یافت نشد",
                        HajmVarede             = "موردی یافت نشد",
                        MiyanginGheymateSadere = "موردی یافت نشد"
                        ,
                        MiyanginGheymateVarede = "موردی یافت نشد",
                        Mojoodi            = "موردی یافت نشد",
                        ShopID             = "موردی یافت نشد",
                        ShopName           = "موردی یافت نشد",
                        TotalPriceOfsadere = "موردی یافت نشد",
                        TotalPriceOfVarede = "موردی یافت نشد",
                        TransActionDate    = "موردی یافت نشد",
                    };
                    model.ShowPSIDs.STHList.Add(historyModel);
                }
            }
            //================================================ ShopAvailable4Transaction
            //=================>MRMNeedsEdit
            db.Connect();
            using (DataTable shops = db.Select("SELECT   [shop_id] ,[shop_name]  FROM [tbl_Modules_StockpileShopsMainTable]"))
            {
                db.DC();
                Key_ValueModel kvm;
                for (int i = 0; i < shops.Rows.Count; i++)
                {
                    kvm = new Key_ValueModel()
                    {
                        Id    = Convert.ToInt32(shops.Rows[i]["shop_id"].ToString()),
                        Value = shops.Rows[i]["shop_name"].ToString()
                    };
                    model.ShowPSIDs.ShopAvailable4Transaction.Add(kvm);
                }
            }

            return(View(model));
        }
        public JsonResult GetVaredeAndSadere(ProductInStockpileModelView SenderObj)
        {
            if (ModelState.IsValid)
            {
                if (SenderObj != null)
                {
                    int id_Mpc = 0;
                    if (Int32.TryParse(SenderObj.InOutStructures.id_Mpc, out id_Mpc))
                    {
                        string id_CreatedByAdmin = "0";
                        if (Session["AdministratorRegistery"] != null)
                        {
                            id_CreatedByAdmin = ((Administrator)Session["AdministratorRegistery"]).id_Admin;
                        }
                        else
                        {
                            var           coockie          = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCoockieCode());
                            Administrator administratorobj = CoockieController.SayMyName(coockie.Value);
                            id_CreatedByAdmin = administratorobj.id_Admin;
                        }
                        PDBC db = new PDBC();
                        db.Connect();
                        using (DataTable dt = db.Select("SELECT [id_PQT] ,[PriceModule] FROM [tlb_Product_MainProductConnector] WHERE [id_MPC] = " + id_Mpc))
                        {
                            using (DataTable dtStockpile = db.Select("SELECT [id_Stockpile]  FROM [tbl_Modules_StockpileMainTable] WHERE [id_MPC] = " + id_Mpc))
                            {
                                db.DC();
                                if (dtStockpile.Rows.Count > 0)
                                {
                                    if (dt.Rows.Count > 0)
                                    {
                                        List <ExcParameters> allpars = new List <ExcParameters>();
                                        ExcParameters        par     = new ExcParameters()
                                        {
                                            _KEY   = "@id_TransactionType",
                                            _VALUE = SenderObj.InOutStructures.Whichone
                                        };
                                        allpars.Add(par);
                                        par = new ExcParameters()
                                        {
                                            _KEY   = "@id_Stockpile",
                                            _VALUE = dtStockpile.Rows[0]["id_Stockpile"].ToString()
                                        };
                                        allpars.Add(par);
                                        if (SenderObj.InOutStructures.Whichone == "1")
                                        {
                                            par = new ExcParameters()
                                            {
                                                _KEY   = "@shop_id",
                                                _VALUE = SenderObj.InOutStructures.Shopid1
                                            };
                                            allpars.Add(par);
                                        }
                                        else
                                        {
                                            par = new ExcParameters()
                                            {
                                                _KEY   = "@shop_id",
                                                _VALUE = SenderObj.InOutStructures.shopid2
                                            };
                                            allpars.Add(par);
                                        }
                                        string[]        dates           = SenderObj.InOutStructures.ActionDate.Split('/');
                                        string[]        times           = SenderObj.InOutStructures.Time.Split(':');
                                        PersianDateTime persianDateTime = new PersianDateTime(Convert.ToInt32(dates[0]), Convert.ToInt32(dates[1]), Convert.ToInt32(dates[2]), Convert.ToInt32(times[0]), Convert.ToInt32(times[1]), 0);


                                        par = new ExcParameters()
                                        {
                                            _KEY   = "@StockpileDate_Transaction",
                                            _VALUE = persianDateTime.ToDateTime()
                                        };
                                        allpars.Add(par);
                                        par = new ExcParameters()
                                        {
                                            _KEY   = "@StockpileTime_Transaction",
                                            _VALUE = SenderObj.InOutStructures.Time
                                        };
                                        allpars.Add(par);
                                        par = new ExcParameters()
                                        {
                                            _KEY   = "@id_PQT",
                                            _VALUE = dt.Rows[0]["id_PQT"].ToString()
                                        };
                                        allpars.Add(par);
                                        par = new ExcParameters()
                                        {
                                            _KEY   = "@MoneyId",
                                            _VALUE = dt.Rows[0]["PriceModule"].ToString()
                                        };
                                        allpars.Add(par);
                                        par = new ExcParameters()
                                        {
                                            _KEY   = "@PriceOf_Transaction",
                                            _VALUE = SenderObj.InOutStructures.INOUTPrice
                                        };
                                        allpars.Add(par);
                                        par = new ExcParameters()
                                        {
                                            _KEY   = "@PQTValueOf_Transaction",
                                            _VALUE = SenderObj.InOutStructures.INOUTValue
                                        };
                                        allpars.Add(par);
                                        if (!string.IsNullOrEmpty(SenderObj.InOutStructures.Description))
                                        {
                                            par = new ExcParameters()
                                            {
                                                _KEY   = "@Description_Transaction",
                                                _VALUE = SenderObj.InOutStructures.Description
                                            };
                                            allpars.Add(par);
                                        }
                                        else
                                        {
                                            par = new ExcParameters()
                                            {
                                                _KEY   = "@Description_Transaction",
                                                _VALUE = ""
                                            };
                                            allpars.Add(par);
                                        }
                                        par = new ExcParameters()
                                        {
                                            _KEY   = "@id_SubmiterAdmin",
                                            _VALUE = id_CreatedByAdmin
                                        };
                                        allpars.Add(par);


                                        db.Connect();
                                        string result = db.Script("INSERT INTO [tbl_Modules_StockpileTransactionMainTable]([id_TransactionType],[id_Stockpile],[shop_id],[StockpileDate_Transaction],[StockpileTime_Transaction],[id_PQT],[MoneyId],[PriceOf_Transaction],[PQTValueOf_Transaction],[Description_Transaction],[id_SubmiterAdmin]) VALUES(@id_TransactionType,@id_Stockpile,@shop_id,@StockpileDate_Transaction,@StockpileTime_Transaction,@id_PQT,@MoneyId,@PriceOf_Transaction,@PQTValueOf_Transaction,@Description_Transaction,@id_SubmiterAdmin)", allpars);
                                        db.DC();
                                        if (result == "1")
                                        {
                                            var ModelSender = new ErrorReporterModel
                                            {
                                                ErrorID      = "SX1645605",
                                                Errormessage = $"اطلاعات با موفقیت ثبت شد!",
                                                Errortype    = "Success"
                                            };
                                            return(Json(ModelSender));
                                        }
                                        else
                                        {
                                            PPBugReporter rep         = new PPBugReporter(BugTypeFrom.SQL, "IN Controller : {AdministratorStockpileController}\nMethod : {public JsonResult GetVarede(ProductInStockpileModelView senderObj)  Script : INSERT INTO [tbl_Modules_StockpileTransactionMainTable]([id_TransactionType],[id_Stockpile],[shop_id],[Submitdate_Transaction],[StockpileDate_Transaction],[StockpileTime_Transaction],[id_PQT],[MoneyId],[PriceOf_Transaction],[PQTValueOf_Transaction],[Description_Transaction],[id_SubmiterAdmin]) VALUES(@id_TransactionType,@id_Stockpile,@shop_id,@Submitdate_Transaction,@StockpileDate_Transaction,@StockpileTime_Transaction,@id_PQT,@MoneyId,@PriceOf_Transaction,@PQTValueOf_Transaction,@Description_Transaction,@id_SubmiterAdmin) ||| Result :" + result);
                                            var           ModelSender = new ErrorReporterModel
                                            {
                                                ErrorID      = "EX1186781",
                                                Errormessage = $"عدم توانایی در ثبت اطلاعات",
                                                Errortype    = "Error"
                                            };
                                            return(Json(ModelSender));
                                        }
                                    }
                                    else
                                    {
                                        var ModelSender = new ErrorReporterModel
                                        {
                                            ErrorID      = "EX645756697",
                                            Errormessage = $"محصول مورد نظر یافت نشد",
                                            Errortype    = "Error"
                                        };
                                        return(Json(ModelSender));
                                    }
                                }
                                else
                                {
                                    var ModelSender = new ErrorReporterModel
                                    {
                                        ErrorID      = "EX645697",
                                        Errormessage = $"محصول مورد نظر یافت نشد",
                                        Errortype    = "Error"
                                    };
                                    return(Json(ModelSender));
                                }
                            }
                        }
                    }
                    else
                    {
                        var ModelSender = new ErrorReporterModel
                        {
                            ErrorID      = "EX1897",
                            Errormessage = $"اطلاعات وارده خلاف متغیر های قانونی میباشد!",
                            Errortype    = "Error"
                        };
                        return(Json(ModelSender));
                    }
                }
                else
                {
                    PPBugReporter rep         = new PPBugReporter(BugTypeFrom.SQL, "IN Controller : {AdministratorStockpileController}\nMethod : {public JsonResult GetVarede(ProductInStockpileModelView senderObj)  (senderObj == null)");
                    var           ModelSender = new ErrorReporterModel
                    {
                        ErrorID      = "EX111",
                        Errormessage = $"ورود متغیر خلاف پروتکل های امنیتی",
                        Errortype    = "Error"
                    };
                    return(Json(ModelSender));
                }
            }
            else
            {
                List <ModelErrorReporter> allErrors = new List <ModelErrorReporter>();
                //foreach (ModelError error in ModelState.Values.)
                var AllValues   = ModelState.Values.ToList();
                var AllKeys     = ModelState.Keys.ToList();
                int errorsCount = AllValues.Count;
                for (int i = 0; i < errorsCount; i++)
                {
                    if (AllValues[i].Errors.Count > 0)
                    {
                        ModelErrorReporter er = new ModelErrorReporter()
                        {
                            IdOfProperty = AllKeys[i].Replace("InOutStructures.", "InOutStructures_"),
                            ErrorMessage = AllValues[i].Errors[0].ErrorMessage
                        };
                        allErrors.Add(er);
                    }
                }
                var ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "EX115",
                    Errormessage = $"عدم رعایت استاندارد ها!",
                    Errortype    = "ErrorWithList",
                    AllErrors    = allErrors
                };
                return(Json(ModelSender));
            }



            return(Json(""));
        }
        // GET: AdministratorStockpile
        public ActionResult Index()
        {
            PDBC db = new PDBC();

            db.Connect();
            indexModelView model = new indexModelView()
            {
                Table = new List <indexTableModel>()
            };

            using (DataTable dt = db.Select("SELECT [id_MPC] ,[code_Stockpile] ,[Title] ,[shop_name] ,[shop_IsAvailable]  ,[shop_IsDelete] ,[MoneyTypeName] ,[PQT_Demansion] FROM [v_Stockpile_MainView]"))
            {
                int             dtrowscount = dt.Rows.Count;
                indexTableModel tableModel;
                for (int i = 0; i < dtrowscount; i++)
                {
                    tableModel = new indexTableModel();
                    using (DataTable dtSadere = db.Select("SELECT  SUM([PriceOf_Transaction]) AS [SaderePriceOf_Transaction] ,SUM([PQTValueOf_Transaction]) AS [SaderePQTValueOf_Transaction] FROM [v_Stockpile_Transactions] WHERE [id_MPC] = " + dt.Rows[i]["id_MPC"].ToString() + " AND [id_TransactionType] =2"))
                    {
                        using (DataTable dtVarede = db.Select("SELECT  SUM([PriceOf_Transaction]) AS [VaredePriceOf_Transaction] ,SUM([PQTValueOf_Transaction]) AS [VaredePQTValueOf_Transaction] FROM [v_Stockpile_Transactions] WHERE [id_MPC] = " + dt.Rows[i]["id_MPC"].ToString() + " AND [id_TransactionType] =1"))
                        {
                            if (dtVarede.Rows[0]["VaredePriceOf_Transaction"] != null && !string.IsNullOrEmpty(dtVarede.Rows[0]["VaredePriceOf_Transaction"].ToString()) && !string.IsNullOrEmpty(dtVarede.Rows[0]["VaredePQTValueOf_Transaction"].ToString()) && dtVarede.Rows[0]["VaredePQTValueOf_Transaction"] != null)
                            {
                                tableModel.AllEnteredPrice = String.Format("{0:n0}", dtVarede.Rows[0]["VaredePriceOf_Transaction"].ToString());
                                tableModel.AllEnteredValue = String.Format("{0:n0}", dtVarede.Rows[0]["VaredePQTValueOf_Transaction"].ToString());
                            }
                            else
                            {
                                tableModel.AllEnteredPrice = "0 " + dt.Rows[i]["MoneyTypeName"].ToString();
                                tableModel.AllEnteredValue = "0 " + dt.Rows[i]["PQT_Demansion"].ToString();
                            }
                            if (!string.IsNullOrEmpty(dtSadere.Rows[0]["SaderePriceOf_Transaction"].ToString()) && !string.IsNullOrEmpty(dtSadere.Rows[0]["SaderePQTValueOf_Transaction"].ToString()) && dtSadere.Rows[0]["SaderePriceOf_Transaction"] != null && dtSadere.Rows[0]["SaderePQTValueOf_Transaction"] != null)
                            {
                                tableModel.AllOutPriece = String.Format("{0:n0}", dtSadere.Rows[0]["SaderePriceOf_Transaction"].ToString());
                                tableModel.AllOutValue  = String.Format("{0:n0}", dtSadere.Rows[0]["SaderePQTValueOf_Transaction"].ToString());
                            }
                            else
                            {
                                tableModel.AllOutPriece = "0 " + dt.Rows[i]["MoneyTypeName"].ToString();
                                tableModel.AllOutValue  = "0 " + dt.Rows[i]["PQT_Demansion"].ToString();
                            }
                        }
                    }
                    if (i != 0 && i % 15 == 0)
                    {
                        db.DC();
                        db.Connect();
                    }
                    tableModel.ProductName      = dt.Rows[i]["Title"].ToString();
                    tableModel.rowNumber        = i + 1;
                    tableModel.Shopname         = dt.Rows[i]["shop_name"].ToString();
                    tableModel.ProductDimension = dt.Rows[i]["PQT_Demansion"].ToString();
                    tableModel.ProductCode      = dt.Rows[i]["code_Stockpile"].ToString();
                    tableModel.id_MPC           = dt.Rows[i]["id_MPC"].ToString();
                    model.Table.Add(tableModel);
                }
                db.DC();
            }

            return(View(model));
        }
        public JsonResult LoginAuth(string mobile, string password)
        {
            var ModelSender = new ErrorReporterModel();

            if (string.IsNullOrEmpty(mobile))
            {
                ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "EX1075463",
                    Errormessage = $"لطفا شماره موبایل خودرا وارد نمایید",
                    Errortype    = "Error"
                };
                return(Json(ModelSender));
            }
            if (string.IsNullOrEmpty(password))
            {
                ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "EX1075463",
                    Errormessage = $"لطفا کلمه عبور را وارد نمایید",
                    Errortype    = "Error"
                };
                return(Json(ModelSender));
            }
            EncDec dn = new EncDec();

            password = dn.HMACMD5Generator(password);
            PDBC db = new PDBC();
            List <ExcParameters> pars = new List <ExcParameters>();
            ExcParameters        par  = new ExcParameters()
            {
                _KEY   = "@Mobile",
                _VALUE = mobile
            };

            pars.Add(par);
            par = new ExcParameters()
            {
                _KEY   = "@PASS",
                _VALUE = password
            };
            pars.Add(par);
            db.Connect();
            DataTable dt = db.Select("SELECT [id_Customer] ,[C_Mobile] ,[C_FirstName] ,[C_LastNAme] FROM [tbl_Customer_Main] WHERE [C_Mobile] = @Mobile AND [C_Password] LIKE @PASS AND [C_ISActivate] = 1", pars);

            db.DC();
            if (dt.Rows.Count == 1)
            {
                tbl_Customer_Main tcm = new tbl_Customer_Main()
                {
                    id_Customer = dt.Rows[0]["id_Customer"].ToString(),
                    C_FirstName = dt.Rows[0]["C_FirstName"].ToString(),
                    C_LastNAme  = dt.Rows[0]["C_LastNAme"].ToString(),
                    C_Mobile    = dt.Rows[0]["C_Mobile"].ToString()
                };
                try
                {
                    var userCookieIDV = new HttpCookie(ProjectProperies.AuthCustomerCode());
                    userCookieIDV.Value   = CoockieController.SetCustomerAUTHCookie(tcm);
                    userCookieIDV.Expires = DateTime.Now.AddDays(2);
                    Response.SetCookie(userCookieIDV);
                }
                catch (Exception coockieEXception)
                {
                    PPBugReporter rep = new PPBugReporter(BugTypeFrom.coockieAuth)
                    {
                        EXOBJ = coockieEXception
                    };
                    ModelSender = new ErrorReporterModel
                    {
                        ErrorID      = "EX1075463",
                        Errormessage = $"عدم توانایی در ایجاد نشست فعال برای شما با پشتیبانی تماس حاصل فرمایید کد ارور شما {rep.CodeGenerated}",
                        Errortype    = "Error"
                    };
                    return(Json(ModelSender));
                }

                ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "SX106",
                    Errormessage = $"با موفقیت وارد شدید!",
                    Errortype    = "Success"
                };
                return(Json(ModelSender));
            }
            else
            {
                ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "EX115",
                    Errormessage = $"کاربری با این مشخصات یافت نشد!",
                    Errortype    = "Error"
                };
                return(Json(ModelSender));
            }
        }
Ejemplo n.º 19
0
        public string QueryMaker_BlogPost(string Cat, int Page, int Id, string search, int PostsInPage = 15)
        {
            PDBC db = new PDBC("PandaMarketCMS", true);

            db.Connect();
            int num = 1;

            if (Cat == "همه")
            {
                num = Convert.ToInt32(db.Select("SELECT Count(*) FROM [tbl_BLOG_Post]  where Is_Deleted=0 AND Is_Disabled=0").Rows[0][0]);
            }
            else if (Cat == "دسته بندی")
            {
                num = Convert.ToInt32(db.Select("SELECT Count(*) FROM [tbl_BLOG_Post] where Is_Deleted=0 AND Is_Disabled=0 AND Cat_Id=" + Id).Rows[0][0]);
            }
            else if (Cat == "برچسب")
            {
                num = Convert.ToInt32(db.Select("SELECT COUNT(*) FROM [tbl_BLOG_TagConnector] as A inner join [tbl_BLOG_Post] as B on A.Post_Id=B.Id where Is_Deleted=0 AND Is_Disabled=0 AND Tag_Id=" + Id).Rows[0][0]);
            }
            else if (Cat == "جست و جو")
            {
                num = Convert.ToInt32(db.Select("SELECT Count(*) FROM [tbl_BLOG_Post] where Is_Deleted=0 AND Is_Disabled=0 AND Title Like N'%" + search + "%' OR Text_min Like N'%" + search + "%' OR [Text] Like N'%" + search + "%' ").Rows[0][0]);
            }
            else if (Cat == "گروه بندی")
            {
                num = Convert.ToInt32(db.Select("SELECT Count(*) FROM [tbl_BLOG_Post] where Is_Deleted=0 AND Is_Disabled=0 AND GroupId=" + Id).Rows[0][0]);
            }
            db.DC();
            if (num % PostsInPage == 0)
            {
                num = (num / PostsInPage);
            }
            else
            {
                num = (num / PostsInPage) + 1;
            }


            StringBuilder Query = new StringBuilder();

            if (TopSelector == 0)
            {
                Query.Append("select * from(SELECT NTILE(");
            }
            else
            {
                Query.Append("select TOP(");
                Query.Append(TopSelector);
                Query.Append(") * from(SELECT NTILE(");
            }
            Query.Append(num);
            Query.Append(")over(order by(Date)DESC)as tile,[weight], [Id],[Title],[Text_min],[GroupId],[Text],(SELECT [ad_firstname]+ ' '+ [ad_lastname] as name FROM [tbl_ADMIN_main]where id_Admin=[WrittenBy_AdminId])as adminName ,[Date],[IsImportant],[Is_Deleted],[Is_Disabled],(SELECT [name]FROM [tbl_BLOG_Categories] where Id=[Cat_Id]) as Category,(SELECT [name]FROM [tbl_BLOG_Groups] where G_Id=[GroupId]) as GroupName,(SELECT top 1 B.PicAddress FROM [tbl_BLOG_Pic_Connector] as A inner join [tbl_ADMIN_UploadStructure_ImageAddress] as B on A.[PicId]=B.PicID where A.PostId=Id)as Pic,(SELECT [ad_avatarprofile] FROM[tbl_ADMIN_main] where id_Admin=WrittenBy_AdminId) as AdminPic ,(SELECT[B_TypeToken] FROM [tbl_BLOG_PostType] WHERE B_TypeId=[TypeId]) as TypeId FROM [tbl_BLOG_Post]");

            if (Cat == "همه")
            {
                Query.Append(" where Is_Deleted=0 AND Is_Disabled=0");
                Query.Append(")b where b.tile=");
                Query.Append(Page);
            }
            else if (Cat == "دسته بندی")
            {
                Query.Append(" where Is_Deleted=0 AND Is_Disabled=0 AND Cat_Id=");
                Query.Append(Id);
                Query.Append(")b where b.tile=");
                Query.Append(Page);
            }
            else if (Cat == "گروه بندی")
            {
                Query.Append(" where Is_Deleted=0 AND Is_Disabled=0 AND GroupId=");
                Query.Append(Id);
                Query.Append(")b where b.tile=");
                Query.Append(Page);
            }
            else if (Cat == "برچسب")
            {
                Query.Append(" as B1 inner join [tbl_BLOG_TagConnector] as B2 on B1.Id=B2.Post_Id where Is_Deleted=0 AND Is_Disabled=0 AND B2.Tag_Id=");
                Query.Append(Id);
                Query.Append(")b where b.tile=");
                Query.Append(Page);
            }
            else if (Cat == "جست و جو")
            {
                Query.Append(" where Is_Deleted=0 AND Is_Disabled=0 AND Title Like N'%");
                Query.Append(search);
                Query.Append("%' OR Text_min Like N'%");
                Query.Append(search);
                Query.Append("%' OR [Text] Like N'%");
                Query.Append(search);
                Query.Append("%')b where b.tile=");
                Query.Append(Page);
                Query.Append("order by([weight])DESC");
            }

            return(Query.ToString());
        }
        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"));
            }
        }
Ejemplo n.º 21
0
        public SinglePostPostDetail SinglePostFiller(int idPost, string DateType = "Date")
        {
            SinglePostPostDetail result = new SinglePostPostDetail();
            PDBC db = new PDBC("PandaMarketCMS", true);

            db.Connect();
            using (DataTable dt = db.Select("SELECT * FROM [v_Blog_SinglePost] WHERE PostID = " + idPost))
            {
                if (dt.Rows.Count > 0)
                {
                    result.Cat_Id            = dt.Rows[0]["Cat_Id"].ToString();
                    result.GroupId           = dt.Rows[0]["GroupId"].ToString();
                    result.Gpname            = dt.Rows[0]["Gpname"].ToString();
                    result.CatName           = dt.Rows[0]["CatName"].ToString();
                    result.Title             = dt.Rows[0]["Title"].ToString();
                    result.Text_min          = dt.Rows[0]["Text_min"].ToString();
                    result.Text              = dt.Rows[0]["Text"].ToString();
                    result.Date              = DateReturner(dt.Rows[0]["Date"].ToString(), DateType);
                    result.weight            = dt.Rows[0]["weight"].ToString();
                    result.IsImportant       = dt.Rows[0]["IsImportant"].ToString();
                    result.PostID            = dt.Rows[0]["PostID"].ToString();
                    result.WrittenBy_AdminId = dt.Rows[0]["WrittenBy_AdminId"].ToString();
                    result.ad_firstname      = dt.Rows[0]["ad_firstname"].ToString();
                    result.ad_lastname       = dt.Rows[0]["ad_lastname"].ToString();
                    result.ad_avatarprofile  = AppendServername(dt.Rows[0]["ad_avatarprofile"].ToString());
                    DataTable Comments = db.Select("SELECT [Id],[Email],[message],[Name],[ImagePath],[Date] FROM [tbl_BLOG_Comment] where PostId=" + idPost);
                    var       Com      = new List <CommentsModel>();
                    db.DC();
                    db.Connect();
                    for (int i = 0; i < Comments.Rows.Count; i++)
                    {
                        var       Rep = new List <CommentsModel>();
                        DataTable rep = db.Select("SELECT [Id],[Email],[Name],[Message],[ImagePath],[Date]FROM [tbl_BLOG_Reply] where commentId=" + Comments.Rows[i]["Id"]);
                        for (int j = 0; j < rep.Rows.Count; j++)
                        {
                            var Rmodel = new CommentsModel()
                            {
                                Id        = Convert.ToInt32(rep.Rows[j]["Id"]),
                                Email     = rep.Rows[j]["Email"].ToString(),
                                ImagePath = AppendServername(rep.Rows[j]["ImagePath"].ToString()),
                                Message   = rep.Rows[j]["Message"].ToString(),
                                Name      = rep.Rows[j]["Name"].ToString(),
                                Date      = DateReturner(rep.Rows[j]["Date"].ToString(), DateType)
                            };
                            Rep.Add(Rmodel);
                        }

                        var model = new CommentsModel()
                        {
                            Id        = Convert.ToInt32(Comments.Rows[i]["Id"]),
                            Email     = Comments.Rows[i]["Email"].ToString(),
                            ImagePath = AppendServername(Comments.Rows[i]["ImagePath"].ToString()),
                            Message   = Comments.Rows[i]["Message"].ToString(),
                            Name      = Comments.Rows[i]["Name"].ToString(),
                            Date      = DateReturner(Comments.Rows[i]["Date"].ToString(), DateType),
                            Reply     = Rep
                        };
                        Com.Add(model);
                    }

                    result.Comments = Com;
                }
                else
                {
                    result.PostID = "0";
                }
            }
            db.DC();
            return(result);
        }
Ejemplo n.º 22
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));
            }
        }
Ejemplo n.º 23
0
        public JsonResult ProductCountCalc(string QCount, string idmpc)
        {
            PDBC db = new PDBC();

            db.Connect();
            using (DataTable dt = db.Select("SELECT [Title],[MCName] ,[SCName],[PriceXquantity],[MultyPrice],[MultyPriceStartFromQ]  FROM [v_Connector_MainProductConnectorToProduct] WHERE [id_MPC] = " + idmpc))
            {
                db.DC();
                var ModelSender = new ErrorReporterModel();
                if (dt.Rows.Count == 0)
                {
                    ModelSender = new ErrorReporterModel
                    {
                        ErrorID      = "EX1153455",
                        Errormessage = $"محصول یافت نشد!",
                        Errortype    = "Error"
                    };
                    return(Json(ModelSender));
                }
                else
                {
                    if (Convert.ToInt32(QCount) > Convert.ToInt32(dt.Rows[0]["MultyPriceStartFromQ"].ToString()))
                    {
                        FactorPopUpModel fpm = CoockieController.GetCustomerShopFactorCookie(HttpContext.Request.Cookies.Get(ProjectProperies.CustomerShoppingFactor()).Value);
                        for (int i = 0; i < fpm.items.Count; i++)
                        {
                            if (fpm.items[i].Id == Convert.ToInt32(idmpc))
                            {
                                fpm.items[i].PriceXQ = Convert.ToInt64(dt.Rows[0]["MultyPrice"].ToString());
                                fpm.items[i].number  = Convert.ToInt32(QCount);
                                fpm.items[i].total   = fpm.items[i].PriceXQ * fpm.items[i].number;
                                break;
                            }
                        }
                        Int64 totality = 0;
                        for (int i = 0; i < fpm.items.Count; i++)
                        {
                            totality += fpm.items[i].total;
                        }
                        fpm.totality = totality.ToString();
                        ModelSender  = new ErrorReporterModel
                        {
                            ErrorID      = dt.Rows[0]["MultyPrice"].ToString(),
                            Errormessage = $"",
                            Errortype    = "Success"
                        };
                        var userCookieIDV = new HttpCookie(ProjectProperies.CustomerShoppingFactor());
                        userCookieIDV.Value   = CoockieController.SetCustomerShopFactorCookie(fpm);
                        userCookieIDV.Expires = DateTime.Now.AddDays(2);
                        Response.SetCookie(userCookieIDV);
                        return(Json(ModelSender));
                    }
                    else
                    {
                        FactorPopUpModel fpm = CoockieController.GetCustomerShopFactorCookie(HttpContext.Request.Cookies.Get(ProjectProperies.CustomerShoppingFactor()).Value);
                        for (int i = 0; i < fpm.items.Count; i++)
                        {
                            if (fpm.items[i].Id == Convert.ToInt32(idmpc))
                            {
                                fpm.items[i].PriceXQ = Convert.ToInt64(dt.Rows[0]["PriceXquantity"].ToString());
                                fpm.items[i].number  = Convert.ToInt32(QCount);
                                fpm.items[i].total   = fpm.items[i].PriceXQ * fpm.items[i].number;
                                break;
                            }
                        }
                        Int64 totality = 0;
                        for (int i = 0; i < fpm.items.Count; i++)
                        {
                            totality += fpm.items[i].total;
                        }
                        fpm.totality = totality.ToString();

                        var userCookieIDV = new HttpCookie(ProjectProperies.CustomerShoppingFactor());
                        userCookieIDV.Value   = CoockieController.SetCustomerShopFactorCookie(fpm);
                        userCookieIDV.Expires = DateTime.Now.AddDays(2);
                        Response.SetCookie(userCookieIDV);
                        ModelSender = new ErrorReporterModel
                        {
                            ErrorID      = dt.Rows[0]["PriceXquantity"].ToString(),
                            Errormessage = $"",
                            Errortype    = "Success"
                        };
                        return(Json(ModelSender));
                    }
                }
            }
        }
Ejemplo n.º 24
0
        public ActionResult productpage(string _N, string _M, string _S, int?_P)
        {
            if (string.IsNullOrEmpty(_M))
            {
                return(RedirectToAction("search", "CustomerSide_Product", new { Type = "همه" }));
            }
            if (string.IsNullOrEmpty(_S))
            {
                return(RedirectToAction("search", "CustomerSide_Product", new { Type = "همه" }));
            }
            if (string.IsNullOrEmpty(_N))
            {
                return(RedirectToAction("search", "CustomerSide_Product", new { Type = "همه" }));
            }
            if (_P == null)
            {
                return(RedirectToAction("search", "CustomerSide_Product", new { Type = "همه" }));
            }
            ProductDetail_ModelView model = new ProductDetail_ModelView();

            model.ProductModel = new Product_DesignerModel();
            PDBC db = new PDBC();

            db.Connect();
            using (DataTable dt = db.Select("SELECT [Title] ,[Seo_Description] ,[Seo_KeyWords] ,[Description] ,[PTname] ,[MCName] ,[SCName] FROM [v_tblProductToMCPTSC] WHERE [id_MProduct] = " + _P))
            {
                db.DC();
                if (dt.Rows.Count > 0)
                {
                    model.ProductModel.Id              = Convert.ToInt32(_P);
                    model.ProductModel.Title           = dt.Rows[0]["Title"].ToString();
                    model.ProductModel.SEO_Discription = dt.Rows[0]["Seo_Description"].ToString();
                    model.ProductModel.SEO_Keyword     = dt.Rows[0]["Seo_KeyWords"].ToString();
                    model.ProductModel.Discription     = dt.Rows[0]["Description"].ToString();
                    //string
                    //if (_N != model.ProductModel.Title.Replace(" ", "-") || _M != dt.Rows[0]["MCName"].ToString().Replace(" ", "-") || _S != dt.Rows[0]["SCName"].ToString().Replace(" ", "-"))
                    //{
                    //    return RedirectToAction("search", "CustomerSide_Product", new { Type = "همه" });
                    //}
                }
                else
                {
                    return(RedirectToAction("search", "CustomerSide_Product", new { Type = "همه" }));
                }
            }
            model.ProductModel.Thumpnamil_Pictures = new List <string>();
            model.ProductModel.org_Pictures        = new List <string>();

            db.Connect();
            using (DataTable dt = db.Select("SELECT  [orgUploadAddress] ,[thumUploadAddress] FROM [v_tblProduct_Image] WHERE [id_MProduct] = " + _P))
            {
                db.DC();
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        model.ProductModel.org_Pictures.Add(dt.Rows[i]["orgUploadAddress"].ToString());
                        model.ProductModel.Thumpnamil_Pictures.Add(dt.Rows[i]["thumUploadAddress"].ToString());
                    }
                }
                else
                {
                    model.ProductModel.org_Pictures.Add("/resource/images/Customes/imgNotFound.jpg");
                    model.ProductModel.Thumpnamil_Pictures.Add("/resource/images/Customes/imgNotFound.jpg");
                }
            }
            model.ProductModel.Options = new List <OptionModel>();
            db.Connect();
            using (DataTable dt = db.Select("SELECT  [KeyName] ,[Value] FROM  [tbl_Product_tblOptions] WHERE [id_MProduct] = " + _P))
            {
                db.DC();
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        model.ProductModel.Options.Add(new OptionModel()
                        {
                            Key   = dt.Rows[i]["KeyName"].ToString(),
                            Value = dt.Rows[i]["Value"].ToString()
                        });
                    }
                }
                else
                {
                    model.ProductModel.Options.Add(new OptionModel()
                    {
                        Key   = "موردی برای نمایش وجود ندارد",
                        Value = "موردی برای نمایش وجود ندارد"
                    });
                }
            }
            //===================Comment
            model.ProductModel.Comments = new List <CommentsModel>();
            model.ProductModel.Comments.Add(new CommentsModel()
            {
                Date    = PersianDateTime.Now.ToString(),
                Name    = "موردی برای نمایش وجود ندارد",
                Message = "موردی برای نمایش وجود ندارد",
                Reply   = new List <CommentsModel>()
            });
            //===================Comment
            db.Connect();
            using (DataTable dt = db.Select("SELECT [id_SCOK] ,[SCOKName] FROM [v_tblProductSCOK] WHERE [id_MProduct] = " + _P))
            {
                model.ProductModel.Selectors = new List <SelectsInput>();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    SelectsInput res = new SelectsInput();
                    res.ID_SCOK   = dt.Rows[i]["id_SCOK"].ToString();
                    res.Name_SCOK = dt.Rows[i]["SCOKName"].ToString();
                    res.Options   = new List <OptionModel>();
                    using (DataTable dt2 = db.Select($"SELECT [id_SCOV] FROM  [v_SCOVMPC] WHERE  [id_MProduct] = {_P} AND [id_SCOK] = {dt.Rows[i]["id_SCOK"].ToString()} Group BY [id_SCOV]"))
                    {
                        for (int j = 0; j < dt2.Rows.Count; j++)
                        {
                            using (DataTable dt3 = db.Select("SELECT [SCOVValueName] FROM [tbl_Product_SubCategoryOptionValue] WHERE [id_SCOV] = " + dt2.Rows[j]["id_SCOV"].ToString()))
                            {
                                res.Options.Add(new OptionModel()
                                {
                                    Key   = dt2.Rows[j]["id_SCOV"].ToString(),
                                    Value = dt3.Rows[0]["SCOVValueName"].ToString()
                                });
                            }
                        }
                    }
                    model.ProductModel.Selectors.Add(res);
                }
            }
            db.DC();
            db.Connect();
            using (DataTable dt = db.Select("SELECT [id_MPC] ,[PriceXquantity] FROM [tlb_Product_MainProductConnector] WHERE [id_MProduct] = " + _P))
            {
                db.DC();
                model.ProductModel.MPCs = new List <MPCModel>();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    model.ProductModel.MPCs.Add(new MPCModel()
                    {
                        Id      = Convert.ToInt32(dt.Rows[i]["id_MPC"].ToString()),
                        PriceXQ = String.Format("{0:n0}", dt.Rows[i]["PriceXquantity"].ToString())
                    });
                }
                db.Connect();
                model.PF = new List <ProductFinder>();
                for (int i = 0; i < model.ProductModel.MPCs.Count; i++)
                {
                    using (DataTable dt2 = db.Select("SELECT [id_MPC] ,[id_SCOV] FROM [v_ConnectorTheProductConnectorViewToSCOVandSCOKV_s] WHERE [id_MPC] =" + model.ProductModel.MPCs[i].Id))
                    {
                        string code = "";
                        for (int j = 0; j < dt2.Rows.Count; j++)
                        {
                            code += dt2.Rows[j]["id_SCOV"].ToString();
                        }
                        model.PF.Add(new ProductFinder()
                        {
                            Code  = code,
                            Idmpc = dt2.Rows[0]["id_MPC"].ToString()
                        });
                    }
                }
                db.DC();
            }
            model.JsonSale_Products = JsonConvert.SerializeObject(model.ProductModel.MPCs);
            model.JsonPF            = JsonConvert.SerializeObject(model.PF);
            model.Sale_Products     = new List <MiniProductModel>();
            db.Connect();
            using (DataTable dt = db.Select("SELECT TOP(3)  [id_MProduct] ,MAX([Qsold]) FROM [V_Porforooshha1] Group by [id_MProduct]"))
            {
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        DataTable dts   = db.Select("SELECT TOP(1)  [Title] ,[MCName] ,[SCName] ,[PriceXquantity] FROM [v_Connector_MainProductConnectorToProduct] WHERE [id_MProduct] = " + dt.Rows[i]["id_MProduct"].ToString());
                        DataTable dtimg = db.Select("SELECT TOP(1) [thumUploadAddress] FROM [v_tblProduct_Image] WHERE [id_MProduct] = " + dt.Rows[i]["id_MProduct"].ToString());
                        string    imgp  = "/NOIMG.jpg";
                        if (dtimg.Rows.Count > 0)
                        {
                            imgp = dtimg.Rows[0]["thumUploadAddress"].ToString();
                        }
                        model.Sale_Products.Add(new MiniProductModel()
                        {
                            Id           = Convert.ToInt32(dt.Rows[i]["id_MProduct"].ToString()),
                            MainCatename = dts.Rows[0]["MCName"].ToString(),
                            subCatename  = dts.Rows[0]["SCName"].ToString(),
                            Title        = dts.Rows[0]["Title"].ToString(),
                            PriceXQ      = dts.Rows[0]["PriceXquantity"].ToString(),
                            PicPath      = imgp
                        });
                    }
                }
                else
                {
                    model.Sale_Products = new List <MiniProductModel>();
                }
            }
            db.DC();
            return(View(model));
        }
Ejemplo n.º 25
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));
            }
        }
Ejemplo n.º 26
0
        public string MainProduct_Actions(string action, int id_MProduct, string Quantity, string QuantityModule, string PriceXquantity, string PricePerquantity, string PriceOff, string offTypeValue, string OffType, string id_MainStarTag, string PriceModule, string PriceShow,
                                          string MultyPriceXquantity, string CalculateMultyPriceFromQ, string MultyPricePerquantity, string describtion = " ")
        {
            List <ExcParameters> paramss = new List <ExcParameters>();
            PDBC db         = new PDBC();
            var  parameters = new ExcParameters()
            {
                _KEY   = "@id_MProduct",
                _VALUE = id_MProduct
            };

            paramss.Add(parameters);

            parameters = new ExcParameters()
            {
                _KEY   = "@Quantity",
                _VALUE = Quantity
            };
            paramss.Add(parameters);

            parameters = new ExcParameters()
            {
                _KEY   = "@id_PQT",
                _VALUE = QuantityModule
            };
            paramss.Add(parameters);

            parameters = new ExcParameters()
            {
                _KEY   = "@PriceXquantity",
                _VALUE = PriceXquantity
            };
            paramss.Add(parameters);

            parameters = new ExcParameters()
            {
                _KEY   = "@PricePerquantity",
                _VALUE = PricePerquantity
            };
            paramss.Add(parameters);

            parameters = new ExcParameters()
            {
                _KEY   = "@PriceOff",
                _VALUE = 0
            };
            paramss.Add(parameters);

            parameters = new ExcParameters()
            {
                _KEY   = "@offTypeValue",
                _VALUE = 0
            };
            paramss.Add(parameters);

            parameters = new ExcParameters()
            {
                _KEY   = "@OffType",
                _VALUE = 0
            };
            paramss.Add(parameters);

            parameters = new ExcParameters()
            {
                _KEY   = "@id_MainStarTag",
                _VALUE = id_MainStarTag
            };
            paramss.Add(parameters);

            parameters = new ExcParameters()
            {
                _KEY   = "@PriceModule",
                _VALUE = PriceModule
            };
            paramss.Add(parameters);

            parameters = new ExcParameters()
            {
                _KEY   = "@PriceShow",
                _VALUE = PriceShow
            };
            paramss.Add(parameters);

            parameters = new ExcParameters()
            {
                _KEY   = "@describtion",
                _VALUE = describtion
            };
            paramss.Add(parameters);

            parameters = new ExcParameters()
            {
                _KEY   = "@MultyPriceStartFromQ",
                _VALUE = CalculateMultyPriceFromQ
            };
            paramss.Add(parameters);
            parameters = new ExcParameters()
            {
                _KEY   = "@MultyPrice",
                _VALUE = MultyPricePerquantity
            };
            paramss.Add(parameters);
            parameters = new ExcParameters()
            {
                _KEY   = "@MultyPriceXQ",
                _VALUE = MultyPriceXquantity
            };
            paramss.Add(parameters);
            string query = "";

            if (action == "insert")
            {
                query = "INSERT INTO [tlb_Product_MainProductConnector]  ([id_MProduct]  ,[Quantity]  ,[PriceXquantity]  ,[PricePerquantity]  ,[PriceOff]  ,[offTypeValue]  ,[OffType]  ,[id_MainStarTag]  ,[ISDELETE]  ,[OutOfStock]  ,[id_PQT]  ,[DateToRelease]  ,[PriceModule]  ,[PriceShow]  ,[describtion]  ,[id_Stockpile]  ,[HasMultyPrice]  ,[MultyPriceStartFromQ]  ,[MultyPrice],[MultyPriceXQ])  OUTPUT inserted.id_MPC    VALUES (@id_MProduct  ,@Quantity  ,@PriceXquantity  ,@PricePerquantity  ,0  ,0  ,0 ,@id_MainStarTag  ,0 ,0  ,@id_PQT  ,GETDATE()   ,@PriceModule  ,@PriceShow  ,@describtion   ,0,1  ,@MultyPriceStartFromQ  ,@MultyPrice,@MultyPriceXQ)";
            }
            else if (action == "update")
            {
                query = "UPDATE [tlb_Product_MainProductConnector]SET [Quantity] =  @Quantity ,[PriceXquantity] = @PriceXquantity,[PricePerquantity] =@PricePerquantity ,[PriceOff] =@PriceOff ,[offTypeValue] = @offTypeValue ,[OffType] = @PriceOff,[id_MainStarTag] = @id_MainStarTag ,[id_PQT] = @QuantityModule,[PriceModule] = @PriceModule ,[PriceShow] = @PriceShow  WHERE id_MPC=@id_MProduct";
            }
            else if (action == "delete")
            {
            }

            if (query != "")
            {
                db.Connect();
                string res = db.Script(query, paramss);
                //==========================Add to stockpile=================
                using (DataTable dt = db.Select("SELECT [shop_id]  FROM [tbl_Modules_StockpileShopsMainTable]"))
                {
                    string idForShops = db.Script("INSERT INTO [tbl_Modules_StockpileMainTable] ([id_Stockpile_AllowType] ,[code_Stockpile] ,[id_MPC]) output inserted.id_Stockpile VALUES (1 ,N' ' ," + res + " )");
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        string tes = db.Script("INSERT INTO [tbl_Modules_StockpileConnectorMainToShops] ([id_Stockpile] ,[shop_id] ,[ItemRemaining]) VALUES (" + idForShops + " ," + dt.Rows[i]["shop_id"].ToString() + " ,0)");
                    }
                    db.DC();
                }
                //===========================================
                if (action == "insert")
                {
                    string ss = db.Script("INSERT INTO [tbl_Product_PastProductHistory] VALUES (" + res + ",@PriceXquantity,@PricePerquantity,@PriceOff,@OffType,@id_MainStarTag,GETDATE(),@offTypeValue)", paramss);
                }
                else if (action == "update")
                {
                    db.Script("INSERT INTO [tbl_Product_PastProductHistory]VALUES(@id_MProduct,@PriceXquantity,@PricePerquantity,@PriceOff,@OffType,@id_MainStarTag,GETDATE(),@offTypeValue)", paramss);
                }
                db.DC();
                return(res);
            }
            else
            {
                return("0");
            }
        }
Ejemplo n.º 27
0
        /// /////////////////////{ end : login }////////////////////////

        ////////////////////////{ start : blog }////////////////////////5
        ///مثال
        ////url = MS/blog?NamePage=post&page=1
        ////url = MS/blog?NamePage=Categories&Valuepage=اخبار پاندایی&page=1
        public ActionResult Blog(string Cat = "همه", int Page = 1, int Id = 0, string search = "")
        {
            PDBC   db = new PDBC("PandaMarketCMS", true);
            string SearchNAmeHeader = "تمامی مطالب";
            int    num = 1;

            db.Connect();
            if (Cat == "همه")
            {
                num = Convert.ToInt32(db.Select("SELECT Count(*) FROM [tbl_BLOG_Post]  where Is_Deleted=0 AND Is_Disabled=0").Rows[0][0]);
                db.DC();
            }
            else if (Cat == "دسته بندی")
            {
                num = Convert.ToInt32(db.Select("SELECT Count(*) FROM [tbl_BLOG_Post] where Is_Deleted=0 AND Is_Disabled=0 AND Cat_Id=" + Id).Rows[0][0]);
                using (DataTable dt2 = db.Select("SELECT [name] FROM  [tbl_BLOG_Categories] WHERE [Id] =" + Id))
                {
                    SearchNAmeHeader = dt2.Rows[0][0].ToString();
                }
                db.DC();
            }
            else if (Cat == "گروه بندی")
            {
                num = Convert.ToInt32(db.Select("SELECT Count(*) FROM [tbl_BLOG_Post] where Is_Deleted=0 AND Is_Disabled=0 AND [GroupId] = " + Id).Rows[0][0]);
                using (DataTable dt2 = db.Select("SELECT [name] FROM  [tbl_BLOG_Groups] WHERE [G_Id] =" + Id))
                {
                    SearchNAmeHeader = dt2.Rows[0][0].ToString();
                }
                db.DC();
            }
            else if (Cat == "برچسب")
            {
                num = Convert.ToInt32(db.Select("SELECT COUNT(*) FROM [tbl_BLOG_TagConnector] as A inner join [tbl_BLOG_Post] as B on A.Post_Id=B.Id where Is_Deleted=0 AND Is_Disabled=0 AND Tag_Id=" + Id).Rows[0][0]);
                using (DataTable dt2 = db.Select("SELECT [name] FROM  [tbl_BLOG_Tags] WHERE [Id] =" + Id))
                {
                    SearchNAmeHeader = dt2.Rows[0][0].ToString();
                }
                db.DC();
            }
            else if (Cat == "جست و جو")
            {
                num = Convert.ToInt32(db.Select("SELECT Count(*) FROM [tbl_BLOG_Post] where (Is_Deleted=0 AND Is_Disabled=0) AND (Title Like N'%" + search + "%' OR Text_min Like N'%" + search + "%' OR [Text] Like N'%" + search + "%') ").Rows[0][0]);
                db.DC();
            }

            if (num % 15 == 0)
            {
                num = (num / 15);
            }
            else
            {
                num = (num / 15) + 1;
            }



            Blog_ModelFiller BMF = new Blog_ModelFiller();
            var model            = new BlogPostsModel()
            {
                Categories         = BMF.BCategory_Filler(),
                Tags               = BMF.B_AllTags_Filler(),
                Posts              = BMF.UserPostModels(Cat, Page, Id, search),
                GroupsList         = BMF.C_AllTags_Filler(),
                Pages              = num,
                Page               = Page,
                Cat                = Cat,
                Id                 = Id,
                SearchNAmeHeaderH1 = SearchNAmeHeader
            };

            return(View(model));
        }
        public ActionResult ChangeAuthInformations(ChangeProfileModel informations)
        {
            changeAuthInformation information = informations.authInformation;

            if (ModelState.IsValid)
            {
                string adminID = "";
                try
                {
                    adminID = ((Administrator)Session["AdministratorRegistery"]).id_Admin;
                }
                catch (Exception exception)
                {
                    PPBugReporter rep = new PPBugReporter(BugTypeFrom.sessionAuth, "IN Controller : {AdministratorGeneralController}\nMethod : {public ActionResult Index(ChangeProfileModel adObj1)}")
                    {
                        EXOBJ = exception
                    };
                }
                //If Session Doesent work
                try
                {
                    HttpCookie cookie = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCoockieCode());
                    adminID = CoockieController.SayMyName(cookie.Value).id_Admin;
                }
                catch (Exception EX)
                {
                    PPBugReporter rep = new PPBugReporter(BugTypeFrom.coockieAuth, "IN Controller : {AdministratorGeneralController}\nMethod : {public ActionResult Index(ChangeProfileModel adObj1)}")
                    {
                        EXOBJ = EX
                    };
                }
                if (string.IsNullOrEmpty(adminID))
                {
                    adminID = "NO-ID";
                }
                PDBC db = new PDBC();
                List <ExcParameters> dbparams = new List <ExcParameters>();
                ExcParameters        param    = new ExcParameters()
                {
                    _VALUE = adminID,
                    _KEY   = "@id_Admin"
                };
                dbparams.Add(param);
                db.Connect();
                using (DataTable dt = db.Select("SELECT [ad_password] FROM [tbl_ADMIN_main] WHERE [id_Admin] = @id_Admin", dbparams))
                {
                    db.DC();
                    if (dt.Rows.Count > 0)
                    {
                        EncDec en             = new EncDec();
                        string md5GeneratedPW = en.HMACMD5Generator(information.OLDpassword);
                        if (md5GeneratedPW == dt.Rows[0]["ad_password"].ToString())
                        {
                            if (string.IsNullOrEmpty(information.Newpassword1))
                            {
                                param = new ExcParameters()
                                {
                                    _VALUE = information.Username,
                                    _KEY   = "@ad_username"
                                };
                                dbparams.Add(param);
                                db.Connect();
                                string result = db.Script("UPDATE [tbl_ADMIN_main] SET [ad_username] = @ad_username WHERE [id_Admin] = @id_Admin", dbparams);
                                db.DC();
                                if (result == "1")
                                {
                                    try
                                    {
                                        var sessionChanger = (Administrator)Session["AdministratorRegistery"];
                                        sessionChanger.Username           = information.Username;
                                        Session["AdministratorRegistery"] = sessionChanger;
                                    }
                                    catch (Exception EX)
                                    {
                                        PPBugReporter rep = new PPBugReporter(BugTypeFrom.sessionAuth, "IN Controller : {AdministratorGeneralController}\nMethod : {public ActionResult Index(ChangeProfileModel adObj LINE 298)}")
                                        {
                                            EXOBJ = EX
                                        };
                                    }
                                    try
                                    {
                                        HttpCookie cookie         = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCoockieCode());
                                        var        sessionChanger = CoockieController.SayMyName(cookie.Value);
                                        sessionChanger.Username = information.Username;
                                        var userCookieIDV = new HttpCookie(ProjectProperies.AuthCoockieCode());
                                        userCookieIDV.Value   = CoockieController.SetCoockie(sessionChanger);;
                                        userCookieIDV.Expires = DateTime.Now.AddYears(5);
                                        Response.SetCookie(userCookieIDV);
                                    }
                                    catch (Exception EX)
                                    {
                                        PPBugReporter rep = new PPBugReporter(BugTypeFrom.coockieAuth, "IN Controller : {AdministratorGeneralController}\nMethod : {public ActionResult Index(ChangeProfileModel adObj LINE 315)}")
                                        {
                                            EXOBJ = EX
                                        };
                                    }
                                    var ModelSender = new ErrorReporterModel
                                    {
                                        ErrorID      = "SX102",
                                        Errormessage = "نام کاربری با موفقیت ویرایش شد!",
                                        Errortype    = "Success"
                                    };
                                    return(Json(ModelSender));
                                }
                                else
                                {
                                    PPBugReporter rep         = new PPBugReporter(BugTypeFrom.SQL, result);
                                    var           ModelSender = new ErrorReporterModel
                                    {
                                        ErrorID      = "EX108",
                                        Errormessage = "عدم توانایی در ایجاد نشست فعال برای شما با پشتیبانی تماس حاصل فرمایید",
                                        Errortype    = "Error"
                                    };
                                    return(Json(ModelSender));
                                }
                            }
                            else
                            {
                                if (information.Newpassword1 == information.Newpassword2)
                                {
                                    param = new ExcParameters()
                                    {
                                        _VALUE = information.Username,
                                        _KEY   = "@ad_username"
                                    };
                                    dbparams.Add(param);
                                    param = new ExcParameters()
                                    {
                                        _VALUE = md5GeneratedPW,
                                        _KEY   = "@ad_password"
                                    };
                                    dbparams.Add(param);
                                    db.Connect();
                                    string result = db.Script("UPDATE  [tbl_ADMIN_main] SET [ad_password] = @ad_password,[ad_username] = @ad_username  WHERE [id_Admin] = @id_Admin", dbparams);
                                    db.DC();
                                    if (result == "1")
                                    {
                                        try
                                        {
                                            var sessionChanger = (Administrator)Session["AdministratorRegistery"];
                                            sessionChanger.Username           = information.Username;
                                            Session["AdministratorRegistery"] = sessionChanger;
                                        }
                                        catch (Exception EX)
                                        {
                                            PPBugReporter rep = new PPBugReporter(BugTypeFrom.sessionAuth, "IN Controller : {AdministratorGeneralController}\nMethod : {public ActionResult Index(ChangeProfileModel adObj LINE 126)}")
                                            {
                                                EXOBJ = EX
                                            };
                                        }
                                        try
                                        {
                                            HttpCookie cookie         = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCoockieCode());
                                            var        sessionChanger = CoockieController.SayMyName(cookie.Value);
                                            sessionChanger.Username = information.Username;
                                            var userCookieIDV = new HttpCookie(ProjectProperies.AuthCoockieCode());
                                            userCookieIDV.Value   = CoockieController.SetCoockie(sessionChanger);;
                                            userCookieIDV.Expires = DateTime.Now.AddYears(5);
                                            Response.SetCookie(userCookieIDV);
                                        }
                                        catch (Exception EX)
                                        {
                                            PPBugReporter rep = new PPBugReporter(BugTypeFrom.coockieAuth, "IN Controller : {AdministratorGeneralController}\nMethod : {public ActionResult Index(ChangeProfileModel adObj LINE 126)}")
                                            {
                                                EXOBJ = EX
                                            };
                                        }


                                        var ModelSender = new ErrorReporterModel
                                        {
                                            ErrorID      = "SX103",
                                            Errormessage = "اطلاعات ورود با موفقیت ویرایش شد!",
                                            Errortype    = "Success"
                                        };
                                        return(Json(ModelSender));
                                    }
                                    else
                                    {
                                        PPBugReporter rep         = new PPBugReporter(BugTypeFrom.SQL, result);
                                        var           ModelSender = new ErrorReporterModel
                                        {
                                            ErrorID      = "EX110",
                                            Errormessage = $"عدم توانایی در ویرایش اطلاعات با پشتیبانی تماس حاصل فرمایید! کد پیگیری برای شما :{rep.CodeGenerated}",
                                            Errortype    = "Error"
                                        };
                                        return(Json(ModelSender));
                                    }
                                }
                                else
                                {
                                    List <ModelErrorReporter> allErrors = new List <ModelErrorReporter>();
                                    ModelErrorReporter        er        = new ModelErrorReporter()
                                    {
                                        IdOfProperty = "authInformation_Newpassword1",
                                        ErrorMessage = "عدم یکسانی کلمه های عبور"
                                    };
                                    allErrors.Add(er);
                                    er = new ModelErrorReporter()
                                    {
                                        IdOfProperty = "authInformation_Newpassword2",
                                        ErrorMessage = "عدم یکسانی کلمه های عبور"
                                    };
                                    allErrors.Add(er);
                                    var ModelSender = new ErrorReporterModel
                                    {
                                        ErrorID      = "EX109",
                                        Errormessage = "عدم یکسانی کلمه های عبور",
                                        Errortype    = "ErrorWithList",
                                        AllErrors    = allErrors
                                    };
                                    return(Json(ModelSender));
                                }
                            }
                        }
                        else
                        {
                            List <ModelErrorReporter> allErrors = new List <ModelErrorReporter>();
                            ModelErrorReporter        er        = new ModelErrorReporter()
                            {
                                IdOfProperty = "authInformation_OLDpassword",
                                ErrorMessage = "کلمه عبور بدرستی وارد نشده است"
                            };
                            allErrors.Add(er);
                            var ModelSender = new ErrorReporterModel
                            {
                                ErrorID      = "EX105",
                                Errormessage = $"کلمه عبور حال شما کلید شما برای ایجاد تغییرات میباشد",
                                Errortype    = "ErrorWithList",
                                AllErrors    = allErrors
                            };
                            return(Json(ModelSender));
                        }
                    }
                    else
                    {
                        var ModelSender = new ErrorReporterModel
                        {
                            ErrorID      = "EX107",
                            Errormessage = $"کاربر یافت نشد با پشتیبانی تماس بفرمایید",
                            Errortype    = "Error",
                        };
                        return(Json(ModelSender));
                    }
                }
            }
            else
            {
                List <ModelErrorReporter> allErrors = new List <ModelErrorReporter>();
                var AllValues   = ModelState.Values.ToList();
                var AllKeys     = ModelState.Keys.ToList();
                int errorsCount = AllValues.Count;
                for (int i = 0; i < errorsCount; i++)
                {
                    if (AllValues[i].Errors.Count > 0)
                    {
                        ModelErrorReporter er = new ModelErrorReporter()
                        {
                            IdOfProperty = AllKeys[i].Replace("authInformation.", "authInformation_"),
                            ErrorMessage = AllValues[i].Errors[0].ErrorMessage
                        };
                        allErrors.Add(er);
                    }
                }
                var ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "EX106",
                    Errormessage = $"عدم رعایت استاندارد ها!",
                    Errortype    = "ErrorWithList",
                    AllErrors    = allErrors
                };
                return(Json(ModelSender));
            }
        }
        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 Index(ChangeProfileModel adObj1)
        {
            Administrator adObj = adObj1.administrator;

            if (ModelState.IsValid)
            {
                string adminID = "";
                try
                {
                    adminID = ((Administrator)Session["AdministratorRegistery"]).id_Admin;
                }
                catch (Exception exception)
                {
                    PPBugReporter rep = new PPBugReporter(BugTypeFrom.sessionAuth, "IN Controller : {AdministratorGeneralController}\nMethod : {public ActionResult Index(ChangeProfileModel adObj1)}")
                    {
                        EXOBJ = exception
                    };
                }
                //If Session Doesent work
                try
                {
                    HttpCookie cookie = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCoockieCode());
                    adminID = CoockieController.SayMyName(cookie.Value).id_Admin;
                }
                catch (Exception EX)
                {
                    PPBugReporter rep = new PPBugReporter(BugTypeFrom.coockieAuth, "IN Controller : {AdministratorGeneralController}\nMethod : {public ActionResult Index(ChangeProfileModel adObj1)}")
                    {
                        EXOBJ = EX
                    };
                }
                if (string.IsNullOrEmpty(adminID))
                {
                    adminID = "NO-ID";
                }

                PDBC db = new PDBC();
                List <ExcParameters> dbparams = new List <ExcParameters>();
                adObj.ad_avatarprofile = "/AdminDesignResource/app/media/img/users/100_12.jpg";
                ExcParameters param = new ExcParameters()
                {
                    _VALUE = adminID,
                    _KEY   = "@id_Admin"
                };
                dbparams.Add(param);
                param = new ExcParameters()
                {
                    _VALUE = adObj.ad_firstname,
                    _KEY   = "@ad_firstname"
                };
                dbparams.Add(param);

                param = new ExcParameters()
                {
                    _VALUE = adObj.ad_lastname,
                    _KEY   = "@ad_lastname"
                };
                dbparams.Add(param);
                param = new ExcParameters()
                {
                    _VALUE = adObj.ad_avatarprofile,
                    _KEY   = "@ad_avatarprofile"
                };
                dbparams.Add(param);
                param = new ExcParameters()
                {
                    _VALUE = adObj.ad_email,
                    _KEY   = "@ad_email"
                };
                dbparams.Add(param);
                param = new ExcParameters()
                {
                    _VALUE = adObj.ad_phone,
                    _KEY   = "@ad_phone"
                };
                dbparams.Add(param);
                param = new ExcParameters()
                {
                    _VALUE = adObj.ad_mobile,
                    _KEY   = "@ad_mobile"
                };
                dbparams.Add(param);
                param = new ExcParameters()
                {
                    _VALUE = adObj.ad_NickName,
                    _KEY   = "@ad_NickName"
                };
                dbparams.Add(param);

                db.Connect();
                string result = db.Script(
                    "UPDATE [tbl_ADMIN_main] SET [ad_firstname] = @ad_firstname ,[ad_lastname] = @ad_lastname ,[ad_avatarprofile] = @ad_avatarprofile ,[ad_email] = @ad_email ,[ad_phone] = @ad_phone ,[ad_mobile] = @ad_mobile ,[ad_NickName] = @ad_NickName WHERE id_Admin=@id_Admin",
                    dbparams);
                db.DC();
                if (result == "1")
                {
                    try
                    {
                        var sessionChanger = (Administrator)Session["AdministratorRegistery"];
                        sessionChanger.ad_avatarprofile   = adObj.ad_avatarprofile;
                        sessionChanger.ad_NickName        = adObj.ad_NickName;
                        sessionChanger.ad_firstname       = adObj.ad_firstname;
                        sessionChanger.ad_lastname        = adObj.ad_lastname;
                        sessionChanger.ad_email           = adObj.ad_email;
                        sessionChanger.ad_phone           = adObj.ad_phone;
                        sessionChanger.ad_mobile          = adObj.ad_mobile;
                        Session["AdministratorRegistery"] = sessionChanger;
                    }
                    catch (Exception EX)
                    {
                        PPBugReporter rep = new PPBugReporter(BugTypeFrom.sessionAuth, "IN Controller : {AdministratorGeneralController}\nMethod : {public ActionResult Index(ChangeProfileModel adObj LINE 126)}")
                        {
                            EXOBJ = EX
                        };
                    }
                    try
                    {
                        HttpCookie cookie         = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCoockieCode());
                        var        sessionChanger = CoockieController.SayMyName(cookie.Value);
                        sessionChanger.ad_avatarprofile = adObj.ad_avatarprofile;
                        sessionChanger.ad_NickName      = adObj.ad_NickName;
                        sessionChanger.ad_firstname     = adObj.ad_firstname;
                        sessionChanger.ad_lastname      = adObj.ad_lastname;
                        sessionChanger.ad_email         = adObj.ad_email;
                        sessionChanger.ad_phone         = adObj.ad_phone;
                        sessionChanger.ad_mobile        = adObj.ad_mobile;
                        var userCookieIDV = new HttpCookie(ProjectProperies.AuthCoockieCode());
                        userCookieIDV.Value   = CoockieController.SetCoockie(sessionChanger);;
                        userCookieIDV.Expires = DateTime.Now.AddYears(5);
                        Response.SetCookie(userCookieIDV);
                    }
                    catch (Exception EX)
                    {
                        PPBugReporter rep = new PPBugReporter(BugTypeFrom.coockieAuth, "IN Controller : {AdministratorGeneralController}\nMethod : {public ActionResult Index(ChangeProfileModel adObj LINE 126)}")
                        {
                            EXOBJ = EX
                        };
                    }

                    var ModelSender = new ErrorReporterModel
                    {
                        ErrorID      = "SX101",
                        Errormessage = "اطلاعات کاربری با موفقیت ویرایش شد!",
                        Errortype    = "Success"
                    };

                    return(Json(ModelSender));
                }
                else
                {
                    PPBugReporter rep         = new PPBugReporter(BugTypeFrom.SQL, result);
                    var           ModelSender = new ErrorReporterModel
                    {
                        ErrorID      = "EX103",
                        Errormessage = $"عدم توانایی در ویرایش اطلاعات با پشتیبانی تماس حاصل فرمایید! کد پیگیری برای شما :{rep.CodeGenerated}",
                        Errortype    = "Error"
                    };
                    ViewBag.EXLogin = ModelSender;
                    return(Json(ModelSender));
                }
            }
            else
            {
                List <ModelErrorReporter> allErrors = new List <ModelErrorReporter>();
                //foreach (ModelError error in ModelState.Values.)
                var AllValues   = ModelState.Values.ToList();
                var AllKeys     = ModelState.Keys.ToList();
                int errorsCount = AllValues.Count;
                for (int i = 0; i < errorsCount; i++)
                {
                    if (AllValues[i].Errors.Count > 0)
                    {
                        ModelErrorReporter er = new ModelErrorReporter()
                        {
                            IdOfProperty = AllKeys[i].Replace("administrator.", "administrator_"),
                            ErrorMessage = AllValues[i].Errors[0].ErrorMessage
                        };
                        allErrors.Add(er);
                    }
                }
                var ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "EX104",
                    Errormessage = $"عدم رعایت استاندارد ها!",
                    Errortype    = "ErrorWithList",
                    AllErrors    = allErrors
                };
                return(Json(ModelSender));
            }
        }