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_VatTu cls = new clsDM_VatTu(); for (int i = fg.Rows.Fixed; i < fg.Rows.Count; i++) { if (fg.GetDataDisplay(i, "IsEdit").ToLower() == "") { continue; } cls.Ten_VatTu = fg.GetDataDisplay(i, "Ten_VatTu"); cls.ID_NhaCungCap = fg.GetIntValue(i, "ID_NhaCungCap"); cls.SuDung = fg.GetBoolValue(i, "SuDung"); //delete if (fg.GetDataDisplay(i, "IsEdit") == "0") { cls.ID_VatTu = int.Parse(fg.GetDataDisplay(i, "ID_VatTu")); cls.TonTai = false; cls.Update(); } else if (fg.GetDataDisplay(i, "IsEdit") == "1") { cls.TonTai = true; if (fg.GetDataDisplay(i, "ID_VatTu") == "") { cls.Insert(); } else { cls.ID_VatTu = int.Parse(fg.GetDataDisplay(i, "ID_VatTu")); cls.Update(); } } } BaseMessages.ShowInformationMessage("Cập nhật thành công!"); }
private void LoadfgChiTiet(int ID_QuyetDinh, int ID_NhaCungCap) { //if (fgQD.Row < fgQD.Rows.Fixed) //{ // return; //} var fg = fgChiTiet; fg.Tag = 0; fg.BeginUpdate(); int iSTT = 1; fg.Rows.Count = fg.Rows.Fixed; if (ID_QuyetDinh != 0) //Xem/Sua { clsQD_NhapVatTu_ChiTiet cls = new clsQD_NhapVatTu_ChiTiet(); Byte byLoai = 0; //dang xem if (!btnSua.Visible) { byLoai = 1; //dang cap nhat } DataTable dt = cls.Select_DS_VatTuVer2(ID_QuyetDinh, ID_NhaCungCap, byLoai); foreach (DataRow dr in dt.Rows) { Row fgRow = fg.Rows.Add(); fgRow["STT"] = iSTT; iSTT++; fgRow["ID_QuyetDinh"] = dr["ID_QuyetDinh"]; fgRow["Chon"] = dr["Chon"]; fgRow["ID_VatTu"] = dr["ID_VatTu"]; fgRow["Ten_VatTu"] = dr["Ten_VatTu"]; fgRow["ID_Kho"] = dr["ID_Kho"]; fgRow["Ten_Kho"] = dr["Ten_Kho"]; fgRow["SoLuong"] = dr["SoLuong"]; } } else //ID_QuyetDinh = 0, Them moi' QD { clsDM_VatTu cls = new clsDM_VatTu(); DataTable dt = cls.SelectVatTuWithID_NhaCungCap(ID_NhaCungCap); foreach (DataRow dr in dt.Rows) { Row fgRow = fg.Rows.Add(); fgRow["STT"] = iSTT; iSTT++; fgRow["Chon"] = false; fgRow["ID_VatTu"] = dr["ID_VatTu"]; fgRow["Ten_VatTu"] = dr["Ten_VatTu"]; fgRow["ID_Kho"] = dr["ID_Kho"]; fgRow["Ten_Kho"] = dr["Ten_Kho"]; } } // //Tao combobox chon. Kho // //clsDM_Kho clsKho = new clsDM_Kho(); //DataTable dtKho = clsKho.SelectAll(); //dtKho.DefaultView.RowFilter = "TonTai = 1"; //ListDictionary datamap = new ListDictionary(); //for (int i = 0; i <= dtKho.DefaultView.ToTable().Rows.Count - 1; i++) //{ // datamap.Add(dtKho.Rows[i][0], dtKho.Rows[i][1]); //} //fg.Cols["ID_Kho"].DataMap = datamap; // // fg.Row = -1; fg.AutoSizeRows(); fg.EndUpdate(); fg.Tag = 1; }