• 食蔬宝配送分拣软件V1.0


    食蔬宝配送分拣软件V1.0

             public bool DataBindSalesProducts(string PsnSearch, int Materialid = 0)
            {
                bool returnvalue = false;
                var Weight = string.Empty;
                if (string.IsNullOrWhiteSpace(PsnSearch))
                    return returnvalue;

                #region  特殊扫码功能出现功能            
                if (PsnSearch.Equals("#9999"))
                {
                    //这里是扫描查看注册信息
                    Form frm = null;
                    frm = ApplicationFormMainClient.LoadShowDialogForm("DotNet.WinForm.exe", "DotNet.WinForm.FormRegistryInfo");
                    if (frm.DialogResult == DialogResult.OK)
                    {

                    }
                }
                //注册界面信息
                if (PsnSearch.Equals("#8888"))
                {
                    Form frm = null;
                    frm = ApplicationFormMainClient.LoadShowDialogForm("DotNet.WinForm.exe", "DotNet.WinForm.Formkeygen");
                    if (frm.DialogResult == DialogResult.OK)
                    {
                        // 消息提醒   
                        LoadingUtil.ShowInformationMessage("授权成功", AppMessage.MSG0000);
                    }
                }
                #endregion

                //是否扫码
                bool IsBarCode = false;
                CurrentSalesProductsModel currentSalesProductsModel = new CurrentSalesProductsModel();

                #region 商品信息检验
                //单号是否以0开头的
                if (PsnSearch.StartsWith("0") && PsnSearch.Length > 10)
                {
                    //获得货号
                    var Psn = PsnSearch.Substring(1, PsnSearch.Length - 6);
                    //获得重量
                    Weight = PsnSearch.Substring(PsnSearch.Length - 5);
                    PsnSearch = Psn;
                    IsBarCode = true;
                }

                #region  食蔬宝系统生成的条码          
                //大于16位以上的条码是认为是食蔬宝系统生成的条码
                if (PsnSearch.Length > 16)
                {
                    //条码校验折分 货号 称重重量 单价
                    LabelSampleTicketModel labelSampleTicketModel = new LabelSampleTicketModel();
                    labelSampleTicketModel.BarCode = PsnSearch;//条码
                    //校验条码是否正确
                    string CheckCode = labelSampleTicketModel.GetCheckMD5Encrypt16(PsnSearch);
                    bool Verify = labelSampleTicketModel.VerifyMD5Encrypt16Str(labelSampleTicketModel.BarCode, CheckCode);
                    if (Verify)
                    {
                        StatusMessage = "条码校验成功!";
                        labelSampleTicketModel.PsnCode = labelSampleTicketModel.GetPsnCode();//货号                  
                        labelSampleTicketModel.Qty = labelSampleTicketModel.FormatResultString(2, labelSampleTicketModel.GetBarCodeWeight());//格式化重量  //称重重量
                        labelSampleTicketModel.UnitPrice = labelSampleTicketModel.FormatResultString(3, labelSampleTicketModel.GetBarCodeUnitPrice());//格式化单价

                        //验证一下重量不能小于零 单价不能等于零
                        if (labelSampleTicketModel.Qty <= 0.00m)
                        {
                            WinformUserControl.Forms.FrmTips.ShowTipsSuccess(this.ParentForm, "称重重量不能小于等于零!");
                            returnvalue = false;
                            return returnvalue;
                        }
                        //设置销售模型的重量、单价
                        currentSalesProductsModel.WeighingWeight = labelSampleTicketModel.Qty;//条码标签重量
                        //货号、重量 、单价都有了进行加入到购物车操作
                        //获得离线缓存商品数据                   
                        currentSalesProductsModel.CurrentPartProductInfo = ProductsService.GetPartProductInfoByPsnOfflineCachingData(labelSampleTicketModel.PsnCode);//商品信息
                        //销售单位  离线获取
                        var UnitidName = WorkCollectionContextHelp.GetItemIdByItemName(currentSalesProductsModel.CurrentPartProductInfo.Unitid.ToString());//当前销售单位名称  
                        OS2WeightService.CurrentWeighingmodel.Weighingunit = UnitidName;//称重单位               
                        UCOS2Weight.SetUnitPrice((decimal)labelSampleTicketModel.UnitPrice);//称重单价  这里采用条码的单价 这个称重的时候可以议价后的价格
                        labelSampleTicketModel.UnitName = UnitidName;//称重单位
                        //单击选中商品加入到购物车集合
                        PossClientCartInfo ClientCartInfo = BaseSystemInfoClient.FindSelectedClientCartByMaterialid(currentSalesProductsModel.CurrentPartProductInfo.Pid, currentSalesProductsModel.CurrentPartProductInfo);
                        ClientCartInfo.Qty = labelSampleTicketModel.Qty;//称重重量 采用条码上来的称重重量

                        WorkCollectionContextHelp.SetCurrentSalesProductsModel(currentSalesProductsModel);//设置当前销售商品模型
                        //将选中商品加入到零售商品流水表集合
                        CurrentWorkContext.CurrentMoneyModel = SalesRetailProductsService.ConvertSalesretailProductsDt(CurrentWorkContext.CurrentMoneyModel, currentSalesProductsModel, labelSampleTicketModel);//转换零售商品流水模型
                        //获得当前单号行集合对象的值
                        DataRow CurrentDataRow = BaseBusinessLogic.GetDataRow(CurrentWorkContext.CurrentMoneyModel.CurrentMoneyOperationModel.CurrentSalesretailProductsDt, "Psn", labelSampleTicketModel.PsnCode);
                        if (CurrentDataRow != null)
                        {
                            ClientCartInfo.Discount = ValuesData.TurnToDecimal(CurrentDataRow["Discount"].ToString()); //折扣值
                            ClientCartInfo.Qty = currentSalesProductsModel.WeighingWeight;//称重重量
                            ClientCartInfo.Costprice = ValuesData.TurnToDecimal(CurrentDataRow["Costprice"].ToString()); //原单价
                            ClientCartInfo.CostAmount = ValuesData.TurnToDecimal(CurrentDataRow["CostAmount"].ToString()); //原销售金额
                            ClientCartInfo.Saleprice = ValuesData.TurnToDecimal(CurrentDataRow["Saleprice"].ToString()); //折后销售价                                
                            ClientCartInfo.Saleamount = ValuesData.TurnToDecimal(CurrentDataRow["Saleamount"].ToString()); //现销售单价
                        }
                        //单击选中商品加入到购物车集合
                        AddSelectedSource(ClientCartInfo, ClientCartInfo.Qty);
                        //定位到当前记录
                        BaseSystemInfoClient.SelectionClientCartInfo(ClientCartInfo);
                        //设置购物车当前选中的商品
                        UcSortingLeftListViewCart.SelectedSource = BaseSystemInfoClient.GetCurrentSelectDataSoruce();
                        returnvalue = true;
                        return returnvalue;
                    }
                    StatusMessage = "条码校验失败!";
                    // 消息提醒   
                    LoadingUtil.ShowInformationMessage(StatusMessage, AppMessage.MSG0000);
                    return returnvalue;
                }
                #endregion

                //称重商品这里是称好的商品 (大货单独的电子称)外部电子称接入
                //if (PsnSearch.Length == 18)
                //{
                //    //截取分离商品货号 、总金额、重量
                //    //称重号码规则 前1位是店号 后6位是商品货号 5位是总金额 5位是重量 1位是校验码
                //    //160062000012000231
                //    PsnSearch = TxtPsnSearch.Text.Substring(0, 6);//截取货号
                //    var TotalAmount = TxtPsnSearch.Text.Substring(7, 5);//总金额
                //    var Weight = TxtPsnSearch.Text.Substring(12, 5);//总重量
                //    currentSalesProductsModel.WeighingAmount = decimal.Parse(TotalAmount) / 100;//总金额
                //    currentSalesProductsModel.WeighingWeight = decimal.Parse(Weight) / 1000;//
                //    //ValuesData.TurnToInt(Weight.ToString().Substring()) / 100;//总重量(总数量)
                //}


                //获得是否调用离线操作数据
                if (PosParameterSettingOperation.GetchIsOfflineOperatingData())
                {
                    //启用巴枪扫码功能
                    if (PosParameterSettingOperation.GetGunScanning())
                    {
                        //获得离线缓存商品数据                   
                        currentSalesProductsModel.CurrentPartProductInfo = ProductsService.GetPartProductInfoByPsnOfflineCachingData(PsnSearch);//商品信息
                    }
                    else
                    {

                        //获得离线缓存商品数据                    
                        currentSalesProductsModel.CurrentPartProductInfo = ProductsService.GetPartProductInfoByPidOfflineCachingData(Materialid);//商品信息
                    }

                }
                else
                {
                    //启用巴枪扫码功能
                    if (PosParameterSettingOperation.GetGunScanning())
                    {
                        //获得商品信息
                        currentSalesProductsModel.CurrentPartProductInfo = ProductsService.GetPartProductByPsnInfo(UserInfo, PsnSearch);//商品信息

                    }
                    else
                    {
                        //获得商品信息
                        currentSalesProductsModel.CurrentPartProductInfo = ProductsService.GetPartProductByPidInfo(UserInfo, Materialid);//商品信息
                    }

                }

                //商品信息不存
                if (currentSalesProductsModel.CurrentPartProductInfo == null)
                {
                    WinformUserControl.Forms.FrmTips.ShowTipsSuccess(this.ParentForm, "商品记录未找到!尝试重建基础资料 ");
                    return returnvalue;
                }

                //营业员已下班
                if (BaseSystemInfoClient.GetWorkCollectionContext().SalesclerkInfo == null)
                {
                    returnvalue = false;
                    // 消息提醒   
                    //LoadingUtil.ShowInformationMessage("营业员已下班,请上线营业员进行收银操作!", AppMessage.MSG0000);
                    WinformUserControl.Forms.FrmTips.ShowTipsSuccess(this.ParentForm, "营业员已下班,请上线营业员进行收银操作! ");
                    return returnvalue;
                }


                //检验商品状态             
                if (currentSalesProductsModel.CurrentPartProductInfo.State == 0)
                {
                    returnvalue = false;
                    // 消息提醒   
                    LoadingUtil.ShowInformationMessage("商品不在上架中! 如果想继续做出库操作请在商品资料中设置上架", AppMessage.MSG0000);
                    return returnvalue;
                }

                //启用过期提示
                if (currentSalesProductsModel.CurrentPartProductInfo.Star3 == 1)
                {
                    //DateTime t1 = Convert.ToDateTime(currentSalesProductsModel.CurrentProductsInfo.Productiondate);//生产日期
                    //DateTime t2 = Convert.ToDateTime(DateTime.Now);//生产日期 currentSalesProductsModel.CurrentProductsInfo.Stopbuytime    
                    string str1 = currentSalesProductsModel.CurrentPartProductInfo.Productiondate.ToString();//生产日期
                    string str2 = DateTime.Now.ToString();
                    DateTime d1 = Convert.ToDateTime(str1);
                    DateTime d2 = Convert.ToDateTime(str2);
                    DateTime d3 = Convert.ToDateTime(string.Format("{0}-{1}-{2}", d1.Year, d1.Month, d1.Day));
                    DateTime d4 = Convert.ToDateTime(string.Format("{0}-{1}-{2}", d2.Year, d2.Month, d2.Day));
                    int days = (d4 - d3).Days;
                    currentSalesProductsModel.GuaranteeQuality = days;//保质期(天)
                    if (currentSalesProductsModel.GuaranteeQuality > currentSalesProductsModel.CurrentPartProductInfo.Guaranteequality)
                    {
                        // 消息提醒   
                        LoadingUtil.ShowInformationMessage(string.Format("商品启用了过期提示,超出过期天数 {0}天", currentSalesProductsModel.GuaranteeQuality - currentSalesProductsModel.CurrentPartProductInfo.Guaranteequality), AppMessage.MSG0000);
                    }

                    if (currentSalesProductsModel.GuaranteeQuality <= currentSalesProductsModel.CurrentPartProductInfo.Guaranteequality)
                    {
                        if ((currentSalesProductsModel.CurrentPartProductInfo.Guaranteequality - currentSalesProductsModel.GuaranteeQuality) <= 7)
                        {
                            // 消息提醒   
                            LoadingUtil.ShowInformationMessage(string.Format("商品启用了过期提示,距离过期天数 {0}天 请尽快处理该商品", currentSalesProductsModel.CurrentPartProductInfo.Guaranteequality - currentSalesProductsModel.GuaranteeQuality), AppMessage.MSG0000);
                        }

                    }
                }

                //获得库存信息
                if (PosParameterSettingOperation.GetchIsOfflineOperatingData())
                {
                    currentSalesProductsModel.CurrentProductstocksInfo = ProductsService.GetPartProductstockInfoByPidOfflineCachingData(currentSalesProductsModel.CurrentPartProductInfo.Pid.ToString());
                }
                else
                {
                    currentSalesProductsModel.CurrentProductstocksInfo = ProductstocksService.GetProductstocksInfo(UserInfo, currentSalesProductsModel.CurrentPartProductInfo.Pid.ToString());
                }

                //提示库存信息不完整
                if (currentSalesProductsModel.CurrentProductstocksInfo == null)
                {
                    returnvalue = false;
                    // 消息提醒   
                    LoadingUtil.ShowInformationMessage("库存信息不完整! 新增商品请重新下载一下资料", AppMessage.MSG0000);
                    return returnvalue;
                }

                //检验库存数量
                if (!PosParameterSettingOperation.GetAssstockData())
                {
                    //检验库存数量 负库存不能销售             
                    if (currentSalesProductsModel.CurrentPartProductInfo.Assstock == 1)
                    {
                        if (currentSalesProductsModel.CurrentProductstocksInfo.Stockqty == 0)
                        {
                            returnvalue = false;
                            // 消息提醒   
                            LoadingUtil.ShowInformationMessage("库存数量不足! 如果想继续做出库操作请在商品资料中取消关联库存设置", AppMessage.MSG0000);
                            return returnvalue;
                        }
                    }
                }

                //单个订单总金额超出上限
                if (CurrentWorkContext.CurrentMoneyModel.CurrentMoneyOperationModel.TotalPayCollectedAmount + currentSalesProductsModel.CurrentPartProductInfo.Marketprice >= PosParameterSettingOperation.GetTotalPayAmount())
                {
                    // 消息提醒   
                    LoadingUtil.ShowInformationMessage("单个订单总金额超出上限:" + PosParameterSettingOperation.GetTotalPayAmount(), AppMessage.MSG0000);
                    returnvalue = false;
                    return returnvalue;
                }
                #endregion

                //分拣订单下单模式下 所有商品都按计价方工处理先订单在称重 再进称分拣称重操作
                //分拣出货模式下
                if (!ChShippingmode.Checked)
                {

                    #region 收货模式下              
                    if (ChReceivingMode.Checked)
                    {
                        //计价方式=其他的计价商品(除了称重其他的计价方式商品) 不是称重商品输入数量
                        if (!currentSalesProductsModel.CurrentPartProductInfo.Pricingmethod.Equals(6227))
                        {
                            //这时是转到分拣商品下单去了
                            BaseSystemInfoClient.CurrentSelectDataSoruceCartInfo.Qty = 1;//
                            Form frm = null;
                            object[] Objarray = null;

                            frm = ApplicationFormMainClient.LoadShowDialogForm("DotNet.WinForm.exe", "DotNet.WinForm.FormMicroOrderdialogClient", Objarray);

                            if (frm.DialogResult == DialogResult.OK)
                            {
                                //下面是没有对话框跳出
                                //这里是分拣下单时操作流程
                                //计价方式=其他的计价商品(除了称重其他的计价方式商品)
                                //currentSalesProductsModel.WeighingWeight += 1.00m;//这里是每次的数量
                                currentSalesProductsModel.WeighingWeight = BaseSystemInfoClient.CurrentSelectDataSoruceCartInfo.Qty;
                                //将选中商品加入到零售商品流水表集合
                                CurrentWorkContext.CurrentMoneyModel = SalesRetailProductsService.ConvertSalesretailSortingProductsDt(CurrentWorkContext.CurrentMoneyModel, currentSalesProductsModel, null, null, true);//转换零售商品流水模型

                                WorkCollectionContextHelp.SetCurrentSalesProductsModel(currentSalesProductsModel);//设置当前销售商品模型
                                                                                                                  //设置集合对象的值
                                DataRow CurrentDataRow = BaseBusinessLogic.GetDataRow(CurrentWorkContext.CurrentMoneyModel.CurrentMoneyOperationModel.CurrentSalesretailProductsDt, "Psn", PsnSearch);

                                //单击选中商品加入到购物车集合
                                PossClientCartInfo ClientCartInfo = BaseSystemInfoClient.FindSelectedClientCartByMaterialid(currentSalesProductsModel.CurrentPartProductInfo.Pid, currentSalesProductsModel.CurrentPartProductInfo);
                                {
                                    ClientCartInfo.Qty = currentSalesProductsModel.WeighingWeight;//数量给到购物车界面
                                    ClientCartInfo.Discount = ValuesData.TurnToDecimal(CurrentDataRow["Discount"].ToString()); //折扣值
                                    ClientCartInfo.Saleprice = ValuesData.TurnToDecimal(CurrentDataRow["Saleprice"].ToString()); //折后销售价
                                    ClientCartInfo.Saleamount = ClientCartInfo.Qty * ClientCartInfo.Saleprice; //折后销售价
                                }

                                //加入购物车集合
                                AddSelectedSource(ClientCartInfo, currentSalesProductsModel.WeighingWeight, 3);

                                //定位到当前记录
                                BaseSystemInfoClient.SelectionClientCartInfo(ClientCartInfo);
                                //设置购物车当前选中的商品
                                UcSortingLeftListViewCart.SelectedSource = BaseSystemInfoClient.GetCurrentSelectDataSoruce();
                                returnvalue = true;

                            }
                        }
                        else
                        {
                            //称重商品 //6227 按称重  6225 按数量 6226 按件 6876 按份
                            if (currentSalesProductsModel.CurrentPartProductInfo.Pricingmethod.Equals(6227))
                            {
                                //是否已称重的条码扫码进来的
                                if (IsBarCode)
                                {
                                    string NewWeight = Weight.Insert(2, ".");
                                    currentSalesProductsModel.WeighingWeight = ValuesData.TurnToDecimal(NewWeight);// 总重量
                                    decimal TotalAmount = (decimal)currentSalesProductsModel.CurrentPartProductInfo.Marketprice * currentSalesProductsModel.WeighingWeight;
                                    currentSalesProductsModel.WeighingAmount = Math.Round(TotalAmount, 2);//总金额
                                    WorkCollectionContextHelp.SetCurrentSalesProductsModel(currentSalesProductsModel);//设置

                                    //将选中商品加入到零售商品流水表集合
                                    CurrentWorkContext.CurrentMoneyModel = SalesRetailProductsService.ConvertSalesretailProductsDt(CurrentWorkContext.CurrentMoneyModel, currentSalesProductsModel);//转换零售商品流水模型

                                    //设置集合对象的值
                                    DataRow CurrentDataRow = BaseBusinessLogic.GetDataRow(CurrentWorkContext.CurrentMoneyModel.CurrentMoneyOperationModel.CurrentSalesretailProductsDt, "Psn", PsnSearch);
                                    returnvalue = true;
                                    return returnvalue;
                                }

                                //弹出式称重 称重显示模式 true 是采用主窗体还是弹出式称重
                                if (PosParameterSettingOperation.GetPopupmode())
                                {
                                    //是否使用的是一体机称重 直接获取数据
                                    if (PosParameterSettingOperation.GetCheckIntegratedweighing())
                                    {
                                        //这里是称重的商品跟出称重界面                   
                                        Form frm = null;
                                        object[] Objarray = { currentSalesProductsModel };
                                        WorkCollectionContextHelp.SetCurrentSalesProductsModel(currentSalesProductsModel);//
                                        frm = ApplicationFormMainClient.LoadShowDialogForm("DotNet.WinForm.exe", "DotNet.WinForm.FormProductsWeigh", Objarray);
                                        if (frm.DialogResult == DialogResult.OK)
                                        {
                                            //获得获取当前零售商品流水实体工具模型
                                            currentSalesProductsModel = WorkCollectionContextHelp.GetCurrentSalesProductsModel();
                                            //单击选中商品加入到购物车集合
                                            PossClientCartInfo ClientCartInfo = BaseSystemInfoClient.FindSelectedClientCartByMaterialid(currentSalesProductsModel.CurrentPartProductInfo.Pid, currentSalesProductsModel.CurrentPartProductInfo);
                                            //判断上一次的重量是否当前是一致
                                            returnvalue = BaseSystemInfoClient.FindLastWeight(ClientCartInfo, currentSalesProductsModel.WeighingWeight);
                                            if (returnvalue)
                                            {
                                                WinformUserControl.Forms.FrmTips.ShowTipsSuccess(this.ParentForm, "称重重量未改变!");
                                                returnvalue = false;
                                                return returnvalue;
                                            }
                                            //将选中商品加入到零售商品流水表集合
                                            CurrentWorkContext.CurrentMoneyModel = SalesRetailProductsService.ConvertSalesretailProductsDt(CurrentWorkContext.CurrentMoneyModel, currentSalesProductsModel);//转换零售商品流水模型
                                                                                                                                                                                                            //获得当前单号行集合对象的值
                                            DataRow CurrentDataRow = BaseBusinessLogic.GetDataRow(CurrentWorkContext.CurrentMoneyModel.CurrentMoneyOperationModel.CurrentSalesretailProductsDt, "Psn", PsnSearch);
                                            {
                                                ClientCartInfo.Discount = ValuesData.TurnToDecimal(CurrentDataRow["Discount"].ToString()); //折扣值
                                                ClientCartInfo.Qty = currentSalesProductsModel.WeighingWeight;//称重重量
                                                ClientCartInfo.Costprice = ValuesData.TurnToDecimal(CurrentDataRow["Costprice"].ToString()); //原单价
                                                ClientCartInfo.CostAmount = ValuesData.TurnToDecimal(CurrentDataRow["CostAmount"].ToString()); //原销售金额
                                                ClientCartInfo.Saleprice = ValuesData.TurnToDecimal(CurrentDataRow["Saleprice"].ToString()); //折后销售价                                
                                                ClientCartInfo.Saleamount = ValuesData.TurnToDecimal(CurrentDataRow["Saleamount"].ToString()); //现销售单价
                                            }
                                            //单击选中商品加入到购物车集合
                                            AddSelectedSource(ClientCartInfo, ClientCartInfo.Qty);
                                            //定位到当前记录
                                            BaseSystemInfoClient.SelectionClientCartInfo(ClientCartInfo);
                                            //设置购物车当前选中的商品
                                            UcSortingLeftListViewCart.SelectedSource = BaseSystemInfoClient.GetCurrentSelectDataSoruce();
                                            returnvalue = true;

                                        }
                                        else
                                        {
                                            returnvalue = false;
                                            return returnvalue;
                                        }
                                    }
                                }

                                //窗体导航称重 称重显示模式 false 是采用主窗体
                                if (!PosParameterSettingOperation.GetPopupmode())
                                {
                                    //是否使用的是一体机称重 直接获取数据
                                    if (PosParameterSettingOperation.GetCheckIntegratedweighing())
                                    {
                                        //销售单位  离线获取
                                        var UnitidName = WorkCollectionContextHelp.GetItemIdByItemName(currentSalesProductsModel.CurrentPartProductInfo.Unitid.ToString());//当前销售单位名称  
                                        OS2WeightService.CurrentWeighingmodel.Weighingunit = UnitidName;//称重单位
                                        if (!OS2WeightService.CurrentWeighingmodel.IsGetWeight)
                                        {
                                            WinformUserControl.Forms.FrmTips.ShowTipsSuccess(this.ParentForm, "称重重量不稳定! ");
                                            returnvalue = false;
                                            return returnvalue;
                                        }
                                        UCOS2Weight.SetUnitPrice((decimal)currentSalesProductsModel.CurrentPartProductInfo.Marketprice);//称重单价  

                                        CurrentWorkContext.CurrentposParameterSettingData = PosParameterSettingOperation.GetPosParameterSettingData();

                                        if (CurrentWorkContext.CurrentposParameterSettingData != null)
                                        {
                                            //校验值           
                                            decimal Ndifference = CurrentWorkContext.CurrentposParameterSettingData.ElectronicScaleSettings.GetNdifference();//负差值
                                            decimal Pdifference = CurrentWorkContext.CurrentposParameterSettingData.ElectronicScaleSettings.GetPdifference();//正差值

                                            Weighingmodel currentWeighingmodel = OS2WeightService.CurrentWeighingmodel;
                                            //称重单是否公斤与斤
                                            if (currentWeighingmodel.Weighingunit.Contains("斤"))
                                            {
                                                currentSalesProductsModel.WeighingWeight = Math.Round(currentWeighingmodel.TotalWeight * 2, CurrentWorkContext.CurrentposParameterSettingData.NumReservedbits);// 总重量
                                            }
                                            else
                                            {
                                                currentSalesProductsModel.WeighingWeight = currentWeighingmodel.TotalWeight;// 总重量
                                            }
                                            decimal Jin = currentWeighingmodel.ShiJin;
                                            if (Jin <= 0.00m)
                                            {
                                                WinformUserControl.Forms.FrmTips.ShowTipsSuccess(this.ParentForm, "称重重量不能小于等于零!");
                                                returnvalue = false;
                                                return returnvalue;
                                            }

                                            //单击选中商品加入到购物车集合
                                            PossClientCartInfo ClientCartInfo = BaseSystemInfoClient.FindSelectedClientCartByMaterialid(currentSalesProductsModel.CurrentPartProductInfo.Pid, currentSalesProductsModel.CurrentPartProductInfo);

                                            ClientCartInfo.Qty = currentSalesProductsModel.WeighingWeight;//称重重量
                                                                                                          //判断上一次的重量是否当前是一致
                                            returnvalue = BaseSystemInfoClient.FindLastWeight(ClientCartInfo, currentSalesProductsModel.WeighingWeight);
                                            if (returnvalue)
                                            {
                                                WinformUserControl.Forms.FrmTips.ShowTipsSuccess(this.ParentForm, "称重重量未改变!");
                                                returnvalue = false;
                                                return returnvalue;
                                            }
                                            var TotalAmount = Math.Round(currentWeighingmodel.Totalamount, CurrentWorkContext.CurrentposParameterSettingData.NumReservedbits);//总金额
                                            currentSalesProductsModel.WeighingAmount = TotalAmount;//总金额

                                            WorkCollectionContextHelp.SetCurrentSalesProductsModel(currentSalesProductsModel);//设置当前销售商品模型

                                            //将选中商品加入到零售商品流水表集合
                                            CurrentWorkContext.CurrentMoneyModel = SalesRetailProductsService.ConvertSalesretailProductsDt(CurrentWorkContext.CurrentMoneyModel, currentSalesProductsModel);//转换零售商品流水模型

                                            //获得当前单号行集合对象的值
                                            DataRow CurrentDataRow = BaseBusinessLogic.GetDataRow(CurrentWorkContext.CurrentMoneyModel.CurrentMoneyOperationModel.CurrentSalesretailProductsDt, "Psn", PsnSearch);

                                            {
                                                ClientCartInfo.Discount = ValuesData.TurnToDecimal(CurrentDataRow["Discount"].ToString()); //折扣值
                                                ClientCartInfo.Qty = currentSalesProductsModel.WeighingWeight;//称重重量
                                                ClientCartInfo.Costprice = ValuesData.TurnToDecimal(CurrentDataRow["Costprice"].ToString()); //原单价
                                                ClientCartInfo.CostAmount = ValuesData.TurnToDecimal(CurrentDataRow["CostAmount"].ToString()); //原销售金额
                                                ClientCartInfo.Saleprice = ValuesData.TurnToDecimal(CurrentDataRow["Saleprice"].ToString()); //折后销售价                                
                                                ClientCartInfo.Saleamount = ValuesData.TurnToDecimal(CurrentDataRow["Saleamount"].ToString()); //现销售单价
                                            }

                                            //单击选中商品加入到购物车集合
                                            AddSelectedSource(ClientCartInfo, ClientCartInfo.Qty);
                                            //定位到当前记录
                                            BaseSystemInfoClient.SelectionClientCartInfo(ClientCartInfo);
                                            //设置购物车当前选中的商品
                                            UcSortingLeftListViewCart.SelectedSource = BaseSystemInfoClient.GetCurrentSelectDataSoruce();
                                            returnvalue = true;
                                        }
                                    }
                                }

                                //外接设备称重
                                if (PosParameterSettingOperation.GetExternalWeighing())
                                {
                                    //这里显示外接是那一家厂商的
                                    string ManufacturerName = PosParameterSettingOperation.GetManufacturerName();
                                    if (ManufacturerName.Equals("大华"))
                                    {

                                        //将选中商品加入到零售商品流水表集合
                                        CurrentWorkContext.CurrentMoneyModel = SalesRetailProductsService.ConvertSalesretailProductsDt(CurrentWorkContext.CurrentMoneyModel, currentSalesProductsModel);//转换零售商品流水模型

                                        //设置集合对象的值
                                        DataRow CurrentDataRow = BaseBusinessLogic.GetDataRow(CurrentWorkContext.CurrentMoneyModel.CurrentMoneyOperationModel.CurrentSalesretailProductsDt, "Psn", PsnSearch);

                                        if (TxtPsnSearch.Text.Length != 18)
                                        {
                                            returnvalue = false;
                                            // 消息提醒   
                                            LoadingUtil.ShowInformationMessage("称重商品称重条码未能识别!", AppMessage.MSG0000);
                                            return returnvalue;
                                        }
                                    }
                                }

                                //验证称重重量不能大于多少
                                if (currentSalesProductsModel.WeighingWeight >= 30.00m)
                                {
                                    // 消息提醒   
                                    LoadingUtil.ShowInformationMessage("称重数量大于上限要求", AppMessage.MSG0000);
                                    return returnvalue;
                                }


                            }
                        }
                        //WinformUserControl.Forms.FrmTips.ShowTipsSuccess(this.ParentForm, "进入收货模式下!");
                        return returnvalue;
                    }
                    #endregion

                    //称重商品 //6227 按称重  6225 按数量 6226 按件 6876 按份
                    if (currentSalesProductsModel.CurrentPartProductInfo.Pricingmethod.Equals(6227))
                    {
                        //是否已称重的条码扫码进来的
                        if (IsBarCode)
                        {
                            string NewWeight = Weight.Insert(2, ".");
                            currentSalesProductsModel.WeighingWeight = ValuesData.TurnToDecimal(NewWeight);// 总重量
                            decimal TotalAmount = (decimal)currentSalesProductsModel.CurrentPartProductInfo.Marketprice * currentSalesProductsModel.WeighingWeight;
                            currentSalesProductsModel.WeighingAmount = Math.Round(TotalAmount, 2);//总金额
                            WorkCollectionContextHelp.SetCurrentSalesProductsModel(currentSalesProductsModel);//设置

                            //将选中商品加入到零售商品流水表集合
                            CurrentWorkContext.CurrentMoneyModel = SalesRetailProductsService.ConvertSalesretailProductsDt(CurrentWorkContext.CurrentMoneyModel, currentSalesProductsModel);//转换零售商品流水模型

                            //设置集合对象的值
                            DataRow CurrentDataRow = BaseBusinessLogic.GetDataRow(CurrentWorkContext.CurrentMoneyModel.CurrentMoneyOperationModel.CurrentSalesretailProductsDt, "Psn", PsnSearch);
                            returnvalue = true;
                            return returnvalue;
                        }

                        //弹出式称重 称重显示模式 true 是采用主窗体还是弹出式称重
                        if (PosParameterSettingOperation.GetPopupmode())
                        {
                            //是否使用的是一体机称重 直接获取数据
                            if (PosParameterSettingOperation.GetCheckIntegratedweighing())
                            {
                                //这里是称重的商品跟出称重界面                   
                                Form frm = null;
                                object[] Objarray = { currentSalesProductsModel };
                                WorkCollectionContextHelp.SetCurrentSalesProductsModel(currentSalesProductsModel);//
                                frm = ApplicationFormMainClient.LoadShowDialogForm("DotNet.WinForm.exe", "DotNet.WinForm.FormProductsWeigh", Objarray);
                                if (frm.DialogResult == DialogResult.OK)
                                {
                                    //获得获取当前零售商品流水实体工具模型
                                    currentSalesProductsModel = WorkCollectionContextHelp.GetCurrentSalesProductsModel();
                                    //单击选中商品加入到购物车集合
                                    PossClientCartInfo ClientCartInfo = BaseSystemInfoClient.FindSelectedClientCartByMaterialid(currentSalesProductsModel.CurrentPartProductInfo.Pid, currentSalesProductsModel.CurrentPartProductInfo);
                                    //判断上一次的重量是否当前是一致
                                    returnvalue = BaseSystemInfoClient.FindLastWeight(ClientCartInfo, currentSalesProductsModel.WeighingWeight);
                                    if (returnvalue)
                                    {
                                        WinformUserControl.Forms.FrmTips.ShowTipsSuccess(this.ParentForm, "称重重量未改变!");
                                        returnvalue = false;
                                        return returnvalue;
                                    }
                                    //将选中商品加入到零售商品流水表集合
                                    CurrentWorkContext.CurrentMoneyModel = SalesRetailProductsService.ConvertSalesretailProductsDt(CurrentWorkContext.CurrentMoneyModel, currentSalesProductsModel);//转换零售商品流水模型
                                                                                                                                                                                                    //获得当前单号行集合对象的值
                                    DataRow CurrentDataRow = BaseBusinessLogic.GetDataRow(CurrentWorkContext.CurrentMoneyModel.CurrentMoneyOperationModel.CurrentSalesretailProductsDt, "Psn", PsnSearch);
                                    {
                                        ClientCartInfo.Discount = ValuesData.TurnToDecimal(CurrentDataRow["Discount"].ToString()); //折扣值
                                        ClientCartInfo.Qty = currentSalesProductsModel.WeighingWeight;//称重重量
                                        ClientCartInfo.Costprice = ValuesData.TurnToDecimal(CurrentDataRow["Costprice"].ToString()); //原单价
                                        ClientCartInfo.CostAmount = ValuesData.TurnToDecimal(CurrentDataRow["CostAmount"].ToString()); //原销售金额
                                        ClientCartInfo.Saleprice = ValuesData.TurnToDecimal(CurrentDataRow["Saleprice"].ToString()); //折后销售价                                
                                        ClientCartInfo.Saleamount = ValuesData.TurnToDecimal(CurrentDataRow["Saleamount"].ToString()); //现销售单价
                                    }
                                    //单击选中商品加入到购物车集合
                                    AddSelectedSource(ClientCartInfo, ClientCartInfo.Qty);
                                    //定位到当前记录
                                    BaseSystemInfoClient.SelectionClientCartInfo(ClientCartInfo);
                                    //设置购物车当前选中的商品
                                    UcSortingLeftListViewCart.SelectedSource = BaseSystemInfoClient.GetCurrentSelectDataSoruce();
                                    returnvalue = true;

                                }
                                else
                                {
                                    returnvalue = false;
                                    return returnvalue;
                                }
                            }
                        }

                        //窗体导航称重 称重显示模式 false 是采用主窗体
                        if (!PosParameterSettingOperation.GetPopupmode())
                        {
                            //是否使用的是一体机称重 直接获取数据
                            if (PosParameterSettingOperation.GetCheckIntegratedweighing())
                            {
                                //销售单位  离线获取
                                var UnitidName = WorkCollectionContextHelp.GetItemIdByItemName(currentSalesProductsModel.CurrentPartProductInfo.Unitid.ToString());//当前销售单位名称  
                                OS2WeightService.CurrentWeighingmodel.Weighingunit = UnitidName;//称重单位
                                if (!OS2WeightService.CurrentWeighingmodel.IsGetWeight)
                                {
                                    WinformUserControl.Forms.FrmTips.ShowTipsSuccess(this.ParentForm, "称重重量不稳定! ");
                                    returnvalue = false;
                                    return returnvalue;
                                }
                                UCOS2Weight.SetUnitPrice((decimal)currentSalesProductsModel.CurrentPartProductInfo.Marketprice);//称重单价  

                                CurrentWorkContext.CurrentposParameterSettingData = PosParameterSettingOperation.GetPosParameterSettingData();

                                if (CurrentWorkContext.CurrentposParameterSettingData != null)
                                {
                                    //校验值           
                                    decimal Ndifference = CurrentWorkContext.CurrentposParameterSettingData.ElectronicScaleSettings.GetNdifference();//负差值
                                    decimal Pdifference = CurrentWorkContext.CurrentposParameterSettingData.ElectronicScaleSettings.GetPdifference();//正差值

                                    Weighingmodel currentWeighingmodel = OS2WeightService.CurrentWeighingmodel;
                                    //称重单是否公斤与斤
                                    if (currentWeighingmodel.Weighingunit.Contains("斤"))
                                    {
                                        currentSalesProductsModel.WeighingWeight = Math.Round(currentWeighingmodel.TotalWeight * 2, CurrentWorkContext.CurrentposParameterSettingData.NumReservedbits);// 总重量
                                    }
                                    else
                                    {
                                        currentSalesProductsModel.WeighingWeight = currentWeighingmodel.TotalWeight;// 总重量
                                    }
                                    decimal Jin = currentWeighingmodel.ShiJin;
                                    if (Jin <= 0.00m)
                                    {
                                        WinformUserControl.Forms.FrmTips.ShowTipsSuccess(this.ParentForm, "称重重量不能小于等于零!");
                                        returnvalue = false;
                                        return returnvalue;
                                    }

                                    //单击选中商品加入到购物车集合
                                    PossClientCartInfo ClientCartInfo = BaseSystemInfoClient.FindSelectedClientCartByMaterialid(currentSalesProductsModel.CurrentPartProductInfo.Pid, currentSalesProductsModel.CurrentPartProductInfo);

                                    ClientCartInfo.Qty = currentSalesProductsModel.WeighingWeight;//称重重量
                                                                                                  //判断上一次的重量是否当前是一致
                                    returnvalue = BaseSystemInfoClient.FindLastWeight(ClientCartInfo, currentSalesProductsModel.WeighingWeight);
                                    if (returnvalue)
                                    {
                                        WinformUserControl.Forms.FrmTips.ShowTipsSuccess(this.ParentForm, "称重重量未改变!");
                                        returnvalue = false;
                                        return returnvalue;
                                    }
                                    var TotalAmount = Math.Round(currentWeighingmodel.Totalamount, CurrentWorkContext.CurrentposParameterSettingData.NumReservedbits);//总金额
                                    currentSalesProductsModel.WeighingAmount = TotalAmount;//总金额

                                    WorkCollectionContextHelp.SetCurrentSalesProductsModel(currentSalesProductsModel);//设置当前销售商品模型

                                    //将选中商品加入到零售商品流水表集合
                                    CurrentWorkContext.CurrentMoneyModel = SalesRetailProductsService.ConvertSalesretailProductsDt(CurrentWorkContext.CurrentMoneyModel, currentSalesProductsModel);//转换零售商品流水模型

                                    //获得当前单号行集合对象的值
                                    DataRow CurrentDataRow = BaseBusinessLogic.GetDataRow(CurrentWorkContext.CurrentMoneyModel.CurrentMoneyOperationModel.CurrentSalesretailProductsDt, "Psn", PsnSearch);

                                    {
                                        ClientCartInfo.Discount = ValuesData.TurnToDecimal(CurrentDataRow["Discount"].ToString()); //折扣值
                                        ClientCartInfo.Qty = currentSalesProductsModel.WeighingWeight;//称重重量
                                        ClientCartInfo.Costprice = ValuesData.TurnToDecimal(CurrentDataRow["Costprice"].ToString()); //原单价
                                        ClientCartInfo.CostAmount = ValuesData.TurnToDecimal(CurrentDataRow["CostAmount"].ToString()); //原销售金额
                                        ClientCartInfo.Saleprice = ValuesData.TurnToDecimal(CurrentDataRow["Saleprice"].ToString()); //折后销售价                                
                                        ClientCartInfo.Saleamount = ValuesData.TurnToDecimal(CurrentDataRow["Saleamount"].ToString()); //现销售单价
                                    }

                                    //单击选中商品加入到购物车集合
                                    AddSelectedSource(ClientCartInfo, ClientCartInfo.Qty);
                                    //定位到当前记录
                                    BaseSystemInfoClient.SelectionClientCartInfo(ClientCartInfo);
                                    //设置购物车当前选中的商品
                                    UcSortingLeftListViewCart.SelectedSource = BaseSystemInfoClient.GetCurrentSelectDataSoruce();
                                    returnvalue = true;
                                }
                            }
                        }

                        //外接设备称重
                        if (PosParameterSettingOperation.GetExternalWeighing())
                        {
                            //这里显示外接是那一家厂商的
                            string ManufacturerName = PosParameterSettingOperation.GetManufacturerName();
                            if (ManufacturerName.Equals("大华"))
                            {

                                //将选中商品加入到零售商品流水表集合
                                CurrentWorkContext.CurrentMoneyModel = SalesRetailProductsService.ConvertSalesretailProductsDt(CurrentWorkContext.CurrentMoneyModel, currentSalesProductsModel);//转换零售商品流水模型

                                //设置集合对象的值
                                DataRow CurrentDataRow = BaseBusinessLogic.GetDataRow(CurrentWorkContext.CurrentMoneyModel.CurrentMoneyOperationModel.CurrentSalesretailProductsDt, "Psn", PsnSearch);

                                if (TxtPsnSearch.Text.Length != 18)
                                {
                                    returnvalue = false;
                                    // 消息提醒   
                                    LoadingUtil.ShowInformationMessage("称重商品称重条码未能识别!", AppMessage.MSG0000);
                                    return returnvalue;
                                }
                            }
                        }

                        //验证称重重量不能大于多少
                        if (currentSalesProductsModel.WeighingWeight >= 30.00m)
                        {
                            // 消息提醒   
                            LoadingUtil.ShowInformationMessage("称重数量大于上限要求", AppMessage.MSG0000);
                            return returnvalue;
                        }


                    }


                    //计价方式=其他的计价商品(除了称重其他的计价方式商品)
                    if (!currentSalesProductsModel.CurrentPartProductInfo.Pricingmethod.Equals(6227))
                    {
                        WorkCollectionContextHelp.SetCurrentSalesProductsModel(currentSalesProductsModel);//设置当前销售商品模型

                        //将选中商品加入到零售商品流水表集合
                        CurrentWorkContext.CurrentMoneyModel = SalesRetailProductsService.ConvertSalesretailProductsDt(CurrentWorkContext.CurrentMoneyModel, currentSalesProductsModel);//转换零售商品流水模型

                        //设置集合对象的值
                        DataRow CurrentDataRow = BaseBusinessLogic.GetDataRow(CurrentWorkContext.CurrentMoneyModel.CurrentMoneyOperationModel.CurrentSalesretailProductsDt, "Psn", PsnSearch);

                        //单击选中商品加入到购物车集合
                        PossClientCartInfo ClientCartInfo = BaseSystemInfoClient.FindSelectedClientCartByMaterialid(currentSalesProductsModel.CurrentPartProductInfo.Pid, currentSalesProductsModel.CurrentPartProductInfo);

                        {
                            ClientCartInfo.Discount = ValuesData.TurnToDecimal(CurrentDataRow["Discount"].ToString()); //折扣值
                            ClientCartInfo.Saleprice = ValuesData.TurnToDecimal(CurrentDataRow["Saleprice"].ToString()); //折后销售价
                        }
                        //加入购物车集合
                        AddSelectedSource(ClientCartInfo);
                        //定位到当前记录
                        BaseSystemInfoClient.SelectionClientCartInfo(ClientCartInfo);
                        //设置购物车当前选中的商品
                        UcSortingLeftListViewCart.SelectedSource = BaseSystemInfoClient.GetCurrentSelectDataSoruce();
                        returnvalue = true;
                    }

                    //开启客户屏数据显示
                    if (PosParameterSettingOperation.GetchShowOrderdata())
                    {
                        FormExtendedDisplay formExtendedDisplay = (FormExtendedDisplay)BaseSystemInfoClient.Exfrm;
                        if (formExtendedDisplay != null)
                        {
                            formExtendedDisplay.GetList();
                        }
                    }
                }
                else
                {
                    //这时是转到分拣商品下单去了
                    BaseSystemInfoClient.CurrentSelectDataSoruceCartInfo.Qty = 1;//
                    Form frm = null;
                    object[] Objarray = null;
                    frm = ApplicationFormMainClient.LoadShowDialogForm("DotNet.WinForm.exe", "DotNet.WinForm.FormMicroOrderdialogClient", Objarray);
                    if (frm.DialogResult == DialogResult.OK)
                    {
                        //下面是没有对话框跳出
                        //这里是分拣下单时操作流程
                        //计价方式=其他的计价商品(除了称重其他的计价方式商品)
                        currentSalesProductsModel.WeighingWeight = BaseSystemInfoClient.CurrentSelectDataSoruceCartInfo.Qty;

                        //将选中商品加入到零售商品流水表集合
                        CurrentWorkContext.CurrentMoneyModel = SalesRetailProductsService.ConvertSalesretailSortingProductsDt(CurrentWorkContext.CurrentMoneyModel, currentSalesProductsModel, null, null, true);//转换零售商品流水模型

                        WorkCollectionContextHelp.SetCurrentSalesProductsModel(currentSalesProductsModel);//设置当前销售商品模型
                        //设置集合对象的值
                        DataRow CurrentDataRow = BaseBusinessLogic.GetDataRow(CurrentWorkContext.CurrentMoneyModel.CurrentMoneyOperationModel.CurrentSalesretailProductsDt, "Psn", PsnSearch);


                        //单击选中商品加入到购物车集合
                        PossClientCartInfo ClientCartInfo = BaseSystemInfoClient.FindSelectedClientCartByMaterialid(currentSalesProductsModel.CurrentPartProductInfo.Pid, currentSalesProductsModel.CurrentPartProductInfo);
                        {
                            BaseBusinessLogic.SetProperty(CurrentWorkContext.CurrentMoneyModel.CurrentMoneyOperationModel.CurrentSalesretailProductsDt, "Psn", CurrentDataRow["Psn"].ToString(), "Saleprice", BaseSystemInfoClient.CurrentSelectDataSoruceCartInfo.Saleprice);//销售单价
                            BaseBusinessLogic.SetProperty(CurrentWorkContext.CurrentMoneyModel.CurrentMoneyOperationModel.CurrentSalesretailProductsDt, "Psn", CurrentDataRow["Psn"].ToString(), "Saleamount", BaseSystemInfoClient.CurrentSelectDataSoruceCartInfo.Saleamount);//销售总金额                        
                            ClientCartInfo.Qty = currentSalesProductsModel.WeighingWeight;//数量给到购物车界面
                            ClientCartInfo.Discount = ValuesData.TurnToDecimal(CurrentDataRow["Discount"].ToString()); //折扣值
                            ClientCartInfo.Saleprice = ValuesData.TurnToDecimal(CurrentDataRow["Saleprice"].ToString()); //折后销售价

                            ClientCartInfo.Saleamount = ClientCartInfo.Qty * ClientCartInfo.Saleprice; //折后销售价
                        }

                        //加入购物车集合
                        AddSelectedSource(ClientCartInfo, currentSalesProductsModel.WeighingWeight, 3);

                        //定位到当前记录
                        BaseSystemInfoClient.SelectionClientCartInfo(ClientCartInfo);
                        //设置购物车当前选中的商品
                        UcSortingLeftListViewCart.SelectedSource = BaseSystemInfoClient.GetCurrentSelectDataSoruce();
                        returnvalue = true;

                    }
                }
                //设置控件状态
                SetControlState();
                return returnvalue;
            }

     单机版免使用 下载安装可使用

    下载地址:http://sdkjt.kjtcn.net/CrossBorderKcy/Downloadlist/downloadSortingSoftwareSetup

    加我QQ :183840232,手机:15557148372,微信号:15557148372

  • 相关阅读:
    CPU和GPU实现julia
    基于SURF特征的图像与视频拼接技术的研究和实现(一)
    验证码识别--type7
    机器视觉项目基础框架
    实现gabor filter的滤波
    神经网络研究项目--以工程师的视角
    集装箱项目
    基于海康监控的图像识别设计
    反人脸识别的思路和实现
    单向信息传输系统设计实现
  • 原文地址:https://www.cnblogs.com/kuangood2018/p/15674532.html
Copyright © 2020-2023  润新知