private void detele(object sender, RoutedEventArgs e) { if (isNewSupply) { NavigationService.Navigate(new Page()); return; } SupplyView newSupply = null; foreach (var supply in ResourcePage.SupplyList) { if (supply.Id == Int32.Parse(idLabel.Content.ToString())) { newSupply = supply; break; } } MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Da li ste sigurni da zelite da izbrišete ovaj materijal?", "Delete Confirmation", System.Windows.MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { if (_medicalSupplyController.Get(newSupply.Id) != null) { _medicalSupplyController.Remove(newSupply.Convert()); } ResourcePage.SupplyList.Remove(newSupply); System.Windows.MessageBox.Show("Promene uspešno sačuvane"); NavigationService.Navigate(new Page()); return; } }
private void button_Copy_Click(object sender, RoutedEventArgs e) { SupplyView newSupply = new SupplyView(); MedicalSupply medicalSupply = new MedicalSupply(); if (!isNewSupply) { foreach (var supply in ResourcePage.SupplyList) { if (supply.Id == Int32.Parse(idLabel.Content.ToString())) { newSupply = supply; break; } } } else { newSupply.Id = medicalSupply.Id; } if (nameTextBox.Text.Length == 0) { System.Windows.MessageBox.Show("Unesite pravilno ime materijala."); return; } if (!isNewSupply) { ResourcePage.SupplyList.Remove(newSupply); } newSupply.Type = nameTextBox.Text; string s = countTextBox.Text; int x = 0; int ux; if (int.TryParse(s, out ux)) { x = int.Parse(s) % 24; } newSupply.Count = x; medicalSupply = newSupply.Convert(); if (!isNewSupply) { _medicalSupplyController.Update(medicalSupply); } else { _medicalSupplyController.Add(medicalSupply); } ResourcePage.SupplyList.Add(newSupply); System.Windows.MessageBox.Show("Uspešno ste sačuvali informacije."); NavigationService.Navigate(new Page()); }
private void addSupply_Click(object sender, RoutedEventArgs e) { SupplyView supply = new SupplyView(); //SupplyList.Add(supply); var openPage = new SupplyProfilePage(supply, true); frame.Navigate(openPage); }
public SupplyProfilePage(SupplyView supply, bool isPrivate = false) { isNewSupply = isPrivate; _medicalSupplyController = (Application.Current as App).MedicalSupplyController; InitializeComponent(); nameTextBox.Text = supply.Type; if (!isNewSupply) { idLabel.Content = supply.Id; } countTextBox.Text = supply.Count.ToString(); }
// GET: SupplyViews/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SupplyView supplyView = new SupplyView(serviceSupplies.GetSupply(Convert.ToInt32(id))); if (supplyView == null) { return(HttpNotFound()); } return(View(supplyView)); }
public List <SupplyView> GetAll() { var listSupplies = new List <SupplyView>(); // example data var sup1 = new SupplyView() { Name = "Wheelchair" }; var sup2 = new SupplyView() { Name = "Crutch" }; listSupplies.Add(sup1); listSupplies.Add(sup2); return(listSupplies); }
public List <SupplyView> getSupplyFromFile(Stream fileStream) { try { var errorMessage = string.Empty; using (var reader = new StreamReader(fileStream)) { var listSupply = new List <SupplyView>(); newSupplies = new List <NewSuply>(); int good = 0; int all = 0; while (!reader.EndOfStream) { var str = reader.ReadLine(); all++; var stArr = str.Trim().Split(';'); //if (stArr.Length == 5) { try { var newSupply = new NewSuply { providerId = long.Parse(stArr[0]), shopId = long.Parse(stArr[1]), goodId = long.Parse(stArr[2]), count = decimal.Parse(stArr[3].Replace('.', ',')), supplyPriceOne = decimal.Parse(stArr[4].Replace('.', ',')) }; using (var db = new baseDataDataContext()) { var g = db.Goods.First(s => s.id == newSupply.goodId); var sh = db.Shops.First(s => s.id == newSupply.shopId); var pr = db.Providers.First(s => s.id == newSupply.providerId); if (g != null && sh != null && pr != null) { var supply = new SupplyView { adress = sh.adress, goodId = g.id, goodInfo = g.info, goodName = g.name, price = g.price, typeName = g.name, shopId = sh.id, providerId = pr.id, name = pr.name, count = newSupply.count }; good++; listSupply.Add(supply); newSupplies.Add(newSupply); } else { errorMessage += "Один из указанных ИД не определен в базе! Для: " + str + Environment.NewLine; } } } catch (Exception ex) { errorMessage += "Не удалось разобрать строчку \"" + str + "\" " + ex.Message + Environment.NewLine; } } } if (listSupply.Count > 0 && good != all) { if (ErrorEvent != null) { ErrorEvent(this, new MessageEventArgs(errorMessage + "Загружено успешно " + good + " из " + all + " строк транспортного файла.")); } } return(listSupply.Count > 0 ? listSupply : null); } } catch (Exception ex) { if (ErrorEvent != null) { ErrorEvent(this, new MessageEventArgs(ex.Message)); } return(null); } }
private void FormSupplyModify_Load(object sender, EventArgs e) { if (this.mode == FormMode.ALTER && this.supplyID == -1) { throw new Exception("未设置源零件信息"); } Utilities.CreateEditPanel(this.tableLayoutPanelTextBoxes, SupplyViewMetaData.supplykeyNames); TextBox textboxsuppliername = (TextBox)this.Controls.Find("textBoxSupplierName", true)[0]; TextBox textBoxComponentName = (TextBox)this.Controls.Find("textBoxComponentName", true)[0]; TextBox textboxLastUpdateUserUsername = (TextBox)this.Controls.Find("textBoxLastUpdateUserUsername", true)[0]; this.textboxCreateUserUsername = (TextBox)this.Controls.Find("textBoxCreateUserUsername", true)[0]; textboxsuppliername.ReadOnly = true; textboxLastUpdateUserUsername.ReadOnly = true; textboxCreateUserUsername.ReadOnly = true; textBoxComponentName.ReadOnly = true; TextBox textBoxSupplierName = (TextBox)this.Controls.Find("textBoxSupplierName", true)[0]; textBoxSupplierName.BackColor = Color.White; textBoxComponentName.BackColor = Color.White; this.SupplierIDGetter = Utilities.BindTextBoxSelect <FormSelectSupplier, Supplier>(this, "textBoxSupplierName", "Name"); this.ComponenIDGetter = Utilities.BindTextBoxSelect <FormSelectComponen, DataAccess.Component>(this, "textBoxComponentName", "Name"); if (this.mode == FormMode.ALTER) { try { SupplyView supplyView = (from s in this.wmsEntities.SupplyView where s.ID == this.supplyID select s).FirstOrDefault(); Utilities.CopyPropertiesToTextBoxes(supplyView, this); } catch (Exception) { MessageBox.Show("修改失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } } else if (this.mode == FormMode.ADD) { this.Text = "添加供货信息"; try { User user = (from u in wmsEntities.User where u.ID == this.userID select u).FirstOrDefault(); if (user == null) { MessageBox.Show("登录用户不存在,请重新登录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } this.textboxCreateUserUsername.Text = user.Username; //this.textBoxCreateTime.Text = DateTime.Now.ToString(); } catch { MessageBox.Show("加载失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } //this.Controls.Find("textBoxSupplierName", true)[0].Click += textBoxSupplierName_Click; //this.Controls.Find("textBoxComponentName", true)[0].TextChanged += textBoxComponentName_TextChanged; }