Beispiel #1
0
        public void OP_Command(object sender, CommandEventArgs e)
        {
            int    intIdGoods    = Convert.ToInt32(e.CommandArgument);
            int    intIdContract = Convert.ToInt32(ViewState["ContractId"]);
            string strUrl;

            if (e.CommandName == "AddGoods")
            {
                if (!HelperUtility.hasPurviewOP("InventoryContract_update"))
                {
                    HelperUtility.showAlert("没有操作权限", "list.aspx?page=" + ViewState["page"]);
                }
                int         rowIndex     = ((GridViewRow)((Button)sender).NamingContainer).RowIndex;
                GridViewRow row          = gvShow.Rows[rowIndex];
                TextBox     tbAmountFill = (TextBox)row.FindControl("tbAmountFill");
                if (tbAmountFill is null)
                {
                    return;
                }
                Label lblAmountReal  = (Label)row.FindControl("lblAmountReal");
                Label lblAmountStock = (Label)row.FindControl("lblAmountStock");

                ModelInventoryRecord model = new ModelInventoryRecord();
                model.id_contract  = intIdContract;
                model.id_goods     = intIdGoods;
                model.amount_real  = Convert.ToDecimal(lblAmountReal.Text);
                model.amount_stock = Convert.ToDecimal(lblAmountStock.Text);
                model.amount_fill  = Convert.ToDecimal(tbAmountFill.Text);
                BllInventoryRecord.add(model);
            }
            LoadData();
        }
Beispiel #2
0
        protected void gvShow_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#e1f2e9'");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");

                int   intContractId = Convert.ToInt32(ViewState["ContractId"]);
                Label lblGoodsId    = (Label)e.Row.FindControl("lblGoodsId");
                int   intGoodsId    = Convert.ToInt32(lblGoodsId.Text);
                if (BllInventoryRecord.isRecordAdded(intContractId, intGoodsId))
                {
                    Button btnAddGoods = (Button)e.Row.FindControl("btnAddGoods");
                    btnAddGoods.Text    = "已添加";
                    btnAddGoods.Enabled = false;
                    return;
                }
                HyperLink hlProductName = (HyperLink)e.Row.FindControl("hlProductName");
                hlProductName.NavigateUrl = "/BackManager/sales_goods/show.aspx?id=" + intGoodsId;
                // 显示入库量、计算库存、实时库存要用到的Label控件
                Label lblAmountIn   = (Label)e.Row.FindControl("lblAmountIn");
                Label lblAmountReal = (Label)e.Row.FindControl("lblAmountReal");
                // 得到入库的货品总量
                decimal intIn = Convert.ToDecimal(lblAmountIn.Text);
                // 得到实际出库的货品总量
                decimal intOut = BllCheckoutRecord.getAmountByGoodsId(intGoodsId);
                // 显示计算库存量
                lblAmountReal.Text = (intIn - intOut).ToString("N");
            }
        }
