private void Treelist_btnDel_Click(object sender, EventArgs e) { TreeListNode nodeSelect = null; nodeSelect = treeList1.FocusedNode; if (nodeSelect != null) { if (nodeSelect.Nodes.Count > 0) { MessageBox.Show("Không xóa được nhóm này <Chỉ được xóa nhóm không có nhóm con>"); } else { if (MessageBox.Show("Bạn có muốn xóa nhóm hàng này không?", "Xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { int intNhomHangID = Int32.Parse(nodeSelect["NhomHangID"].ToString()); NhomHangController.Del(intNhomHangID); //load lai danh sach nhom hang trlNhomHangCha.Properties.DataSource = NhomHangController.Getlist(); treeList1.DataSource = NhomHangController.Getlist(); treeList1.ExpandAll(); } } } }
private void LayDanhSachNhomHang() { treelistNhomHang.Properties.DataSource = NhomHangController.Getlist(); treelistNhomHang.Properties.DisplayMember = "TenNhomHang"; treelistNhomHang.Properties.ValueMember = "NhomHangID"; treelistNhomHang.Properties.TreeList.KeyFieldName = "NhomHangID"; treelistNhomHang.Properties.TreeList.ParentFieldName = "NhomHangChaID"; }
private void simpleButton1_Click(object sender, EventArgs e) { Save(); //load lai danh sach nhom hang trlNhomHangCha.Properties.DataSource = NhomHangController.Getlist(); treeList1.DataSource = NhomHangController.Getlist(); treeList1.ExpandAll(); }
private void lookupNhomHang_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { if (e.Button.Index == 1) { frmAddNhomHang f = new frmAddNhomHang(); f.ShowDialog(this); //load lại danh sach nhom hang. treelistNhomHang.Properties.DataSource = NhomHangController.Getlist(); } }
private void Save() { NhomHang item = new NhomHang(); item.TenNhomHang = txtTenNhomHang.Text.Trim(); if (trlNhomHangCha.EditValue != null) { item.NhomHangChaID = Int32.Parse(trlNhomHangCha.EditValue.ToString()); } else { item.NhomHangChaID = null; } item.NguoiDungID = Utility.NguoiSuDung.NguoiDungID; item.TenNguoiDung = Utility.NguoiSuDung.TenNguoiDung; item.LastUpdate = DateTime.Now; NhomHangController.Add(item); }
public void LayDanhSachNhomHang() { treeList1.DataSource = NhomHangController.Getlist(); treeList1.KeyFieldName = "NhomHangID"; treeList1.ParentFieldName = "NhomHangChaID"; trlNhomHangCha.Properties.DataSource = NhomHangController.Getlist(); trlNhomHangCha.Properties.DisplayMember = "TenNhomHang"; trlNhomHangCha.Properties.ValueMember = "NhomHangID"; trlNhomHangCha.Properties.TreeList.KeyFieldName = "NhomHangID"; trlNhomHangCha.Properties.TreeList.ParentFieldName = "NhomHangChaID"; //khong hien thi duong ke trlNhomHangCha.Properties.TreeList.OptionsView.ShowHorzLines = false; trlNhomHangCha.Properties.TreeList.OptionsView.ShowVertLines = false; trlNhomHangCha.Properties.NullText = "chưa chọn nhóm hàng cha"; trlNhomHangCha.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //trlNhomHangCha.Text = "chưa chọn nhóm hàng"; }
private void frmTimSanPham_Load(object sender, System.EventArgs e) { KhoiTaoLuoi(); //gridControl1.DataSource = SanPhamController.GetAllList(); TableSanPham = SanPhamController.TonKhoHeThong(); dtView = TableSanPham.DefaultView; gridControl1.DataSource = dtView; gridView1.BestFitColumns(); treeList1.DataSource = NhomHangController.Getlist(); treeList1.Columns[0].Caption = "Nhóm Hàng"; treeList1.Columns[0].FieldName = "TenNhomHang"; treeList1.Columns[0].OptionsColumn.AllowEdit = false; treeList1.ParentFieldName = "NhomHangChaID"; treeList1.KeyFieldName = "NhomHangID"; treeList1.ExpandAll(); //treeList1.BestFitColumns(); treeList1.OptionsView.ShowHorzLines = false; treeList1.OptionsView.ShowVertLines = false; }
private void btn_save_Click(object sender, EventArgs e) { if (MessageBox.Show("Bạn có muốn cập nhật danh mục sản phẩm vào hệ thống?", "Xác nhận", MessageBoxButtons.YesNo) == DialogResult.Yes) { int intTotalRow = gridView1.RowCount; int i = 1; int intDongXL = 0; splashScreenManager1.ShowWaitForm(); splashScreenManager1.SetWaitFormCaption("Đợi xíu..."); while (gridView1.RowCount > intDongXL) //xử lý từng dòng, từ dòng đầu tiên { splashScreenManager1.SetWaitFormDescription(string.Format("Đang xử lý dòng {0}/{1}", i, intTotalRow)); i++; try { //nếu dòng đó có mã và tên sản phẩm thì xử lý string strID = gridView1.GetRowCellValue(intDongXL, gridView1.Columns["SanPhamID"]).ToString(); string strTen = gridView1.GetRowCellValue(intDongXL, gridView1.Columns["TenSanPham"]).ToString(); if (strID != string.Empty) { //0:Ma SP //1:TenSP //2:GioTinh //3:Nhom Size //4:Gia ban le //5:NhomSP //6:DVT SanPham objSanPham = new SanPham(); objSanPham.SanPhamID = strID; string strNhomSize = gridView1.GetRowCellValue(intDongXL, gridView1.Columns["NhomSize"]).ToString(); if (strNhomSize != string.Empty) { objSanPham.NhomSize = strNhomSize; } string strNhomHang = gridView1.GetRowCellValue(intDongXL, gridView1.Columns["NhomSanPham"]).ToString(); if (strTen != string.Empty) { objSanPham.TenSanPham = strTen; } else { objSanPham.TenSanPham = strNhomHang; } if (gridView1.GetRowCellValue(intDongXL, gridView1.Columns[2]) != null) { objSanPham.GioTinh = gridView1.GetRowCellValue(intDongXL, gridView1.Columns["GioTinh"]).ToString(); } NhomHang objNhomHang = NhomHangController.GetByName(strNhomHang); if (objNhomHang != null) { objSanPham.NhomHangID = objNhomHang.NhomHangID; } else { objNhomHang = new NhomHang(); objNhomHang.TenNhomHang = strNhomHang; objNhomHang.NguoiDungID = Utility.NguoiSuDung.NguoiDungID; objNhomHang.TenNguoiDung = Utility.NguoiSuDung.TenNguoiDung; objSanPham.NhomHangID = NhomHangController.Add(objNhomHang); } //string strMaNhomHang = Utility.TenVietTat(strNhomHang); //objSanPham.NhomHangID = strMaNhomHang; if ((gridView1.GetRowCellValue(intDongXL, gridView1.Columns["GiaBanLe"]) != null)) { int intGiaBan = 0; if (Int32.TryParse(gridView1.GetRowCellValue(intDongXL, gridView1.Columns["GiaBanLe"]).ToString(), out intGiaBan)) { objSanPham.GiaBan = intGiaBan; } else { objSanPham.GiaBan = 0; } } //objSanPham.NgayKhoiTao = DateTime.Now; if (gridView1.GetRowCellValue(intDongXL, gridView1.Columns["DVT"]) != null) { objSanPham.DVT = gridView1.GetRowCellValue(intDongXL, gridView1.Columns["DVT"]).ToString(); } if (gridView1.GetRowCellValue(intDongXL, gridView1.Columns["EXT_ID"]) != null) { objSanPham.EXT_ID = gridView1.GetRowCellValue(intDongXL, gridView1.Columns["EXT_ID"]).ToString(); } objSanPham.NguoiDungID = Utility.NguoiSuDung.NguoiDungID; objSanPham.NgungKinhDoanh = false; SanPhamController.Add(objSanPham); gridView1.DeleteRow(intDongXL);//remove dong dang xly //gridControl1.Invalidate(); //gridControl1.Update(); } else { gridView1.SetRowCellValue(intDongXL, "ERROR", "Không có mã hoặc tên sản phẩm!"); intDongXL++; //bỏ qua dòng này không xly. } } catch (Exception ex) { gridView1.SetRowCellValue(intDongXL, "ERROR", ex.Message); //gridControl1.Invalidate(); //gridControl1.Update(); intDongXL++; //bỏ qua dòng lỗi; xly dòng tiep theo. //throw; } //làm mới lại lưới gridControl1.Invalidate(); gridControl1.Update(); } //Them Danh Muc Nhom Hang vao he thong. splashScreenManager1.CloseWaitForm(); } }