Пример #1
0
        /// <summary>
        ///     提交编辑
        /// </summary>
        private bool SubmintEdit()
        {
            if (LiquidPlan != null)
            {
                LiquidPlan.CreateBy = ddlFSalesman.SelectedValue;
                LiquidPlan.FDate    = txtFDate.SelectedDate;

                LiquidPlan.FDate4 = FDate4.SelectedDate;

                LiquidPlan.FItemCode = tbxFItemName.SelectedValue;
                LiquidPlan.FItemName = tbxFItemName.SelectedText;

                LiquidPlan.FBill       = tbxFBill.SelectedValue;
                LiquidPlan.FVehicleNum = tbxFVehicleNum.SelectedValue;
                LiquidPlan.FDriver     = GasHelper.GetDropDownListArrayString(tbxFDriver.SelectedItemArray);
                LiquidPlan.FSupercargo = tbxFSupercargo.SelectedValue;
                LiquidPlan.FMargin     = Convert.ToDecimal(tbxFMargin.Text);
                LiquidPlan.FMemo       = txtFMemo.Text;

                //--------------------------------------------
                LiquidPlan.FSupplierCode  = txtFSupplierCode.Text;
                LiquidPlan.FSupplierName  = tbxFSupplier.Text;
                LiquidPlan.FPurchasedDate = txtFPurchasedDate.Text;

                if (!string.IsNullOrEmpty(txtFGross.Text))
                {
                    LiquidPlan.FGross = Convert.ToDecimal(txtFGross.Text);
                }

                if (!string.IsNullOrEmpty(txtFPacked.Text))
                {
                    LiquidPlan.FPacked = Convert.ToDecimal(txtFPacked.Text);
                }

                if (!string.IsNullOrEmpty(tbxFPurchasedPrice.Text))
                {
                    LiquidPlan.FPurchasedPrice = Convert.ToDecimal(tbxFPurchasedPrice.Text);
                }

                if (!string.IsNullOrEmpty(tbxFPurchasedQty.Text))
                {
                    LiquidPlan.FPurchasedQty = Convert.ToDecimal(tbxFPurchasedQty.Text);
                }

                //------------------------------------
                LiquidPlan.FCode1 = tbxFCode1.Text;
                LiquidPlan.FName1 = tbxFName1.Text;
                LiquidPlan.FDate1 = FDate1.SelectedDate;
                LiquidPlan.FTime1 = FTime1.Text;

                if (!string.IsNullOrEmpty(txtFGross1.Text))
                {
                    LiquidPlan.FGross1 = Convert.ToDecimal(txtFGross1.Text);
                }

                if (!string.IsNullOrEmpty(txtFPacked1.Text))
                {
                    LiquidPlan.FPacked1 = Convert.ToDecimal(txtFPacked1.Text);
                }

                if (!string.IsNullOrEmpty(txtFQty1.Text))
                {
                    LiquidPlan.FQty1 = Convert.ToDecimal(txtFQty1.Text);
                }

                if (!string.IsNullOrEmpty(txtFPrice1.Text))
                {
                    LiquidPlan.FPrice1 = Convert.ToDecimal(txtFPrice1.Text);
                }

                //------------------------------------
                LiquidPlan.FCode2 = tbxFCode2.Text;
                LiquidPlan.FName2 = tbxFName2.Text;
                LiquidPlan.FDate2 = FDate2.SelectedDate;
                LiquidPlan.FTime2 = FTime2.Text;
                if (!string.IsNullOrEmpty(txtFGross2.Text))
                {
                    LiquidPlan.FGross2 = Convert.ToDecimal(txtFGross2.Text);
                }

                if (!string.IsNullOrEmpty(txtFPacked2.Text))
                {
                    LiquidPlan.FPacked2 = Convert.ToDecimal(txtFPacked2.Text);
                }

                if (!string.IsNullOrEmpty(txtFQty2.Text))
                {
                    LiquidPlan.FQty2 = Convert.ToDecimal(txtFQty2.Text);
                }

                if (!string.IsNullOrEmpty(txtFPrice2.Text))
                {
                    LiquidPlan.FPrice2 = Convert.ToDecimal(txtFPrice2.Text);
                }

                //------------------------------------
                LiquidPlan.FCode3 = tbxFCode3.Text;
                LiquidPlan.FName3 = tbxFName3.Text;
                LiquidPlan.FDate3 = FDate3.SelectedDate;
                LiquidPlan.FTime3 = FTime3.Text;
                if (!string.IsNullOrEmpty(txtFGross3.Text))
                {
                    LiquidPlan.FGross3 = Convert.ToDecimal(txtFGross3.Text);
                }

                if (!string.IsNullOrEmpty(txtFPacked3.Text))
                {
                    LiquidPlan.FPacked3 = Convert.ToDecimal(txtFPacked3.Text);
                }

                if (!string.IsNullOrEmpty(txtFQty3.Text))
                {
                    LiquidPlan.FQty3 = Convert.ToDecimal(txtFQty3.Text);
                }

                if (!string.IsNullOrEmpty(txtFPrice3.Text))
                {
                    LiquidPlan.FPrice3 = Convert.ToDecimal(txtFPrice3.Text);
                }


                ////////////////////////////////////////////
                if (LiquidRefuel != null)
                {
                    LiquidRefuel.FBeginAddress = txtFBeginAddress.Text;
                    LiquidRefuel.FEndAddress   = txtFEndAddress.Text;

                    if (!string.IsNullOrEmpty(txtFBeginMileage.Text))
                    {
                        LiquidRefuel.FBeginMileage = Convert.ToDecimal(txtFBeginMileage.Text);
                    }

                    if (!string.IsNullOrEmpty(txtFEndMileage.Text))
                    {
                        LiquidRefuel.FEndMileage = Convert.ToDecimal(txtFEndMileage.Text);
                    }

                    if (!string.IsNullOrEmpty(txtFQty.Text))
                    {
                        LiquidRefuel.FQty = Convert.ToDecimal(txtFQty.Text);
                    }

                    if (!string.IsNullOrEmpty(txtFPrice.Text))
                    {
                        LiquidRefuel.FPrice = Convert.ToDecimal(txtFPrice.Text);
                    }

                    if (!string.IsNullOrEmpty(txtFAmount.Text))
                    {
                        LiquidRefuel.FAmount = Convert.ToDecimal(txtFAmount.Text);
                    }

                    if (!string.IsNullOrEmpty(txtFOtherAmount.Text))
                    {
                        LiquidRefuel.FOtherAmount = Convert.ToDecimal(txtFOtherAmount.Text);
                    }

                    LiquidRefuelService.SaveChanges();
                }

                if (!string.IsNullOrEmpty(txtFMileage.Text))
                {
                    LiquidPlan.FMileage = Convert.ToDecimal(txtFMileage.Text);
                }

                LiquidPlan.FAmt  = LiquidPlan.FPurchasedQty * LiquidPlan.FPurchasedPrice;
                LiquidPlan.FAmt1 = LiquidPlan.FPrice1 * LiquidPlan.FQty1;
                LiquidPlan.FAmt2 = LiquidPlan.FPrice2 * LiquidPlan.FQty2;
                LiquidPlan.FAmt3 = LiquidPlan.FPrice3 * LiquidPlan.FQty3;

                ////余量
                //LiquidPlan.FMarginEnd = Convert.ToDecimal(tbxFMargin.Text) + Convert.ToDecimal(tbxFPurchasedQty.Text) //
                //                        - Convert.ToDecimal(txtFQty1.Text) - Convert.ToDecimal(txtFQty2.Text) -
                //                        Convert.ToDecimal(txtFQty3.Text);

                LiquidPlanService.SaveChanges();

                var parms = new Dictionary <string, object>();
                parms.Clear();

                parms.Add("@companyId", CurrentUser.AccountComId);
                parms.Add("@keyid", Key);

                SqlService.ExecuteProcedureCommand("proc_LiquidMargin", parms);



                return(true);
            }

            return(false);
        }
Пример #2
0
        /// <summary>
        ///     ModifiedGrid
        /// </summary>
        private void ModifiedGrid()
        {
            //编辑行事件
            var dictModified = Grid1.GetModifiedDict();

            foreach (var rowKey in dictModified.Keys)
            {
                string datakey = Grid1.DataKeys[rowKey][0].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);
                }

                if (sValues.ToString().Contains("-1"))
                {
                    Alert.Show("请输入有效信息!", MessageBoxIcon.Warning);
                    return;
                }

                var details = LiquidPlanService.Where(p => p.KeyId == datakey && p.FCompanyId == CurrentUser.AccountComId).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) && key.Length > 0)
                    {
                        if (details != null)
                        {
                            #region Edit

                            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);
                            }

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


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


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

                            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);
                            }

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

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

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

                            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);
                            }

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

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

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

                            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);
                            }

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

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

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

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


                            #endregion
                        }
                    }

                    #endregion
                }

                LiquidPlanService.SaveChanges();

                var parms = new Dictionary <string, object>();
                parms.Clear();

                parms.Add("@companyId", CurrentUser.AccountComId);
                parms.Add("@keyid", datakey);

                SqlService.ExecuteProcedureCommand("proc_LiquidMargin", parms);
            }
        }