Beispiel #3
0
        protected void btnClearZero_Click(object sender, EventArgs e)
        {
            int intContractId = Convert.ToInt32(ViewState["ContractId"]);

            BllInventoryRecord.clearZero(intContractId);
            string strUrlBack = "?cid=" + ViewState["ContractId"] + "&cpage=" + ViewState["ContractPage"];

            Response.Redirect("list.aspx" + strUrlBack);
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            if (context.Request.Params["InventoryContractId"] == null ||
                !HelperUtility.isDecimal(context.Request.Params["InventoryContractId"].ToString()))
            {
                context.Response.Write(HelperUtility.setReturnJson("500", "需要指明盘点单ID!", ""));
                return;
            }
            if (context.Request.Params["GoodsId"] == null ||
                !HelperUtility.isDecimal(context.Request.Params["GoodsId"].ToString()))
            {
                context.Response.Write(HelperUtility.setReturnJson("500", "需要指明盘点货品ID!", ""));
                return;
            }
            if (context.Request.Params["Amount"] == null ||
                !HelperUtility.isDecimal(context.Request.Params["Amount"].ToString()))
            {
                context.Response.Write(HelperUtility.setReturnJson("500", "需要指明货品盘点数量!", ""));
                return;
            }

            int     intCheckoutContractId = Convert.ToInt32(context.Request.Params["CheckoutContractId"]);
            int     intGoodsId            = Convert.ToInt32(context.Request.Params["GoodsId"]);
            decimal dcmAmount             = Convert.ToDecimal(context.Request.Params["Amount"]);

            if (!(intCheckoutContractId > 0 && intGoodsId > 0 && dcmAmount > 0))
            {
                context.Response.Write(HelperUtility.setReturnJson("500", "数字不对!", ""));
                return;
            }
            ModelInventoryRecord model = new ModelInventoryRecord();

            model.id_contract  = intCheckoutContractId;
            model.id_goods     = intGoodsId;
            model.amount_real  = dcmAmount;
            model.amount_stock = dcmAmount;
            model.amount_fill  = dcmAmount;
            int intId = BllInventoryRecord.add(model);

            if (intId > 0)
            {
                context.Response.Write(HelperUtility.setReturnJson("200", "", intId.ToString()));
                return;
            }
            else
            {
                context.Response.Write(HelperUtility.setReturnJson("500", "添加失败,请联系管理员!", ""));
                return;
            }
        }
Beispiel #5
0
        public void OP_Command(object sender, CommandEventArgs e)
        {
            int    intId      = Convert.ToInt32(e.CommandArgument);
            string strUrlBack = "?cid=" + ViewState["ContractId"] + "&cpage=" + ViewState["ContractPage"];

            if (e.CommandName == "del")
            {
                if (HelperUtility.hasPurviewOP("InventoryRecord_del"))
                {
                    BllInventoryRecord.deleteById(intId);
                }
                else
                {
                    HelperUtility.showAlert("没有操作权限", "list.aspx" + strUrlBack);
                }
            }
            LoadDataPage();
        }
Beispiel #6
0
        public void LoadDataQuery(int intContractId, string strProductName)
        {
            DataTable objDT = BllInventoryRecord.getByQuery(intContractId, strProductName);

            gvShow.DataSource = objDT;
            gvShow.DataBind();
            lbtnFirst.Enabled  = false;
            lbtnPrev.Enabled   = false;
            lbtnNext.Enabled   = false;
            lbtnLast.Enabled   = false;
            ViewState["page"]  = "1";
            lblCurentPage.Text = "1";
            // 设置显示盘点总金额的Label控件值,以货币形式显示 2.5.ToString("C")
            decimal[] aryPriceTotal = BllInventoryRecord.getPriceTotalInventory(intContractId);
            lblPriceTotalReal.Text  = aryPriceTotal[0].ToString("C");
            lblPriceTotalStock.Text = aryPriceTotal[1].ToString("C");
            lblPriceTotalFill.Text  = aryPriceTotal[2].ToString("C");
        }
Beispiel #7
0
        protected void gvShow_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            int intId, intGoodsId;

            // string strId = gvShow.DataKeys[e.RowIndex].Values[0].ToString();
            intId = Convert.ToInt32(gvShow.DataKeys[e.RowIndex].Values["id"].ToString());
            Label lblGoodsId = (Label)gvShow.Rows[e.RowIndex].FindControl("lblGoodsId");

            if (lblGoodsId != null)
            {
                intGoodsId = Convert.ToInt32(lblGoodsId.Text);
            }
            else
            {
                intGoodsId = 0;
            }
            // 更新盘点数
            TextBox tbInventoryAmountFill = (TextBox)gvShow.Rows[e.RowIndex].FindControl("tbInventoryAmountFill");

            if (null == tbInventoryAmountFill)
            {
                return;
            }
            if ("".Equals(tbInventoryAmountFill.Text))
            {
                tbInventoryAmountFill.Text = "0";
            }
            decimal dcmInventoryAmountFill = Convert.ToDecimal(tbInventoryAmountFill.Text);

            // 只有盘点数大于0的时候才去更新货品的盘点数
            if (dcmInventoryAmountFill >= 0)
            {
                // 更新盘点表里的盘点数
                BllInventoryRecord.updateFillById(dcmInventoryAmountFill, intId);
                // 同时更新货品的库存量为盘点量
                BllSalesGoods.updateAmountStockByInventory(dcmInventoryAmountFill, intGoodsId);
            }
            gvShow.EditIndex = -1;
            LoadDataPage();
        }
