Esempio n. 1
0
        /// <summary>
        ///     ModifiedGrid
        /// </summary>
        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 = LeaseDetailsService.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_LeaseDetails_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("FBottleQty"))
                            {
                                details.FBottleQty = Convert.ToInt32(value);
                                details.FAmount    = details.FBottleQty * details.FPrice;
                            }

                            if (key.Equals("FRentDay"))
                            {//租金/天
                                details.FRentDay = Convert.ToDecimal(value);
                            }

                            if (key.Equals("FPrice"))
                            {//押金/个
                                details.FPrice  = Convert.ToDecimal(value);
                                details.FAmount = details.FPrice * details.FBottleQty;
                            }

                            if (key.Equals("FAmount"))
                            {//押金
                                details.FAmount = details.FBottleQty * details.FPrice;
                            }
                        }

                        var detailslog = new LHLeaseDetails_Log
                        {
                            FUpdateBy   = CurrentUser.AccountName,
                            FUpdateDate = DateTime.Now,
                            FBottle     = details.FBottle,
                            FPrice      = details.FPrice,
                            FBottleQty  = details.FBottleQty,
                            FAmount     = details.FAmount,
                            KeyId       = details.KeyId,
                            FRentDay    = details.FRentDay,
                            FStatus     = "变更",
                            FCompanyId  = CurrentUser.AccountComId,
                            //FMemo = string.Format(@"时间:{0} 变更人:{1}", DateTime.Now, CurrentUser.AccountName)
                        };

                        LeaseDetailsLogService.Add(detailslog);
                    }
                    #endregion
                }

                LeaseDetailsService.SaveChanges();
            }
        }