Exemple #1
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 (Grid1.Rows.Count > 0)
                {
                    if (GetRequestEventArgument() == "UPDATE_SUMMARY")
                    {
                        // 页面要求重新计算合计行的值
                        OutputSummaryData();

                        //写入
                        ModifiedGrid();

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

                #endregion
            }
        }
Exemple #2
0
        /// <summary>
        /// 计算合计
        /// </summary>
        private void OutputSummaryData()
        {
            Grid1.CommitChanges();
            decimal sumTotalMoney = 0, sumAuditTotalMoney = 0, totalMoney = 0, auditTotalMoney = 0, priceMoney = 0, auditPriceMoney = 0;
            int     counts = 0, auditCounts = 0;

            for (int i = 0; i < Grid1.Rows.Count; i++)
            {
                counts         = Funs.GetNewIntOrZero(this.Grid1.Rows[i].Values[3].ToString());
                priceMoney     = Funs.GetNewDecimalOrZero(this.Grid1.Rows[i].Values[4].ToString());
                totalMoney     = counts * priceMoney;
                sumTotalMoney += totalMoney;
                this.Grid1.Rows[i].Values[5] = totalMoney.ToString();
                auditCounts                  = Funs.GetNewIntOrZero(this.Grid1.Rows[i].Values[6].ToString());
                auditPriceMoney              = Funs.GetNewDecimalOrZero(this.Grid1.Rows[i].Values[7].ToString());
                auditTotalMoney              = auditCounts * auditPriceMoney;
                sumAuditTotalMoney          += auditTotalMoney;
                this.Grid1.Rows[i].Values[8] = auditTotalMoney.ToString();
            }
            if (this.Grid1.Rows.Count > 0)
            {
                JObject summary = new JObject();
                summary.Add("PriceMoney", "总计");
                summary.Add("TotalMoney", sumTotalMoney);
                summary.Add("AuditTotalMoney", sumAuditTotalMoney);
                Grid1.SummaryData = summary;
            }
            else
            {
                Grid1.SummaryData = null;
            }
        }
Exemple #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 (!string.IsNullOrEmpty(txtFCode.Text))
                {
                }

                if (GetRequestEventArgument().Contains("reloadGrid:"))
                {
                    #region Grid1
                    //查找所选商品代码,查访产品集合
                    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 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 LHStockOutDetails();

                            decimal price = GasHelper.GeSupplierPrice("", //
                                                                      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.FCompanyId    = CurrentUser.AccountComId;
                            details.KeyId         = txtKeyId.Text.Trim();
                            details.FCateId       = Convert.ToInt32(table.Rows[i]["FId"].ToString());

                            details.FCostPrice = 0;
                            details.FBalance   = 0;

                            //默认包装物
                            details.FBottle = table.Rows[i]["FBottle"].ToString();

                            StockOutDetailsService.AddEntity(details);

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

                            case WebAction.Edit:
                                //记录一下当前新增人操作内容
                                var detailslog = new LHStockOutDetails_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)
                                };

                                StockOutDetailsLogService.Add(detailslog);

                                break;
                            }
                        }

                        StockOutDetailsService.SaveChanges();

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

                #region 更新合计

                if (Grid1.Rows.Count > 0)
                {
                    if (GetRequestEventArgument() == "UPDATE_SUMMARY")
                    {
                        OutputSummaryData();

                        ModifiedGrid();

                        Grid1.CommitChanges();
                    }
                }

                #endregion
            }
        }
Exemple #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
            {
                #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_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 LHInitMonthDetails();

                            details.FItemCode  = table.Rows[i]["FItemCode"].ToString();
                            details.FQty       = 1;
                            details.FCompanyId = CurrentUser.AccountComId;
                            details.KeyId      = txtKeyId.Text.Trim();
                            details.FCateId    = Convert.ToInt32(table.Rows[i]["FId"].ToString());

                            InitMonthDetailsService.AddEntity(details);

                            //日志
                            //switch (Actions)
                            //{
                            //    case WebAction.Add:
                            //        break;
                            //    case WebAction.Edit:
                            //        //记录一下当前新增人操作内容
                            //        var detailslog = new LHStockOutDetails_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)
                            //        };
                            //        StockOutDetailsLogService.Add(detailslog);
                            //        break;
                            //}
                        }

                        InitMonthDetailsService.SaveChanges();

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

                #region 更新合计
                if (GetRequestEventArgument() == "UPDATE_SUMMARY")
                {
                    // 页面要求重新计算合计行的值
                    OutputSummaryData();

                    //写入
                    ModifiedGrid();

                    // 为了保持前后台上传,回发更新合计行值后,必须进行数据绑定或者提交更改
                    Grid1.CommitChanges();
                }
                #endregion
            }
        }
