Пример #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();

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

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

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

                    DataTable table = dataSet.Tables[0];

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

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

                        var details = new LHPassCardDetails
                        {
                            FItemCode     = table.Rows[0]["FItemCode"].ToString(),
                            FPrice        = 0,
                            FQty          = 1,
                            FAmount       = 0,
                            FBottleQty    = 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())
                        };

                        StockOutDetailsService.Add(details);
                    }
                }
            }
            #endregion

            if (addList.Count > 0)
            {
                BindDataGrid();
            }
        }
Пример #2
0
        /// <summary>
        ///     Grid1_RowCommand
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
        {
            if (e.CommandName == "Delete" || e.CommandName == "Add")
            {
                var datakey = Convert.ToInt32(Grid1.DataKeys[e.RowIndex][1]);

                StockOutDetailsService.Delete(p => p.FId == datakey && p.FCompanyId == CurrentUser.AccountComId);

                BindDataGrid();
            }
        }
Пример #3
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            bool isSucceed = false;

            try
            {
                switch (Actions)
                {
                case WebAction.Add:
                    isSucceed = SubmintAdd();
                    break;

                case WebAction.Edit:
                    isSucceed = SubmintEdit();
                    break;
                }

                tmsModel t = new tmsModel();
                try
                {
                    IQueryable <LHDispatchCenter> center = DispatchCenterService.Where(p => p.KeyId == lblKeyId.Text);
                    if (center.Count() > 0)
                    {
                        t.dispatchCenterList = center.ToList();
                    }
                    IQueryable <LHStockOut> iP = new StockOutService().Where(p => p.FDispatchNum == lblKeyId.Text);
                    t.stockOutList        = iP.ToList <LHStockOut>();
                    t.stockOutDetailsList = new List <LHStockOutDetails>();
                    foreach (LHStockOut item in iP)
                    {
                        IQueryable <LHStockOutDetails> li = new StockOutDetailsService().Where(p => p.KeyId == item.KeyId);
                        foreach (LHStockOutDetails outDetails in li)
                        {
                            t.stockOutDetailsList.Add(outDetails);
                        }
                    }
                    IQueryable <LHPassCard> lHPasses = PassCardService.Where(p => p.FDispatchNum == lblKeyId.Text);
                    if (lHPasses != null)
                    {
                        t.passCardList = lHPasses.ToList();
                    }

                    t.passCardDetailsList = new List <LHPassCardDetails>();
                    foreach (LHPassCard item in t.passCardList)
                    {
                        IQueryable <LHPassCardDetails> cardDetails = new PassCardDetailsService().Where(p => p.KeyId == item.KeyId);
                        foreach (LHPassCardDetails details in cardDetails)
                        {
                            t.passCardDetailsList.Add(details);
                        }
                    }

                    IQueryable <LHStockIn> skin = new StockInService().Where(p => p.FDispatchNum == lblKeyId.Text);
                    if (skin != null && skin.Count() > 0)
                    {
                        t.stockInList        = skin.ToList();
                        t.stockInDetailsList = new List <LHStockInDetails>();
                        foreach (LHStockIn item in skin)
                        {
                            IQueryable <LHStockInDetails> inDetails = new StockInDetailsService().Where(p => p.KeyId == item.KeyId);
                            foreach (LHStockInDetails inDetail in inDetails)
                            {
                                t.stockInDetailsList.Add(inDetail);
                            }
                        }
                    }
                    new HttpRequest().httpRequest(t, "open/dbo/dboData");
                }
                catch (Exception)
                {
                }
            }
            catch (DbEntityValidationException ex)
            {
                string msg = string.Empty;
                List <ICollection <DbValidationError> > errors = (from u in ex.EntityValidationErrors select u.ValidationErrors).ToList();
                foreach (ICollection <DbValidationError> item in errors)
                {
                    msg += item.FirstOrDefault().ErrorMessage;
                }
                isSucceed = false;
            }
            finally
            {
                if (isSucceed)
                {
                    PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
                }
                else
                {
                    Alert.Show("提交失败!", MessageBoxIcon.Error);
                }
            }
        }
