private void toolStripMenuItem1_Click(object sender, EventArgs e) { PrentaR prentaH = new PrentaR(); hr_dags g_dags = new hr_dags(); g_dags.Foreldri1 = this; string dags1 = ""; string dags2 = ""; string kennitala = ""; if (g_dags.ShowDialog() == DialogResult.OK) { dags1 = g_dags.dagur1; dags2 = g_dags.dagur2; kennitala = g_dags.kennitala; } else { g_dags.Close(); return; } g_dags.Close(); prentaH.prentaHreyfingar(dags1, dags2, kennitala); }
private void button2_Click(object sender, EventArgs e) { try { XmlTextWriter XmlReiknWriter = null; MySqlConnection connection = new MySqlConnection(MetSala.MyConString); MySqlCommand command = connection.CreateCommand(); MySqlDataReader Reader; connection.Open(); command.CommandText = "SELECT id FROM reikningar ORDER BY id DESC"; Reader = command.ExecuteReader(); Reader.Read(); //Bara að sækja númerið Reader.Close(); command.CommandText = "UPDATE reikningar SET kredit='1' WHERE id = '" + comboBox2.Text + "'"; command.ExecuteNonQuery(); int r_num = 0; try { r_num = Reader.GetInt32(0) + 1; } catch { r_num = 100000; } connection.Close(); XmlReiknWriter = new XmlTextWriter("reikn.xml", System.Text.Encoding.UTF8); XmlReiknWriter.Formatting = Formatting.Indented; //XmlReiknWriter.WriteStartDocument(true); //XmlReiknWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='iso-8859-1'"); XmlReiknWriter.WriteStartElement("Reikningar"); XmlReiknWriter.WriteStartElement("Reikningur", null); XmlReiknWriter.WriteElementString("Dags", null, n_reiknd); XmlReiknWriter.WriteElementString("Nafn", null, comboBox1.SelectedItem.ToString()); XmlReiknWriter.WriteElementString("Vidskm", null, vidsknr[comboBox1.SelectedIndex]); XmlReiknWriter.WriteElementString("Kt", null, vidskkt[comboBox1.SelectedIndex]); XmlReiknWriter.WriteElementString("Heimili", null, n_heimili); XmlReiknWriter.WriteElementString("Postnr", null, n_pnr.ToString()); XmlReiknWriter.WriteElementString("Postst", null, n_stadur); XmlReiknWriter.WriteElementString("Texti1", null, rhaus1.Text); XmlReiknWriter.WriteElementString("Texti2", null, rhaus2.Text); XmlReiknWriter.WriteElementString("Numer", null, r_num.ToString()); for (int i = 0; i < (dataGridView1.Rows.Count); i++) { if (dataGridView1.Rows[i].Cells[0].Value == null) { break; } XmlReiknWriter.WriteElementString("Item", (string)dataGridView1[0, i].Value); XmlReiknWriter.WriteElementString("Lysing", (string)dataGridView1[1, i].Value); XmlReiknWriter.WriteElementString("Magn", "-" + (double)dataGridView1[3, i].Value); XmlReiknWriter.WriteElementString("Lafsl", dataGridView1[4, i].Value.ToString()); XmlReiknWriter.WriteElementString("Verd", "-" + string.Format("{0:0,0}", dataGridView1[2, i].Value)); XmlReiknWriter.WriteElementString("Lsamt", "-" + string.Format("{0:0,0}", dataGridView1[5, i].Value)); XmlReiknWriter.WriteElementString("VFl", lina_vskf[i]); } XmlReiknWriter.WriteElementString("solumadur", solumadur.Text); XmlReiknWriter.WriteElementString("Samtals", "-" + tmvsk.Text); XmlReiknWriter.WriteElementString("Vsk1", "-" + t1vsk.Text); XmlReiknWriter.WriteElementString("Vsk2", "-" + t2vsk.Text); XmlReiknWriter.WriteElementString("Sanvsk", "-" + tsamtals.Text); XmlReiknWriter.WriteElementString("Safsl", textafsl.Text); if (Convert.ToDouble(tmvsk.Text) < 0) { XmlReiknWriter.WriteElementString("Frumrit", "Frumrit KREDIT"); } else { XmlReiknWriter.WriteElementString("Frumrit", "Frumrit"); } XmlReiknWriter.WriteEndElement(); //Lokið við haus XmlReiknWriter.WriteEndElement(); //Write the XML to file and close the writer XmlReiknWriter.Flush(); XmlReiknWriter.Close(); if (XmlReiknWriter != null) { XmlReiknWriter.Close(); } //Klára reikning færa í DB og setja inn númer á reikningi if (Convert.ToDouble(tsamtals.Text) < 0) { MessageBox.Show("Ekki er hægt að kreditfæra reikning"); } else { skrifa(r_num); PrentaR Prentreik = new PrentaR(); Prentreik.prenta(2); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void button1_Click(object sender, EventArgs e) { try { XmlTextWriter XmlReiknWriter = null; //Bara að sækja númerið XmlReiknWriter = new XmlTextWriter("reikn.xml", System.Text.Encoding.UTF8); XmlReiknWriter.Formatting = Formatting.Indented; //XmlReiknWriter.WriteStartDocument(true); //XmlReiknWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='iso-8859-1'"); XmlReiknWriter.WriteStartElement("Reikningar"); XmlReiknWriter.WriteStartElement("Reikningur", null); XmlReiknWriter.WriteElementString("Dags", null, n_reiknd); XmlReiknWriter.WriteElementString("Nafn", null, comboBox1.SelectedItem.ToString()); XmlReiknWriter.WriteElementString("Vidskm", null, vidsknr[comboBox1.SelectedIndex]); XmlReiknWriter.WriteElementString("Kt", null, vidskkt[comboBox1.SelectedIndex]); XmlReiknWriter.WriteElementString("Heimili", null, n_heimili); XmlReiknWriter.WriteElementString("Postnr", null, n_pnr.ToString()); XmlReiknWriter.WriteElementString("Postst", null, n_stadur); XmlReiknWriter.WriteElementString("Texti1", null, rhaus1.Text); XmlReiknWriter.WriteElementString("Texti2", null, rhaus2.Text); XmlReiknWriter.WriteElementString("Numer", null, comboBox2.Text); for (int i = 0; i < (dataGridView1.Rows.Count); i++) { if (dataGridView1.Rows[i].Cells[0].Value == null) { break; } XmlReiknWriter.WriteElementString("Item", (string)dataGridView1[0, i].Value); XmlReiknWriter.WriteElementString("Lysing", (string)dataGridView1[1, i].Value); XmlReiknWriter.WriteElementString("Magn", dataGridView1[3, i].Value.ToString()); XmlReiknWriter.WriteElementString("Lafsl", dataGridView1[4, i].Value.ToString()); XmlReiknWriter.WriteElementString("Verd", string.Format("{0:0,0}", dataGridView1[2, i].Value)); XmlReiknWriter.WriteElementString("Lsamt", string.Format("{0:0,0}", dataGridView1[5, i].Value)); XmlReiknWriter.WriteElementString("VFl", lina_vskf[i]); } XmlReiknWriter.WriteElementString("solumadur", null, solumadur.Text); XmlReiknWriter.WriteElementString("Samtals", tmvsk.Text); XmlReiknWriter.WriteElementString("Vsk1", t1vsk.Text); XmlReiknWriter.WriteElementString("Vsk2", t2vsk.Text); XmlReiknWriter.WriteElementString("Sanvsk", tsamtals.Text); XmlReiknWriter.WriteElementString("Safsl", textafsl.Text); XmlReiknWriter.WriteElementString("Frumrit", "Afrit"); XmlReiknWriter.WriteEndElement(); //Lokið við haus XmlReiknWriter.WriteEndElement(); //Write the XML to file and close the writer XmlReiknWriter.Flush(); XmlReiknWriter.Close(); if (XmlReiknWriter != null) { XmlReiknWriter.Close(); } //Klára reikning færa í DB og setja inn númer á reikningi //Kalla á prenta reikning PrentaR Prentreik = new PrentaR(); // 1 afrit 0 frumrit og 2 kredit Prentreik.prenta(1); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
void xmlreik() { try { XmlTextWriter XmlReiknWriter = null; MySqlConnection connection = new MySqlConnection(MetSala.MyConString); MySqlCommand command = connection.CreateCommand(); MySqlDataReader Reader; connection.Open(); command.CommandText = "SELECT id FROM reikningar ORDER BY id DESC"; Reader = command.ExecuteReader(); Reader.Read(); //Bara að sækja númerið Reader.Close(); int r_num = 0; try { r_num = Reader.GetInt32(0) + 1; } catch { r_num = 100000; } connection.Close(); XmlReiknWriter = new XmlTextWriter("reikn.xml", System.Text.Encoding.UTF8); XmlReiknWriter.Formatting = Formatting.Indented; XmlReiknWriter.WriteStartElement("Reikningar"); XmlReiknWriter.WriteStartElement("Reikningur", null); XmlReiknWriter.WriteElementString("Dags", null, rdags.Text); XmlReiknWriter.WriteElementString("Nafn", null, comboBox1.SelectedItem.ToString()); XmlReiknWriter.WriteElementString("Vidskm", null, comboBox2.SelectedItem.ToString()); XmlReiknWriter.WriteElementString("Kt", null, kennitala.Text); XmlReiknWriter.WriteElementString("Heimili", null, heimili.Text); XmlReiknWriter.WriteElementString("Postnr", null, pnr.Text); XmlReiknWriter.WriteElementString("Postst", null, stadur.Text); XmlReiknWriter.WriteElementString("Texti1", null, rhaus1.Text); XmlReiknWriter.WriteElementString("Texti2", null, rhaus2.Text); XmlReiknWriter.WriteElementString("Numer", null, r_num.ToString()); for (int i = 0; i < (dataGridView1.Rows.Count); i++) { if (dataGridView1.Rows[i].Cells[0].Value == null) { break; } XmlReiknWriter.WriteElementString("Item", (string)dataGridView1[0, i].Value); XmlReiknWriter.WriteElementString("Lysing", (string)dataGridView1[1, i].Value); XmlReiknWriter.WriteElementString("Magn", (string)dataGridView1[3, i].Value); XmlReiknWriter.WriteElementString("Lafsl", dataGridView1[4, i].Value.ToString()); XmlReiknWriter.WriteElementString("Verd", string.Format("{0:0,0}", dataGridView1[2, i].Value)); XmlReiknWriter.WriteElementString("Lsamt", string.Format("{0:0,0}", dataGridView1[5, i].Value)); XmlReiknWriter.WriteElementString("VFl", lina_vskf[i]); } XmlReiknWriter.WriteElementString("solumadur", null, solumadur.Text); XmlReiknWriter.WriteElementString("Samtals", tmvsk.Text); XmlReiknWriter.WriteElementString("Vsk1", t1vsk.Text); XmlReiknWriter.WriteElementString("Vsk2", t2vsk.Text); XmlReiknWriter.WriteElementString("Sanvsk", tsamtals.Text); XmlReiknWriter.WriteElementString("Safsl", textafsl.Text); XmlReiknWriter.WriteElementString("Frumrit", "Frumrit"); XmlReiknWriter.WriteEndElement(); //Lokið við haus XmlReiknWriter.WriteEndElement(); //Write the XML to file and close the writer XmlReiknWriter.Flush(); XmlReiknWriter.Close(); if (XmlReiknWriter != null) { XmlReiknWriter.Close(); } //Klára reikning færa í DB og setja inn númer á reikningi if (t1vsk.Text.Equals("")) { MessageBox.Show("Ekki hægt að gera 0 reikning"); } else { skrifa(r_num); PrentaR Prentreik = new PrentaR(); Prentreik.prenta(0); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void prentaAllaSamningaToolStripMenuItem_Click(object sender, EventArgs e) { PrentaR prentaH = new PrentaR(); prentaH.prentasamninga(); }