食蔬宝收银称重软件V1.0
Posted kuangood
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了食蔬宝收银称重软件V1.0相关的知识,希望对你有一定的参考价值。
免费收银称重软件1.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.LoadDialogForm("DotNet.WinForm.exe", "DotNet.WinForm.FormRegistryInfo");
if (frm.DialogResult == DialogResult.OK)
{
}
}
//注册界面信息
if (PsnSearch.Equals("#8888"))
{
Form frm = null;
frm = ApplicationFormMainClient.LoadDialogForm("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;
}
//大于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);
//设置购物车当前选中的商品
UcPosLeftListViewCart.SelectedSource = BaseSystemInfoClient.GetCurrentSelectDataSoruce();
returnvalue = true;
return returnvalue;
}
StatusMessage = "条码校验失败!";
// 消息提醒
LoadingUtil.ShowInformationMessage(StatusMessage, AppMessage.MSG0000);
return returnvalue;
}
//称重商品这里是称好的商品 (大货单独的电子称)外部电子称接入
//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 || currentSalesProductsModel.CurrentPartProductInfo.State == 2)
{
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
//称重商品 //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.LoadDialogForm("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);
//设置购物车当前选中的商品
UcPosLeftListViewCart.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);
//设置购物车当前选中的商品
&n
以上是关于食蔬宝收银称重软件V1.0的主要内容,如果未能解决你的问题,请参考以下文章