Exemple #5
0
        /// <summary>
        ///     AddListGrid
        /// </summary>
        private void AddListGrid()
        {
            //新增行事件
            var dictList = Grid1.GetNewAddedList();

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

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

                var keys   = sKeys.ToString().Split(',');
                var values = sValues.ToString().Split(',');

                var details = new LHDispatchCommissionDetails();

                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("KeyId"))
                            {
                                details.KeyId = value;
                            }

                            if (key.Equals("FDate"))
                            {
                                details.FDate = Convert.ToDateTime(value);
                            }
                            if (key.Equals("FCode"))
                            {
                                details.FCode = value;
                            }
                            if (key.Equals("FName"))
                            {
                                details.FName = value;
                            }

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

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

                            if (key.Equals("FQty"))
                            {
                                details.FQty = Convert.ToInt32(value);
                            }

                            if (key.Equals("FPrice"))
                            {
                                details.FPrice = Convert.ToDecimal(value);
                            }

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

                            if (key.Equals("FDriverPrice"))
                            {
                                details.FDriverPrice = Convert.ToDecimal(value);
                            }
                            if (key.Equals("FSupercargo"))
                            {
                                details.FSupercargo = value;
                            }
                            if (key.Equals("FSupercargoPrice"))
                            {
                                details.FSupercargoPrice = Convert.ToDecimal(value);
                            }
                            if (key.Equals("FVehicleNum"))
                            {
                                details.FVehicleNum = value;
                            }

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

                    #endregion
                }


                details.FCompanyId = CurrentUser.AccountComId;
                StockOutDetailsService.Add(details);
            }

            Grid1.CommitChanges();
        }
Exemple #6
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_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 LHPassCardDetails();

                            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          = 1;
                            details.FAmount       = price;
                            details.FBottleQty    = 1;
                            details.FBottleOweQty = 0;
                            details.FCompanyId    = CurrentUser.AccountComId;
                            details.KeyId         = txtKeyId.Text.Trim();
                            details.FCateId       = Convert.ToInt32(table.Rows[i]["FId"].ToString());
                            details.FBSpec        = table.Rows[i]["FBSpec"].ToString();
                            details.FRecycleQty   = 0;
                            details.FCostPrice    = 0;
                            details.FBalance      = 0;

                            //默认包装物
                            details.FBottle = table.Rows[i]["FBottle"].ToString();

                            StockOutDetailsService.AddEntity(details);
                        }

                        StockOutDetailsService.SaveChanges();

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

                #region 更新合计

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

                        //写入
                        ModifiedGrid();

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

                #endregion
            }
        }
Exemple #7
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
            }
        }