Beispiel #8
0
        /* 货品出库时
         * 一、出库表里新加一条记录
         * 二、更新某个货品的库存数量字段(amount_stock)(更新方法是amount_stock = amount_stock - amountOut)
         * 添加出库货品时显示的是某个货品的库存量(amount_stock),
         * 货品表里每个货品有一个进货数量(amount)和库存数量(amount_stock)
         * 盘点时
         * 一、新建盘点单,然后搜索所有库存量大于0的货品添加到此盘点单对应的盘点货品单里。
         * 二、盘点时,修改盘点货品单里每个货品的盘点数量和修改(显示用)数量。
         * 三、在修改盘点货品表时,同时将某次盘点货品单里所有货品的库存量(amount_stock)都修改为盘点量(还是修改量???)。
         * 显示某盘点单下所有盘点货品时,显示的是该货品的库存数量(amount_stock)字段,盘点货品单下的盘点数量和修改数量。
         */

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int intAdminId = HelperUtility.hasPurviewPage("InventoryRecord_show");
                ViewState["AdminId"] = intAdminId;
                // 因此要得到要显示哪个盘点单的cid值和页面的cpage值用于返回
                int intContractId = HelperUtility.getQueryInt("cid");
                if (intContractId == 0)
                {
                    HelperUtility.showAlert("", "/BackManager/login.aspx");
                }
                ViewState["ContractId"]   = intContractId;
                ViewState["ContractPage"] = HelperUtility.getQueryInt("cpage");
                LoadDataPage();
                hlBackContract.NavigateUrl = "../inventory_contract/list.aspx?page=" + ViewState["ContractPage"];
                // hlAddNew.NavigateUrl = "add.aspx?cid=" + intContractId;
                // 设置显示库存总金额的Label控件值,以货币形式显示 2.5.ToString("C")
                decimal[] aryPriceTotal = BllInventoryRecord.getPriceTotalInventory(intContractId);
                lblPriceTotalReal.Text  = aryPriceTotal[0].ToString("C");
                lblPriceTotalStock.Text = aryPriceTotal[1].ToString("C");
                lblPriceTotalFill.Text  = aryPriceTotal[2].ToString("C");
            }
        }
