protected void Page_Load(object sender, EventArgs e)
    {
        userId = Int32.Parse(Session["UserID"].ToString());

        if (Request.QueryString["type"] != null && Request.QueryString["type"] != "")
        {
            type = Request.QueryString["type"];
        }

        #region  入日期
        if (Request.QueryString["date"] != null && Request.QueryString["date"] != "")
        {
            if (!ValidHelper.CheckDate(Request.QueryString["date"]))
            {
                Session["TodayDate"] = DateTime.Now.ToString("yyyy-MM-dd");
            }
            else
            {
                Session["TodayDate"] = Request.QueryString["date"];
            }
        }
        #endregion
        today = Session["TodayDate"].ToString();

        if (!IsPostBack)
        {
            PopulateControls();
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        itemName = Request.QueryString["itemName"] ?? "";
        itemType = Request.QueryString["itemType"] ?? "";

        //比较分析明细进入使用
        today = Session["TodayDate"].ToString();
        if (Request.QueryString["date"] != null && Request.QueryString["date"] != "")
        {
            if (ValidHelper.CheckDate(Request.QueryString["date"]))
            {
                today = Request.QueryString["date"];
            }
        }

        userId = Int32.Parse(Session["UserID"].ToString());

        if (Request.QueryString["catTypeId"] != null && Request.QueryString["catTypeId"] != "")
        {
            catTypeId = Request.QueryString["catTypeId"];
        }

        if (!IsPostBack)
        {
            PopulateControls();
        }
    }
    protected void PopulateControls()
    {
        string title     = Request.QueryString["title"];
        string itemName  = Request.QueryString["itemName"] ?? "";
        string itemType  = Request.QueryString["itemType"] ?? "";
        string today     = Session["TodayDate"].ToString();
        string catTypeId = "0";

        if (Request.QueryString["catTypeId"] != null && Request.QueryString["catTypeId"] != "")
        {
            catTypeId = Request.QueryString["catTypeId"];
        }
        //比较分析明细进入使用
        if (Request.QueryString["date"] != null && Request.QueryString["date"] != "")
        {
            if (ValidHelper.CheckDate(Request.QueryString["date"]))
            {
                today = Request.QueryString["date"];
            }
        }
        int       userId   = Int32.Parse(Session["UserID"].ToString());
        double    priceMax = 0;
        DataTable dt       = ItemAccess.GetItemNumDetailList(itemName, itemType, userId, Int32.Parse(catTypeId), today, "list", out priceMax);

        string max           = "1";
        string step          = "1";
        string itemNameValue = "";
        string itemPrice     = "";

        if (dt.Rows.Count > 0)
        {
            max  = Math.Ceiling(priceMax).ToString();
            step = Math.Floor(Double.Parse(max) / 10).ToString();

            int i = 0;
            foreach (DataRow dr in dt.Rows)
            {
                if (i == 15)
                {
                    break;
                }
                string dot = (i < 15 - 1 && i < dt.Rows.Count - 1 ? "," : "");
                itemNameValue += "{\"text\":\"" + DateTime.Parse(dr["ItemBuyDate"].ToString()).ToString("yyyy-MM-dd") + "\",\"rotate\":90}" + dot;
                itemPrice     += dr["ItemPrice"].ToString() + dot;
                i++;
            }
        }
        else
        {
            itemNameValue = "{\"text\":\"0\"},{\"text\":\"1\"}";
        }

        Response.Write(GetChartJsonString(itemNameValue, itemPrice, title, max, step));
        Response.End();
    }
Exemple #4
0
        //检查内容
        private bool CheckSave()
        {
            string itemType  = this.ItemTypeHid.Value;
            int    catTypeId = Convert.ToInt32(this.CategoryTypeDown.SelectedValue);
            string itemName  = this.ItemName.Text.Trim();
            string itemPrice = this.ItemPrice.Text.Trim();

            if (itemType == "")
            {
                Utility.Alert(this, "消费分类填写错误!");
                return(false);
            }

            if (catTypeId == 0)
            {
                Utility.Alert(this, "商品类别填写错误!");
                return(false);
            }

            if (itemName == "")
            {
                Utility.Alert(this, "商品名称填写错误!");
                return(false);
            }

            if (!ValidHelper.CheckDouble(itemPrice))
            {
                Utility.Alert(this, "商品价格填写错误!");
                return(false);
            }

            if (this.RegionID.Checked)
            {
                if (!ValidHelper.CheckDate(this.ItemBuyDate1.Text.Trim()) || !ValidHelper.CheckDate(this.ItemBuyDate2.Text.Trim()))
                {
                    Utility.Alert(this, "购买日期填写错误!");
                    return(false);
                }
            }
            else
            {
                if (!ValidHelper.CheckDate(this.ItemBuyDateHid.Value))
                {
                    Utility.Alert(this, "购买日期填写错误!");
                    return(false);
                }
            }

            return(true);
        }
Exemple #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        userId       = Int32.Parse(Session["UserID"].ToString());
        catTypeList  = UserCategoryAccess.GetCategoryTypeList(userId);
        itemTypeList = ItemAccess.GetItemListType();
        cardList     = CardAccess.GetCardList(userId);

        if (Request.QueryString["date"] != null && Request.QueryString["date"] != "")
        {
            if (!ValidHelper.CheckDate(Request.QueryString["date"]))
            {
                Session["TodayDate"] = DateTime.Now.ToString("yyyy-MM-dd");
            }
            else
            {
                Session["TodayDate"] = Request.QueryString["date"];
            }
        }
        today = Session["TodayDate"].ToString();

        if (!IsPostBack)
        {
            BindGrid();

            this.CatTypeEmpIns.DataSource     = catTypeList;
            this.CatTypeEmpIns.DataTextField  = "CategoryTypeName";
            this.CatTypeEmpIns.DataValueField = "CategoryTypeID";
            this.CatTypeEmpIns.DataBind();
            if (Request.Cookies["CatTypeID"] != null)
            {
                this.CatTypeEmpIns.SelectedValue = Request.Cookies["CatTypeID"].Value;
            }

            this.ItemTypeEmpIns.DataSource     = itemTypeList;
            this.ItemTypeEmpIns.DataTextField  = "ItemTypeName";
            this.ItemTypeEmpIns.DataValueField = "ItemTypeValue";
            this.ItemTypeEmpIns.DataBind();

            //钱包
            this.CardEmpIns.DataSource     = cardList;
            this.CardEmpIns.DataTextField  = "CardName";
            this.CardEmpIns.DataValueField = "CardID";
            this.CardEmpIns.DataBind();
            if (Request.Cookies["CardID"] != null)
            {
                this.CardEmpIns.SelectedValue = Request.Cookies["CardID"].Value;
            }
        }
    }