Exemple #8
0
        /// <summary>
        ///     AddListGrid
        /// </summary>
        private void AddListGrid()
        {
            //新增行事件
            var dictList = Grid1.GetNewAddedList();

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

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

                var keys   = sKeys.ToString().Split(',');
                var values = sValues.ToString().Split(',');

                var details = new LHLiquidPlan();

                for (int i = 0; i < keys.Count(); i++)
                {
                    #region 修改内容

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

                    if (!string.IsNullOrEmpty(key) && key.Length > 0)
                    {
                        if (details != null)
                        {
                            #region Add

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

                            if (key.Equals("FDate"))
                            {
                                details.FDate = Convert.ToDateTime(value);
                            }

                            if (key.Equals("FItemName"))//产品
                            {
                                details.FItemCode = value;

                                if (!string.IsNullOrEmpty(value))
                                {
                                    details.FItemName =
                                        ItemsService.FirstOrDefault(
                                            p => p.FCode == value && p.FCompanyId == CurrentUser.AccountComId).FName;
                                }
                            }

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

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

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

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

                                if (value != null && !string.IsNullOrEmpty(value))
                                {
                                    var vehicle = new VehicleService().FirstOrDefault(p => p.FNum == value);

                                    details.FMargin = Convert.ToDecimal(vehicle.FMargin);
                                }
                            }

                            //if (key.Equals("FMargin"))
                            //{
                            //    details.FMargin = Convert.ToDecimal(value);
                            //}

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

                            if (key.Equals("FSupplierName"))
                            {
                                details.FSupplierCode = value;
                                if (!string.IsNullOrEmpty(value))
                                {
                                    details.FSupplierName =
                                        SupplierService.FirstOrDefault(
                                            p => p.FCode == value && p.FCompanyId == CurrentUser.AccountComId).FName;
                                }
                            }

                            if (key.Equals("FPurchasedPrice"))
                            {
                                details.FPurchasedPrice = Convert.ToDecimal(value);
                                details.FAmt            = details.FPurchasedPrice * details.FPurchasedQty;
                            }

                            if (key.Equals("FPurchasedQty"))
                            {
                                details.FPurchasedQty = Convert.ToDecimal(value);
                                details.FAmt          = details.FPurchasedPrice * details.FPurchasedQty;
                            }

                            //--------------------------------------

                            if (key.Equals("FDate1"))
                            {
                                details.FDate1 = Convert.ToDateTime(value);
                            }

                            if (key.Equals("FName1"))
                            {
                                details.FCode1 = value;
                                if (!string.IsNullOrEmpty(value))
                                {
                                    details.FName1 =
                                        CustomerService.FirstOrDefault(
                                            p => p.FCode == value && p.FCompanyId == CurrentUser.AccountComId).FName;
                                }
                            }

                            if (key.Equals("FPrice1"))
                            {
                                details.FPrice1 = Convert.ToDecimal(value);
                                details.FAmt1   = details.FPrice1 * details.FQty1;
                            }

                            if (key.Equals("FQty1"))
                            {
                                details.FQty1 = Convert.ToDecimal(value);
                                details.FAmt1 = details.FPrice1 * details.FQty1;
                            }

                            //--------------------

                            if (key.Equals("FDate2"))
                            {
                                details.FDate2 = Convert.ToDateTime(value);
                            }

                            if (key.Equals("FName2"))
                            {
                                details.FCode2 = value;
                                if (!string.IsNullOrEmpty(value))
                                {
                                    details.FName2 =
                                        CustomerService.FirstOrDefault(
                                            p => p.FCode == value && p.FCompanyId == CurrentUser.AccountComId).FName;
                                }
                            }

                            if (key.Equals("FPrice2"))
                            {
                                details.FPrice2 = Convert.ToDecimal(value);
                                details.FAmt2   = details.FPrice2 * details.FQty2;
                            }

                            if (key.Equals("FQty2"))
                            {
                                details.FQty2 = Convert.ToDecimal(value);
                                details.FAmt2 = details.FPrice2 * details.FQty2;
                            }

                            //--------------------

                            if (key.Equals("FDat3"))
                            {
                                details.FDate3 = Convert.ToDateTime(value);
                            }

                            if (key.Equals("FName3"))
                            {
                                details.FCode3 = value;
                                if (!string.IsNullOrEmpty(value))
                                {
                                    details.FName3 =
                                        CustomerService.FirstOrDefault(
                                            p => p.FCode == value && p.FCompanyId == CurrentUser.AccountComId).FName;
                                }
                            }

                            if (key.Equals("FPrice3"))
                            {
                                details.FPrice3 = Convert.ToDecimal(value);
                                details.FAmt3   = details.FPrice3 * details.FQty3;
                            }

                            if (key.Equals("FQty3"))
                            {
                                details.FQty3 = Convert.ToDecimal(value);
                                details.FAmt3 = details.FPrice3 * details.FQty3;
                            }
                            //--------------------

                            if (key.Equals("FMarginEnd"))
                            {
                                details.FMarginEnd = Convert.ToDecimal(value);
                            }

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


                            #endregion
                        }
                    }

                    #endregion
                }

                string keyId = SequenceService.CreateSequence(Convert.ToDateTime(details.FDate), "LP", CurrentUser.AccountComId);
                details.KeyId       = keyId;
                details.FDeleteFlag = 0;
                details.FType       = 26;
                details.FFlag       = 1;
                details.CreateBy    = CurrentUser.AccountName;
                details.FStatus     = 10;

                details.FCompanyId = CurrentUser.AccountComId;
                LiquidPlanService.Add(details);

                var refuel = new LHLiquidRefuel
                {
                    FFlag      = 1,
                    CreateBy   = CurrentUser.AccountName,
                    FDate      = details.FDate,
                    KeyId      = details.KeyId,
                    FCompanyId = CurrentUser.AccountComId
                };
                LiquidRefuelService.Add(refuel);
            }

            Grid1.CommitChanges();
        }
