Ejemplo n.º 1
0
        /// <summary>
        ///     提交添加
        /// </summary>
        private bool SubmintAdd()
        {
            var stock = StockInService.Where(p => p.KeyId == txtKeyId.Text.Trim() && p.FCompanyId == CurrentUser.AccountComId).FirstOrDefault();

            if (stock != null)
            {
                ModifiedGrid();

                var prod =
                    StockInDetailsService.FirstOrDefault(
                        p => p.KeyId == txtKeyId.Text && p.FCompanyId == CurrentUser.AccountComId);

                if (prod == null)
                {
                    //生产产品入库
                    var product = new LHStockInDetails
                    {
                        KeyId         = txtKeyId.Text,
                        FItemCode     = txtFCode.Text,
                        FPrice        = 0,
                        FAmount       = 0,
                        FQty          = Convert.ToDecimal(txtFQty.Text),
                        FBottle       = tbxFBottle.SelectedValue,
                        FBottleQty    = Convert.ToInt16(txtFBottleQty.Text),
                        FBottleOweQty = 0,
                        FCompanyId    = CurrentUser.AccountComId,
                        FCateId       = 2000,
                        FMemo         = "生产入库",
                        FCostPrice    = Convert.ToDecimal(txtFCostPrice.Text),
                        FBalance      = Convert.ToDecimal(txtFBalance.Text),
                    };

                    StockInDetailsService.Add(product);
                }
                else
                {
                    prod.FItemCode  = txtFCode.Text;
                    prod.FQty       = Convert.ToDecimal(txtFQty.Text);
                    prod.FBottle    = tbxFBottle.SelectedValue;
                    prod.FBottleQty = Convert.ToInt32(txtFBottleQty.Text);
                    prod.FCostPrice = Convert.ToDecimal(txtFCostPrice.Text);
                    prod.FBalance   = Convert.ToDecimal(txtFBalance.Text);

                    StockInDetailsService.SaveChanges();
                }
                //-------------------------------------------------------------------

                stock.FCompanyId  = CurrentUser.AccountComId;
                stock.FFlag       = 1;
                stock.FDeleteFlag = 0;
                stock.FMemo       = txtFMemo.Text.Trim();

                var parms = new Dictionary <string, object>();
                parms.Clear();

                parms.Add("@keyID", stock.KeyId);
                parms.Add("@companyId", CurrentUser.AccountComId);
                var amt =
                    Convert.ToDecimal(SqlService.ExecuteProcedureCommand("proc_PurchaseAmt", parms).Tables[0].Rows[0][0]);

                stock.FAmount = amt;

                stock.FSurveyor = !ddlFSurveyor.SelectedValue.Equals("-1") ? ddlFSurveyor.SelectedText : "";
                stock.FProducer = !ddlFProducer.SelectedValue.Equals("-1") ? ddlFProducer.SelectedText : "";//GasHelper.GetDropDownListArrayString(ddlFProducer.SelectedItemArray);

                stock.FBatchNumber = txtFBatchNumber.Text.Trim();

                stock.FProductionWorkshop = ddlWorkShop.SelectedValue;

                stock.FCate = "内部";
                stock.FCode = CurrentUser.AccountComId.ToString(CultureInfo.InvariantCulture);
                stock.FName = "";
                stock.FDate = txtFDate.SelectedDate;


                StockInService.SaveChanges();


                if (txtKeyId.Text.Contains("TM"))
                {
                    //单据号问题
                    string newKeyId   = SequenceService.CreateSequence(Convert.ToDateTime(txtFDate.SelectedDate), "PR", CurrentUser.AccountComId);
                    var    orderParms = new Dictionary <string, object>();
                    orderParms.Clear();
                    orderParms.Add("@oldKeyId", txtKeyId.Text);
                    orderParms.Add("@newKeyId", newKeyId);
                    orderParms.Add("@Bill", "6");
                    orderParms.Add("@companyId", CurrentUser.AccountComId);
                    SqlService.ExecuteProcedureCommand("proc_num", orderParms);
                    txtKeyId.Text = newKeyId;



                    var orders = new Dictionary <string, object>();
                    orders.Clear();
                    orders.Add("@KeyId", newKeyId);
                    orders.Add("@companyId", CurrentUser.AccountComId);

                    SqlService.ExecuteProcedureCommand("proc_ProuctOrder", orders);


                    //新增日志
                    var billStatus = new LHBillStatus
                    {
                        KeyId       = newKeyId,
                        FCompanyId  = CurrentUser.AccountComId,
                        FActionName = "新增",
                        FDate       = DateTime.Now,
                        FDeptId     = CurrentUser.AccountOrgId,
                        FOperator   = CurrentUser.AccountName,
                        FMemo       = String.Format("单据号{0},{1}新增生产单据。", newKeyId, CurrentUser.AccountName)
                    };
                    GasHelper.AddBillStatus(billStatus);
                }

                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Grid1_AfterEdit(object sender, GridAfterEditEventArgs e)
        {
            var addList = Grid1.GetNewAddedList();

            foreach (var add in addList)
            {
                var dictValues = add.Values;

                //商品代码
                var firstOrDefault = dictValues.First();

                if (firstOrDefault != null && !string.IsNullOrEmpty(firstOrDefault.ToString()))
                {
                    DataSet dataSet = GasHelper.GetPurchaseItem(firstOrDefault.ToString(), CurrentUser.AccountComId);

                    DataTable table = dataSet.Tables[0];

                    if (table != null && table.Rows.Count > 0)
                    {
                        decimal price = GasHelper.GeSupplierPrice(txtFCode.Text.Trim(),//
                                                                  table.Rows[0]["FItemCode"].ToString(), CurrentUser.AccountComId);

                        table.Rows[0]["FPrice"] = price;

                        var details = new LHStockInDetails
                        {
                            FItemCode     = table.Rows[0]["FItemCode"].ToString(),
                            FPrice        = price,
                            FQty          = 0,
                            FAmount       = price,
                            FBottleQty    = 0,
                            FReturnQty    = 0,
                            FBottleOweQty = 0,
                            FRecycleQty   = 0,
                            FCompanyId    = CurrentUser.AccountComId,
                            KeyId         = txtKeyId.Text.Trim(),
                            FBottle       = table.Rows[0]["FBottleCode"].ToString(),
                            FCateId       = Convert.ToInt32(table.Rows[0]["FId"].ToString())
                        };

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

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

                            StockInDetailsLogService.Add(detailslog);

                            break;
                        }


                        StockInDetailsService.Add(details);
                    }
                }
            }

            //var dictModified = Grid1.GetModifiedDict();

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

            //    foreach (var dictValue in dictModified.Values)
            //    {
            //        foreach (KeyValuePair<string, object> keyValuePair in dictValue)
            //        {
            //            string key = keyValuePair.Key;
            //            string value = keyValuePair.Value.ToString();

            //            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_StockInDetails_Log", parms);

            //            if (details != null)
            //            {
            //                switch (key)
            //                {
            //                    case "FPrice":
            //                        details.FPrice = Convert.ToDecimal(value);
            //                        details.FAmount = details.FPrice * details.FQty;
            //                        break;

            //                    case "FQty":
            //                        details.FQty = Convert.ToDecimal(value);
            //                        details.FAmount = details.FPrice * details.FQty;
            //                        break;

            //                    case "FBottle":
            //                        details.FBottle = value;
            //                        break;

            //                    case "FBottleName":
            //                        details.FBottle = value;
            //                        break;

            //                    case "FBottleQty":
            //                        details.FBottleQty = Convert.ToInt32(value);
            //                        break;

            //                    case "FMemo":
            //                        details.FMemo = value;
            //                        break;
            //                }

            //                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,
            //                    FStatus = "变更",
            //                    FCompanyId = CurrentUser.AccountComId,
            //                    FMemo = string.Format(@"时间:{0} 变更人:{1}", DateTime.Now, CurrentUser.AccountName)
            //                };
            //                StockInDetailsLogService.Add(detailslog);

            //            }

            //            StockInDetailsService.SaveChanges();
            //        }
            //    }
            //}

            if (addList.Count > 0)
            {
                BindDataGrid();
            }
        }
Ejemplo n.º 3
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();
                    }
                }
            }
        }
Ejemplo n.º 4
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();
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     单元格编辑与修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Grid1_AfterEdit(object sender, GridAfterEditEventArgs e)
        {
            Window1.Hidden = true;
            Window2.Hidden = true;
            Window3.Hidden = true;

            //新增行事件
            var addList = Grid1.GetNewAddedList();

            foreach (var add in addList)
            {
                var dictValues = add.Values;

                //商品代码
                var firstOrDefault = dictValues.First();

                if (firstOrDefault != null)
                {
                    DataSet dataSet = GasHelper.GetSalesItem(firstOrDefault.ToString(), CurrentUser.AccountComId);

                    DataTable table = dataSet.Tables[0];

                    if (table != null && table.Rows.Count > 0)
                    {
                        decimal price = GasHelper.GeCustomerPrice("",//
                                                                  table.Rows[0]["FItemCode"].ToString(), CurrentUser.AccountComId);

                        table.Rows[0]["FPrice"] = price;

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

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

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

                            StockInDetailsLogService.Add(detailslog);

                            break;
                        }

                        StockInDetailsService.Add(details);
                    }
                }
            }

            if (addList.Count > 0)
            {
                BindDataGrid();
            }
        }