public static void SyncProductInStoreTemplate() { var rowVersionList = RpcFacade.Call <IEnumerable <RpcObject> >("/MainSystem/B3Butchery/Rpcs/ProductInStoreRpc/GetRowVersion", SysConfig.Current.AccountingUnit_ID).Select(obj => new Tuple <long, int>(obj.Get <long>("ID"), obj.Get <int>("RowVersion"))).ToList(); var folder = Path.Combine(Util.DataFolder, typeof(ClientProductInStore).Name); BeforeWriteFile(rowVersionList, folder); var templateList = RpcFacade.Call <IEnumerable <RpcObject> >("/MainSystem/B3Butchery/Rpcs/ProductInStoreRpc/GetProductInStoreTemplate", rowVersionList.Select(x => new long?(x.Item1)).ToArray()); foreach (var template in templateList) { var clientBill = new ClientProductInStore(); clientBill.ID = template.Get <long>("ID"); clientBill.Name = template.Get <string>("Name"); clientBill.Department_ID = template.Get <long>("Department_ID"); clientBill.Department_Name = template.Get <string>("Department_Name"); clientBill.InStoreType_ID = template.Get <long?>("InStoreType_ID"); clientBill.InStoreType_Name = template.Get <string>("InStoreType_Name"); var rowVersion = template.Get <int>("RowVersion"); var storeDetailList = template.Get <IList <RpcObject> >("StoreDetails"); foreach (var detail in storeDetailList) { var storeDetail = new ClientProductInStore_StoreDetail(); storeDetail.Store_ID = detail.Get <long>("Store_ID"); storeDetail.Store_Name = detail.Get <string>("Store_Name"); storeDetail.Store_Code = detail.Get <string>("Store_Code"); clientBill.StoreDetails.Add(storeDetail); } var goodsDetailList = template.Get <IList <RpcObject> >("GoodsDetails"); foreach (var detail in goodsDetailList) { var goodsDetail = new ClientProductInStore_GoodsDetail(); goodsDetail.Goods_ID = detail.Get <long>("Goods_ID"); goodsDetail.Goods_Name = detail.Get <string>("Goods_Name"); goodsDetail.Goods_Code = detail.Get <string>("Goods_Code"); goodsDetail.Goods_UnitConvertDirection = string.Format("{0}", detail.Get <object>("Goods_UnitConvertDirection")); goodsDetail.Goods_MainUnitRatio = detail.Get <decimal?>("Goods_MainUnitRatio"); goodsDetail.Goods_SecondUnitRatio = detail.Get <decimal?>("Goods_SecondUnitRatio"); clientBill.GoodsDetails.Add(goodsDetail); } XmlSerializer serializer = new XmlSerializer(typeof(ClientProductInStore)); using (var stream = File.Open(Path.Combine(folder, clientBill.ID + ".xml"), FileMode.Create)) { serializer.Serialize(stream, clientBill); } using (var stream = File.CreateText(Path.Combine(folder, clientBill.ID + ".ver"))) { stream.Write(rowVersion); } } }
private void btn_OK_Click(object sender, EventArgs e) { try { #region //ClientProduceOutputBillSave clientDmo = new ClientProduceOutputBillSave //{ // AccountingUnit_ID = SysConfig.Current.AccountingUnit_ID.Value, // Department_ID = SysConfig.Current.Department_ID ?? 0, // Domain_ID = SysConfig.Current.Domain_ID, // User_ID = SysConfig.Current.User_ID, // CreateTime = DateTime.Now //}; #endregion ClientProductInStore productInStore = new ClientProductInStore { Department_ID = SysConfig.Current.Department_ID ?? 0, InStoreType_ID = 01, }; var clientDetail = new ClientAllGoods(); clientDetail.Goods_ID = mClientGoods.Goods_ID; clientDetail.Goods_Name = mClientGoods.Goods_Name; clientDetail.Goods_Number = decimal.Parse(txtNumber.Text); mSelectList.Add(clientDetail); MessageBox.Show("操作成功"); txtNumber.Text = ""; textBox1.Text = ""; } catch (Exception ex) { MessageBox.Show(ex.Message);; } }
public ProductInStoreDialog(long departMentID, long template) { InitializeComponent(); Util.SetSceen(this); productInStore = new ClientProductInStoreBillSave { AccountingUnit_ID = SysConfig.Current.AccountingUnit_ID.Value, Department_ID = departMentID, Domain_ID = SysConfig.Current.Domain_ID, User_ID = SysConfig.Current.User_ID, CreateTime = DateTime.Today }; comboBoxSelectStore.Items.Add(""); comboBoxSelectGoods.Items.Add(""); comboBoxProductPlan.Items.Add(""); string file = Path.Combine(Path.Combine(Util.DataFolder, typeof(ClientProductInStore).Name), template.ToString() + ".xml"); XmlSerializer serializer = new XmlSerializer(typeof(ClientProductInStore)); using (var stream = File.Open(file, FileMode.Open)) { productInStoreTemplate = serializer.Deserialize(stream) as ClientProductInStore; } productInStore.InStoreType_ID = productInStoreTemplate.InStoreType_ID; productInStore.InStoreType_Name = productInStoreTemplate.InStoreType_Name; foreach (var storeDetail in productInStoreTemplate.StoreDetails) { if (storeDetail.Store_ID != 0) { comboBoxSelectStore.Items.Add(new Option(storeDetail.Store_Name, storeDetail.Store_ID)); } } foreach (var goodsDetail in productInStoreTemplate.GoodsDetails) { if (goodsDetail.Goods_ID != 0) { comboBoxSelectGoods.Items.Add(new Option(goodsDetail.Goods_Name, goodsDetail.Goods_ID)); } if (!goodsInfo.ContainsKey(goodsDetail.Goods_ID)) { goodsInfo.Add(goodsDetail.Goods_ID, new Tuple <string, decimal?, decimal?>(goodsDetail.Goods_UnitConvertDirection, goodsDetail.Goods_MainUnitRatio, goodsDetail.Goods_SecondUnitRatio)); } } var productPlanFolder = Path.Combine(Util.DataFolder, typeof(ClientProductPlan).Name); if (Directory.Exists(productPlanFolder)) { var productPlanFile = Directory.GetFiles(productPlanFolder, "*.xml"); XmlSerializer ppSerializer = new XmlSerializer(typeof(ClientProductPlan)); foreach (var ppFile in productPlanFile) { using (var stream = File.Open(ppFile, FileMode.Open)) { var productPlan = ppSerializer.Deserialize(stream) as ClientProductPlan; comboBoxProductPlan.Items.Add(new Option(productPlan.PlanNumber, productPlan.ID)); } } } comboBoxProductPlan.Focus(); DeviceContext.Current.ScannerReader += new EventHandler <ScanEventArgs>(Device_ScannerReaders); }