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"); } }
protected bool add(DTOINFORBILLBAN a, int t) { string query = string.Format("INSERT dbo.billxuatinfor (MAXUAT,manhasx,soluong,tongtien,maxe) VALUES ( '{4}', '{0}', {1}, {2}, '{3}')", a.Manhasx, a.Soluong, t, a.Maxe, a.Ma); return(executenonquery(query)); }
public bool Add(DTOINFORBILLBAN a, int t) { return(add(a, t)); }