示例#1
0
        /// <summary>
        ///     加载页面数据
        /// </summary>
        private void LoadData()
        {
            switch (Actions)
            {
            case WebAction.Add:

                Region1.Title = "添加生产单";
                txtKeyId.Text = SequenceService.CreateSequence("TM", CurrentUser.AccountComId);
                var temp = new LHStockIn
                {
                    KeyId = txtKeyId.Text,

                    FFlag = 1,

                    FDeleteFlag = 1,

                    //发货单
                    FType = Convert.ToInt32(GasEnumBill.Production),

                    CreateBy = CurrentUser.AccountName,

                    FDate = txtFDate.SelectedDate,

                    FCompanyId = CurrentUser.AccountComId,

                    FStatus = Convert.ToInt32(GasEnumBillStauts.Add),

                    FProgress = Convert.ToInt32(GasEnumBillStauts.Add),
                };

                //临时写入单据
                StockInService.Add(temp);

                break;

            case WebAction.Edit:
                txtKeyId.Text = KeyId;
                Region1.Title = "编辑生产单";

                if (StockIn != null)
                {
                    txtFMemo.Text = StockIn.FMemo;
                    ddlFProducer.SelectedValue = StockIn.FProducer;
                    ddlFSurveyor.SelectedValue = StockIn.FSurveyor;
                    ddlWorkShop.SelectedValue  = StockIn.FProductionWorkshop;
                    var product =
                        StockInDetailsService.Where(
                            p => p.KeyId == KeyId && p.FCompanyId == CurrentUser.AccountComId).FirstOrDefault();

                    if (product != null)
                    {
                        txtFCode.Text            = product.FItemCode;
                        txtFQty.Text             = product.FQty.ToString();
                        tbxFBottle.SelectedValue = product.FBottle;
                        txtFBottleQty.Text       = product.FBottleQty.ToString();
                        txtFCostPrice.Text       = product.FCostPrice.ToString();
                        txtFBalance.Text         = product.FBalance.ToString();

                        //
                        var item =
                            new ItemsService().Where(
                                p => p.FCode == txtFCode.Text && p.FCompanyId == CurrentUser.AccountComId)
                            .FirstOrDefault();

                        if (item != null)
                        {
                            tbxFName.Text = item.FName;
                        }
                    }

                    BindDataGrid();
                }
                break;
            }
        }
示例#2
0
        private void ModifiedGrid()
        {
            //编辑行事件
            var dictModified = Grid1.GetModifiedDict();

            foreach (var rowKey in dictModified.Keys)
            {
                int datakey = Convert.ToInt32(Grid1.DataKeys[rowKey][1].ToString());

                var sKeys   = new StringBuilder();
                var sValues = new StringBuilder();
                foreach (var key in dictModified[rowKey].Keys)
                {
                    sKeys.AppendFormat("{0},", key);
                }

                foreach (var dictValue in dictModified[rowKey].Values)
                {
                    sValues.AppendFormat("{0},", dictValue);
                }

                var details = StockInDetailsService.Where(p => p.FId == datakey && //
                                                          p.FCompanyId == CurrentUser.AccountComId).FirstOrDefault();

                //写入原始,通过存储过程完成明细复制
                var parms = new Dictionary <string, object>();
                parms.Clear();

                parms.Add("@fid", datakey);
                parms.Add("@opr", CurrentUser.AccountName);
                parms.Add("@companyId", CurrentUser.AccountComId);
                SqlService.ExecuteProcedureCommand("proc_StockOutDetails_Log", parms);

                var keys   = sKeys.ToString().Split(',');
                var values = sValues.ToString().Split(',');
                for (int i = 0; i < keys.Count(); i++)
                {
                    #region 修改内容

                    var key   = keys[i];
                    var value = values[i];

                    if (!string.IsNullOrEmpty(key))
                    {
                        if (details != null)
                        {
                            if (key.Equals("FPrice"))
                            {
                                details.FPrice  = Convert.ToDecimal(value);
                                details.FAmount = details.FPrice * details.FQty;
                            }

                            if (key.Equals("FQty"))
                            {
                                details.FQty       = Convert.ToDecimal(value);
                                details.FBottleQty = (Int32)(Convert.ToDecimal(value));
                                details.FAmount    = details.FPrice * details.FQty;
                            }

                            if (key.Equals("FBottle"))
                            {
                                details.FBottle = value;
                            }

                            if (key.Equals("FBottleName"))
                            {
                                details.FBottle = value;
                            }

                            if (key.Equals("FBottleQty"))
                            {
                                int result = 0;
                                int.TryParse(value, out result);

                                details.FBottleQty = result;

                                //details.FBottleQty = (Int32)(Convert.ToDecimal(value));
                            }
                            if (key.Equals("FT6Warehouse"))
                            {
                                details.FT6WarehouseNum = GasHelper.GetWarehouseByName(value);
                            }
                            if (key.Equals("FReturnQty"))
                            {
                                details.FReturnQty = Convert.ToDecimal(value);
                            }
                            if (key.Equals("FRecycleQty"))
                            {
                                int result = 0;
                                int.TryParse(value, out result);

                                details.FRecycleQty = result;
                                //details.FRecycleQty = (Int32)(Convert.ToDecimal(value));
                            }

                            var detailslog = new LHStockInDetails_Log
                            {
                                FUpdateBy     = CurrentUser.AccountName,
                                FUpdateDate   = DateTime.Now,
                                FItemCode     = details.FItemCode,
                                FPrice        = details.FPrice,
                                FQty          = details.FQty,
                                FAmount       = details.FAmount,
                                FBottleQty    = details.FBottleQty,
                                FBottleOweQty = details.FBottleOweQty,
                                KeyId         = details.KeyId,
                                FBottle       = details.FBottle,
                                FCompanyId    = CurrentUser.AccountComId,
                                FStatus       = "变更",
                                FMemo         = string.Format(@"时间:{0} 变更人:{1}", DateTime.Now, CurrentUser.AccountName)
                            };
                            StockInDetailsLogService.Add(detailslog);
                        }
                    }
                    #endregion
                }

                StockInDetailsService.SaveChanges();
            }
        }