public static Boolean isValid() { MakerspaceDataDataContext db = new MakerspaceDataDataContext(); User userInQuestion; var data = from User in db.Users where User.Id == App.UID select User; var array= data.ToArray<User>(); userInQuestion= array[0]; string tempUNI=userInQuestion.UNI; string tempUID=userInQuestion.Id; MessageBox.Show(App.UID); MessageBox.Show(tempUID); if ( App.UID.Trim()== tempUID.Trim()) { App.UNI = tempUNI; return true; } else { MessageBox.Show("Wrong ID"); App.appReset(); return false; } }
public ComboBox loadCatalogue(ComboBox data) { MakerspaceDataDataContext db = new MakerspaceDataDataContext(); var query = from e in db.Inventories select e; var listItems=query.ToList(); List<string> ItemIDs=new List<string>(); foreach( var i in listItems){ ItemIDs.Add( i.ItemID); }; ItemIDs.Sort(); data.ItemsSource = ItemIDs; data.SelectedIndex = 0; return data; }
public static void subtractFromInventory(string item,int amtTaken ) { MakerspaceDataDataContext db = new MakerspaceDataDataContext(); var inv = from e in db.Inventories where e.ItemID == item select e; foreach (var i in inv) { i.AmountInStock = i.AmountInStock - amtTaken; MessageBox.Show(i.AmountInStock.ToString()); //=========================================================================== if (i.AmountInStock < 0) { System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(); foreach (string email in adminsEmails) { mail.To.Add(email); }; mail.From = new System.Net.Mail.MailAddress("*****@*****.**"); mail.Subject = "We have run out of " + i.ItemID+" -> this note was auto-generated by the Makerspace app as a TEST"; mail.Body = " last transaction info-> UNI:" + App.UNI + "AmountTaken:" + amtTaken + "Time:" + DateTime.Now; System.Net.Mail.SmtpClient SmtpServer = new System.Net.Mail.SmtpClient(); SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential("jonathanbarrios81", "******"); SmtpServer.EnableSsl = true; SmtpServer.Host = "smtp.gmail.com"; SmtpServer.Send(mail); //client.Send(mail); //================================================================================ }//============= } //-------------------------------------------------------------------------------- //========================================================================================*/ try { //MessageBox.Show("hi"); db.SubmitChanges(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public static Boolean RepeatedUID(string UID) { MakerspaceDataDataContext db = new MakerspaceDataDataContext(); var data = from User in db.Users select User.Id; var list = data.ToList<String>(); if (list.Contains(UID)) { //this must be a repeated UID MessageBox.Show("repeat UID"); return true; } else { return false; } }
public static void recordTran(string item, int amt) { MakerspaceDataDataContext db = new MakerspaceDataDataContext(); Tran trans = new Tran { UNI = App.UNI, amount = amt, ItemName = item, date = DateTime.Now, Id = System.Guid.NewGuid() }; db.Trans.InsertOnSubmit(trans); try { db.SubmitChanges(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }