public Boolean init(string dbname, string workingdir) { string sqlStr; OleDbDataReader oleReader; contractDb = new db(dbname); edit = false; laisuat = 0; MaHD = ""; HTTra = TraDinhKy; optTraDK.Checked = true; dbfile = dbname; frmNhapTN = new NhapKyTraNo(); frmNhapTN.saved = false; dirWork = workingdir; if (contractDb == null) { MessageBox.Show("Loi ket noi den database"); this.Close(); } sqlStr = "SELECT [MaKH] FROM [KHACHHANG] ORDER BY [MaKH]"; try { oleReader = contractDb.genDataReader(sqlStr); while (oleReader.Read()) { cbxMaKH.Items.Add(oleReader[0].ToString()); } cbxMaKH.Text = cbxMaKH.Items[0].ToString(); sqlStr = "SELECT [LaiSuat], [LoaiLS] FROM [LAISUAT]"; oleReader = contractDb.genDataReader(sqlStr); LSChovay = new ArrayList(); LSHuydong = new ArrayList(); while (oleReader.Read()) { if (oleReader["LoaiLS"].ToString() == "1") { LSChovay.Add(oleReader["LaiSuat"].ToString()); cbxLaisuat.Items.Add(oleReader["LaiSuat"].ToString()); } else { LSHuydong.Add(oleReader["LaiSuat"].ToString()); } } Create_List_CT(); return(true); } catch (Exception ex) { //MessageBox.Show(ex.Message); contractDb.close(); this.Close(); return(false); } }
public Boolean init(string dbname, string workingdir) { string sqlStr; OleDbDataReader oleReader; contractDb = new db(dbname); edit = false; laisuat = 0; MaHD = ""; HTTra = TraDinhKy; optTraDK.Checked = true; dbfile = dbname; frmNhapTN = new NhapKyTraNo(); frmNhapTN.saved = false; dirWork = workingdir; if (contractDb == null) { MessageBox.Show("Loi ket noi den database"); this.Close(); } sqlStr = "SELECT [MaKH] FROM [KHACHHANG] ORDER BY [MaKH]"; try { oleReader = contractDb.genDataReader(sqlStr); while (oleReader.Read()) { cbxMaKH.Items.Add(oleReader[0].ToString()); } cbxMaKH.Text = cbxMaKH.Items[0].ToString(); sqlStr = "SELECT [LaiSuat], [LoaiLS] FROM [LAISUAT]"; oleReader = contractDb.genDataReader(sqlStr); LSChovay = new ArrayList(); LSHuydong = new ArrayList(); while (oleReader.Read()) { if (oleReader["LoaiLS"].ToString() == "1") { LSChovay.Add(oleReader["LaiSuat"].ToString()); cbxLaisuat.Items.Add(oleReader["LaiSuat"].ToString()); } else LSHuydong.Add(oleReader["LaiSuat"].ToString()); } Create_List_CT(); return true; } catch (Exception ex) { //MessageBox.Show(ex.Message); contractDb.close(); this.Close(); return false; } }
public void init(string dbname, string maHD, string workingdir) { string sqlStr; OleDbDataReader oleReader; contractDb = new db(dbname); Int64 tongtien = 0; int i; MaHD = maHD; edit = true; dbfile = dbname; txtMaHD.Text = maHD; txtMaHD.Enabled = false; cmdKytraShow.Enabled = false; frmNhapTN = new NhapKyTraNo(dbname); frmNhapTN.saved = false; cmdViewContracts.Enabled = true; cmdViewContracts.Visible = true; dirWork = workingdir; if (contractDb == null) { MessageBox.Show("Loi ket noi den database"); this.Close(); } sqlStr = "SELECT [MaKH] FROM [KHACHHANG] ORDER BY [MaKH]"; oleReader = contractDb.genDataReader(sqlStr); while (oleReader.Read()) { cbxMaKH.Items.Add(oleReader[0].ToString()); } sqlStr = "SELECT [MaKH], [NgayHD], [Tongtien], [Real], [Kyhan], [DonVT], [Laisuat], [Desc] FROM [HOPDONG]"; sqlStr = sqlStr + " WHERE [MaHD] = '" + maHD + "'"; try { oleReader = contractDb.genDataReader(sqlStr); while (oleReader.Read()) { cbxMaKH.Text = oleReader["MaKH"].ToString(); cbxMaKH.Enabled = false; tongtien = Int64.Parse(oleReader["Tongtien"].ToString()); cbxKyhan.Text = oleReader["Kyhan"].ToString(); cbxKyhan.Enabled = false; cbxDonvitinh.Text = oleReader["DonVT"].ToString(); cbxDonvitinh.Enabled = false; chkReal.Checked = !(Boolean.Parse(oleReader["Real"].ToString())); cbxDateContracts.Value = DateTime.Parse(oleReader["NgayHD"].ToString()); cbxDateContracts.Enabled = false; txtDesc.Text = oleReader["Desc"].ToString(); laisuat = int.Parse(oleReader["Laisuat"].ToString()); cbxLaisuat.Text = float.Parse(laisuat.ToString()) / 100 + ""; oldLS = cbxLaisuat.Text; // cbxLaisuat.Enabled = false; } if (chkReal.Checked == false) { chkReal.Enabled = false; } if (tongtien > 0) { cbxLoaiHD.Text = cbxLoaiHD.Items[1].ToString(); txtTongtien.Text = tongtien.ToString(); } else { cbxLoaiHD.Text = cbxLoaiHD.Items[0].ToString(); tongtien = Math.Abs(tongtien); txtTongtien.Text = tongtien.ToString(); } txtTongtien.Enabled = false; cbxLoaiHD.Enabled = false; // cbxMaKH.Text = cbxMaKH.Items[0].ToString(); grBoxKytra.Enabled = false; sqlStr = "SELECT [LaiSuat], [LoaiLS] FROM [LAISUAT]"; oleReader = contractDb.genDataReader(sqlStr); LSChovay = new ArrayList(); LSHuydong = new ArrayList(); while (oleReader.Read()) { if (oleReader["LoaiLS"].ToString() == "1") { LSChovay.Add(oleReader["LaiSuat"].ToString()); cbxLaisuat.Items.Add(oleReader["LaiSuat"].ToString()); } else { LSHuydong.Add(oleReader["LaiSuat"].ToString()); } } Create_List_CT(); } catch (Exception ex) { MessageBox.Show(ex.Message); contractDb.close(); this.Close(); } }
public void init(string dbname, string maHD, string workingdir) { string sqlStr; OleDbDataReader oleReader; contractDb = new db(dbname); Int64 tongtien = 0; int i; MaHD = maHD; edit = true; dbfile = dbname; txtMaHD.Text = maHD; txtMaHD.Enabled = false; cmdKytraShow.Enabled = false; frmNhapTN = new NhapKyTraNo(dbname); frmNhapTN.saved = false; cmdViewContracts.Enabled = true; cmdViewContracts.Visible = true; dirWork = workingdir; if (contractDb == null) { MessageBox.Show("Loi ket noi den database"); this.Close(); } sqlStr = "SELECT [MaKH] FROM [KHACHHANG] ORDER BY [MaKH]"; oleReader = contractDb.genDataReader(sqlStr); while (oleReader.Read()) { cbxMaKH.Items.Add(oleReader[0].ToString()); } sqlStr = "SELECT [MaKH], [NgayHD], [Tongtien], [Real], [Kyhan], [DonVT], [Laisuat], [Desc] FROM [HOPDONG]"; sqlStr = sqlStr + " WHERE [MaHD] = '" + maHD + "'"; try { oleReader = contractDb.genDataReader(sqlStr); while (oleReader.Read()) { cbxMaKH.Text = oleReader["MaKH"].ToString(); cbxMaKH.Enabled = false; tongtien = Int64.Parse(oleReader["Tongtien"].ToString()); cbxKyhan.Text = oleReader["Kyhan"].ToString(); cbxKyhan.Enabled = false; cbxDonvitinh.Text = oleReader["DonVT"].ToString(); cbxDonvitinh.Enabled = false; chkReal.Checked = !(Boolean.Parse(oleReader["Real"].ToString())); cbxDateContracts.Value = DateTime.Parse(oleReader["NgayHD"].ToString()); cbxDateContracts.Enabled = false; txtDesc.Text = oleReader["Desc"].ToString(); laisuat = int.Parse(oleReader["Laisuat"].ToString()); cbxLaisuat.Text = float.Parse(laisuat.ToString()) / 100 + ""; oldLS = cbxLaisuat.Text; // cbxLaisuat.Enabled = false; } if (chkReal.Checked == false) chkReal.Enabled = false; if (tongtien > 0) { cbxLoaiHD.Text = cbxLoaiHD.Items[1].ToString(); txtTongtien.Text = tongtien.ToString(); } else { cbxLoaiHD.Text = cbxLoaiHD.Items[0].ToString(); tongtien = Math.Abs(tongtien); txtTongtien.Text = tongtien.ToString(); } txtTongtien.Enabled = false; cbxLoaiHD.Enabled = false; // cbxMaKH.Text = cbxMaKH.Items[0].ToString(); grBoxKytra.Enabled = false; sqlStr = "SELECT [LaiSuat], [LoaiLS] FROM [LAISUAT]"; oleReader = contractDb.genDataReader(sqlStr); LSChovay = new ArrayList(); LSHuydong = new ArrayList(); while (oleReader.Read()) { if (oleReader["LoaiLS"].ToString() == "1") { LSChovay.Add(oleReader["LaiSuat"].ToString()); cbxLaisuat.Items.Add(oleReader["LaiSuat"].ToString()); } else LSHuydong.Add(oleReader["LaiSuat"].ToString()); } Create_List_CT(); } catch (Exception ex) { MessageBox.Show(ex.Message); contractDb.close(); this.Close(); } }