Exemplo n.º 1
0
    protected void PupolateControls()
    {
        int userId = 0;

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

        UserList.DataSource = UserAccess.GetAdminUserListById(userId);
        UserList.DataBind();

        OAuthList.DataSource = OAuthAccess.GetAdminOAuthList(userId);
        OAuthList.DataBind();

        UserCategoryList.DataSource = UserCategoryAccess.GetAdminUserCategoryList(userId);
        UserCategoryList.DataBind();

        ZhuanTiList.DataSource = ZhuanTiAccess.GetAdminZhuanTiList(userId);
        ZhuanTiList.DataBind();

        CardList.DataSource = CardAccess.GetAdminCardList(userId);
        CardList.DataBind();

        List.DataSource = ItemAccess.GetAdminItemListByUserId(userId);
        List.DataBind();
    }
Exemplo n.º 2
0
    protected void BindGrid()
    {
        DataTable dt = CardAccess.GetCardList(userId);

        this.CardList.DataSource = dt;
        this.CardList.DataBind();

        foreach (DataRow dr in dt.Rows)
        {
            totalMoney += Double.Parse(dr["CardMoney"].ToString());
        }
    }
Exemplo n.º 3
0
    //钱包更改
    protected void CardList_SelectionChanged(object sender, EventArgs e)
    {
        int userId = Int32.Parse(Session["UserID"].ToString());
        int cardId = Int32.Parse(this.CardList.SelectedValue);

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

        CardEntity card = CardAccess.GetCardByCardId(cardId, userId);

        this.Label14.Text = "¥ " + card.CardMoney.ToString("0.0##");
    }
Exemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int userId = Int32.Parse(Session["UserID"].ToString());

            DataTable catTypeList = UserCategoryAccess.GetCategoryTypeList(userId);
            this.CatTypeList.DataSource = catTypeList;
            this.CatTypeList.DataBind();

            this.CategoryTypeDown.DataSource     = catTypeList;
            this.CategoryTypeDown.DataTextField  = "CategoryTypeName";
            this.CategoryTypeDown.DataValueField = "CategoryTypeID";
            this.CategoryTypeDown.DataBind();
            this.CategoryTypeDown.Items.Insert(0, new ListItem("请选择", "0"));

            this.ZhuanTiDown.DataSource     = ZhuanTiAccess.GetZhuanTiList(userId);
            this.ZhuanTiDown.DataTextField  = "ZhuanTiName";
            this.ZhuanTiDown.DataValueField = "ZTID";
            this.ZhuanTiDown.DataBind();
            this.ZhuanTiDown.Items.Insert(0, new ListItem("请选择", "0"));

            this.ItemType.Attributes.Add("readonly", "readonly");
            this.CategoryTypeDown.Attributes.Add("readonly", "readonly");
            this.ItemBuyDate.Attributes.Add("readonly", "readonly");
            //this.ItemBuyDate1.Attributes.Add("readonly", "readonly");
            //this.ItemBuyDate2.Attributes.Add("readonly", "readonly");

            if (Session["TodayDate"] != null)
            {
                string today  = Session["TodayDate"].ToString();
                string today2 = DateTime.Parse(today).AddMonths(11).ToString("yyyy-MM-dd");

                this.ItemBuyDate.Text     = today + " " + ItemHelper.GetWeekString(today, 0);
                this.ItemBuyDateHid.Value = today;

                this.ItemBuyDate1.Text = today;
                this.ItemBuyDate2.Text = today2;
            }

            //钱包
            this.CardDown.DataSource     = CardAccess.GetCardList(userId);
            this.CardDown.DataTextField  = "CardName";
            this.CardDown.DataValueField = "CardID";
            this.CardDown.DataBind();
            if (Request.Cookies["CardID"] != null)
            {
                string cardId = Request.Cookies["CardID"].Value;
                this.CardDown.SelectedValue = cardId;
            }
        }
    }
Exemplo n.º 5
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //http://stackoverflow.com/questions/1483652/wpf-combobox-binding-behaviour?rq=1 for binding
            CardAccess ca = new CardAccess();

            if (comboBox.Text != "")
            {
                if (ca.RegisterCard(EmpSetWhenChange.Emp_Id.ToString()))
                {
                    MessageBox.Show("Card Created for \"" + EmpSetWhenChange.Emp_Name + "\"");
                }
            }
        }