Пример #4
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 = StockOutDetailsService.Where(p => p.FId == datakey).FirstOrDefault();
                //写入原始,通过存储过程完成明细复制
                var parmsLog = new Dictionary <string, object>();
                parmsLog.Clear();

                parmsLog.Add("@fid", datakey);
                parmsLog.Add("@opr", CurrentUser.AccountName);
                parmsLog.Add("@companyId", CurrentUser.AccountComId);
                SqlService.ExecuteProcedureCommand("proc_StockOutDetails_Log", parmsLog);

                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("FPrice"))
                            {
                                details.FPrice  = Convert.ToDecimal(value);
                                details.FAmount = details.FPrice * details.FQty;
                            }

                            if (key.Equals("FQty"))
                            {
                                details.FQty       = Convert.ToDecimal(value);
                                details.FBottleQty = Convert.ToInt32(details.FQty);
                                details.FAmount    = details.FPrice * details.FQty;
                            }

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

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

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

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

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

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

                            StockOutDetailsLogService.Add(detailslog);
                        }
                    }

                    #endregion
                }

                StockOutDetailsService.SaveChanges();
            }
        }
Пример #5
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)
                {
                    DataSet dataSet = GasHelper.GetSalesItem(firstOrDefault.ToString(), CurrentUser.AccountComId);

                    DataTable table = dataSet.Tables[0];

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

                        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,
                                FCompanyId    = CurrentUser.AccountComId,
                                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;
                        }


                        StockOutDetailsService.Add(details);
                    }
                }
            }

            if (addList.Count > 0)
            {
                BindDataGrid();
            }
        }
Пример #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
            {
                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
            }
        }