Exemple #6
0
 //传入日期处理
 public static DateTime GetRequestDate(string date)
 {
     if (date != null && date != "" && ValidHelper.CheckDate(date))
     {
         HttpContext.Current.Session["TodayDate"] = date;
         return(Convert.ToDateTime(date));
     }
     else if (HttpContext.Current.Session["TodayDate"] != null)
     {
         return(Convert.ToDateTime(HttpContext.Current.Session["TodayDate"]));
     }
     else
     {
         HttpContext.Current.Session["TodayDate"] = DateTime.Now.ToString("yyyy-MM-dd");
         return(DateTime.Now);
     }
 }
    protected int SaveItem()
    {
        string itemType = this.ItemTypeHid.Value;

        if (itemType == "")
        {
            Utility.Alert(this, "消费分类填写错误!");
            return(2);
        }

        int catTypeId = Int32.Parse(this.CategoryTypeDown.SelectedValue);

        if (catTypeId == 0)
        {
            Utility.Alert(this, "商品类别填写错误!");
            return(2);
        }
        Response.Cookies["CatTypeID"].Value   = catTypeId.ToString();
        Response.Cookies["CatTypeID"].Expires = DateTime.MaxValue;

        string itemName = this.ItemName.Text.Trim();

        if (itemName == "")
        {
            Utility.Alert(this, "商品名称填写错误!");
            return(2);
        }

        int userId = Int32.Parse(Session["UserID"].ToString());

        string itemPrice = this.ItemPrice.Text.Trim();

        if (!ValidHelper.CheckDouble(itemPrice))
        {
            Utility.Alert(this, "商品价格填写错误!");
            return(2);
        }

        int zhuanTiId = Int32.Parse(this.ZhuanTiDown.SelectedValue);

        int cardId = Int32.Parse(this.CardDown.SelectedValue);

        Response.Cookies["CardID"].Value   = cardId.ToString();
        Response.Cookies["CardID"].Expires = DateTime.MaxValue;

        DateTime itemBuyDate  = DateTime.Now;
        DateTime itemBuyDate1 = DateTime.Now;
        DateTime itemBuyDate2 = DateTime.Now;
        int      monthRegion  = 0;
        int      regionId     = 0;
        string   regionType   = "";

        if (this.RegionID.Checked)
        {
            if (!ValidHelper.CheckDate(this.ItemBuyDate1.Text.Trim()) || !ValidHelper.CheckDate(this.ItemBuyDate2.Text.Trim()))
            {
                Utility.Alert(this, "购买日期填写错误!");
                return(2);
            }
            else
            {
                itemBuyDate1 = DateTime.Parse(this.ItemBuyDate1.Text.Trim() + " " + DateTime.Now.ToString("HH:mm:ss"));
                itemBuyDate2 = DateTime.Parse(this.ItemBuyDate2.Text.Trim() + " " + DateTime.Now.ToString("HH:mm:ss"));
            }

            regionType  = this.RegionTypeHid.Value;
            itemBuyDate = itemBuyDate1;
            regionId    = Int32.Parse(ItemAccess.GetItemListMaxRegionId(userId));
            monthRegion = ItemHelper.GetMonthRegion(itemBuyDate1, itemBuyDate2, regionType);

            //判断区间最大天数
            int    maxRegion = 0;
            string regionStr = "";
            switch (regionType)
            {
            case "d":
            case "b":
                maxRegion = 92;
                regionStr = "应小于3个月。";
                break;

            case "w":
                maxRegion = (int)Math.Floor((double)92 / 7);
                regionStr = "应小于3个月。";
                break;

            case "m":
                maxRegion = 36;
                regionStr = "应小于3年。";
                break;

            case "y":
                maxRegion = 15;
                regionStr = "应小于15年。";
                break;
            }

            if (monthRegion <= 0 || monthRegion >= maxRegion)
            {
                Utility.Alert(this, "区间日期设置不合理!" + regionStr);
                return(2);
            }
        }
        else
        {
            if (!ValidHelper.CheckDate(this.ItemBuyDateHid.Value))
            {
                Utility.Alert(this, "购买日期填写错误!");
                return(2);
            }
            else
            {
                itemBuyDate  = DateTime.Parse(this.ItemBuyDateHid.Value + " " + DateTime.Now.ToString("HH:mm:ss"));
                itemBuyDate1 = itemBuyDate;
            }
        }

        ItemEntity item = new ItemEntity();

        item.ItemType       = itemType;
        item.ItemName       = itemName;
        item.CategoryTypeID = catTypeId;
        item.ItemPrice      = Double.Parse(itemPrice);
        item.UserID         = userId;
        item.RegionID       = regionId;
        item.RegionType     = regionType;
        item.Synchronize    = 1;
        item.ZhuanTiID      = zhuanTiId;
        item.CardID         = cardId;

        bool success = false;

        for (int i = 0; i <= monthRegion; i++)
        {
            switch (regionType)
            {
            case "d":
                itemBuyDate = itemBuyDate1.AddDays(i);
                break;

            case "w":
                itemBuyDate = itemBuyDate1.AddDays(i * 7);
                break;

            case "m":
                itemBuyDate = itemBuyDate1.AddMonths(i);
                break;

            case "y":
                itemBuyDate = itemBuyDate1.AddYears(i);
                break;

            case "b":
                DateTime curDate = itemBuyDate1.AddDays(i);
                if (ItemHelper.GetWorkDayFinal(curDate, Session["UserWorkDay"].ToString()))
                {
                    itemBuyDate = curDate;
                }
                else
                {
                    continue;
                }
                break;
            }

            item.ItemBuyDate = itemBuyDate;
            success          = ItemAccess.InsertItem(item, 1);
        }

        if (success)
        {
            Session["TodayDate"] = itemBuyDate1.ToString("yyyy-MM-dd");
            return(1);
        }
        else
        {
            return(0);
        }
    }
