Beispiel #1
0
        private void recordWithPaymentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                string company       = comboBox1.Text;
                string contactperson = textBox2.Text;
                string address       = textBox1.Text;
                Int64  ph            = Int64.Parse(maskedTextBox1.Text);
                string shiptoo       = "";
                try { shiptoo = textBox3.Text; }
                catch { shiptoo = ""; }

                string shipbyy = "";
                try { shipbyy = textBox6.Text; }
                catch { shipbyy = ""; }

                Int64 shipcost = 0;
                try
                { shipcost = Int64.Parse(maskedTextBox2.Text); }
                catch
                { shipcost = 0; }

                string date    = dateTimePicker1.Text;
                Int64  payment = 0;
                try { payment = Int64.Parse(domainUpDown2.Text); }
                catch { payment = 0; }

                string salesperson = "";
                try { salesperson = textBox5.Text; }
                catch { salesperson = ""; }

                string note = "";
                try { note = textBox4.Text; }
                catch { note = ""; }
                double      total  = double.Parse(label9.Text) + shipcost;
                double      paid   = double.Parse(label9.Text);
                double      change = 0;
                string      done   = "true";
                int         idd    = 0;
                ado_project d      = new ado_project();

                d.select_id_Companyname(company, ref idd);
                d.insert_invoice(company, contactperson, address, ph, shiptoo, shipbyy, shipcost, date, date, payment, salesperson, note, total, paid, change, done, idd);

                int use_id = 0;
                d.select_id(company, date, ref use_id);
                for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                {
                    Int64  amount_num   = Int64.Parse(dataGridView1.Rows[i].Cells[0].Value.ToString());
                    int    item         = int.Parse(dataGridView1.Rows[i].Cells[1].Value.ToString());
                    string descriiption = dataGridView1.Rows[i].Cells[2].Value.ToString();
                    Int64  unittprice   = Int64.Parse(dataGridView1.Rows[i].Cells[3].Value.ToString());
                    Int64  ssuptotal    = Int64.Parse(dataGridView1.Rows[i].Cells[4].Value.ToString());

                    //string itemm = "";
                    //d.select_itemmname(item,ref itemm);
                    d.insert_invoice2(amount_num, item, ssuptotal, use_id);

                    Int64 ref_unmber = 0;
                    d.select_itemname(item, ref ref_unmber);
                    Int64 new_num = ref_unmber - amount_num;
                    d.update_numberitem(item, new_num);
                }
                DialogResult dialogResult = MessageBox.Show("Recoding With Payment Done ,Do you Want Print Invoice?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dialogResult == DialogResult.Yes)
                {
                    DataTable2TableAdapter          d2 = new DataTable2TableAdapter();
                    invoiceSet1.DataTable2DataTable dd = new invoiceSet1.DataTable2DataTable();
                    d2.Fill(dd, use_id);
                    testt rpt = new testt();
                    rpt.SetDataSource(dd[0].Table);


                    Report_Viewer vd = new Report_Viewer();

                    vd.crystalReportViewer1.ReportSource = rpt;
                    vd.ShowDialog();
                }
            }
            catch (Exception)
            { MessageBox.Show("Try Again"); }


            textBox3.Text       = "";
            textBox6.Text       = "";
            maskedTextBox1.Text = "";
            textBox4.Text       = "";
            textBox5.Text       = "";
            domainUpDown2.Text  = "";
            label9.Text         = "00.00";
        }
Beispiel #2
0
        private void recordOnlyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                string company       = comboBox1.Text;
                string contactperson = textBox2.Text;
                string address       = textBox1.Text;
                Int64  ph            = Int64.Parse(maskedTextBox1.Text);
                string shiptoo       = "";
                try { shiptoo = textBox3.Text; }
                catch { shiptoo = ""; }

                string shipbyy = "";
                try { shipbyy = textBox6.Text; }
                catch { shipbyy = ""; }

                Int64 shipcost = 0;
                try
                { shipcost = Int64.Parse(maskedTextBox2.Text); }
                catch
                { shipcost = 0; }

                string date    = dateTimePicker1.Text;
                Int64  payment = 0;
                try { payment = Int64.Parse(domainUpDown2.Text); }
                catch { payment = 0; }

                string salesperson = "";
                try { salesperson = textBox5.Text; }
                catch { salesperson = ""; }

                string note = "";
                try { note = textBox4.Text; }
                catch { note = ""; }
                double      total    = double.Parse(label9.Text) + shipcost;
                double      ppaid    = 0;
                double      cchange  = double.Parse(label9.Text);
                string      done     = "false";
                string      date_due = "Not Paid";
                int         idd      = 0;
                ado_project d        = new ado_project();
                d.select_id_Companyname(company, ref idd);

                d.insert_invoice(company, contactperson, address, ph, shiptoo, shipbyy, shipcost, date, date_due, payment, salesperson, note, total, ppaid, cchange, done, idd);

                int use_id = 0;
                d.select_id(company, date, ref use_id);
                for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                {
                    Int64  amount_num   = Int64.Parse(dataGridView1.Rows[i].Cells[0].Value.ToString());
                    int    item         = int.Parse(dataGridView1.Rows[i].Cells[1].Value.ToString());
                    string descriiption = dataGridView1.Rows[i].Cells[2].Value.ToString();
                    Int64  unittprice   = Int64.Parse(dataGridView1.Rows[i].Cells[3].Value.ToString());
                    Int64  ssuptotal    = Int64.Parse(dataGridView1.Rows[i].Cells[4].Value.ToString());

                    //string itemm = "";
                    //d.select_itemmname(item, ref itemm);
                    d.insert_invoice2(amount_num, item, ssuptotal, use_id);

                    Int64 ref_unmber = 0;
                    d.select_itemname(item, ref ref_unmber);
                    Int64 new_num = ref_unmber - amount_num;
                    d.update_numberitem(item, new_num);
                }
                MessageBox.Show("Recording Done");
            }
            catch (Exception)
            { MessageBox.Show("Try Again"); }


            textBox3.Text       = "";
            textBox6.Text       = "";
            maskedTextBox1.Text = "";
            textBox4.Text       = "";
            textBox5.Text       = "";
            domainUpDown2.Text  = "";
            label9.Text         = "00.00";
        }