/// <summary> /// The next code do : /// make xml file /// <Info> /// <National_ID> /// </National_ID> /// <Name></Name> /// <Phone></Phone> /// <Country></Country> /// <City></City> /// <Address></Address> /// </Info> /// /// </summary> public XmlDocument Return_Xml_info(int ID) { DataClasses1DataContext dc = new DataClasses1DataContext(); var q = from a in dc.GetTable<Customers>() where a.Customer_ID == ID select a; XmlDocument xml_info = null; foreach (var c in q) { var Info = new XElement("Info", new XElement("National_ID", c.National_ID), new XElement("Name", c.Name), new XElement("Phone", c.Phone), new XElement("Country", c.Country), new XElement("City", c.City), new XElement("Address", c.Address)); string str = System.Convert.ToString(Info); xml_info.Load(str); } return xml_info; }
/// <summary> /// The next code do : /// Drag from user balance to the bank balance /// </summary> private int Cancel_Book_Query(int Bank_ID, string Pass, int Cust_ID, decimal Cost) { DataClasses1DataContext dc = new DataClasses1DataContext(); var Bank_Q = (from a in dc.GetTable<Customers>() where a.Customer_ID == Bank_ID && a.Password == Pass select a).First(); var Cust_Q = (from a in dc.GetTable<Customers>() where a.Customer_ID == Cust_ID select a).First(); Bank_Q.Balance -= Cost; if (Cust_Q != null) { Cust_Q.Balance += Cost; return 0; } else return 1; }
/// <summary> /// The next code do : /// Drag from Bank balance to the user balance /// </summary> private int Book_Query(int ID, int Bank_ID, string pass, decimal Trip_cost) { DataClasses1DataContext dc = new DataClasses1DataContext(); var q = (from a in dc.GetTable<Customers>() where a.Customer_ID == ID select a).First(); if (q != null) { if (q.Password == pass) { if (q.Balance >= Trip_cost) { q.Balance -= Trip_cost; var q_Bank = (from a in dc.GetTable<Customers>() where a.Customer_ID == Bank_ID select a).First(); q_Bank.Balance += Trip_cost; return 0; } else return 1; } else return 2; } else return 2; }