Пример #7
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string backouts = context.Request["params"];

            TmsReturnModel         returnModel    = new TmsReturnModel();
            StockOutDetailsService service        = new StockOutDetailsService();
            DispatchCenterService  centerService  = new DispatchCenterService();
            StockInDetailsService  stockInDetails = new StockInDetailsService();

            try
            {
                using (TransactionScope trans = new TransactionScope())
                {
                    tmsModel outs = JsonConvert.DeserializeObject <tmsModel>(backouts);
                    if (outs.stockOutDetailsList != null)
                    {
                        foreach (LHStockOutDetails items in outs.stockOutDetailsList)
                        {
                            LHStockOutDetails details = service.Where(p => p.KeyId == items.KeyId && p.FId == items.FId).FirstOrDefault();

                            if (details != null)
                            {
                                details.FRecycleQty = items.FRecycleQty;
                                details.FReturnQty  = items.FReturnQty;

                                details.FDevice = items.FDevice;

                                details.FDeviceValue = string.IsNullOrEmpty(items.FDeviceValue.ToString()) ? 0 : Convert.ToDecimal(items.FDeviceValue);

                                details.FInTemperature = string.IsNullOrEmpty(items.FInTemperature.ToString()) //
                                    ? 0 : Convert.ToDecimal(items.FInTemperature.ToString());
                                details.FInPressure = string.IsNullOrEmpty(items.FInPressure.ToString())       //
                                    ? 0 : Convert.ToDecimal(items.FInPressure.ToString());

                                details.FOutTemperature = string.IsNullOrEmpty(items.FOutTemperature.ToString()) //
                                    ? 0 : Convert.ToDecimal(items.FOutTemperature.ToString());
                                details.FOutPressure = string.IsNullOrEmpty(items.FOutPressure.ToString())       //
                                    ? 0 : Convert.ToDecimal(items.FOutPressure.ToString());

                                details.FPayTemperature = string.IsNullOrEmpty(items.FPayTemperature.ToString()) //
                                    ? 0 : Convert.ToDecimal(items.FPayTemperature.ToString());
                                details.FPayPressure = string.IsNullOrEmpty(items.FPayPressure.ToString())       //
                                    ? 0 : Convert.ToDecimal(items.FPayPressure.ToString());

                                details.FReceiveTemperature = string.IsNullOrEmpty(items.FReceiveTemperature.ToString()) //
                                                    ? 0 : Convert.ToDecimal(items.FReceiveTemperature.ToString());
                                details.FReceivePressure = string.IsNullOrEmpty(items.FReceivePressure.ToString())       //
                                    ? 0 : Convert.ToDecimal(items.FReceivePressure.ToString());

                                //数量计算
                                LHStockOut StockOut = new StockOutService().Where(p => p.KeyId == items.KeyId).FirstOrDefault();
                                string     FCode    = StockOut.FCode;
                                //计算公式
                                LHTubePrice v1 = new TubePriceService().Where(p => p.FBill == "销售" &&//
                                                                              p.FCode == FCode &&//
                                                                              p.FItemCode == details.FItemCode).FirstOrDefault();

                                if (v1 != null)
                                {
                                    //< font color = "red" >$W1:进厂温度、$W2:出厂温度、$W3: 交付温度、$W4: 接收温度、$V: 水容积 </ font >< br />
                                    //< font color = "red" >$Y1:进厂压力、$Y2:出厂压力、$Y3: 交付压力、$Y4: 接收压力 </ font >< br />

                                    string inW = Convert.ToDecimal(details.FInTemperature).ToString(CultureInfo.InvariantCulture);
                                    string inY = Convert.ToDecimal(details.FInPressure).ToString(CultureInfo.InvariantCulture);

                                    string outW = Convert.ToDecimal(details.FOutTemperature).ToString(CultureInfo.InvariantCulture);
                                    string outY = Convert.ToDecimal(details.FOutPressure).ToString(CultureInfo.InvariantCulture);;

                                    string payW = Convert.ToDecimal(details.FPayTemperature).ToString(CultureInfo.InvariantCulture);
                                    string payY = Convert.ToDecimal(details.FPayPressure).ToString(CultureInfo.InvariantCulture);

                                    string recW = Convert.ToDecimal(details.FReceiveTemperature).ToString(CultureInfo.InvariantCulture);
                                    string recY = Convert.ToDecimal(details.FReceivePressure).ToString(CultureInfo.InvariantCulture);

                                    //水溶积
                                    string v = Convert.ToDecimal(details.FDeviceValue).ToString(CultureInfo.InvariantCulture);

                                    //数量
                                    string s1 = v1.FFormula.Replace("$W1", inW) //
                                                .Replace("$W2", outW)
                                                .Replace("$W3", payW)           //
                                                .Replace("$W4", recW)           //
                                                .Replace("$Y1", inY)            //
                                                .Replace("$Y2", outY)           //
                                                .Replace("$Y3", payY)           //
                                                .Replace("$Y4", recY)           //
                                                .Replace("$V", v);

                                    //数量
                                    details.FQty = Convert.ToDecimal(FormulaCalculator.Eval(s1));
                                    //金额
                                    details.FAmount = details.FQty * details.FPrice;
                                }


                                service.SaveChanges();
                            }
                        }
                    }
                    if (outs.dispatchCenterList != null)
                    {
                        foreach (LHDispatchCenter item in outs.dispatchCenterList)
                        {
                            LHDispatchCenter lH = centerService.Where(p => p.KeyId == item.KeyId & p.FAuditFlag == 0).FirstOrDefault();
                            if (lH != null)
                            {
                                lH.FDriver     = item.FDriver;
                                lH.FSupercargo = item.FSupercargo;
                                lH.FMileage    = item.FMileage;
                            }

                            centerService.SaveChanges();
                        }
                    }
                    trans.Complete();
                }

                returnModel.code = "200";
                returnModel.msg  = "成功";
            }
            catch (Exception ex)
            {
                returnModel.code = "500";
                returnModel.msg  = "失败";
                returnModel.msg  = ex.Message;
            }



            context.Response.Write(JsonConvert.SerializeObject(returnModel));
        }
Пример #8
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 = StockOutDetailsService.Where(p => p.FId == datakey).FirstOrDefault();

                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("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
                }

                StockOutDetailsService.SaveChanges();
            }
        }
