void LoadListSupplier() { Class.clsListSupplier cls = new Class.clsListSupplier(); DataTable dt = cls.tbSupplier_GetList(); cboSupplier.Properties.DataSource = dt; cboSupplier.Properties.DisplayMember = "SupplierName"; cboSupplier.Properties.ValueMember = "SupplierCode"; //cboSupplier.EditValue = dt.Rows[0]["SupplierCode"]; }
private void btnSaveNew_Click(object sender, EventArgs e) { Class.clsListSupplier cls = new Class.clsListSupplier(); //Ran buoc du lieu form if (txtSupplierCode.Text.Trim() == "") { MessageBox.Show("Bạn chưa nhập mã nhà cung cấp.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); txtSupplierCode.Focus(); return; } if (txtSupplierName.Text.Trim() == "") { MessageBox.Show("Bạn chưa nhập tên nhà cung cấp.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); txtSupplierName.Focus(); return; } if (statusForm) { DataTable dt = cls.tbSupplier_GetList(); for (int i = 0; i <= dt.Rows.Count - 1; i++) if (dt.Rows[i]["SupplierCode"].ToString() == txtSupplierCode.Text) { MessageBox.Show("Đã tồn tại nhà cung cấp này !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); txtSupplierCode.Focus(); return; } //Class.clsListSupplier cls = new Class.clsListSupplier(); cls.SupplierCode = txtSupplierCode.Text; cls.SupplierName = txtSupplierName.Text; cls.Address = txtAddress.Text; cls.Telephone = txtTelephone.Text; cls.Mail = txtMail.Text; cls.Group = txtGroup.Text; cls.Contact = txtContact.Text; cls.Note = txtNote.Text; if (cls.Insert()) { MessageBox.Show("Thêm thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); save = true; //this.Close(); } else { MessageBox.Show("Thêm thất bại.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } else { //Class.clsListSupplier cls = new Class.clsListSupplier(); cls.SupplierCode = txtSupplierCode.Text; cls.SupplierName = txtSupplierName.Text; cls.Address = txtAddress.Text; cls.Telephone = txtTelephone.Text; cls.Mail = txtMail.Text; cls.Group = txtGroup.Text; cls.Contact = txtContact.Text; cls.Note = txtNote.Text; if (cls.Update()) { MessageBox.Show("Sửa thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); save = true; // this.Close(); } else { MessageBox.Show("Sửa thất bại.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } Addnew(); }
//load Grid view void tbSupplier_GetList() { Class.clsListSupplier cls = new Class.clsListSupplier(); DataTable dt = cls.tbSupplier_GetList(); gridItem.DataSource = dt; }