Exemplo n.º 6
0
    //类别更新操作
    protected void CardList_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        int     cardId      = Int32.Parse(CardList.DataKeys[e.RowIndex].Value.ToString());
        TextBox cardNameBox = (TextBox)CardList.Rows[e.RowIndex].FindControl("CardNameBox");
        string  cardName    = cardNameBox.Text.Trim();

        if (cardName == "")
        {
            Utility.Alert(this, "名称未填写!");
            return;
        }
        TextBox cardMoneyBox = (TextBox)CardList.Rows[e.RowIndex].FindControl("CardMoneyBox");
        string  cardMoney    = cardMoneyBox.Text.Trim();

        if (!ValidHelper.CheckDouble(cardMoney))
        {
            Utility.Alert(this, "余额填写错误!");
            return;
        }

        bool success = false;

        if (cardId == 0)
        {
            success = UserAccess.UpdateUserMoneyNew(userId, Double.Parse(cardMoney));
        }
        else
        {
            CardEntity card = new CardEntity();
            card.CardID      = cardId;
            card.CardName    = cardName;
            card.CardMoney   = Double.Parse(cardMoney);
            card.UserID      = userId;
            card.CardLive    = 1;
            card.Synchronize = 1;

            success = CardAccess.UpdateCard(card);
        }

        if (success)
        {
            Utility.Alert(this, "更新成功。");

            CardList.EditIndex = -1;
            BindGrid();
        }
        else
        {
            Utility.Alert(this, "更新失败!");
        }
    }
Exemplo n.º 7
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;
            }
        }
    }
Exemplo n.º 8
0
        void AddCard(object sender, RoutedEventArgs e)
        {
            Employee obj = ((FrameworkElement)sender).DataContext as Employee;

            if (obj.Status == "no card")
            {
                CardAccess ca = new CardAccess();
                if (ca.RegisterCard(obj.Id.ToString()))
                {
                    MessageBox.Show("Card Created");
                }
            }
            else
            {
                MessageBox.Show("Card Already Exists");
            }
        }
Exemplo n.º 9
0
        void BlockCard(object sender, RoutedEventArgs e)
        {
            Employee obj = ((FrameworkElement)sender).DataContext as Employee;

            if (obj.Status != "card blocked")
            {
                SelectFrmDb sdb = new SelectFrmDb();
                CardAccess  ca  = new CardAccess();
                if (sdb.BlockCard(obj.Id))
                {
                    MessageBox.Show("Card Blocked");
                }
            }
            else
            {
                MessageBox.Show("Card Already Blocked");
            }
        }
Exemplo n.º 10
0
    //添加类别操作
    protected void Button1_Click(object sender, EventArgs e)
    {
        string cardName = this.CardNameEmpIns.Text.Trim();

        if (cardName == "")
        {
            Utility.Alert(this, "名称未填写!");
            return;
        }
        string cardMoney = this.CardMoneyEmpIns.Text.Trim();

        if (cardMoney != "")
        {
            if (!ValidHelper.CheckDouble(cardMoney))
            {
                Utility.Alert(this, "余额填写错误!");
                return;
            }
        }
        else
        {
            cardMoney = "0";
        }

        CardEntity card = new CardEntity();

        card.CardName    = cardName;
        card.CardMoney   = Double.Parse(cardMoney);
        card.UserID      = userId;
        card.CardLive    = 1;
        card.Synchronize = 1;

        bool success = CardAccess.InsertCard(card);

        if (success)
        {
            Utility.Alert(this, "添加成功。", "UserCardAdmin.aspx");
        }
        else
        {
            Utility.Alert(this, "添加失败!");
        }
    }
Exemplo n.º 11
0
    //类别删除操作
    protected void CardList_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int cardId = Int32.Parse(CardList.DataKeys[e.RowIndex].Value.ToString());

        if (cardId == 0)
        {
            Utility.Alert(this, "不能删除我的钱包!");
            return;
        }

        CardEntity card = CardAccess.GetCardByCardId(cardId, userId);

        card.CardLive    = 0;
        card.Synchronize = 1;

        bool success = CardAccess.CheckItemListByCardId(userId, cardId);

        if (!success)
        {
            success = CardAccess.UpdateCard(card);
            if (success)
            {
                Utility.Alert(this, "删除成功。");

                CardList.EditIndex = -1;
                BindGrid();
            }
            else
            {
                Utility.Alert(this, "删除失败!");
            }
        }
        else
        {
            Utility.Alert(this, "不能删除已使用的钱包!");
        }
    }
