Exemplo n.º 1
0
        /// <summary>
        ///     Page_Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //初始化控件数据
                InitData();

                //加载数据
                LoadData();
            }
            else
            {
                if (GetRequestEventArgument().Contains("reloadGrid:"))
                {
                    //查找所选商品代码,查访产品集合
                    string keys = GetRequestEventArgument().Split(':')[1];

                    var values = keys.Split(',');

                    string codes = String.Empty;
                    for (int i = 0; i < values.Count(); i++)
                    {
                        codes += string.Format("'{0}',", values[i]);
                    }

                    var value = codes.Substring(0, codes.Length - 1);

                    var data = SqlService.Where(string.Format("SELECT * FROM dbo.vm_PurchaseItem a WHERE a.FItemCode IN ({0}) and FCompanyId={1}", value, CurrentUser.AccountComId
                                                              ));

                    if (data != null && data.Tables.Count > 0 && data.Tables[0].Rows.Count > 0)
                    {
                        var table = data.Tables[0];
                        for (int i = 0; i < table.Rows.Count; i++)
                        {
                            var details = new LHStockInDetails();

                            decimal price = GasHelper.GeSupplierPrice(txtFCode.Text.Trim(), //
                                                                      table.Rows[i]["FItemCode"].ToString(), CurrentUser.AccountComId);

                            details.FItemCode     = table.Rows[i]["FItemCode"].ToString();
                            details.FPrice        = price;
                            details.FQty          = 0;
                            details.FAmount       = price;
                            details.FBottleQty    = 0;
                            details.FBottleOweQty = 0;
                            details.FCompanyId    = CurrentUser.AccountComId;
                            details.KeyId         = txtKeyId.Text.Trim();
                            details.FCateId       = Convert.ToInt32(table.Rows[i]["FId"].ToString());
                            details.FNum          = table.Rows[i]["FINum"].ToString();//U8代码
                            details.FReturnQty    = 0;
                            details.FRecycleQty   = 0;

                            //默认包装物
                            details.FBottle = table.Rows[i]["FBottle"].ToString();

                            StockInDetailsService.AddEntity(details);

                            //日志
                            switch (Actions)
                            {
                            case WebAction.Add:
                                break;

                            case WebAction.Edit:
                                ////记录一下当前新增人操作内容
                                //var detailslog = new LHStockInDetails_Log
                                //{
                                //    FUpdateBy = CurrentUser.AccountName,
                                //    FUpdateDate = DateTime.Now,
                                //    FItemCode = details.FItemCode,
                                //    FPrice = price,
                                //    FQty = 1,
                                //    FAmount = price,
                                //    FBottleQty = 1,
                                //    FBottleOweQty = 0,
                                //    FCompanyId = CurrentUser.AccountComId,
                                //    KeyId = txtKeyId.Text.Trim(),
                                //    FBottle = details.FBottle,
                                //    FStatus = "新增",
                                //    FMemo = string.Format(@"时间:{0} 操作人:{1}", DateTime.Now, CurrentUser.AccountName)
                                //};

                                //StockInDetailsLogService.Add(detailslog);

                                break;
                            }
                        }

                        StockInDetailsService.SaveChanges();

                        //重新绑定值
                        BindDataGrid();
                    }
                }

                //更新合计
                if (GetRequestEventArgument() == "UPDATE_SUMMARY")
                {
                    // 页面要求重新计算合计行的值
                    OutputSummaryData();

                    //
                    ModifiedGrid();

                    // 为了保持前后台上传,回发更新合计行值后,必须进行数据绑定或者提交更改
                    Grid1.CommitChanges();
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Page_Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //初始化控件数据
                InitData();

                //加载数据
                LoadData();
            }
            else
            {
                if (GetRequestEventArgument().Contains("reloadGrid:"))
                {
                    //查找所选商品代码,查访产品集合
                    string keys = GetRequestEventArgument().Split(':')[1];

                    var values = keys.Split(',');

                    string codes = String.Empty;
                    for (int i = 0; i < values.Count(); i++)
                    {
                        codes += string.Format("'{0}',", values[i]);
                    }

                    var value = codes.Substring(0, codes.Length - 1);

                    var data = SqlService.Where(string.Format("SELECT * FROM dbo.vm_SalesItem a WHERE a.FItemCode IN ({0}) AND a.FCompanyId={1}", value, CurrentUser.AccountComId));

                    if (data != null && data.Tables.Count > 0 && data.Tables[0].Rows.Count > 0)
                    {
                        var table = data.Tables[0];
                        for (int i = 0; i < table.Rows.Count; i++)
                        {
                            var details = new LHStockInDetails();

                            decimal price = GasHelper.GeCustomerPrice(txtFCode.Text.Trim(), //
                                                                      table.Rows[i]["FItemCode"].ToString(), CurrentUser.AccountComId);

                            details.FItemCode     = table.Rows[i]["FItemCode"].ToString();
                            details.FPrice        = price;
                            details.FQty          = 1;
                            details.FAmount       = price;
                            details.FBottleQty    = 1;
                            details.FBottleOweQty = 0;
                            details.FBottle       = table.Rows[i]["FItemCode"].ToString();
                            details.FCompanyId    = CurrentUser.AccountComId;
                            details.KeyId         = txtKeyId.Text.Trim();
                            details.FCateId       = Convert.ToInt32(table.Rows[i]["FId"].ToString());


                            StockInDetailsService.AddEntity(details);

                            //日志
                            switch (Actions)
                            {
                            case WebAction.Add:
                                break;

                            case WebAction.Edit:
                                //记录一下当前新增人操作内容
                                var detailslog = new LHStockInDetails_Log
                                {
                                    FUpdateBy     = CurrentUser.AccountName,
                                    FUpdateDate   = DateTime.Now,
                                    FItemCode     = details.FItemCode,
                                    FPrice        = price,
                                    FQty          = 1,
                                    FAmount       = price,
                                    FBottleQty    = 1,
                                    FBottleOweQty = 0,
                                    KeyId         = txtKeyId.Text.Trim(),
                                    FBottle       = details.FBottle,
                                    FStatus       = "新增",
                                    FCompanyId    = CurrentUser.AccountComId,
                                    FMemo         = string.Format(@"时间:{0} 操作人:{1}", DateTime.Now, CurrentUser.AccountName)
                                };

                                StockInDetailsLogService.Add(detailslog);

                                break;
                            }
                        }

                        StockInDetailsService.SaveChanges();

                        //重新绑定值
                        BindDataGrid();
                    }
                }
            }
        }