Example #1
0
        private void buttonthanhtoan_Click(object sender, EventArgs e)
        {
            string   manv = textBoxmanvban.Text;
            DateTime day  = dateTimePickerban.Value;
            string   a    = textBoxthongtinkh.Lines[0];
            string   b    = textBoxthongtinkh.Lines[1];
            bool     ch   = Int32.TryParse(textBoxthongtinkh.Lines[2], out int c);
            string   d    = textBoxthongtinkh.Lines[3];
            int      tt   = Convert.ToInt32(textBoxtongtienban.Text);
            DTOKH    k    = new DTOKH(a, b, c, d);

            if (a != "" && b != "" && d != "" && ch != false)
            {
                if (kh.Add(k))
                {
                    string     makh = kh.Getmax().ToString();
                    DTOBILLBAN bi   = new DTOBILLBAN(day, tt, makh, manv);
                    if (billban.Add(bi))
                    {
                        string idbi = billban.Getmax().ToString();
                        foreach (ListViewItem item in listViewBAN.Items)
                        {
                            string nhasx   = item.SubItems[2].Text;
                            string xe      = item.SubItems[0].Text;
                            bool   soluong = Int32.TryParse(item.SubItems[3].Text, out int sl);
                            Int32.TryParse(item.SubItems[4].Text, out int tien);
                            DTOINFORBILLBAN bif = new DTOINFORBILLBAN(xe, sl, nhasx, idbi);
                            if (infbillban.Add(bif, tien))
                            {
                                load();
                            }
                            else
                            {
                                MessageBox.Show("them thong tin bill that bai");
                                billban.Delete(idbi);
                                kh.Delete(makh);
                                load();
                            }
                        }
                    }
                    else
                    {
                        kh.Delete(makh);
                        MessageBox.Show("them bill that bai");
                    }
                }
                else
                {
                    MessageBox.Show("them khach hang that bai");
                }
            }
            else
            {
                MessageBox.Show("them that bai");
            }
        }
Example #2
0
 public bool Add(DTOBILLBAN a)
 {
     return(add(a));
 }
Example #3
0
 protected bool add(DTOBILLBAN a)
 {
     string day = a.Ngay.ToString("yyyyMMdd");
     string query = string.Format("INSERT dbo.billxuat (ngay,  makh, manvxuat, tongtienxuat ) VALUES ( '{0}', '{1}','{2}', {3} )",day,a.Makh,a.Manv,a.Tongtien);
     return executenonquery(query);
 }