Beispiel #9
0
        // 读取所有的数据并分页
        public void LoadDataPage()
        {
            int    intContractId  = Convert.ToInt32(ViewState["ContractId"]);
            string strProductName = Convert.ToString(ViewState["NameProduct"]);

            if (!"".Equals(strProductName))
            {
                // 如果关键字词不为空,说明是根据关键字词查询得到的数据
                LoadDataQuery(intContractId, strProductName);
            }
            else
            {
                DataTable objDT;
                if ("".Equals(lblCurentPage.Text.Trim()))
                {
                    lblCurentPage.Text = "1";
                }
                intCurrentPage = Convert.ToInt32(lblCurentPage.Text.Trim());
                if (intCurrentPage <= 0)
                {
                    intCurrentPage = 1;
                }
                // 得到总记录数
                intRecordCount = BllInventoryRecord.getRecordsAmount(intContractId);
                // 计算总页数
                intPageCount = (intRecordCount + intPageSize - 1) / intPageSize;
                if (intCurrentPage > intPageCount)
                {
                    intCurrentPage = intPageCount;
                }
                lblPageCount.Text = intPageCount.ToString();
                // 根据当前页获取当前页的分页记录DataTable
                if (intRecordCount > 0)
                {
                    objDT = BllInventoryRecord.getPage(intContractId, intCurrentPage, intPageSize);
                }
                else
                {
                    lblCurentPage.Text = "1";
                    objDT = null;
                }
                if (objDT != null && objDT.Rows.Count > 0)
                {
                    lbtnFirst.Enabled = true;
                    lbtnPrev.Enabled  = true;
                    lbtnNext.Enabled  = true;
                    lbtnLast.Enabled  = true;
                    if (intCurrentPage == 1)
                    {
                        lbtnFirst.Enabled = false;
                        lbtnPrev.Enabled  = false;
                    }
                    if (intCurrentPage == intPageCount)
                    {
                        lbtnNext.Enabled = false;
                        lbtnLast.Enabled = false;
                    }
                }
                else
                {
                    lbtnFirst.Enabled = false;
                    lbtnPrev.Enabled  = false;
                    lbtnNext.Enabled  = false;
                    lbtnLast.Enabled  = false;
                }
                gvShow.DataSource = objDT;
                gvShow.DataBind();
                lblRecordCount.Text = intRecordCount.ToString();
                lblCurentPage.Text  = intCurrentPage.ToString();
                tbPageNum.Text      = intCurrentPage.ToString();
                ViewState["page"]   = intCurrentPage;
                // 设置显示盘点总金额的Label控件值,以货币形式显示 2.5.ToString("C")
                decimal[] aryPriceTotal = BllInventoryRecord.getPriceTotalInventory(intContractId);
                lblPriceTotalReal.Text  = aryPriceTotal[0].ToString("C");
                lblPriceTotalStock.Text = aryPriceTotal[1].ToString("C");
                lblPriceTotalFill.Text  = aryPriceTotal[2].ToString("C");
            }
        }
Beispiel #10
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (!HelperUtility.hasPurviewOP("InventoryContract_add"))
            {
                string strUrl = "/BackManager/home.aspx";
                HelperUtility.showAlert("没有操作权限", strUrl);
            }
            string strMsgError = "";

            string strTimeStart = tbTimeStart.Value.Trim();

            if ("".Equals(strTimeStart))
            {
                strMsgError += "开始时间不能为空!";
            }
            if (!HelperUtility.isDateType(strTimeStart))
            {
                strMsgError += "开始时间格式不正确!";
            }
            string strTimeEnd = tbTimeEnd.Value.Trim();

            if ("".Equals(strTimeEnd))
            {
                strMsgError += "结束时间不能为空!";
            }
            if (!HelperUtility.isDateType(strTimeEnd))
            {
                strMsgError += "结束时间格式不正确!";
            }
            if (Convert.ToDateTime(strTimeEnd) <= Convert.ToDateTime(strTimeStart))
            {
                strMsgError += "结束时间不能早于开始时间!";
            }
            string strNameSign = tbNameSign.Text.Trim();

            if ("".Equals(strNameSign))
            {
                strMsgError += "盘点人员签名不能为空!";
            }
            string strComment = tbComment.Text.Trim();

            if (strComment.Length > 500)
            {
                strMsgError += "备注信息不能超过500个字数!";
            }
            if (!"".Equals(strMsgError))
            {
                HelperUtility.showAlert(strMsgError, "add.aspx");
                return;
            }
            string strPhotoUrls = "";
            // 验证完毕,提交数据,盘点单表添加一条记录
            int intAdminId = Convert.ToInt32(ViewState["AdminId"]);
            ModelInventoryContract model = new ModelInventoryContract();

            model.id_admin   = intAdminId;
            model.name_sign  = strNameSign;
            model.photo_urls = strPhotoUrls;
            model.comment    = strComment;
            model.time_start = Convert.ToDateTime(strTimeStart);
            model.time_end   = Convert.ToDateTime(strTimeEnd);
            int intContractId = BllInventoryContract.add(model);

            if (intContractId <= 0)
            {
                HelperUtility.showAlert("添加失败,请联系管理员!", "add.aspx");
            }
            // 盘点单表添加完成后,在盘点物品表里添加所有库存量大于0的货品记录
            BllInventoryRecord.setInventoryRecord(intContractId);
            HelperUtility.showAlert("添加成功!", "list.aspx");
        }