private void btnAdd_Click(object sender, EventArgs e) { frmAddNhaCungCap f = new frmAddNhaCungCap(); f.ShowDialog(this); gridControl1.DataSource = NhaCungCapControlller.GetList(); }
private void save() { NhaCungCap item = new NhaCungCap(); item.TenNhaCungCap = txtTenNhaCungCap.Text; item.SoDienThoai = txtSoDienThoai.Text; item.DiaChi = txtDiaChi.Text; item.Email = txtEmail.Text; item.MST = txtMST.Text; item.NguoiLienHe = textNguoiLienHe.Text; if (txtNhaCungCapID.Text.Trim() == string.Empty)//người dùng khong nhập mã { item.NhaCungCapID = NhaCungCapControlller.TaoMaNhaCungCap("AB", 8); } else { item.NhaCungCapID = txtNhaCungCapID.Text; } if (this.frmMode.ToUpper().Equals("EDIT")) { NhaCungCapControlller.Edit(item); EditItem = null; } else { NhaCungCapControlller.Add(item); strNewNhaCungCapID = item.NhaCungCapID; //lấy mã khách hàng mới vừa được tạo để đưa về form gọi } }
private void lookUpEditNhaCungCap_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { if (e.Button.Caption.ToUpper().Equals("ADD")) { frmAddNhaCungCap f = new frmAddNhaCungCap(); f.ShowDialog(this); lookUpEditNhaCungCap.Properties.DataSource = NhaCungCapControlller.GetList(); if (f.strNewNhaCungCapID != string.Empty) { lookUpEditNhaCungCap.EditValue = f.strNewNhaCungCapID; } f.Dispose(); } }
//private void KhoiTaoDuLieuSearch() //{ // int i = 0; // txtSanPham.Properties.Columns[i].Caption = "Mã sản phẩm"; // txtSanPham.Properties.Columns[i].FieldName = "SanPhamID"; // i++; // txtSanPham.Properties.Columns[i].Caption = "Tên sản phẩm"; // txtSanPham.Properties.Columns[i].FieldName = "TenSanPham"; // i++; // txtSanPham.Properties.Columns[i].Caption = "Giá bán"; // txtSanPham.Properties.Columns[i].FieldName = "GiaBan"; // txtSanPham.Properties.Columns[i].FormatType = DevExpress.Utils.FormatType.Numeric; // txtSanPham.Properties.Columns[i].FormatString = "# ##0"; // i++; // txtSanPham.Properties.Columns[i].Caption = "Tồn kho"; // txtSanPham.Properties.Columns[i].FieldName = "SLTonKho"; // //txtSearch.Properties. // txtSanPham.Properties.AutoSearchColumnIndex = 1; // txtSanPham.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard; // txtSanPham.Properties.SearchMode = DevExpress.XtraEditors.Controls.SearchMode.AutoComplete; // txtSanPham.Properties.DisplayMember = "SanPhamID"; // txtSanPham.Properties.ValueMember = "SanPhamID"; // txtSanPham.Properties.NullValuePrompt = "Nhập mã sản phẩm hoặc tên"; //} private void KhoiTaoDSNhaCungCap() { lookUpEditNhaCungCap.Properties.DataSource = NhaCungCapControlller.GetList(); lookUpEditNhaCungCap.Properties.DisplayMember = "TenNhaCungCap"; lookUpEditNhaCungCap.Properties.ValueMember = "NhaCungCapID"; lookUpEditNhaCungCap.Properties.NullText = "Chưa chọn nhà cung cấp"; lookUpEditNhaCungCap.Text = string.Empty; lookUpEditNhaCungCap.Properties.Columns[0].Caption = "Mã nhà cung cấp"; lookUpEditNhaCungCap.Properties.Columns[0].FieldName = "NhaCungCapID"; lookUpEditNhaCungCap.Properties.Columns[1].Caption = "Tên nhà cung cấp"; lookUpEditNhaCungCap.Properties.Columns[1].FieldName = "TenNhaCungCap"; lookUpEditNhaCungCap.Properties.SearchMode = DevExpress.XtraEditors.Controls.SearchMode.AutoComplete; lookUpEditNhaCungCap.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard; }
private void gr_btn_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { int intRow = gridView1.FocusedRowHandle; string strNhaCungCapID = gridView1.GetRowCellValue(intRow, "NhaCungCapID").ToString(); if ((e.Button.Caption.ToUpper().Equals("DEL")) && (strNhaCungCapID != string.Empty)) { if (MessageBox.Show("Bạn muốn xóa nhà cung cấp này không", "Xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { NhaCungCapControlller.DelItem(strNhaCungCapID); gridControl1.DataSource = NhaCungCapControlller.GetList(); } } }
private void gridView1_DoubleClick(object sender, EventArgs e) { int intRow = gridView1.FocusedRowHandle; if (intRow >= 0) { string strNhaCungCapID = gridView1.GetRowCellValue(intRow, "NhaCungCapID").ToString(); NhaCungCap item = NhaCungCapControlller.GetItem(strNhaCungCapID); if (item != null) { frmAddNhaCungCap f = new frmAddNhaCungCap(); f.frmMode = "edit"; f.EditItem = item; if (f.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { gridControl1.DataSource = NhaCungCapControlller.GetList(); gridView1.FocusedRowHandle = intRow; } } } }
private void frmNhaCungCap_Load(object sender, EventArgs e) { KhoiTaoLuoi(); gridControl1.DataSource = NhaCungCapControlller.GetList(); }