private void barLargeButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (MessageBox.Show("Bạn Muốn Xóa Khách Hàng Này?", "Cảnh Báo", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (gridView1.RowCount > 0) { int rs = -1; string id = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns[1]).ToString(); rs = new CUSTOMERController().XoaCUSTOMER(id); if (rs < 1) { MessageBox.Show("Khách hàng không được xóa", "Thông báo"); } else { MessageBox.Show("Khách hàng đã được xóa", "Thông báo"); } repositoryItemLookUpEdit1.DataSource = new CUSTOMER_GROUPController().LayDSCUSTOMER_GROUP(); gridControl1.DataSource = new CUSTOMERController().LayDSCUSTOMER(); } else { MessageBox.Show("Dữ liệu không tồn tại", "Thông báo"); } } }
private void simpleButton1_Click(object sender, EventArgs e) { int rs = -1; objcustomer_group = new CUSTOMER_GROUPController().LayTTCUSTOMER_ByName(lookupkhuvuc.Text.Trim()); objcustomer.Customer_ID = txtMaKhach.Text.Trim(); objcustomer.Barcode = txtMaKhach.Text.Trim(); objcustomer.OrderID = 0; objcustomer.CustomerName = txtTen.Text; objcustomer.Customer_Type_ID = lookUpLoaiKhach.GetColumnValue("Customer_Type_ID").ToString(); objcustomer.Customer_Group_ID = objcustomer_group.Customer_Group_ID; objcustomer.CustomerAddress = txtDiaChi.Text.Trim(); objcustomer.Tax = txtMST.Text; objcustomer.Fax = txtFax.Text; objcustomer.Tel = txtDienThoai.Text; objcustomer.Mobile = txtMobile.Text; objcustomer.Website = txtwebsite.Text; objcustomer.BankAccount = txtTaiKhoan.Text; objcustomer.BankName = txtNganHang.Text; objcustomer.CreditLimit = double.Parse(calLimitNo.Text); objcustomer.Discount = double.Parse(calchietkhau.Text); objcustomer.Contact = txtnguoilienhe.Text; objcustomer.NickYM = txtyahoo.Text; objcustomer.NickSky = txtsky.Text; objcustomer.Active = chkquanli.Checked; rs = new CUSTOMERController().ThemCUSTOMER(objcustomer); if (rs < 1) { MessageBox.Show("Khách hàng đã tồn tại", "Thông báo"); } else { MessageBox.Show("Khách hàng mới đã được lưu", "Thông báo"); txtMaKhach.Text = SinhMaKhachHang(); lookupkhuvuc.SelectedText = ""; txtTen.Text = ""; txtDiaChi.Text = ""; txtMST.Text = ""; txtFax.Text = ""; txtDienThoai.Text = ""; txtMobile.Text = ""; txtEmail.Text = ""; txtTaiKhoan.Text = ""; txtNganHang.Text = ""; calLimitNo.Text = ""; calchietkhau.Text = ""; txtnguoilienhe.Text = ""; txtyahoo.Text = ""; txtsky.Text = ""; chkquanli.Checked = true; } }
private void barLargeButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (gridView1.FocusedRowHandle >= 0) { string id = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns[1]).ToString(); //MessageBox.Show(id); CUSTOMER objcustomer = new CUSTOMER(); objcustomer = new CUSTOMERController().LayTTCUSTOMER(id); frmCapNhatKhachHang frm = new frmCapNhatKhachHang(); frm.Load_Data(objcustomer); frm.ShowDialog(); } }
private void gridControl1_DoubleClick(object sender, EventArgs e) { if (gridView1.Columns[0].View.FocusedRowHandle >= 0) { string id = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns[1]).ToString(); //MessageBox.Show(id); CUSTOMER objcustomer = new CUSTOMER(); objcustomer = new CUSTOMERController().LayTTCUSTOMER(id); frmCapNhatKhachHang frm = new frmCapNhatKhachHang(); frm.Load_Data(objcustomer); frm.ShowDialog(); } }
private void simpleButton3_Click(object sender, EventArgs e) { CUSTOMER objnganh = new CUSTOMER(); int rs = -1; if (gridView1.RowCount > 0) { for (int i = 0; i < gridView1.RowCount; i++) { objnganh.Customer_ID = gridView1.GetRowCellValue(i, gridView1.Columns[0]).ToString(); objnganh.CustomerName = gridView1.GetRowCellValue(i, gridView1.Columns[1]).ToString(); objnganh.CustomerAddress = gridView1.GetRowCellValue(i, gridView1.Columns[2]).ToString(); objnganh.Tax = gridView1.GetRowCellValue(i, gridView1.Columns[3]).ToString(); objnganh.Tel = gridView1.GetRowCellValue(i, gridView1.Columns[4]).ToString(); objnganh.Contact = gridView1.GetRowCellValue(i, gridView1.Columns[5]).ToString(); objnganh.Customer_Group_ID = lookUpNhom.GetColumnValue("Customer_Group_ID").ToString(); objnganh.Customer_Type_ID = lookUpLoaiKhach.GetColumnValue("Customer_Type_ID").ToString(); objnganh.Active = true; rs = new CUSTOMERController().ThemCUSTOMER(objnganh); if (rs == -1) { MessageBox.Show("Lưu Thất Bại", "Thông Báo"); break; } } if (rs > -1) { MessageBox.Show("Lưu Thành công", "Thông Báo"); } else { MessageBox.Show("Lưu Thất bại", "Thông Báo"); } frmkhachhang.RefreshData(); } else { MessageBox.Show("Chưa có dữ liệu nhập", "Thông Báo"); } }
private void simpleButton1_Click(object sender, EventArgs e) { int rs = -1; objcustomer_group = new CUSTOMER_GROUPController().LayTTCUSTOMER_ByName(lookupkhuvuc.Text.Trim()); objcustomer_form.Customer_ID = txtMaKhach.Text.Trim(); objcustomer_form.OrderID = 0; objcustomer_form.CustomerName = txtTen.Text; objcustomer_form.Customer_Type_ID = lookUpLoaiKhach.GetColumnValue("Customer_Type_ID").ToString(); objcustomer_form.Customer_Group_ID = objcustomer_group.Customer_Group_ID; objcustomer_form.CustomerAddress = txtDiaChi.Text.Trim(); objcustomer_form.Tax = txtMST.Text; objcustomer_form.Fax = txtFax.Text; objcustomer_form.Tel = txtDienThoai.Text; objcustomer_form.Mobile = txtMobile.Text; objcustomer_form.Website = txtwebsite.Text; objcustomer_form.BankAccount = txtTaiKhoan.Text; objcustomer_form.BankName = txtNganHang.Text; objcustomer_form.CreditLimit = double.Parse(calLimitNo.Text); objcustomer_form.Discount = double.Parse(calchietkhau.Text); objcustomer_form.Contact = txtnguoilienhe.Text; objcustomer_form.NickYM = txtyahoo.Text; objcustomer_form.NickSky = txtsky.Text; objcustomer_form.Active = chkquanli.Checked; objcustomer_form.Barcode = txtMaKhach.Text; rs = new CUSTOMERController().CapNhatCUSTOMER(objcustomer_form, objcustomer_form.Customer_ID); if (rs < 1) { MessageBox.Show("Cập nhật thất bại", "Thông báo"); } else { MessageBox.Show("Cập nhật thành công", "Thông báo"); Close(); } }
public UC_KetThucNhap(DataTable _table, int tuychon, int khuvuc) { InitializeComponent(); luachon = tuychon; loai = khuvuc; import = _table; if (khuvuc == 0)//khu vực { CUSTOMER_GROUP objcustomer = new CUSTOMER_GROUP(); foreach (DataRow datarow in import.Rows) { try { objcustomer.Customer_Group_ID = datarow["Mã Khu Vực"].ToString().Trim(); objcustomer.Customer_Group_Name = datarow["Tên Khu Vực"].ToString().Trim(); objcustomer.Description = datarow["Ghi Chú"].ToString().Trim(); objcustomer.Active = true; int rs = new CUSTOMER_GROUPController().ThemCUSTOMER_GROUP(objcustomer); listBoxControl1.Items.Add("Khu Vực " + datarow["Mã Khu Vực"].ToString().Trim() + " Nhập Thành Công"); } catch { listBoxControl1.Items.Add("Khu Vực " + datarow["Mã Khu Vực"].ToString().Trim() + " Nhập Thất Bại"); break; } } } else if (khuvuc == 1)//khách hàng { CUSTOMER objcustomer = new CUSTOMER(); foreach (DataRow datarow in import.Rows) { try { objcustomer.Customer_ID = datarow["Mã Khách Hàng"].ToString().Trim(); objcustomer.CustomerName = datarow["Tên Khách Hàng"].ToString().Trim(); objcustomer.CustomerAddress = datarow["Địa Chỉ"].ToString().Trim(); objcustomer.Tax = datarow["Mã Số Thuế"].ToString().Trim(); objcustomer.Tel = datarow["Điện Thoại Bàn"].ToString().Trim(); objcustomer.Mobile = datarow["Di Động"].ToString().Trim(); objcustomer.Email = datarow["Email"].ToString().Trim(); objcustomer.Fax = datarow["Fax"].ToString().Trim(); objcustomer.BankAccount = datarow["Số Tài Khoản"].ToString().Trim(); objcustomer.BankName = datarow["Tên Ngân Hàng"].ToString().Trim(); objcustomer.Contact = datarow["Người Liên Hệ"].ToString().Trim(); objcustomer.Position = datarow["Chức Vụ"].ToString().Trim(); objcustomer.Description = datarow["Ghi Chú"].ToString().Trim(); objcustomer.Website = datarow["Website"].ToString().Trim(); objcustomer.Barcode = datarow["Mã Vạch"].ToString().Trim(); objcustomer.CreditLimit = double.Parse(datarow["Giới Hạn Nợ"].ToString().Trim()); objcustomer.Discount = double.Parse(datarow["Chiết Khấu"].ToString().Trim()); objcustomer.NickYM = datarow["Nick Yahoo"].ToString().Trim(); objcustomer.NickSky = datarow["Nick Skype"].ToString().Trim(); objcustomer.Active = true; int rs = new CUSTOMERController().ThemCUSTOMER(objcustomer); listBoxControl1.Items.Add("Khách Hàng " + datarow["Mã Khách Hàng"].ToString().Trim() + " Nhập Thành Công"); } catch { listBoxControl1.Items.Add("Khách Hàng " + datarow["Mã Khách Hàng"].ToString().Trim() + " Nhập Thất Bại"); break; } } } else if (khuvuc == 2)// nhà phân phối { PROVIDER objprovider = new PROVIDER(); foreach (DataRow datarow in import.Rows) { try { objprovider.Customer_ID = datarow["Mã Nhà Cung Cấp"].ToString().Trim(); objprovider.Barcode = datarow["Mã Vạch"].ToString().Trim(); objprovider.OrderID = 0; objprovider.CustomerName = datarow["Tên Nhà Cung Cấp"].ToString().Trim(); objprovider.Customer_Type_ID = "0"; //objprovider.Customer_Group_ID = datarow["Mã Khách Hàng"].ToString().Trim(); objprovider.CustomerAddress = datarow["Địa Chỉ"].ToString().Trim(); objprovider.Tax = datarow["Mã Số Thuế"].ToString().Trim(); objprovider.Fax = datarow["Fax"].ToString().Trim(); objprovider.Tel = datarow["Điện Thoại Bàn"].ToString().Trim(); objprovider.Mobile = datarow["Di Động"].ToString().Trim(); objprovider.Contact = datarow["Người Liên Hệ"].ToString().Trim(); objprovider.Website = datarow["Website"].ToString().Trim(); objprovider.BankAccount = datarow["Số Tài Khoản"].ToString().Trim(); objprovider.BankName = datarow["Tên Ngân Hàng"].ToString().Trim(); objprovider.CreditLimit = double.Parse(datarow["Giới Hạn Nợ"].ToString().Trim()); objprovider.Discount = double.Parse(datarow["Chiết Khấu"].ToString().Trim()); objprovider.Position = datarow["Chức Vụ"].ToString().Trim(); objprovider.Email = datarow["Email"].ToString().Trim(); objprovider.Description = datarow["Ghi Chú"].ToString().Trim(); objprovider.Active = true; int rs = new PROVIDERController().PROVIDER_Insert(objprovider); listBoxControl1.Items.Add("Khách Hàng " + datarow["Mã Nhà Cung Cấp"].ToString().Trim() + " Nhập Thành Công"); } catch { listBoxControl1.Items.Add("Khách Hàng " + datarow["Mã Nhà Cung Cấp"].ToString().Trim() + " Nhập Thất Bại"); break; } } } else if (khuvuc == 3)// nhóm hàng { PRODUCT_GROUP objproduct = new PRODUCT_GROUP(); foreach (DataRow datarow in import.Rows) { try { objproduct.ProductGroup_ID = datarow["Mã Nhóm Hàng"].ToString().Trim(); objproduct.ProductGroup_Name = datarow["Tên Nhóm Hàng"].ToString().Trim(); objproduct.Description = datarow["Ghi Chú"].ToString().Trim(); objproduct.Active = true; int rs = new PRODUCT_GROUPController().PRODUCT_GROUP_Insert(objproduct); listBoxControl1.Items.Add("Nhóm Hàng " + datarow["Mã Nhóm Hàng"].ToString().Trim() + " Nhập Thành Công"); } catch { listBoxControl1.Items.Add("Nhóm Hàng " + datarow["Mã Nhóm Hàng"].ToString().Trim() + " Nhập Thất Bại"); break; } } } else if (khuvuc == 4)// kho hàng { STOCK objstock = new STOCK(); foreach (DataRow datarow in import.Rows) { try { objstock.Stock_ID = datarow["Mã Kho"].ToString().Trim(); objstock.Stock_Name = datarow["Tên Kho"].ToString().Trim(); objstock.Mobi = datarow["Di Động"].ToString().Trim(); objstock.Contact = datarow["Người Liên Hệ"].ToString().Trim(); objstock.Address = datarow["Địa Chỉ"].ToString().Trim(); objstock.Telephone = datarow["Điện Thoại Bàn"].ToString().Trim(); objstock.Fax = datarow["Fax"].ToString().Trim(); objstock.Email = datarow["Email"].ToString().Trim(); objstock.Description = datarow["Ghi Chú"].ToString().Trim(); objstock.Manager = datarow["Người Quản Lý"].ToString().Trim(); objstock.Manager = "NV000001"; objstock.Active = true; int rs = new STOCKController().STOCK_Insert(objstock); listBoxControl1.Items.Add("Kho Hàng " + datarow["Mã Kho"].ToString().Trim() + " Nhập Thành Công"); } catch { listBoxControl1.Items.Add("Kho Hàng " + datarow["Mã Kho"].ToString().Trim() + " Nhập Thất Bại"); break; } } } else if (khuvuc == 5)// đơn vị { UNIT objunit = new UNIT(); foreach (DataRow datarow in import.Rows) { try { objunit.Unit_ID = datarow["Mã Đơn Vị"].ToString().Trim(); objunit.Unit_Name = datarow["Tên Đơn Vị"].ToString().Trim(); objunit.Description = datarow["Ghi Chú"].ToString().Trim(); objunit.Active = true; int rs = new UNITController().UNIT_Insert(objunit); listBoxControl1.Items.Add("Đơn Vị " + datarow["Mã Đơn Vị"].ToString().Trim() + " Nhập Thành Công"); } catch { listBoxControl1.Items.Add("Đơn Vị " + datarow["Mã Đơn Vị"].ToString().Trim() + " Nhập Thất Bại"); break; } } } else if (khuvuc == 6)// hàng hóa { PRODUCT objproduct = new PRODUCT(); byte[] buff = { 1 }; objproduct.Photo = buff; foreach (DataRow datarow in import.Rows) { try { //objproduct.Product_Type_ID = datarow["Mã Đơn Vị"].ToString().Trim(); //objproduct.Provider_ID = datarow["Mã Đơn Vị"].ToString().Trim(); //objproduct.Product_Group_ID = datarow["Mã Đơn Vị"].ToString().Trim(); //objproduct.Product_ID = datarow["Mã Đơn Vị"].ToString().Trim(); //objproduct.Barcode = txtbarcode.Text; //objproduct.Product_Name = txtten.Text; //objproduct.Unit = (new UNITController().UNIT_GetByName(lookdonvi.Text)).Unit_ID; //objproduct.Origin = txtxuatxu.Text; //objproduct.MinStock = double.Parse(caltoithieu.Text); //objproduct.Customer_ID = (new PROVIDERController().PROVIDER_GetByName(looknhacungcap.Text)).Customer_ID; //objproduct.Org_Price = double.Parse(calcgiamua.Text); //objproduct.Sale_Price = double.Parse(calcgiasi.Text); //objproduct.Retail_Price = double.Parse(calcgiale.Text); //objproduct.UnitRate = 1; //objproduct.Customer_Name = looknhacungcap.Text; //objproduct.ExchangeRate = 1; //objproduct.Active = true; //objproduct.UserID = "US000001"; //objproduct.Currency_ID = "VND"; //int rs = new PRODUCTController().PRODUCT_Insert_Photo(objproduct); listBoxControl1.Items.Add("Đơn Vị " + datarow["Mã Đơn Vị"].ToString().Trim() + " Nhập Thành Công"); } catch { listBoxControl1.Items.Add("Đơn Vị " + datarow["Mã Đơn Vị"].ToString().Trim() + " Nhập Thất Bại"); break; } } } }