private void Customer_GridView_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e) { Customer_GridView.ClearColumnErrors(); Customer row = e.Row.CastTo <Customer>(); GridView view = sender as GridView; if (string.IsNullOrEmpty(row.CustomerName)) { e.Valid = false; //Set errors with specific descriptions for the columns GridColumn column = view.Columns[nameof(row.CustomerName)]; view.SetColumnError(column, BSMessage.BSM000015); } if (string.IsNullOrEmpty(row.CustomerSName)) { e.Valid = false; //Set errors with specific descriptions for the columns GridColumn column = view.Columns[nameof(row.CustomerSName)]; view.SetColumnError(column, BSMessage.BSM000012); } // Kiểm tra tồn tại trong grid if (CustommersData.ToList().Count(o => o.CustomerSName == row.CustomerSName) > 1) { e.Valid = false; //Set errors with specific descriptions for the columns GridColumn column = view.Columns[nameof(row.CustomerSName)]; view.SetColumnError(column, BSMessage.BSM000010); } }
private void Add_Button_Click(object sender, EventArgs e) { this.Customer_GridView.ClearColumnsFilter(); AddCount++; CustommersData.Add(new Customer { CustomerIDTemp = $"XXXXX{AddCount}", Status = ModifyMode.Insert }); }
private void ImportData() { List <Customer> customers = ExcelHelper.LoadCustomer(out StringBuilder error); foreach (var item in customers) { item.Status = ModifyMode.Insert; CustommersData.Add(item); } if (error != null && error.Length > 0) { ClientCommon.ShowErrorBox(error.ToString()); } }