public GoodsType() { filedirectory = Properties.Settings.Default.Goods; FileCreate.FileAndDirCreate(FileType.directory, filedirectory); FileCreate.FileAndDirCreate(FileType.File, filedirectory + @"/" + FILENAME); filefullname = filedirectory + @"/" + FILENAME; lgoods = new List <Goods>(); }
public GoodsType(string name, int price) { goods.GoodName = name; goods.GoodPrice = price; filedirectory = Properties.Settings.Default.Goods; FileCreate.FileAndDirCreate(FileType.directory, filedirectory); FileCreate.FileAndDirCreate(FileType.File, filedirectory + @"/" + FILENAME); filefullname = filedirectory + @"/" + FILENAME; lgoods = new List <Goods>(); }
//结算 public void Settlement(DataTable dt, int TotalPrice) { //删除库存 Banlance bl = new Banlance(vinfo); vinfo.Balance -= TotalPrice; bl.ExecAdd(TotalPrice, BanlanceType.消费); vinfo.EditVipUser(vinfo); //写入文件 RecordsConsumption ls = new RecordsConsumption(); ls.VipCard = vinfo.VipCard; ls.Vtype = vinfo.VipType; ls.UserName = vinfo.UserName; ls.PhoneNumber = vinfo.PhoneNumber; ls.Banlance = vinfo.PhoneNumber; ls.ls = new List <ConsumptionInfo>(); ConsumptionInfo cinfo; for (int i = 0; i < dt.Rows.Count; i++) { cinfo = new ConsumptionInfo(); cinfo.Goods = dt.Rows[i]["Goods"].ToString(); cinfo.GoodsNumber = dt.Rows[i]["GoodsNumber"].ToString(); cinfo.TotalPrice = dt.Rows[i]["TotalPrice"].ToString(); cinfo.UnitPrice = dt.Rows[i]["UnitPrice"].ToString(); ls.ls.Add(cinfo); } ls.ConsumptionTime = DateTime.Now.ToLocalTime().ToString(); string filediry = filedir + @"/" + ls.VipCard; string fileurl = filediry + $"/{DateTime.Now.ToString("yyyyMMddhhmmss")}.txt"; FileCreate.FileAndDirCreate(FileType.directory, filediry); //FileCreate.FileAndDirCreate(FileType.File, fileurl); File.WriteAllText(fileurl, JsonConvert.SerializeObject(ls)); }