Пример #9
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();
        }
Пример #10
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 = StockOutDetailsService.Where(p => p.FId == datakey).FirstOrDefault();

                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("FPrice"))
                            {
                                details.FPrice  = Convert.ToDecimal(value);
                                details.FAmount = details.FPrice * details.FQty;
                            }

                            if (key.Equals("FQty"))
                            {
                                details.FQty       = Convert.ToDecimal(value);
                                details.FBottleQty = Convert.ToInt32(details.FQty);
                                details.FAmount    = details.FPrice * details.FQty;
                            }

                            if (key.Equals("FBottleName"))
                            {
                                details.FBottle = GasHelper.GetBottleCodeByName(value);
                            }

                            if (key.Equals("FRecycleQty"))
                            {
                                details.FRecycleQty = 0;//Convert.ToInt32(value);
                                //写入回空单
                            }

                            if (key.Equals("FBottleQty"))
                            {
                                int result = 0;
                                int.TryParse(value, out result);

                                details.FBottleQty = result;
                            }

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

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

                            if (key.Equals("FName"))
                            {
                                details.FName = value;
                                details.FCode = hfdCode.Text.Trim();
                            }
                        }
                    }

                    #endregion
                }

                StockOutDetailsService.SaveChanges();
            }
        }
Пример #11
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
            }
        }
Пример #12
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)
            {
                #region AddDetails

                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 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,
                                FCompanyId    = CurrentUser.AccountComId,
                                FBottleOweQty = 0,
                                KeyId         = txtKeyId.Text.Trim(),
                                FBottle       = table.Rows[0]["FBottleCode"].ToString(),
                                FStatus       = "新增",
                                FMemo         = string.Format(@"时间:{0} 新增人:{1}", DateTime.Now, CurrentUser.AccountName)
                            };

                            StockOutDetailsLogService.Add(detailslog);

                            break;
                        }


                        StockOutDetailsService.Add(details);
                    }
                }
                #endregion
            }

            ////编辑行事件
            //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 = StockOutDetailsService.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_StockOutDetails_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.FBottleQty = Convert.ToInt32(details.FQty);
            //                        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 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,
            //                    FCompanyId = CurrentUser.AccountComId,
            //                    FStatus = "变更",
            //                    FMemo = string.Format(@"时间:{0} 变更人:{1}", DateTime.Now, CurrentUser.AccountName)
            //                };

            //                StockOutDetailsLogService.Add(detailslog);

            //            }

            //            StockOutDetailsService.SaveChanges();
            //        }
            //    }
            //}

            if (addList.Count > 0)
            {
                BindDataGrid();
            }
        }
Пример #13
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();

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

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

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

                    DataTable table = dataSet.Tables[0];

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

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

                        var details = new LHStockOutDetails
                        {
                            FItemCode     = table.Rows[0]["FItemCode"].ToString(),
                            FPrice        = price,
                            FQty          = 1,
                            FAmount       = price,
                            FBottleQty    = 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 LHStockOutDetails_Log
                            //{
                            //    FUpdateBy = CurrentUser.AccountName,
                            //    FUpdateDate = DateTime.Now,
                            //    FItemCode = table.Rows[0]["FItemCode"].ToString(),
                            //    FPrice = price,
                            //    FQty = 1,
                            //    FAmount = price,
                            //    FBottleQty = 0,
                            //    FCompanyId = CurrentUser.AccountComId,
                            //    FBottleOweQty = 0,
                            //    KeyId = txtKeyId.Text.Trim(),
                            //    FBottle = table.Rows[0]["FBottleCode"].ToString(),
                            //    FStatus = "新增",
                            //    FMemo = string.Format(@"时间:{0} 新增人:{1}", DateTime.Now, CurrentUser.AccountName)
                            //};

                            //StockOutDetailsLogService.Add(detailslog);

                            break;
                        }

                        StockOutDetailsService.Add(details);
                    }
                }
            }
            #endregion

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