Exemple #9
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 reloadGrid
                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 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 LHLeaseDetails();

                            decimal price = GasHelper.GeCustomerPrice(txtFCode.Text, //
                                                                      table.Rows[i]["FItemCode"].ToString(), CurrentUser.AccountComId);

                            details.FBottle    = table.Rows[i]["FItemCode"].ToString();
                            details.FPrice     = price;
                            details.FBottleQty = 1;
                            details.FAmount    = price;
                            details.FBottleQty = 1;
                            //details.FBottleOweQty = 0;
                            details.FCompanyId = CurrentUser.AccountComId;
                            details.KeyId      = txtKeyId.Text.Trim();
                            details.FCateId    = Convert.ToInt32(table.Rows[i]["FId"].ToString());
                            //每天租赁费
                            details.FRentDay = 0;
                            //押金
                            details.FAmount = price;

                            //已归还量
                            details.FReturnQty = 0;

                            LeaseDetailsService.AddEntity(details);

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

                            case WebAction.Edit:
                                //记录一下当前新增人操作内容
                                var detailslog = new LHLeaseDetails_Log
                                {
                                    FUpdateBy   = CurrentUser.AccountName,
                                    FUpdateDate = DateTime.Now,
                                    FBottle     = details.FBottle,
                                    FPrice      = price,
                                    FBottleQty  = 1,
                                    FAmount     = price,
                                    FCompanyId  = CurrentUser.AccountComId,
                                    KeyId       = txtKeyId.Text.Trim(),
                                    FStatus     = "新增",
                                };

                                LeaseDetailsLogService.Add(detailslog);

                                break;
                            }
                        }

                        LeaseDetailsService.SaveChanges();

                        //重新绑定值
                        BindDataGrid();
                    }
                }
                else if (GetRequestEventArgument().Contains("reloadSalesGrid:"))
                {
                    string key = GetRequestEventArgument().Split(':')[1];

                    tbxFSalesNum.Text = key;

                    var sales = new StockOutService().Where(p => p.KeyId == key && p.FCompanyId == CurrentUser.AccountComId
                                                            ).FirstOrDefault();
                    if (sales != null)
                    {
                        txtFCode.Text     = sales.FCode;
                        tbxFCustomer.Text = sales.FName;
                        txtFAddress.Text  = sales.FAddress;
                        txtFPhone.Text    = sales.FPhone;
                        txtFLinkman.Text  = sales.FLinkman;
                    }

                    var data = SqlService.Where(string.Format(@"SELECT * FROM dbo.vm_SalesDetails WHERE FCateId =2000 AND keyId='{0}' and FCompanyId={1}", tbxFSalesNum.Text, 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 LHLeaseDetails();

                            decimal price = GasHelper.GeCustomerPrice(txtFCode.Text, //
                                                                      table.Rows[i]["FBottleCode"].ToString(), CurrentUser.AccountComId);

                            details.FBottle    = table.Rows[i]["FBottleCode"].ToString();
                            details.FPrice     = price;
                            details.FAmount    = price;
                            details.FBottleQty = Convert.ToInt32(table.Rows[i]["FBottleQty"]);
                            details.FCompanyId = CurrentUser.AccountComId;
                            details.KeyId      = txtKeyId.Text.Trim();

                            //钢瓶
                            details.FCateId = Convert.ToInt32(table.Rows[i]["FCateId"].ToString());
                            //每天租赁费
                            details.FRentDay = 0;
                            //押金
                            details.FAmount = price;

                            //已归还量
                            details.FReturnQty = 0;

                            LeaseDetailsService.AddEntity(details);

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

                            case WebAction.Edit:
                                //记录一下当前新增人操作内容
                                var detailslog = new LHLeaseDetails_Log
                                {
                                    FUpdateBy   = CurrentUser.AccountName,
                                    FUpdateDate = DateTime.Now,
                                    FBottle     = details.FBottle,
                                    FPrice      = price,
                                    FBottleQty  = 1,
                                    FAmount     = price,
                                    KeyId       = txtKeyId.Text.Trim(),
                                    FCompanyId  = CurrentUser.AccountComId,
                                    FStatus     = "新增",
                                };

                                LeaseDetailsLogService.Add(detailslog);

                                break;
                            }
                        }

                        LeaseDetailsService.SaveChanges();

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

                #endregion


                #region 更新合计

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

                //写入
                ModifiedGrid();

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

                #endregion
            }
        }