Exemple #8
0
    protected void BindGrid()
    {
        if (Request.QueryString["date"] != null && Request.QueryString["date"] != "")
        {
            if (!ValidHelper.CheckDate(Request.QueryString["date"]))
            {
                Session["TodayDate"] = DateTime.Now.ToString("yyyy-MM-dd");
            }
            else
            {
                Session["TodayDate"] = Request.QueryString["date"];
            }
        }

        string today  = Session["TodayDate"].ToString();
        int    userId = Int32.Parse(Session["UserID"].ToString());

        //图表点击事件
        double    priceMax = 0;
        DataTable dd       = ItemAccess.GetItemDateTopList(today, userId, "chart", out priceMax);

        this.hidChartData.Value = ItemHelper.GetChartData(dd, "ItemBuyDate");

        #region 每日消费代码
        double    shouruPrice      = 0;
        double    zhichuPrice      = 0;
        double    shouruPriceMonth = 0;
        double    zhichuPriceMonth = 0;
        double    shouruPriceYear  = 0;
        double    zhichuPriceYear  = 0;
        DataTable total            = ItemAccess.GetItemListShouZhi(today, userId, out shouruPrice, out zhichuPrice, out shouruPriceMonth, out zhichuPriceMonth, out shouruPriceYear, out zhichuPriceYear);
        this.Label2.Text  = shouruPrice.ToString("0.0##");
        this.Label4.Text  = zhichuPrice.ToString("0.0##");
        this.Label1.Text  = shouruPriceMonth.ToString("0.0##");
        this.Label3.Text  = zhichuPriceMonth.ToString("0.0##");
        this.Label11.Text = shouruPriceYear.ToString("0.0##");
        this.Label12.Text = zhichuPriceYear.ToString("0.0##");

        double    jiechuPrice  = 0;
        double    huanruPrice  = 0;
        double    jieruPrice   = 0;
        double    huanchuPrice = 0;
        DataTable jiehuan      = ItemAccess.GetItemListJieHuanYear(today, userId, out jiechuPrice, out huanruPrice, out jieruPrice, out huanchuPrice);
        this.Label5.Text = jiechuPrice.ToString("0.##");
        this.Label6.Text = huanruPrice.ToString("0.##");
        this.Label7.Text = jieruPrice.ToString("0.##");
        this.Label8.Text = huanchuPrice.ToString("0.##");

        this.Label9.Text  = (jiechuPrice - huanruPrice).ToString("0.##");
        this.Label10.Text = (jieruPrice - huanchuPrice).ToString("0.##");
        #endregion

        //首页功能链接
        string userFunction = "";
        if (Session["UserFunction"] != null)
        {
            userFunction = Session["UserFunction"].ToString();
        }
        this.Label13.Text = UserAccess.GetUserFunctionText(userFunction);

        //钱包列表
        this.CardList.DataSource     = CardAccess.GetCardList(userId);
        this.CardList.DataTextField  = "CardName";
        this.CardList.DataValueField = "CardID";
        this.CardList.DataBind();
        if (Request.Cookies["CardID"] != null)
        {
            string cardId = Request.Cookies["CardID"].Value;
            this.CardList.SelectedValue = cardId;
        }
        CardList_SelectionChanged(this.CardList, null);
    }