private void Loadfg() { fg.Tag = 0; fg.BeginUpdate(); clsDM_NhaCungCap cls = new clsDM_NhaCungCap(); DataTable dt = cls.SelectAll(); dt.DefaultView.RowFilter = "TonTai = 1"; int iSTT = 1; int i = fg.Rows.Fixed; fg.Rows.Count = fg.Rows.Fixed; foreach (DataRow dr in dt.DefaultView.ToTable().Rows) { fg.Rows.Add(); fg[i, "STT"] = iSTT; iSTT++; fg[i, "ID_NhaCungCap"] = dr["ID_NhaCungCap"]; fg[i, "Ten_NhaCungCap"] = dr["Ten_NhaCungCap"]; fg[i, "DiaChi"] = dr["DiaChi"]; fg[i, "Email"] = dr["Email"]; fg[i, "SoDienThoai"] = dr["SoDienThoai"]; fg[i, "SuDung"] = dr["SuDung"]; fg[i, "TonTai"] = dr["TonTai"]; i++; } fg.Row = -1; fg.AutoSizeRows(); fg.EndUpdate(); fg.Tag = 1; }
private void Loadfg() { fg.Tag = 0; fg.BeginUpdate(); clsDM_VatTu cls = new clsDM_VatTu(); DataTable dt = cls.SelectAll(); dt.DefaultView.RowFilter = "TonTai = 1"; dt.DefaultView.Sort = "ID_NhaCungCap ASC"; int iSTT = 1; fg.Rows.Count = fg.Rows.Fixed; foreach (DataRow dr in dt.DefaultView.ToTable().Rows) { Row fgRow = fg.Rows.Add(); fgRow["STT"] = iSTT; iSTT++; fgRow["ID_VatTu"] = dr["ID_VatTu"]; fgRow["Ten_VatTu"] = dr["Ten_VatTu"]; fgRow["ID_NhaCungCap"] = dr["ID_NhaCungCap"]; fgRow["SuDung"] = dr["SuDung"]; fgRow["TonTai"] = dr["TonTai"]; } clsDM_NhaCungCap clsNCC = new clsDM_NhaCungCap(); dt = clsNCC.SelectAll(); dt.DefaultView.RowFilter = "TonTai = 1"; ListDictionary dataMap = new ListDictionary(); for (int i = 0; i < dt.DefaultView.ToTable().Rows.Count; i++) { dataMap.Add(dt.Rows[i][0], dt.Rows[i][1]); } fg.Cols["ID_NhaCungCap"].DataMap = dataMap; fg.Row = -1; fg.AutoSizeRows(); fg.EndUpdate(); fg.Tag = 1; }
private void SaveData() { clsDM_NhaCungCap cls = new clsDM_NhaCungCap(); for (int i = fg.Rows.Fixed; i < fg.Rows.Count; i++) { if (fg.GetDataDisplay(i, "IsEdit").ToLower() == "") { continue; } cls.Ten_NhaCungCap = fg.GetDataDisplay(i, "Ten_NhaCungCap"); cls.DiaChi = fg.GetDataDisplay(i, "DiaChi"); cls.Email = fg.GetDataDisplay(i, "Email"); cls.SoDienThoai = fg.GetDataDisplay(i, "SoDienThoai"); cls.SuDung = fg.GetBoolValue(i, "SuDung"); //delete if (fg.GetDataDisplay(i, "IsEdit") == "0") { cls.ID_NhaCungCap = int.Parse(fg.GetDataDisplay(i, "ID_NhaCungCap")); cls.TonTai = false; cls.Update(); } else if (fg.GetDataDisplay(i, "IsEdit") == "1") { cls.TonTai = true; if (fg.GetDataDisplay(i, "ID_NhaCungCap") == "") { cls.Insert(); } else { cls.ID_NhaCungCap = int.Parse(fg.GetDataDisplay(i, "ID_NhaCungCap")); cls.Update(); } } } BaseMessages.ShowInformationMessage("Cập nhật thành công!"); }
/// <summary> /// Load flexgrids and comboboxs /// </summary> #region Load private void LoadCmbNhaCungCap() { var cmb = cmbNhaCungCap; cmb.Tag = 0; clsDM_NhaCungCap cls = new clsDM_NhaCungCap(); DataTable dt = cls.SelectAll(); dt.DefaultView.RowFilter = "TonTai = 1"; dt.DefaultView.Sort = "ID_NhaCungCap ASC"; //if (dt.DefaultView.ToTable().Rows.Count > 0) //{ // DataRow dr = dt.NewRow(); // dr["ID_NhaCungCap"] = 0; // dr["Ten_NhaCungCap"] = "Tất cả"; // dt.Rows.InsertAt(dr, 0); //} dt = dt.DefaultView.ToTable(); cmb.Properties.DataSource = dt; cmb.Properties.DisplayMember = "Ten_NhaCungCap"; cmb.Properties.ValueMember = "ID_NhaCungCap"; cmb.EditValue = 0; cmb.Tag = 1; }