private void buttonsuanhasx_Click(object sender, EventArgs e) { //lấy thông tin từ textbox string manhasx = textBoxmanhasx.Text; string tennhasx = textBoxtennhasx.Text; string emailnhasx = textBoxemailnhasx.Text; Int32.TryParse(textBoxsdtnhasx.Text, out int sdtnhax); NHASX a = new NHASX(manhasx, tennhasx, emailnhasx, sdtnhax); //tạo 1 DTO nhà sx if (manhasx != "" && tennhasx != "" && emailnhasx != "" && sdtnhax != 0) //kiểm tra textbox khác 0 { if (nhasx.Update(a)) //kiểm tra thực hiện query thành công { load(); //load lại bảng } else { MessageBox.Show("sua that bai"); } } else { MessageBox.Show("sua that bai"); } }
private void comboBoxnhasxnhap_SelectedIndexChanged(object sender, EventArgs e) { NHASX a = comboBoxnhasxnhap.SelectedItem as NHASX; // ép kiểu về nhasx string i = a.Ma; //lấy mã nhà sản xuất comboBoxxenhap.DataSource = xe.listxe(i); // load lại combobox comboBoxxenhap.DisplayMember = "tenxe"; }
public List <NHASX> listnhasx() { List <NHASX> nhasx = new List <NHASX>(); DataTable data = getnhasx(); foreach (DataRow item in data.Rows) { NHASX a = new NHASX(item); nhasx.Add(a); } return(nhasx); }
private void buttonthemvaobillnhap_Click(object sender, EventArgs e) { DTOXE xeban = comboBoxxeban.SelectedItem as DTOXE; string a = xeban.Maxe; string b = xeban.Tenxe; NHASX sx = comboBoxnhasxban.SelectedItem as NHASX; string c = sx.Ma; int d = Convert.ToInt32(numericUpDownxeban.Value.ToString()); int f = xeban.Giaban * d; if (a != "" && b != "" && c != "" && d != 0) { listViewBAN.Items.Add(addlistban(a, b, c, d, f)); loadttienban(f); } }
private void buttonthembillnhap_Click(object sender, EventArgs e) { DTOXE xenhap = comboBoxxenhap.SelectedItem as DTOXE; string a = xenhap.Maxe; string b = xenhap.Tenxe; NHASX sx = comboBoxnhasxnhap.SelectedItem as NHASX; string c = sx.Ma; int d = Convert.ToInt32(numericUpDownnhap.Value.ToString()); int f = (xenhap.Giaban * d) / 10 * 7; if (a != "" && b != "" && c != "" && d != 0) { listViewnhap.Items.Add(addlistnhap(a, b, c, d, f)); loadttiennhap(f); comboBoxnhasxnhap.Enabled = false; } }
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"); } }
public bool Update(NHASX a) { return(update(a)); }
public bool ADD(NHASX a) { return(add(a)); }
protected bool update(NHASX a) { string query = string.Format("UPDATE dbo.nhasx SET tennhasx= '{1}',email = '{2}' , sdt='{3}' WHERE MANHASX ='{0}'", a.Ma, a.Ten, a.Email, a.Sdt); return(executenonquery(query)); }
protected bool add(NHASX a) { string query = string.Format("INSERT dbo.nhasx(MANHASX,tennhasx,email,sdt) VALUES( N'{0}', N'{1}', N'{2}', {3} )", a.Ma, a.Ten, a.Email, a.Sdt); return(executenonquery(query)); }