Beispiel #1
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());

            //        DataTable table = dataSet.Tables[0];

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

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

            //            var details = new LHStockOutDetails
            //            {
            //                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 LHStockOutDetails_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 = "新增",
            //                        FMemo = string.Format(@"时间:{0} 新增人:{1}", DateTime.Now, CurrentUser.AccountName)
            //                    };

            //                    //detailslog.FCompanyId = CurrentUser.AccountComId;
            //                    //detailslog.FCateId = Convert.ToInt32(table.Rows[0]["FId"].ToString());

            //                    StockOutDetailsLogService.Add(detailslog);

            //                    break;
            //            }

            //           // CollectionOrderBanksService.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 banks = SKOrderBanksService.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);

                        //SqlService.ExecuteProcedureCommand("proc_StockOutDetails_Log", parms);

                        if (banks != null)
                        {
                            switch (key)
                            {
                            case "FAmt":
                                banks.FAmt = Convert.ToDecimal(value);
                                break;

                            case "FDiscountAmount":
                                banks.FDiscountAmount = Convert.ToDecimal(value);
                                break;

                            case "FCardNo":
                                banks.FCardNo = value;
                                break;

                            case "FBankNo":
                                banks.FBankNo = value;
                                break;

                            case "FBillNo":
                                banks.FBillNo = value;
                                break;

                            case "FExpireDate":
                                banks.FExpireDate = Convert.ToDateTime(value);
                                break;

                            case "FMemo":
                                banks.FMemo = value;
                                break;
                            }


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

                            //StockOutDetailsLogService.Add(detailslog);
                        }

                        SKOrderBanksService.SaveChanges();
                    }
                }
            }

            BindDataGrid();
        }
Beispiel #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_Bank a WHERE a.FCode IN ({0}) and FCompanyId={1} and FDate='{2}'", value, CurrentUser.AccountComId, DateTime.Now.ToString("yyyy-MM")));

                    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 banks = new LHSKOrderBanks();
                            banks.FDiscountAmount = 0;
                            banks.FAmt            = 0;
                            banks.FCardNo         = table.Rows[i]["FComment"].ToString();
                            banks.KeyId           = txtKeyId.Text.Trim();
                            banks.FCode           = table.Rows[i]["FCode"].ToString();
                            banks.FName           = table.Rows[i]["FName"].ToString();
                            banks.FMemo           = "";
                            banks.FBankNo         = "";
                            banks.FBillNo         = "";
                            banks.FCompanyId      = CurrentUser.AccountComId;
                            //banks.FExpireDate =
                            SKOrderBanksService.AddEntity(banks);

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

                            //        StockOutDetailsLogService.Add(detailslog);

                            //        break;
                            //}
                        }

                        SKOrderBanksService.SaveChanges();

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