private void DelButton_Click(object sender, EventArgs e) { bool a = true; Zayavka Z = zayavki.findByID(tek); Zayavka next = zayavki.Next(tek); if (next.ID == tek) // Он последний { next = zayavki.Prev(tek); if (next.ID == tek) // Он был вообще один { tek = 1; groupBox1.Text = "Заявка №" + 1; ClientBox.Text = ""; CostBox.Text = ""; TimeBox.Text = ""; DateTimeBox.Value = DateTime.Today; Check(); a = false; DelButton.Enabled = false; } } zayavki.DelZayavka(Z); zayavki.SaveZayavki(); if (a) { ShowData(next); } }
public Form2(Form main) { this.main = main; InitializeComponent(); opers = new Opers(); clients = new Clients(); zayavki = new Zayavki(clients, opers); tek = zayavki.getMax(); Zayavka Z = zayavki.findByID(tek); FillComboBoxes(); this.ShowData(Z); this.Check(); }
public List <Zayavka> readZayavki(Clients clients, Opers opers) { List <Zayavka> catalog = new List <Zayavka>(); XmlDocument xDoc = new XmlDocument(); xDoc.Load("../../DataBase.xml"); XmlElement xRoot = xDoc.DocumentElement; // получим корневой элемент foreach (XmlNode xnode in xRoot) // обход всех узлов в корневом элементе { Zayavka temp = new Zayavka(); XmlNode attr = xnode.Attributes.GetNamedItem("ID"); temp.ID = Convert.ToInt32(attr.Value); // обходим все дочерние узлы foreach (XmlNode childnode in xnode.ChildNodes) { if (childnode.Name == "Client") { temp.client = clients.findByID(Convert.ToInt32(childnode.InnerText)); } if (childnode.Name == "OperrationType") { temp.oper = opers.findByID(Convert.ToInt32(childnode.InnerText)); } if (childnode.Name == "Cost") { temp.cost = Convert.ToInt32(childnode.InnerText); } if (childnode.Name == "During") { temp.time = childnode.InnerText; } if (childnode.Name == "Nomenklatura") { temp.nomen = childnode.InnerText; } if (childnode.Name == "Date") { temp.date = childnode.InnerText; } } catalog.Add(temp); } return(catalog); }
private void EditButton_Click(object sender, EventArgs e) { if (tek >= zayavki.getMax()) { Client a = clients.findByFIO(ClientBox.Text); if (a == null) { Client C = new Client(); C.FIO = ClientBox.Text; C.ID = clients.getMax() + 1; clients.AddClient(C); clients.SaveClients(); } } int O; if (HimButton.Checked == true) { O = 1; } else { O = 2; } Zayavka Z = new Zayavka(tek, ClientBox.Text, O, CostBox.Text, TimeBox.Text, Convert.ToString(DateTimeBox.Value), clients, opers); if (Z.ID <= zayavki.getMax()) { zayavki.findByID(Z.ID).client = Z.client; zayavki.findByID(Z.ID).oper = Z.oper; zayavki.findByID(Z.ID).cost = Z.cost; zayavki.findByID(Z.ID).time = Z.time; zayavki.findByID(Z.ID).date = Z.date; } else { zayavki.AddZayavka(Z); } zayavki.SaveZayavki(); FillComboBoxes(); Check(); }
private void ShowData(Zayavka Z) { tek = Z.ID; groupBox1.Text = "Заявка №" + Z.ID; ClientBox.Text = Z.client.FIO; if (Z.oper.ID == 1) { HimButton.Checked = true; ObStButton.Checked = false; } else { HimButton.Checked = false; ObStButton.Checked = true; } CostBox.Text = Convert.ToString(Z.cost); TimeBox.Text = Z.time; DateTimeBox.Value = Convert.ToDateTime(Z.date); Check(); }
private void BackButton_Click(object sender, EventArgs e) { Zayavka Z = zayavki.Prev(tek); this.ShowData(Z); }
private void NextButton_Click(object sender, EventArgs e) { Zayavka Z = zayavki.Next(tek); ShowData(Z); }
public void DelZayavka(Zayavka Z) { AllZayavki.Remove(Z); }
public void AddZayavka(Zayavka Z) { AllZayavki.Add(Z); }
public void ReadData() { XmlElement Main = xDoc.DocumentElement;// получим корневой элемент XmlNode xRootC = Main.SelectSingleNode("clients"); foreach (XmlNode xnodeC in xRootC)// обход всех узлов в корневом элементе { Client tempC = new Client(); XmlNode attr = xnodeC.Attributes.GetNamedItem("ID"); tempC.ID = Convert.ToInt32(attr.Value); // обходим все дочерние узлы foreach (XmlNode childnode in xnodeC.ChildNodes) { if (childnode.Name == "FIO") { tempC.FIO = childnode.InnerText; } } C.AddClient(tempC); } XmlNode xRootO = Main.SelectSingleNode("opers"); foreach (XmlNode xnodeO in xRootO)// обход всех узлов в корневом элементе { Oper temp = new Oper(); XmlNode attr = xnodeO.Attributes.GetNamedItem("ID"); temp.ID = Convert.ToInt32(attr.Value); // обходим все дочерние узлы foreach (XmlNode childnode in xnodeO.ChildNodes) { if (childnode.Name == "style") { temp.Style = childnode.InnerText; } } O.AddOper(temp); } XmlNode xRootZ = Main.SelectSingleNode("Zayavki"); foreach (XmlNode xnodeZ in xRootZ) { Zayavka temp = new Zayavka(); XmlNode attr = xnodeZ.Attributes.GetNamedItem("ID"); temp.ID = Convert.ToInt32(attr.Value); // обходим все дочерние узлы foreach (XmlNode childnode in xnodeZ.ChildNodes) { if (childnode.Name == "Client") { temp.client = C.findByID(Convert.ToInt32(childnode.InnerText)); } if (childnode.Name == "OperrationType") { temp.oper = O.findByID(Convert.ToInt32(childnode.InnerText)); } if (childnode.Name == "Cost") { temp.cost = Convert.ToInt32(childnode.InnerText); } if (childnode.Name == "During") { temp.time = childnode.InnerText; } if (childnode.Name == "Nomenklatura") { temp.nomen = childnode.InnerText; } if (childnode.Name == "Date") { temp.date = childnode.InnerText; } } Z.AddZayavka(temp); } }