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 = LeaseReturnDetailsService.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_LeaseReturnDetails_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"))
                            {
                                var parmsQty = new Dictionary <string, object>();
                                parmsQty.Clear();

                                parmsQty.Add("@FCode", txtFCode.Text);
                                parmsQty.Add("@FId", datakey);
                                parmsQty.Add("@companyId", CurrentUser.AccountComId);
                                var dataQty = SqlService.ExecuteProcedureCommand("proc_LeaseBottleARByFCode", parmsQty).Tables[0];

                                //int arBottleQty = 0;
                                //if (dataQty != null && dataQty.Rows.Count > 0)
                                //    arBottleQty = Convert.ToInt32(dataQty.Rows[0]["ARBottleQty"]);

                                //验证当前回收量是否大于本次应回收量
                                //if (Convert.ToInt32(value) > arBottleQty)
                                //{
                                //    Alert.ShowInParent("本次回收量不能大余应回收量,请输入合法值。", MessageBoxIcon.Information);
                                //    return;
                                //}

                                details.FBottleQty       = Convert.ToInt32(value);
                                details.FPaymentRentals  = details.FBottleQty * details.FDays * details.FRentDay;
                                details.FDepositSecurity = details.FBottleQty * details.FPrice;
                            }

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

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

                            if (key.Equals("FAmount"))
                            {//押金
                                details.FPaymentRentals  = details.FBottleQty * details.FDays * details.FRentDay;
                                details.FDepositSecurity = details.FBottleQty * details.FPrice;
                                break;
                            }

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

                            LeaseReturnDetailsLogService.Add(detailslog);
                        }
                    }
                    #endregion
                }

                LeaseReturnDetailsService.SaveChanges();
            }
        }
Esempio 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
            {
                #region 退租明细
                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_LeaseBottleAR a WHERE a.FId 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 LHLeaseReturnDetails();

                            details.FBottle    = table.Rows[i]["FBottle"].ToString();
                            details.FPrice     = Convert.ToDecimal(table.Rows[i]["FPrice"]);
                            details.FBottleQty = Convert.ToInt32(table.Rows[i]["ARBottleQty"]);//
                            details.FCompanyId = CurrentUser.AccountComId;
                            details.KeyId      = txtKeyId.Text.Trim();
                            //每天租赁费
                            details.FRentDay = Convert.ToDecimal(table.Rows[i]["FRentDay"]);
                            //押金
                            details.FDepositSecurity = Convert.ToDecimal(table.Rows[i]["FDepositSecurity"]);

                            details.FDays = Convert.ToInt32(table.Rows[i]["days"]);

                            details.FPaymentRentals = Convert.ToDecimal(table.Rows[i]["ARRentals"]);

                            //租赁明细Id
                            details.FDetailsFId = Convert.ToInt32(table.Rows[i]["FId"]);
                            LeaseReturnDetailsService.AddEntity(details);

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

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

                                LeaseReturnDetailsLogService.Add(detailslog);

                                break;
                            }
                        }

                        LeaseReturnDetailsService.SaveChanges();

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

                #region 更新合计

                if (Grid1.Rows.Count > 0)
                {
                    if (GetRequestEventArgument() == "UPDATE_SUMMARY")
                    {
                        // 页面要求重新计算合计行的值
                        OutputSummaryData();

                        //写入
                        ModifiedGrid();

                        // 为了保持前后台上传,回发更新合计行值后,必须进行数据绑定或者提交更改
                        Grid1.CommitChanges();
                    }
                }

                #endregion
            }
        }