Exemplo n.º 12
0
    //导出数据到App//
    protected void Button1_Click(object sender, EventArgs e)
    {
        int userId = Int32.Parse(Session["UserID"].ToString());

        fileName = "aalife2.bak";

        StringBuilder sb = new StringBuilder();

        DataTable itemListTab = BackupAccess.BackupItemTableById(userId);

        if (itemListTab.Rows.Count > 0)
        {
            sb.AppendLine("DELETE FROM ItemTable;");
            foreach (DataRow dr in itemListTab.Rows)
            {
                sb.AppendLine("INSERT INTO ItemTable (ItemType, ItemName, ItemPrice, ItemBuyDate, CategoryID, Recommend, Synchronize, RegionID, RegionType, ZhuanTiID, CardID) VALUES ('" +
                              dr["ItemType"].ToString() + "', '" +
                              dr["ItemName"].ToString() + "', '" +
                              dr["ItemPrice"].ToString() + "', '" +
                              String.Format("{0:yyyy-MM-dd}", dr["ItemBuyDate"]) + "', '" +
                              dr["CategoryTypeID"].ToString() + "', '" +
                              dr["Recommend"].ToString() + "', '0', '" +
                              dr["RegionID"].ToString() + "', '" +
                              dr["RegionType"].ToString() + "', '" +
                              dr["ZhuanTiID"].ToString() + "', '" +
                              dr["CardID"].ToString() + "');");
            }
            sb.AppendLine("");
        }

        DataTable catListTab = UserCategoryAccess.GetCategoryTypeList(userId);

        if (catListTab.Rows.Count > 0)
        {
            sb.AppendLine("DELETE FROM CategoryTable;");
            foreach (DataRow dr in catListTab.Rows)
            {
                sb.AppendLine("INSERT INTO CategoryTable (CategoryID, CategoryName, CategoryPrice, CategoryRank, CategoryDisplay, CategoryLive) VALUES ('" +
                              dr["CategoryTypeID"].ToString() + "', '" +
                              dr["CategoryTypeName"].ToString() + "', '" +
                              dr["CategoryTypePrice"].ToString() + "', '" +
                              dr["CategoryTypeID"].ToString() + "', '1', '1');");
            }
            sb.AppendLine("");
        }

        DataTable zhuanTiTab = ZhuanTiAccess.GetZhuanTiList(userId);

        if (zhuanTiTab.Rows.Count > 0)
        {
            sb.AppendLine("DELETE FROM ZhuanTiTable;");
            foreach (DataRow dr in zhuanTiTab.Rows)
            {
                sb.AppendLine("INSERT INTO ZhuanTiTable (ZTID, ZhuanTiName, ZhuanTiImage, ZhuanTiLive, Synchronize) VALUES ('" +
                              dr["ZTID"].ToString() + "', '" +
                              dr["ZhuanTiName"].ToString() + "', '" +
                              dr["ZhuanTiImage"].ToString() + "', '" +
                              dr["ZhuanTiLive"].ToString() + "', '0');");
            }
            sb.AppendLine("");
        }

        DataTable cardTab = CardAccess.GetCardList(userId);

        if (cardTab.Rows.Count > 0)
        {
            sb.AppendLine("DELETE FROM CardTable;");
            foreach (DataRow dr in cardTab.Rows)
            {
                if (dr["CardID"].ToString() == "0")
                {
                    continue;
                }
                sb.AppendLine("INSERT INTO CardTable (CDID, CardName, CardMoney, CardLive, Synchronize) VALUES ('" +
                              dr["CardID"].ToString() + "', '" +
                              dr["CardName"].ToString() + "', '" +
                              dr["CardMoney"].ToString() + "', '" +
                              dr["CardLive"].ToString() + "', '0');");
            }
        }

        BackupAccess.WriteBackupFile(filePath + fileName, sb.ToString());

        //Utility.Alert(this, "导出成功。");

        DownBackFile();
    }
Exemplo n.º 13
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);
    }