Exemplo n.º 1
0
        private void buttonthanhtoannhap_Click(object sender, EventArgs e)
        {
            NHASX       sx   = comboBoxnhasxnhap.SelectedItem as NHASX;
            string      s    = sx.Ma;
            string      manv = textBoxmanvnhap.Text;
            DateTime    day  = dateTimePickernhap.Value;
            int         tt   = Convert.ToInt32(textBoxtongtiennhap.Text);
            DTOBILLNHAP bi   = new DTOBILLNHAP(day, tt, manv, s);

            if (billnhap.Add(bi))
            {
                string idbi = billnhap.Getnew().ToString();
                foreach (ListViewItem item in listViewnhap.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);
                    DTOINFORBILLNHAP bif = new DTOINFORBILLNHAP(xe, sl, idbi);
                    if (infbillnhap.Add(bif, tien))
                    {
                        load();
                    }
                    else
                    {
                        MessageBox.Show("them thong tin bill that bai");
                        billnhap.Delete(idbi);
                        load();
                    }
                }
            }
            else
            {
                MessageBox.Show("them bill that bai");
            }
        }
Exemplo n.º 2
0
 public bool Add(DTOINFORBILLNHAP a, int t)
 {
     return(add(a, t));
 }
Exemplo n.º 3
0
        protected bool add(DTOINFORBILLNHAP a, int t)
        {
            string query = string.Format("INSERT dbo.billnhapinfor (MANHAP,soluong,tongtien,maxe) VALUES ( '{3}',  {0}, {1}, '{2}')", a.Soluong, t, a.Maxe, a.Ma);

            return(executenonquery(query));
        }