Exemple #1
0
        public List <PostModel> Posttable()
        {
            var  res = new List <PostModel>();
            PDBC db  = new PDBC("PandaMarketCMS", true);

            db.Connect();

            DataTable dt = db.Select("SELECT [Id],[Title],[GroupId],[Text_min],[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 FROM [tbl_BLOG_Post] order by(date)desc");

            db.DC();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DateTime        date            = Convert.ToDateTime(dt.Rows[i]["Date"]);
                PersianDateTime persianDateTime = new PersianDateTime(date);
                var             model           = new PostModel()
                {
                    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(),
                    ImagePath       = AppendServername(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            = persianDateTime.ToLongDateString(),
                    GPIDforPostPAge = dt.Rows[i]["GroupId"].ToString()
                };
                res.Add(model);
            }
            return(res);
        }
Exemple #2
0
        public DimDate(DateTime d)
        {
            var j = new PersianDateTime(d);

            Date          = d;
            LongDate      = d.ToLongDateString();
            DayOfWeek     = (int)d.DayOfWeek + 1;
            DayOfWeekName = d.DayOfWeek.ToString();
            DayOfMonth    = d.Day;
            DayOfYear     = d.DayOfYear;
            Month         = d.Month;
            MonthName     = DateUtility.GetMonthName(d.Month);
            Year          = d.Year;

            PersianDate          = j.ToShortDateString();
            PersianDateInt       = j.ToShortDateInt();
            PersianLongDate      = j.ToLongDateString();
            PersianDayOfWeek     = (int)j.PersianDayOfWeek + 1;
            PersianDayOfWeekName = j.GetLongDayOfWeekName;
            PersianDayOfMonth    = j.Day;
            PersianDayOfYear     = j.GetDayOfYear;
            PersianWeekOfMonth   = j.GetWeekOfMonth;
            PersianWeekOfYear    = j.GetWeekOfYear;
            PersianMonth         = j.Month;
            PersianMonthName     = j.MonthName;
            PersianQuarter       = DateUtility.GetQuarter(j.Month);
            PersianQuarterName   = DateUtility.GetPersinQuarterName(PersianQuarter);
            PersianHalfYear      = DateUtility.GetHalfYear(j.Month);
            PersianHalfYearName  = DateUtility.GetPersianHalfYearName(PersianHalfYear);
            PersianYear          = j.Year;
            PersianIsLeapYear    = j.IsLeapYear;
        }
Exemple #3
0
        public static string ToPersian(this DateTime datetime)
        {
            TimeSpan        a = DateTime.Now - datetime;
            double          b = a.TotalDays;
            int             c = a.Days;
            PersianDateTime persianDateTime = new PersianDateTime(datetime);

            return(persianDateTime.ToLongDateString());
        }
        /// <summary>
        ///  زمان را به صورت رشته دریافت میکند و به صورت های مختلف تاریخ شمسی تبدیل میکند
        /// </summary>
        /// <param name="date_">زمان به صورت رشته</param>
        /// <param name="DateType">
        /// Date : تاریخ به فارسی
        /// Time : زمان
        /// DateTime : تاریخ و زمان به طور کامل
        /// Ago : چند دقیقه ، ساعت یا روز پیش
        /// ShortDate :تاریخ
        /// </param>
        /// <returns>تاریخ تبدیل شده به صورت رشته</returns>
        public static string DateReturner(string date_, string DateType)
        {
            DateTime        date            = Convert.ToDateTime(date_);
            PersianDateTime persianDateTime = new PersianDateTime(date);

            if (DateType == "Date")
            {
                return(persianDateTime.ToLongDateString());
            }
            else if (DateType == "Time")
            {
                return(persianDateTime.ToLongTimeString());
            }
            else if (DateType == "DateTime")
            {
                return(persianDateTime.ToLongDateTimeString());
            }
            else if (DateType == "Ago")
            {
                string          LastSeen = "";
                PersianDateTime PerNow   = new PersianDateTime(DateTime.Now);
                var             dateTest = PerNow.Subtract(persianDateTime);
                if (dateTest.Days < 1)
                {
                    if (dateTest.Hours < 1)
                    {
                        LastSeen = dateTest.Minutes + " دقیقه ی پیش";
                    }
                    else
                    {
                        LastSeen = dateTest.Hours + "ساعت پیش";
                    }
                }
                else
                {
                    LastSeen = dateTest.Days + "روز پیش";
                }
                return(LastSeen);
            }
            else if (DateType == "ShortDate")
            {
                return(persianDateTime.ToShortDateString());
            }
            else
            {
                return("");
            }
        }
        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));
        }