public void BuildEquipListBase() { if (_helmet == null && helmetD != null) { _helmet = helmetD.gameObject.AddComponent <Helmet>(); } if (_breastplate == null && breastplateD != null) { _breastplate = breastplateD.gameObject.AddComponent <Breastplate>(); } if (_gardebras == null && gardebrasD != null) { _gardebras = gardebrasD.gameObject.AddComponent <Gardebras>(); } if (_legging == null && leggingD != null) { _legging = leggingD.gameObject.AddComponent <Legging>(); } if (_jewelry0 == null && jewelry0D != null) { _jewelry0 = jewelry0D.gameObject.AddComponent <Jewelry>(); } if (_jewelry1 == null && jewelry1D != null) { _jewelry1 = jewelry1D.gameObject.AddComponent <Jewelry>(); } if (_weapon == null && weaponD != null) { _weapon = weaponD.gameObject.AddComponent <SDWeapon>(); } }
public List <Dictionary <string, object> > GetPurchaseByUser(string user) { List <Dictionary <string, object> > jewelries = new List <Dictionary <string, object> >(); ColmanInternetiotContext context = new ColmanInternetiotContext(); // Get list of current account purchases List <Purchase> purchases = context.Purchase.Where(x => x.UserId == Account.GetCurrAccountId(User)).ToList(); foreach (Purchase purchase in purchases) { Dictionary <string, object> dictJewelry = new Dictionary <string, object>(); //Get the jewelry object of the jewelry that bought in this purchase Jewelry jewelry = context.Jewelry.First(x => x.Id == purchase.JewelryId); jewelry.Purchase = null; // Convert from Jewelry object to Dictionary dictJewelry = jewelry.GetType() .GetProperties(BindingFlags.Instance | BindingFlags.Public) .ToDictionary(prop => prop.Name.ToLower(), prop => prop.GetValue(jewelry, null)); // Add a summary attribute dictJewelry.Add("summary", purchase.Amount + " X " + jewelry.Price); jewelries.Add(dictJewelry); } return(jewelries); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync(string[] selectedCategories) { var newJewelry = new Jewelry(); if (selectedCategories != null) { newJewelry.JewelryCategories = new List <JewelryCategory>(); foreach (var cat in selectedCategories) { var catToAdd = new JewelryCategory { CategoryID = int.Parse(cat) }; newJewelry.JewelryCategories.Add(catToAdd); } } if (await TryUpdateModelAsync <Jewelry>( newJewelry, "Jewelry", i => i.Product, i => i.Brand, i => i.Price, i => i.ReleaseDate, i => i.MaterialID)) { _context.Jewelry.Add(newJewelry); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } PopulateAssignedCategoryData(_context, newJewelry); return(Page()); }
// GET: Jewelry/Edit/5 public ActionResult Edit(int id) { Jewelry jewelry = dbContext.Jewelries.First(j => j.JewelryId == id); ViewData["Categories"] = dbContext.Categories.ToList(); return(View(jewelry)); }
public async Task <IActionResult> Edit(int id, [Bind("jID,Image,Name,Cost,InStock,mcID,erID,oID")] Jewelry jewelry) { if (id != jewelry.jID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(jewelry); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!JewelryExists(jewelry.jID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["erID"] = new SelectList(_context.EResins, "erID", "erID", jewelry.erID); ViewData["mcID"] = new SelectList(_context.MComponents, "mcID", "mcID", jewelry.mcID); ViewData["oID"] = new SelectList(_context.OComponents, "oID", "oID", jewelry.oID); return(View(jewelry)); }
public async Task <IActionResult> Create([Bind("Weight,Price,Cart,Size,Description,Amount,Discount,Id,Diamonds,ImagePath,Name,CategoryId,SetId")] Jewelry jewelry) { if (Account.isAdmin(User)) { if (ModelState.IsValid) { _context.Add(jewelry); await _context.SaveChangesAsync(); string postToFacebook = ("התכשיט " + jewelry.Name + " נוסף לחנות. יש " + jewelry.Amount + " פריטים. היכנסו לאתר בשביל לקנות"); FacebookPost post = new FacebookPost(); post.PublishToFacebookNoPhoto(postToFacebook); return(RedirectToAction("Index")); } ViewData["CategoryId"] = new SelectList(_context.Category, "Id", "Name", jewelry.CategoryId); ViewData["SetId"] = new SelectList(_context.JewelrySet, "Id", "Name", jewelry.SetId); return(View(jewelry)); } else { return(new RedirectToActionResult("NotAuthorized", "Home", null)); } }
private void button2_Click(object sender, EventArgs e) { var jewelry = new Jewelry(); jewelry.DateOfDel = textBox2.Text; jewelry.JewType = textBox1.Text; jewelry.MetType = textBox3.Text; jewelry.Description = textBox4.Text; jewelry.DateOfReady = Data5 = dateTimePicker1.Value.ToString("dd/MM/yyyy"); var stream = new MemoryStream(); pictureBox1.Image.Save(stream, ImageFormat.Jpeg); jewelry.Photo = stream.ToArray(); pictureBox1.Image = new Bitmap("D:\\AnyTask\\Jewelry\\ClassField\\2057.jpg"); listBox1.Items.Add(jewelry.JewType); Jew.Add(jewelry); tabControl1.SelectedIndex = 1; textBox2.Text = ""; textBox1.Text = ""; textBox3.Text = ""; textBox4.Text = ""; }
public ActionResult Edit(ProductDetailModel data, FormCollection dat) { JewelryCategory category = new JewelryCategory(); category.Id = Convert.ToInt32(dat["Category"]); JewelryColor color = new JewelryColor(); color.Id = Convert.ToInt32(dat["color"]); JewelryType type = new JewelryType(); type.Id = Convert.ToInt32(dat["Type"]); JewelryImages images = new JewelryImages(); //images.Id = Convert.ToInt32(data.ImageUrl); Jewelry jewelry = new Jewelry { Id = data.Id, Name = data.Name, Description = data.Description, Price = data.Price, Category = new JewelryCategory { Id = category.Id }, Color = new JewelryColor { Id = color.Id }, Type = new JewelryType { Id = type.Id }, }; new JewelryHandler().update(jewelry); return(RedirectToAction("home", "admin")); }
public JewelryReward(Jewelry jewelry) { jewelries = new List <Jewelry> { jewelry }; }
private void GenerateMockData() { var jewelry = new Jewelry(); jewelry.JewelryId = "00000001"; jewelry.JewelryType = "Ring"; jewelry.JewelryQuality = "10k"; jewelry.CrystalWeight = 1.5; jewelry.Weight = 6; jewelry.Description = "Few scratches, slightly used"; var loanTransaction = new LoanTransaction(); loanTransaction.Customer = SelectedCustomer; loanTransaction.JewelryCollateral = jewelry; loanTransaction.TransactionDate = DateTime.UtcNow; SelectedCustomer.LoanTransactions.Add(loanTransaction); var paymentTransaction = new PaymentTransaction(); paymentTransaction.Loan = loanTransaction; paymentTransaction.JewelryCollateral = jewelry; paymentTransaction.PaymentDate = new DateTime(2019, 04, 19); paymentTransaction.PaymentAmount = 1000; loanTransaction.PaymentTransactions.Add(paymentTransaction); double payments = 0; foreach (var p in loanTransaction.PaymentTransactions) { payments = payments + p.PaymentAmount; } loanTransaction.RemainingBalance = loanTransaction.ToBePaid - payments; }
private void EditJewelry(Object parameter) { try { if (SelectedJewelry == string.Empty) { MessageBox.Show("Please choose jewelry."); return; } var editedIndex = JewelryList.FindIndex(x => x.ToString() == SelectedJewelry); Jewelry editedJewelry = JewelryList.Find(x => x.ToString() == SelectedJewelry); if (editedJewelry == null) { MessageBox.Show($"Choose one jewerly from dropdown menu."); return; } editJewelryView.InitJewelryFields(ref editedJewelry); JewelryList.RemoveAt(editedIndex); JewelryListUI.RemoveAt(editedIndex); JewelryList.Add(editedJewelry); JewelryListUI.Add(editedJewelry); CurrentAppScreen = (int)ApplicationScreen.EditJewelry; } catch (Exception ex) { MessageBox.Show($"Could not edit jewerly. Reason: {ex.Message}"); } }
public async Task <IActionResult> Create(JewelryViewModel jewelry) { if (ModelState.IsValid) { string uniqueFileName = UploadedFile(jewelry); Jewelry jewel = new Jewelry() { Title = jewelry.Title, Type = jewelry.Type, Size = jewelry.Size, Price = jewelry.Price, JewelryImage = uniqueFileName, Materials = jewelry.Materials.ToModel(m => new Material { MaterialId = m.MaterialId, Title = m.Title, Category = m.Category }).ToList() }; _context.Add(jewel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Jewelry))); } return(View()); }
private static Jewelry CreateAccessory() { Jewelry accessory = new Jewelry(); // Decide which type of accessory to make. (neck,ring... etc); int selector = Random.Range(0,3); if(selector == 0){ //Neck accessory.Name = "Neck"; accessory.Type = Item.ItemType.Neck; accessory.Slot = JewelrySlot.Necklace; return accessory; }else if(selector == 1){ // Ring accessory.Name = "Ring"; accessory.Type = Item.ItemType.Ring; accessory.Slot = JewelrySlot.Rings; return accessory; }else if(selector == 2){ // Wrist accessory.Name = "Wrist"; accessory.Type = Item.ItemType.Wrist; accessory.Slot = JewelrySlot.Bracelets; return accessory; }else{ accessory.Name = "ACC:"+ Random.Range(0,100); return accessory; } }
public ActionResult DeleteConfirmed(int id) { Jewelry jewelry = db.Jewelries.Find(id); db.Jewelries.Remove(jewelry); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(int id) { Jewelry jewelry = con.Jewelries.Find(id); ProductDetailModel prodct = new ProductDetailModel(); prodct.Name = jewelry.Name; prodct.Price = jewelry.Price; prodct.Category = jewelry.Category.Name; prodct.Color = jewelry.Color.Name; prodct.Description = jewelry.Description; prodct.ImageUrl = (jewelry.Images.Count > 0) ? jewelry.Images.First().Url : null; //ViewBag.edit=prodct; List <SelectListItem> list = ModelHelper.ToSelectItemList(Jhandler.Getcategories()); foreach (SelectListItem i in list) { if (i.Text == prodct.Category) { i.Selected = true; } } List <SelectListItem> list1 = ModelHelper.ToSelectItemList(Jhandler.GetColors()); foreach (SelectListItem item in list1) { if (item.Text == prodct.Color) { item.Selected = true; } } List <SelectListItem> list2 = ModelHelper.ToSelectItemList(Jhandler.GetTypes()); foreach (SelectListItem item in list2) { if (item.Text == prodct.type) { item.Selected = true; } } ViewBag.Category = list; ViewBag.Types = list2; ViewBag.Color = list1; UserModel currentUser = (UserModel)Session[WebUtil.CURRENT_USER]; if (currentUser != null) { User user = new UserHandler().GetUserById(currentUser.Id); if (user.IsInRole(WebUtil.ADMIN_ROLE)) { return(View(prodct)); } } return(RedirectToAction("index", "home")); }
public void Setup() { var list = new List <Material>(); list.Add(new Gemstone("gem", 12, 12, Color.Black)); list.Add(new PremiumMaterial("premMat", 12, 12)); list.Add(new Material("material", 12, 12)); bijouterie = new Bijouterie("1", list, 1); anotherJewelry = new Jewelry("2", list); }
void loadJewelry(ItemManager im, XmlNodeList itemInfoList, XmlNode itemInfo) { if (itemInfo.Attributes["ItemType"].Value == "Jewelry") { Jewelry newJewelry = (Jewelry)ScriptableObject.CreateInstance <Jewelry>(); foreach (XmlNode profileItems in itemInfoList) { if (profileItems.Name == "name") { newJewelry.name = profileItems.InnerText; } else if (profileItems.Name == "description") { newJewelry.description = profileItems.InnerText; } else if (profileItems.Name == "cost") { newJewelry.cost = int.Parse(profileItems.InnerText); } else if (profileItems.Name == "icon") { newJewelry.icon = Resources.Load(profileItems.InnerText) as Texture2D; } else if (profileItems.Name == "volume") { newJewelry.volume = int.Parse(profileItems.InnerText); } else if (profileItems.Name == "weight") { newJewelry.weight = int.Parse(profileItems.InnerText); } else if (profileItems.Name == "id") { newJewelry.id = int.Parse(profileItems.InnerText); } else if (profileItems.Name == "maxDurability") { newJewelry.maxDurability = int.Parse(profileItems.InnerText); } else if (profileItems.Name == "curDurability") { newJewelry.curDurability = int.Parse(profileItems.InnerText); } else if (profileItems.Name == "equipType") { newJewelry.equipType = (EquipTag)System.Enum.Parse(typeof(EquipTag), profileItems.InnerText); } else if (profileItems.Name == "hpBuff") { newJewelry.hpBuff = int.Parse(profileItems.InnerText); } } im.itemList.Add(newJewelry); } }
public ActionResult Edit([Bind(Include = "JewelryId,Title,Price,Description,Color,ImageURL,JewelryTypeId")] Jewelry jewelry) { if (ModelState.IsValid) { db.Entry(jewelry).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.JewelryTypeId = new SelectList(db.JewelryTypes, "JewelryTypeId", "JewelryTypeName", jewelry.JewelryTypeId); return(View(jewelry)); }
public static ProductSummaryModel ToProductSummary(Jewelry jewelry) { return(new ProductSummaryModel { Id = jewelry.Id, Name = jewelry.Name, Price = jewelry.Price, Category = jewelry.Category.Name, ImageUrl = (jewelry.Images.Count > 0) ? jewelry.Images.First().Url : null }); }
public IActionResult OnGet() { ViewData["MaterialID"] = new SelectList(_context.Set <Material>(), "ID", "MaterialType"); var jewelry = new Jewelry(); jewelry.JewelryCategories = new List <JewelryCategory>(); PopulateAssignedCategoryData(_context, jewelry); return(Page()); }
private Jewelry createJewelry() { Jewelry item = new Jewelry(); item.itemName = itemName.Text; item.itemClass = Jewel_Class.Text; item.rarity = Jewel_Rarity.Text; item.value = "need a field for this"; item.isEquipped = "false"; item.imagePath = ""; return(item); }
private void AddLoanTransactionProc() { if (InputCustomerAddress != null && InputCustomerContactNumber != null && InputCustomerName != null && InputJewelryDiscount != null && InputJewelryOtherDetails != null && InputJewelryValue != null && InputJewelryWeight != null && InputLoanValue != null) { Random rnd = new Random(); NewJewelry = new Jewelry(); NewCustomer = new Customer(); NewLoan = new Loan(); NewJewelry.JewelryType = SelectedJewelryType; NewJewelry.JewelryQuality = SelectedJewelryQuality; NewJewelry.JewelryWeight = double.Parse(InputJewelryWeight); NewJewelry.JewelryDiscount = double.Parse(InputJewelryDiscount); NewJewelry.JewelryValue = double.Parse(InputJewelryValue); NewJewelry.JewelryOtherDetails = (InputJewelryOtherDetails); NewJewelry.JewelryID = "J-" + Convert.ToString(rnd.Next(1, 9999)); JewelryList.Add(NewJewelry); NewCustomer.CustomerName = InputCustomerName; NewCustomer.CustomerContactNumber = InputCustomerContactNumber; NewCustomer.CustomerAddress = InputCustomerAddress; NewCustomer.CustomerID = "C-" + Convert.ToString(rnd.Next(1, 9999)); CustomerList.Add(NewCustomer); NewLoan.LoanValue = double.Parse(InputLoanValue); NewLoan.Balance = NewLoan.LoanValue * 1.13; NewLoan.TransactionDate = DateTime.Today; NewLoan.TransactionID = "L-" + Convert.ToString(rnd.Next(1, 9999)); NewLoan.JewelryID = NewJewelry.JewelryID; NewLoan.CustomerID = NewCustomer.CustomerID; ListOfLoans.Add(NewLoan); MessageBox.Show("Transaction submitted!", "Loan Transaction Successful", MessageBoxButton.OK, MessageBoxImage.Information); InputCustomerAddress = null; InputCustomerContactNumber = null; InputCustomerName = null; InputJewelryDiscount = null; InputJewelryOtherDetails = null; InputJewelryValue = null; InputJewelryWeight = null; InputLoanValue = null; } else { MessageBox.Show("Please fill in all details.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public FileContentResult GetImage(int jewelryId) { Jewelry jew = dbContext.Jewelries.FirstOrDefault(j => j.JewelryId == jewelryId); if (jew != null) { return(File(jew.Image, jew.ImageMimeType)); } else { return(null); } }
public async Task <IActionResult> Edit(int id, [Bind("Weight,Price,Cart,Size,Description,Amount,Discount,Id,Diamonds,ImagePath,Name,CategoryId,SetId")] Jewelry jewelry) { if (id != jewelry.Id) { return(NotFound()); } if (Account.isAdmin(User)) { if (ModelState.IsValid) { try { ColmanInternetiotContext newContext = new ColmanInternetiotContext(); int?currAmount = newContext.Jewelry.First(x => x.Id == jewelry.Id).Amount; _context.Update(jewelry); await _context.SaveChangesAsync(); if (currAmount != null) { string postToFacebook = ("לתכשיט " + jewelry.Name + " נוספו " + (jewelry.Amount - int.Parse(currAmount.ToString())) + " פריטים חדשים. היכנסו לאתר בשביל לקנות"); FacebookPost post = new FacebookPost(); post.PublishToFacebookNoPhoto(postToFacebook); } } catch (DbUpdateConcurrencyException) { if (!JewelryExists(jewelry.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } ViewData["CategoryId"] = new SelectList(_context.Category, "Id", "Name", jewelry.CategoryId); ViewData["SetId"] = new SelectList(_context.JewelrySet, "Id", "Name", jewelry.SetId); return(View(jewelry)); } else { return(new RedirectToActionResult("NotAuthorized", "Home", null)); } }
//GET: Earring //public ActionResult Earrings() //{ // Repository.EarringRepository JewelryRepo = new Repository.EarringRepository(); // ModelState.Clear();//model state will create a dic object that will contain state of object. Clear because we do not need it in memory // return View(Earrings()); //} // GET: Jewelries/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Jewelry jewelry = db.Jewelries.Find(id); if (jewelry == null) { return(HttpNotFound()); } return(View(jewelry)); }
private void SetFirstData() { Random rnd = new Random(); Jewelry firstJewelry = new Jewelry(); Customer firstCustomer = new Customer(); Loan firstLoan = new Loan(); Payback firstPayback = new Payback(); firstJewelry.JewelryID = "J-8044"; firstJewelry.JewelryType = JewelryType.Bracelets; firstJewelry.JewelryQuality = JewelryQuality.TwentyOneKarats; firstJewelry.JewelryWeight = 50; firstJewelry.JewelryDiscount = 5; firstJewelry.JewelryValue = rnd.Next(35000, 45000); firstJewelry.JewelryOtherDetails = "Perfectly Fine"; JewelryList.Add(firstJewelry); firstCustomer.CustomerID = "C-" + Convert.ToString(rnd.Next(1, 9999)); firstCustomer.CustomerName = "Emery Huang"; firstCustomer.CustomerContactNumber = "0931 123 1423"; firstCustomer.CustomerAddress = "Suite 3, California Street"; CustomerList.Add(firstCustomer); firstLoan.TransactionID = "L-" + Convert.ToString(rnd.Next(1, 9999)); firstLoan.LoanValue = 40000; firstLoan.Balance = firstLoan.LoanValue * 1.13; firstLoan.TransactionDate = DateTime.Today; firstLoan.JewelryID = firstJewelry.JewelryID; firstLoan.CustomerID = firstCustomer.CustomerID; ListOfLoans.Add(firstLoan); firstPayback.JewelryID = firstLoan.JewelryID; firstPayback.TransactionID = "P-" + Convert.ToString(rnd.Next(1, 9999)); firstPayback.CustomerID = firstLoan.CustomerID; firstPayback.LoanValue = firstLoan.LoanValue; firstPayback.TransactionDate = DateTime.Today; firstPayback.Payment = 4000; firstPayback.FullInterestValue = firstPayback.LoanValue * 1.13; firstPayback.Balance = firstLoan.Balance; firstPayback.Balance = firstPayback.Balance - firstPayback.Payment; ListOfPaybacks.Add(firstPayback); foreach (var loan in ListOfLoans) { if (firstPayback.JewelryID == loan.JewelryID) { loan.Balance = firstPayback.Balance; } } }
public async Task <IActionResult> Create([Bind("jID,Image,Name,Cost,InStock,mcID,erID,oID")] Jewelry jewelry) { if (ModelState.IsValid) { _context.Add(jewelry); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["erID"] = new SelectList(_context.EResins, "erID", "erID", jewelry.erID); ViewData["mcID"] = new SelectList(_context.MComponents, "mcID", "mcID", jewelry.mcID); ViewData["oID"] = new SelectList(_context.OComponents, "oID", "oID", jewelry.oID); return(View(jewelry)); }
public async Task <IActionResult> OnGetAsync(Guid?id) { if (id == null) { return(NotFound()); } Jewelry = await _context.Jewelry.FirstOrDefaultAsync(m => m.Id == id); if (Jewelry == null) { return(NotFound()); } return(Page()); }
private ProductDetailModel ToProductModel(Jewelry m) { return(new ProductDetailModel { Id = m.Id, Name = m.Name, Price = m.Price, Description = m.Description, ImageUrl = (m.Images != null && m.Images.Count() > 0) ? m.Images.First().Url : null, Category = m.Category.Name, Color = m.Color.Name, type = m.Type.Name, // ReleaseDate = (m.ReleaseDate != null) ? m.ReleaseDate.Value.ToString("dd-MM-yyyy") : null }); }
public async void Create([Bind("JewelryId,UserId,Date,Amount,Reference,Id,Country")] Purchase purchase) { if (ModelState.IsValid) { _context.Add(purchase); await _context.SaveChangesAsync(); Jewelry jewelry = _context.Jewelry.First(x => x.Id == purchase.JewelryId); jewelry.Amount -= (int)purchase.Amount; _context.Jewelry.Update(jewelry); await _context.SaveChangesAsync(); } }
// GET: Jewelries/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Jewelry jewelry = db.Jewelries.Find(id); if (jewelry == null) { return(HttpNotFound()); } ViewBag.JewelryTypeId = new SelectList(db.JewelryTypes, "JewelryTypeId", "JewelryTypeName", jewelry.JewelryTypeId); return(View(jewelry)); }
public static Jewelry selectOne(string guid) { try { string sql = "select * from Data where guid = '" + guid + "'"; string dbFile = "first"; Jewelry je = new Jewelry(); using (SQLiteConnection sc1 = new SQLiteConnection(string.Format(SQLiteService.connectionFormat, dbFile))) { SQLiteCommand sCom = new SQLiteCommand(sql, sc1); sc1.Open(); using (SQLiteDataReader dr1 = sCom.ExecuteReader()) { if (dr1.Read()) { je.Guid = dr1["guid"].ToString(); je.Image = helper.Base64ToImage(dr1["image"].ToString()); je.BuyTime = helper.DateToString((DateTime)dr1["buytime"]); je.BuyPrice = (double)dr1["buyprice"]; je.BuyWho = dr1["buywho"].ToString(); je.GoldPrice = (double)dr1["goldprice"]; je.Type = dr1["type"].ToString(); je.Color = dr1["color"].ToString(); je.Mark = dr1["mark"].ToString(); je.BuySource = dr1["buySource"].ToString(); je.OwnWho = dr1["ownwho"].ToString(); je.State = dr1["state"].ToString(); je.BorrowTime = helper.DateToString((DateTime)dr1["borrowtime"]); je.BorrowWho = dr1["borrowwho"].ToString(); je.BorrowPirce = (double)dr1["borrowprice"]; je.BorrowReturnTime = helper.DateToString((DateTime)dr1["borrowreturntime"]); je.SaleTime = helper.DateToString((DateTime)dr1["saletime"]); je.SaleWho = dr1["salewho"].ToString(); je.SalePirce = (double)dr1["saleprice"]; je.SaleState = dr1["salestate"].ToString(); } dr1.Close(); } sc1.Close(); } return je; } catch (Exception ex) { throw ex; } }
public static bool Save(Jewelry je) { try { //定义temp存储影响行数 int temp = 0; //判断是否是新增,如果是新增的话,选择不同的语句,为了createtime的插入或者不插入 bool isnew = false; //先进行判断是否是状态改变,如果是的话,往History表插入一条数据 //string _state = IsExitItem(je.Guid); //if (!string.IsNullOrEmpty(_state) && !(_state.Equals(je.State))) //{ // //往历史表插入一条记录(未完成) //} Jewelry tempJe = selectOne(je.Guid); if (!string.IsNullOrEmpty(tempJe.Guid)) { switch (je.State) { case "未卖": if (!je.State.Equals(tempJe.State)) { InsertIntoHistory(je.Guid, je.State, Convert.ToDateTime(null), "", 0, Convert.ToDateTime(null)); } break; case "卖出": if (!je.State.Equals(tempJe.State) || je.SaleTime != tempJe.SaleTime || je.SaleWho != tempJe.SaleWho || je.SalePirce != tempJe.SalePirce) { InsertIntoHistory(je.Guid, je.State, Convert.ToDateTime(je.SaleTime), je.SaleWho, je.SalePirce, Convert.ToDateTime(null)); } break; case "借出": if (!je.State.Equals(tempJe.State) || je.BorrowTime != tempJe.BorrowTime || je.BorrowWho != tempJe.BorrowWho || je.BorrowPirce != tempJe.BorrowPirce || je.BorrowReturnTime != tempJe.BorrowReturnTime) { InsertIntoHistory(je.Guid, je.State, Convert.ToDateTime(je.BorrowTime), je.BorrowWho, je.BorrowPirce, Convert.ToDateTime(je.BorrowReturnTime)); } break; default: break; } } //第一次新增,数据库查询不到对应的纪录,插入一条未卖的纪录入历史表 else { InsertIntoHistory(je.Guid, je.State, Convert.ToDateTime(null), "", 0, Convert.ToDateTime(null)); isnew = true; } //更新数据,不管是编辑,还是新增 string connectString = string.Format(connectionFormat, "first"); //把图片转换成base64编码 string imageString = helper.ImageToBase64(je.Image); string sqlAll, sql; if (isnew) { sqlAll = "insert into Data (guid,image,buytime,buyprice,buywho,goldprice,type,color,mark,buySource,ownwho,state,borrowtime,borrowwho,borrowprice,borrowreturntime,saletime,salewho,saleprice,salestate,createtime,updatetime) Values('{0}','{1}','{2}',{3},'{4}',{5},'{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}',{14},'{15}','{16}','{17}',{18},'{19}','{20}','{21}')"; sql = string.Format(sqlAll, je.Guid, imageString, Convert.ToDateTime(je.BuyTime).ToString("s"), je.BuyPrice, je.BuyWho, je.GoldPrice, je.Type, je.Color, je.Mark, je.BuySource, je.OwnWho, je.State, Convert.ToDateTime(je.BorrowTime).ToString("s"), je.BorrowWho, je.BorrowPirce, Convert.ToDateTime(je.BorrowReturnTime).ToString("s"), Convert.ToDateTime(je.SaleTime).ToString("s"), je.SaleWho, je.SalePirce, je.SaleState, System.DateTime.Now.ToString("s"), System.DateTime.Now.ToString("s")); } else { sqlAll = "update Data set image = '{0}',buytime = '{1}',buyprice = '{2}',buywho = '{3}',goldprice = {4},type = '{5}',color = '{6}',mark = '{7}',buySource = '{8}',ownwho = '{9}',state = '{10}',borrowtime = '{11}',borrowwho = '{12}',borrowprice = {13},borrowreturntime = '{14}',saletime = '{15}',salewho = '{16}',saleprice = {17},salestate = '{18}',updatetime = '{19}' where guid='{20}'"; sql = string.Format(sqlAll, imageString, Convert.ToDateTime(je.BuyTime).ToString("s"), je.BuyPrice, je.BuyWho, je.GoldPrice, je.Type, je.Color, je.Mark, je.BuySource, je.OwnWho, je.State, Convert.ToDateTime(je.BorrowTime).ToString("s"), je.BorrowWho, je.BorrowPirce, Convert.ToDateTime(je.BorrowReturnTime).ToString("s"), Convert.ToDateTime(je.SaleTime).ToString("s"), je.SaleWho, je.SalePirce, je.SaleState, System.DateTime.Now.ToString("s"), je.Guid); } using (SQLiteConnection sqlcon = new SQLiteConnection(connectString)) { SQLiteCommand cmd = new SQLiteCommand(sql, sqlcon); sqlcon.Open(); temp = cmd.ExecuteNonQuery(); sqlcon.Close(); } //返回更新成功或者失败的标志 if (temp > 0) { return true; } return false; } catch (Exception ex) { throw ex; } }
public static MainOneViewModel LoadDataAsMainOneViewModel(string dbFile, string sql) { try { MainOneViewModel vm = new MainOneViewModel(); vm.OCJ = new ObservableCollection<Jewelry>(); //System.Windows.MessageBox.Show(string.Format(SQLiteService.connectionFormat, dbFile)); using (SQLiteConnection sc1 = new SQLiteConnection(string.Format(SQLiteService.connectionFormat, dbFile))) { SQLiteCommand sCom = new SQLiteCommand(sql, sc1); sc1.Open(); using (SQLiteDataReader dr1 = sCom.ExecuteReader()) { while (dr1.Read()) { Jewelry je = new Jewelry(); je.Guid = dr1["guid"].ToString(); je.Image = helper.Base64ToImage(dr1["image"].ToString()); //je.SaleWho = dr1["buytime"].ToString(); je.BuyTime = helper.DateToString((DateTime)dr1["buytime"]); je.BuyPrice = (double)dr1["buyprice"]; je.BuyWho = dr1["buywho"].ToString(); je.GoldPrice = (double)dr1["goldprice"]; je.Type = dr1["type"].ToString(); je.Color = dr1["color"].ToString(); je.Mark = dr1["mark"].ToString(); je.BuySource = dr1["buySource"].ToString(); je.OwnWho = dr1["ownwho"].ToString(); je.State = dr1["state"].ToString(); je.BorrowTime = helper.DateToString((DateTime)dr1["borrowtime"]); je.BorrowWho = dr1["borrowwho"].ToString(); je.BorrowPirce = (double)dr1["borrowprice"]; je.BorrowReturnTime = helper.DateToString((DateTime)dr1["borrowreturntime"]); je.SaleTime = helper.DateToString((DateTime)dr1["saletime"]); je.SaleWho = dr1["salewho"].ToString(); je.SalePirce = (double)dr1["saleprice"]; je.SaleState = dr1["salestate"].ToString(); je.Ohe = LoadHistory(je.Guid); _totalCount = int.Parse(dr1["TotalCount"].ToString()); vm.OCJ.Add(je); //List<string> l1 = new List<string>(); //DataGroup dg1 = new DataGroup(); //for (int i = 0; i < dr1.FieldCount; i++) //{ // DataItem dm1 = new DataItem() // { // ID = dr1.GetName(i), // ItemType = TransSqliteType(dr1.GetDataTypeName(i)), // Value = Convert.ToString(dr1.GetValue(i)) // }; // dg1.Add(dm1); //} //dt1.Add(dg1); } dr1.Close(); } sc1.Close(); } return vm; } catch (Exception ex) { throw ex; } }
internal static void CreateNew(object sender, ExecutedRoutedEventArgs e) { try { //获取参数,如果为空,就返回 Dictionary<string, object> paraDic = e.Parameter as Dictionary<string, object>; if (paraDic == null) return; //定义参数 string type = ""; //新增哪个页面 string pageID = ""; //导航页面 bool isEdit = false; //是否可以编辑,就是是否出现保存和取消按钮 string title = ""; //页面的标题 //获取对应的参数 if (paraDic.ContainsKey("type")) { type = (string)paraDic["type"]; } if (paraDic.ContainsKey("pageID")) { pageID = (string)paraDic["pageID"]; } if (paraDic.ContainsKey("isEdit")) { isEdit = (bool)paraDic["isEdit"]; } if (paraDic.ContainsKey("title")) { title = (string)paraDic["title"]; } switch (type) { //珠宝增加 case "GoodsType": ObservableCollection<Jewelry> main_ic = paraDic["context1"] as ObservableCollection<Jewelry>; if (main_ic != null) { Jewelry _je = new Jewelry(true); //main_ic.Add(_je); WinDetail wd1 = new WinDetail(_je, isEdit, title); wd1.PageFrame.Navigate(new Uri(Tools.PageTool(pageID), UriKind.RelativeOrAbsolute)); bool? res = wd1.ShowDialog(); if (res.HasValue && res.Value) { } CommonReflashData((FrameworkElement)paraDic["context2"]); } break; //珠宝类别增加 case "JeweleyCategoryType": //珠宝归属人增加 case "JeweleyOwnType": //珠宝颜色增加 case "JeweleyColorType": //上面三个类别都用同一个操作 ObservableCollection<TypeEntity> ObTE = paraDic["context1"] as ObservableCollection<TypeEntity>; if (ObTE != null) { TypeEntity _te = new TypeEntity(true); //main_ic.Add(_je); WinDetail2 wd1 = new WinDetail2(_te, isEdit, title); wd1.PageFrame.Navigate(new Uri(Tools.PageTool(pageID), UriKind.RelativeOrAbsolute)); bool? res = wd1.ShowDialog(); if (res.HasValue && res.Value) { } CommonReflashData((FrameworkElement)paraDic["context2"]); } break; case "": break; default: break; } } catch(Exception ex) { MessageBox.Show(ex.Message); //记录日志,暂未添加 } finally { } }
/// <summary> /// 装备首饰 /// </summary> public void RequestEquipJewelry(Jewelry jewelry) { //请求网络 GameClient.Instance.GetGameSceneManager().gameManager.RequestEquipment(jewelry, 3); }
/// <summary> /// 装备首饰 /// </summary> public void EquipJewelry(Jewelry jewelry) { //本地 //如果两个首饰槽都有装备了。覆盖稀有度小的。稀有度一样则随机覆盖 if (this.equipments.jewelry1 != null && this.equipments.jewelry2 != null) { if (this.equipments.jewelry1.GetCardRarity() != this.equipments.jewelry2.GetCardRarity()) { //替换稀有度低的 if (this.equipments.jewelry1.GetCardRarity() > this.equipments.jewelry2.GetCardRarity()) { this.equipments.jewelry1 = jewelry; GameClient.Instance.GetGameSceneManager().gameManager.RequestEquipment(jewelry, 3); } else { this.equipments.jewelry2 = jewelry; GameClient.Instance.GetGameSceneManager().gameManager.RequestEquipment(jewelry, 4); } } else { //随机替换 if (Random.value < 0.5f) { this.equipments.jewelry1 = jewelry; GameClient.Instance.GetGameSceneManager().gameManager.RequestEquipment(jewelry, 3); } else { this.equipments.jewelry2 = jewelry; GameClient.Instance.GetGameSceneManager().gameManager.RequestEquipment(jewelry, 4); } } } else { if (this.equipments.jewelry1 == null) { this.equipments.jewelry1 = jewelry; GameClient.Instance.GetGameSceneManager().gameManager.RequestEquipment(jewelry, 3); } else if (this.equipments.jewelry2 == null) { this.equipments.jewelry2 = jewelry; GameClient.Instance.GetGameSceneManager().gameManager.RequestEquipment(jewelry, 4); } } }
public static Jewelry xmlPras(string xml) { Jewelry je = new Jewelry(); var root = XElement.Parse(xml); je.Type = root.Element("Type").Value.ToString(); je.State = root.Element("State").Value.ToString(); je.OwnWho = root.Element("OwnWho").Value.ToString(); je.Image = helper.Base64ToImage(root.Element("Image").Value.ToString()); return je; }