コード例 #1
0
 public void init(string dbfile, string Wdir, Boolean edit)
 {
     string sqlStr;
     OleDbDataReader oleReader;
     lstMaKH = new ArrayList();
     dbname = dbfile;
     ContractDB = new db(dbfile);
     workingdir = Wdir;
     sqlStr = "SELECT [MaHD], [MaKH], FORMAT([NgayHD], 'dd/mm/yyyy') AS NgayHD, [Tongtien], [Real], [Hoanthanh], [NoQH], [Laisuat]/100 AS LaiSuat, [Desc] FROM [HOPDONG] ORDER BY [MaHD]";
     FillDG(sqlStr);
     dtGridContracts.AllowUserToAddRows = false;
     sqlStr = "SELECT [MaKH], [TenKH] FROM [KHACHHANG]";
     oleReader = ContractDB.genDataReader(sqlStr);
     if (oleReader == null)
     {
         MessageBox.Show("Loi ket noi den database");
         return;
     }
     while (oleReader.Read())
     {
         cbxCusName.Items.Add(oleReader["TenKH"]);
         lstMaKH.Add(oleReader["MaKH"]);
     }
     cbxCusName.Items.Add("All");
     cbxCusName.Text = "All";
     nhapdulieu = edit;
     if (nhapdulieu == false)
         cmdAdd.Enabled = false;
     else cmdAdd.Enabled = true;
     chk_Denhan();
     //ShowDialog()
 }
コード例 #2
0
        public void init(string dbname, string wdir)
        {
            int i;
            Int64 tiendu;
            CashDB = new db(dbname);
            if (create_dtGrid() == false) return;
            if (FillDG() == false) return;
            dbfile = dbname;
            realdata = false;
            workingdir = wdir;
            for (i = 0; i < dtGridCash.Rows.Count; i++)
            {
                tiendu = Int64.Parse(dtGridCash.Rows[i].Cells["Tienvao"].Value.ToString());
                if (dtGridCash.Rows[i].Cells["Tienra"].Value != null)
                    tiendu = tiendu - Int64.Parse(dtGridCash.Rows[i].Cells["Tienra"].Value.ToString());
                dtGridCash.Rows[i].Cells["Ducuoi"].Value = tiendu;
            }
            Tinh_So_Du();
            for (i = 0; i < dtGridCash.Rows.Count; i++)
            {
                tiendu = Int64.Parse(dtGridCash.Rows[i].Cells["Ducuoi"].Value.ToString());
                if (tiendu < 0)
                {
                    dtGridCash.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                }
                if (tiendu > 1000000000)
                {
                    dtGridCash.Rows[i].DefaultCellStyle.BackColor = Color.Yellow;
                }
            }

            this.ShowDialog();
        }
コード例 #3
0
 public void init(string dbName)
 {
     string sqlStr;
     string matien, sotien;
     OleDbDataReader oleReader;
     CashDB = new db(dbName);
     sqlStr = "SELECT [Matien], [SoLuong] FROM [Tien]";
     oleReader = CashDB.genDataReader(sqlStr);
     if (oleReader == null)
         return;
     try
     {
         while (oleReader.Read())
         {
             matien = oleReader["Matien"].ToString();
             sotien = oleReader["SoLuong"].ToString();
             if (matien == "TienVon")
                 txtTienvon.Text = sotien;
             else if (matien == "Tienlai")
                 txtLai.Text = sotien;
             else txtTienmat.Text = sotien;
         }
         voncu = Int64.Parse(txtTienvon.Text);
     }
     catch (Exception ex)
     {
         //MessageBox.Show(ex.Message);
         return;
     }
 }
コード例 #4
0
        public void init(string database, string username)
        {
            DataSet ds;
            DataGridViewButtonColumn dtGridBt = new DataGridViewButtonColumn();
            datafile = database;
            dtGridUser.AllowUserToAddRows = true;
            int i, cullCount;
            string sqlString = "SELECT [Username] AS [Ten nguoi dung], [Locked] AS [Khoa] FROM [QUANLYUSER]";
            dbUser = new db(database);
            ds = dbUser.genDataset(sqlString);
            dtGridUser.DataSource = ds.Tables[0];
            dtGridBt.Width = 60;
            dtGridBt.Text = "Cap nhat";
            dtGridBt.Name = "capnhat";
            dtGridBt.UseColumnTextForButtonValue = true;
            for (i = 0; i < dtGridUser.Columns.Count; i++)
            {
                dtGridUser.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                dtGridUser.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;

            }
            dtGridUser.Columns.Add(dtGridBt);
            cullCount = dtGridUser.Columns.Count;
            for (i = 0; i < dtGridUser.Rows.Count; i++)
            {
                dtGridUser.Rows[i].Cells[cullCount - 1].Value = "Cap nhat";
            }
            dtGridUser.AllowUserToAddRows = false;
            if (username != "admin")
                cmdDelete.Enabled = false;
        }
コード例 #5
0
        public void init(string dbname, string ngaydt, Int64 soducu, Int64 dunocuoiky, Boolean real)
        {
            string sqlStrVG, sqlStrVL;
            string sqlStrRG, sqlStrRL;
            CashDB = new db(dbname);
            lblDunocu.Text = soducu.ToString();
            lblSoducuoi.Text = dunocuoiky.ToString();
            lblNgay.Text = ngaydt;
            sqlStrVG = "SELECT [MaDT], [Sotien], [MaHD], [NoQH], [Datra], [Real], [Mota] FROM [DONGTIEN] ";
            sqlStrVG = sqlStrVG + "WHERE [Sotien] > 0 AND FORMAT([Ngaytra], 'dd/mm/yyyy') = '" + lblNgay.Text + "'";
            if (realdata)
                sqlStrVG = sqlStrVG + "AND [Real] = Yes";
            FillDG(sqlStrVG, dtGridGIn);

            sqlStrVL = "SELECT [MaDT], [Sotienlai], [MaHD], [NoQH], [Datra], [Real], [Mota], [Tienchiulai], ([Laisuat] / 100) AS LaiSuat FROM [Tienlai] ";
            sqlStrVL = sqlStrVL + "WHERE [Sotienlai] > 0 AND FORMAT([Ngaytra], 'dd/mm/yyyy') = '" + lblNgay.Text + "'";
            if (realdata)
                sqlStrVL = sqlStrVL + "AND [Real] = Yes";
            FillDG(sqlStrVL, dtGridLIn);

            sqlStrRG = "SELECT [MaDT], ABS([Sotien]) AS Tientra, [MaHD], [NoQH], [Datra], [Real], [Mota] FROM [DONGTIEN] ";
            sqlStrRG = sqlStrRG + "WHERE [Sotien] < 0 AND FORMAT([Ngaytra], 'dd/mm/yyyy') = '" + lblNgay.Text + "'";
            if (realdata)
                sqlStrRG = sqlStrRG + "AND [Real] = Yes";
            FillDG(sqlStrRG, dtGridGOut);

            sqlStrRL = "SELECT [MaDT], ABS([Sotienlai]) AS Tienlaitra, [MaHD], [NoQH], [Datra], [Real], [Mota], [Tienchiulai], ([Laisuat] / 100) AS LaiSuat FROM [Tienlai] ";
            sqlStrRL = sqlStrRL + "WHERE [Sotienlai] < 0 AND FORMAT([Ngaytra], 'dd/mm/yyyy') = '" + lblNgay.Text + "'";
            if (realdata)
                sqlStrRL = sqlStrVL + "AND [Real] = Yes";
            FillDG(sqlStrRL, dtGridLOut);
            this.Show();
        }
コード例 #6
0
 /*
  * Init function using to create object db for Quanlykhachhang
  * And this function is using to import list custommer from database to form
  */
 public void init(string dbFile)
 {
     string sqlString;
     OleDbDataReader oleReader;
     string LoaiKH;
     int MaLoaiKH, i;
     DataGridViewButtonColumn dtGridBt = new DataGridViewButtonColumn();
     LoaiKHList = new ArrayList();
     QlkhDb = new db(dbFile);
     dbname = dbFile;
     sqlString = "SELECT [MaLoaiKH], [TenLoaiKH] FROM [LOAIKH]";
     dtGridKH.AllowUserToAddRows = true;
     try
     {
         oleReader = QlkhDb.genDataReader(sqlString);
         if (oleReader == null)
         {
             MessageBox.Show("Loi ket noi den database!");
             this.Close();
             return;
         }
         while(oleReader.Read())
         {
             MaLoaiKH = int.Parse(oleReader.GetValue(0).ToString());
             LoaiKH = oleReader.GetString(1);
             cbxLoaiKH.Items.Add(LoaiKH);
             LoaiKHList.Add(MaLoaiKH);
         }
         cbxLoaiKH.Items.Add("All");
         cbxLoaiKH.Text = cbxLoaiKH.Items[0].ToString();
         sqlString = "SELECT [MAKH], [TenKH], [TaikhoanNH], [TenNH], [DinhDanh],[SoDT], [Diachi] FROM [KHACHHANG]";
         QlkhDb.fillDtGridView(sqlString, dtGridKH);
         for (i =0; i < dtGridKH.Columns.Count; i++)
         {
             dtGridKH.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
         }
         for (i = 0; i < dtGridKH.Rows.Count; i++)
         {
             if (rowColor)
                 dtGridKH.Rows[i].DefaultCellStyle.BackColor = activeC;
             else dtGridKH.Rows[i].DefaultCellStyle.BackColor = NegativeC;
             rowColor = !rowColor;
         }
         dtGridBt.Text = "...";
         dtGridBt.Name = "Capnhat";
         dtGridBt.Width = 60;
         dtGridBt.HeaderText = "Cap nhat";
         dtGridBt.UseColumnTextForButtonValue = true;
         dtGridKH.Columns.Add(dtGridBt);
         dtGridKH.AllowUserToAddRows = false;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         QlkhDb.close();
         this.Close();
     }
 }
コード例 #7
0
 public void init(string dbname, string mahd, int intlaisuat)
 {
     CashDB = new db(dbname);
     txtMaHD.Text = mahd;
     laisuat = intlaisuat;
     txtLaisuat.Text = float.Parse(laisuat.ToString()) / 100 + "";
     dtGridCF.AllowUserToAddRows = false;
     Tinhlailai();
     dtGridCF.ReadOnly = true;
 }
コード例 #8
0
 public void init(string dbname, string cusId)
 {
     string sqlStr;
     OleDbDataReader oleReader;
     string tenKH, dinhdanh, ngaycap, noicap, SoDT, Diachi, TKNH, TenNH, MaLoaiKH;
     CusDb = new db(dbname);
     txtCusCode.Text = cusId;
     txtCusCode.Enabled = false;
     sqlStr = "SELECT [TenKH], [DinhDanh], [Ngaycap], [Noicap], [SoDT], [Diachi], [TaikhoanNH], [TenNH], [MaLoaiKH]";
     sqlStr = sqlStr + "FROM [KHACHHANG] WHERE [MaKH] ='" + cusId + "'";
     oleReader = CusDb.genDataReader(sqlStr);
     if (oleReader == null)
         return;
     if (oleReader.Read())
     {
         tenKH = oleReader["TenKH"].ToString();
         dinhdanh = oleReader["DinhDanh"].ToString();
         ngaycap = oleReader["Ngaycap"].ToString();
         noicap = oleReader["Noicap"].ToString();
         SoDT = oleReader["SoDT"].ToString();
         Diachi = oleReader["Diachi"].ToString();
         TKNH = oleReader["TaikhoanNH"].ToString();
         TenNH = oleReader["TenNH"].ToString();
         MaLoaiKH = oleReader["MaLoaiKH"].ToString();
         if (tenKH.Length > 0)
             this.txtCusName.Text = tenKH;
         if (dinhdanh.Length > 0)
             txtIdentCardNum.Text = dinhdanh;
         if (ngaycap.Length > 0)
             txtIssDate.Text = ngaycap;
         if (noicap.Length > 0)
             txtIssPlace.Text = noicap;
         if (SoDT.Length > 0)
             txtPhoneNum.Text = SoDT;
         if (Diachi.Length > 0)
             txtAddress.Text = Diachi;
         if (TKNH.Length > 0)
             txtAccount.Text = TKNH;
         if (tenKH.Length > 0)
             txtBank.Text = TenNH;
         if (check_loai_KH(int.Parse(MaLoaiKH)))
         {
             chkPhanloai.Checked = false;                //Khach hang doanh nghiep
             lblIdenti.Text = "So DKKD";
         }
         else                //Khach hang ca nhan
         {
             chkPhanloai.Checked = true;
             lblIdenti.Text = "So CMT";
         }
         this.Text = "Chinh sua thong tin nguoi dung";
         newuser = false;
     }
 }
コード例 #9
0
 public void init(string dbfilename, Boolean administrator)
 {
     dbName = dbfilename;
     hdbhData = new db(dbName);
     admin = administrator;
     if (admin)
     {
         txtUser.Text = "admin";
         txtUser.Enabled = false;
     }
 }
コード例 #10
0
 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;
     }
 }
コード例 #11
0
 public void init(string dbfile)
 {
     string sqlString, user;
     OleDbDataReader oleReader;
     useridlist = new ArrayList();
     dbFileName = dbfile;
     roledb = new db(dbFileName);
     sqlString = "SELECT DISTINCT UserName FROM [UserRole] WHERE RoleID <> 8";
     oleReader = roledb.genDataReader(sqlString);
     while (oleReader.Read())
     {
         user = oleReader.GetString(0);
         cbxUserName.Items.Add(user);
     }
     oleReader.Close();
     cbxUserName.Text = cbxUserName.Items[0].ToString();
 }
コード例 #12
0
        /*
         * Init function using to create object db for Quanlykhachhang
         * And this function is using to import list custommer from database to form
         */
        public void init(string dbFile, string dbuser, int dbport)
        {
            string sqlString;
            OleDbDataReader oleReader;
            string LoaiKH;
            int MaLoaiKH, i;
            LoaiKHList = new ArrayList();
            QlkhDb = new db(dbFile, dbuser, dbport);
            sqlString = "SELECT [MaLoaiKH], [LoaiKH] FROM [LOAIKH]";

            try
            {
                oleReader = QlkhDb.genDataReader(sqlString);
                if (oleReader == null)
                {
                    MessageBox.Show("Loi ket noi den database!");
                    this.Close();
                }
                while(oleReader.Read())
                {
                    MaLoaiKH = int.Parse(oleReader.GetValue(0).ToString());
                    LoaiKH = oleReader.GetString(1);
                    cbxLoaiKH.Items.Add(LoaiKH);
                    LoaiKHList.Add(MaLoaiKH);
                }
                cbxLoaiKH.Items.Add("All");
                cbxLoaiKH.Text = cbxLoaiKH.Items[0].ToString();
                sqlString = "SELECT [MAKH], [TenKH], [DinhDanh],[SoDT], [Diachi] FROM [KHACHHANG]";
                QlkhDb.fillDtGridView(sqlString, dtGridKH);
                for (i = 0; i < dtGridKH.Rows.Count; i++)
                {
                    if (rowColor)
                        dtGridKH.Rows[i].DefaultCellStyle.BackColor = activeC;
                    else dtGridKH.Rows[i].DefaultCellStyle.BackColor = NegativeC;
                    rowColor = !rowColor;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.Close();
            }
        }
コード例 #13
0
        public void init(string dbname, string ngaydt, Int64 soducu, Int64 dunocuoiky, Boolean real)
        {
            string sqlStrVG, sqlStrVL;
            string sqlStrRG, sqlStrRL;

            CashDB           = new db(dbname);
            lblDunocu.Text   = soducu.ToString();
            lblSoducuoi.Text = dunocuoiky.ToString();
            lblNgay.Text     = ngaydt;
            sqlStrVG         = "SELECT [MaDT], [Sotien], [MaHD], [NoQH], [Datra], [Real], [Mota] FROM [DONGTIEN] ";
            sqlStrVG         = sqlStrVG + "WHERE [Sotien] > 0 AND FORMAT([Ngaytra], 'dd/mm/yyyy') = '" + lblNgay.Text + "'";
            if (realdata)
            {
                sqlStrVG = sqlStrVG + "AND [Real] = Yes";
            }
            FillDG(sqlStrVG, dtGridGIn);

            sqlStrVL = "SELECT [MaDT], [Sotienlai], [MaHD], [NoQH], [Datra], [Real], [Mota], [Tienchiulai], ([Laisuat] / 100) AS LaiSuat FROM [Tienlai] ";
            sqlStrVL = sqlStrVL + "WHERE [Sotienlai] > 0 AND FORMAT([Ngaytra], 'dd/mm/yyyy') = '" + lblNgay.Text + "'";
            if (realdata)
            {
                sqlStrVL = sqlStrVL + "AND [Real] = Yes";
            }
            FillDG(sqlStrVL, dtGridLIn);

            sqlStrRG = "SELECT [MaDT], ABS([Sotien]) AS Tientra, [MaHD], [NoQH], [Datra], [Real], [Mota] FROM [DONGTIEN] ";
            sqlStrRG = sqlStrRG + "WHERE [Sotien] < 0 AND FORMAT([Ngaytra], 'dd/mm/yyyy') = '" + lblNgay.Text + "'";
            if (realdata)
            {
                sqlStrRG = sqlStrRG + "AND [Real] = Yes";
            }
            FillDG(sqlStrRG, dtGridGOut);

            sqlStrRL = "SELECT [MaDT], ABS([Sotienlai]) AS Tienlaitra, [MaHD], [NoQH], [Datra], [Real], [Mota], [Tienchiulai], ([Laisuat] / 100) AS LaiSuat FROM [Tienlai] ";
            sqlStrRL = sqlStrRL + "WHERE [Sotienlai] < 0 AND FORMAT([Ngaytra], 'dd/mm/yyyy') = '" + lblNgay.Text + "'";
            if (realdata)
            {
                sqlStrRL = sqlStrVL + "AND [Real] = Yes";
            }
            FillDG(sqlStrRL, dtGridLOut);
            this.Show();
        }
コード例 #14
0
        public void init(string dbname, string wdir)
        {
            int   i;
            Int64 tiendu;

            CashDB = new db(dbname);
            if (create_dtGrid() == false)
            {
                return;
            }
            if (FillDG() == false)
            {
                return;
            }
            dbfile     = dbname;
            realdata   = false;
            workingdir = wdir;
            for (i = 0; i < dtGridCash.Rows.Count; i++)
            {
                tiendu = Int64.Parse(dtGridCash.Rows[i].Cells["Tienvao"].Value.ToString());
                if (dtGridCash.Rows[i].Cells["Tienra"].Value != null)
                {
                    tiendu = tiendu - Int64.Parse(dtGridCash.Rows[i].Cells["Tienra"].Value.ToString());
                }
                dtGridCash.Rows[i].Cells["Ducuoi"].Value = tiendu;
            }
            Tinh_So_Du();
            for (i = 0; i < dtGridCash.Rows.Count; i++)
            {
                tiendu = Int64.Parse(dtGridCash.Rows[i].Cells["Ducuoi"].Value.ToString());
                if (tiendu < 0)
                {
                    dtGridCash.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                }
                if (tiendu > 1000000000)
                {
                    dtGridCash.Rows[i].DefaultCellStyle.BackColor = Color.Yellow;
                }
            }

            this.ShowDialog();
        }
コード例 #15
0
        public void init(string dbName)
        {
            string          sqlStr;
            string          matien, sotien;
            OleDbDataReader oleReader;

            CashDB    = new db(dbName);
            sqlStr    = "SELECT [Matien], [SoLuong] FROM [Tien]";
            oleReader = CashDB.genDataReader(sqlStr);
            if (oleReader == null)
            {
                return;
            }
            try
            {
                while (oleReader.Read())
                {
                    matien = oleReader["Matien"].ToString();
                    sotien = oleReader["SoLuong"].ToString();
                    if (matien == "TienVon")
                    {
                        txtTienvon.Text = sotien;
                    }
                    else if (matien == "Tienlai")
                    {
                        txtLai.Text = sotien;
                    }
                    else
                    {
                        txtTienmat.Text = sotien;
                    }
                }
                voncu = Int64.Parse(txtTienvon.Text);
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
                return;
            }
        }
コード例 #16
0
        private void MainPoint_Load(object sender, EventArgs e)
        {
            string          sqlString;
            OleDbDataReader oleReader;

            config();
            userdb    = new db(dbFileName);
            sqlString = "SELECT * FROM QUANLYUSER WHERE [Username] = 'admin'";
            oleReader = userdb.genDataReader(sqlString);
            if (oleReader == null)
            {
                this.Close();
                Application.Exit();
                return;
            }
            if (!oleReader.Read())
            {
                CreateUser frmCreateUser = new CreateUser();
                frmCreateUser.Text = "Khoi tao user admin cho he thong";
                frmCreateUser.init(dbFileName, true);
                frmCreateUser.ShowDialog();
                if (frmCreateUser.created == false)
                {
                    this.Close();
                }
                return;
            }
            Login frmLogin = new Login();

            frmLogin.init(dbFileName);
            frmLogin.ShowDialog();
            if (frmLogin.logined == false)
            {
                this.Close();
            }
            username = frmLogin.user;
            check_role(username);
//            userdb.Batch_Process();
        }
コード例 #17
0
        public void init(string dbname, Boolean real, int namtien, Int64 sodu, string wdir)
        {
            int   i;
            Int64 tiendu;

            CashDB   = new db(dbname);
            nam      = namtien;
            realdata = real;
            create_dtGrid();
            FillDG();
            lblNam.Text = namtien.ToString();
            dbfile      = dbname;
            workingdir  = wdir;
            for (i = 0; i < dtGridCash.Rows.Count; i++)
            {
                dtGridCash.Rows[i].Cells["Ducuoi"].Value = Int64.Parse(dtGridCash.Rows[i].Cells["Tienvao"].Value.ToString()) - Int64.Parse(dtGridCash.Rows[i].Cells["Tienra"].Value.ToString());
            }
            dtGridCash.Rows[0].Cells["Ducuoi"].Value = Int64.Parse(dtGridCash.Rows[0].Cells["Ducuoi"].Value.ToString()) + sodu;
            dunamtruoc   = sodu;
            lblDuno.Text = dunamtruoc.ToString();
            Tinh_So_Du();

            //Dua ra nguong canh bao voi dong tien
            for (i = 0; i < dtGridCash.Rows.Count; i++)
            {
                tiendu = Int64.Parse(dtGridCash.Rows[i].Cells["Ducuoi"].Value.ToString());
                if (tiendu < 0)
                {
                    dtGridCash.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                }
                if (tiendu > 1000000000)
                {
                    dtGridCash.Rows[i].DefaultCellStyle.BackColor = Color.Yellow;
                }
            }

            this.ShowDialog();
        }
コード例 #18
0
        public void init(string dbfile, string Wdir, Boolean edit)
        {
            string          sqlStr;
            OleDbDataReader oleReader;

            lstMaKH    = new ArrayList();
            dbname     = dbfile;
            ContractDB = new db(dbfile);
            workingdir = Wdir;
            sqlStr     = "SELECT [MaHD], [MaKH], FORMAT([NgayHD], 'dd/mm/yyyy') AS NgayHD, [Tongtien], [Real], [Hoanthanh], [NoQH], [Laisuat]/100 AS LaiSuat, [Desc] FROM [HOPDONG] ORDER BY [MaHD]";
            FillDG(sqlStr);
            dtGridContracts.AllowUserToAddRows = false;
            sqlStr    = "SELECT [MaKH], [TenKH] FROM [KHACHHANG]";
            oleReader = ContractDB.genDataReader(sqlStr);
            if (oleReader == null)
            {
                MessageBox.Show("Loi ket noi den database");
                return;
            }
            while (oleReader.Read())
            {
                cbxCusName.Items.Add(oleReader["TenKH"]);
                lstMaKH.Add(oleReader["MaKH"]);
            }
            cbxCusName.Items.Add("All");
            cbxCusName.Text = "All";
            nhapdulieu      = edit;
            if (nhapdulieu == false)
            {
                cmdAdd.Enabled = false;
            }
            else
            {
                cmdAdd.Enabled = true;
            }
            chk_Denhan();
            //ShowDialog()
        }
コード例 #19
0
        public void init(string dbname, Boolean real, int namtien, Int64 sodu, string wdir)
        {
            int i;
            Int64 tiendu;
            CashDB = new db(dbname);
            nam = namtien;
            realdata = real;
            create_dtGrid();
            FillDG();
            lblNam.Text = namtien.ToString();
            dbfile = dbname;
            workingdir = wdir;
            for (i = 0; i < dtGridCash.Rows.Count; i++)
            {
                dtGridCash.Rows[i].Cells["Ducuoi"].Value = Int64.Parse(dtGridCash.Rows[i].Cells["Tienvao"].Value.ToString()) - Int64.Parse(dtGridCash.Rows[i].Cells["Tienra"].Value.ToString());
            }
            dtGridCash.Rows[0].Cells["Ducuoi"].Value = Int64.Parse(dtGridCash.Rows[0].Cells["Ducuoi"].Value.ToString()) + sodu;
            dunamtruoc = sodu;
            lblDuno.Text = dunamtruoc.ToString();
            Tinh_So_Du();

            //Dua ra nguong canh bao voi dong tien
            for (i = 0; i < dtGridCash.Rows.Count; i++)
            {
                tiendu = Int64.Parse(dtGridCash.Rows[i].Cells["Ducuoi"].Value.ToString());
                if (tiendu < 0)
                {
                    dtGridCash.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                }
                if (tiendu > 1000000000)
                {
                    dtGridCash.Rows[i].DefaultCellStyle.BackColor = Color.Yellow;
                }
            }

            this.ShowDialog();
        }
コード例 #20
0
        public void Save_Data(Boolean real, string MaHD, string dbname, Boolean chovay, int laisuat, double phiuythac)
        {
            string sqlStrG, sqlStrL, sqlStrP;
            string tientraG, tientraL;
            int i;
            int lephi;
            double lephiuythac_i, ngaychiulai, dunogoc;
            TimeSpan difDays;
            CashDB = new db(dbname);
            lephi = (int)(phiuythac * 100);
            for (i = 0; i < dtGridCF.Rows.Count; i++)
            {
                string ngaytra;
                ngaytra = dtGridCF.Rows[i].Cells["Ngaytra"].Value.ToString();
                tientraG = dtGridCF.Rows[i].Cells["Sotien"].Value.ToString();
                tientraL = dtGridCF.Rows[i].Cells["Tienlai"].Value.ToString();
                dunogoc = double.Parse(dtGridCF.Rows[i].Cells["Duno"].Value.ToString());
                if (chovay == false)
                {
                    tientraG = "-" + tientraG;
                    tientraL = "-" + tientraL;
                }
                sqlStrG = "INSERT INTO [DONGTIEN] ([MaHD], [NoQH], [Datra], [Real], [MoTa], [Sotien], [NgayTra]) ";
                sqlStrG = sqlStrG + "VALUES ('" + MaHD +"', No, No, " + real.ToString() + ", 'Tra goc ky " + (i+1).ToString();
                sqlStrG = sqlStrG + "', " + tientraG + ", '" + ngaytra + "')";

                sqlStrL = "INSERT INTO [TIENLAI] ([MaHD], [NoQH], [Datra], [Real], [MoTa], [Sotienlai], [NgayTra], [Tienchiulai], [Laisuat])";
                sqlStrL = sqlStrL + "VALUES ('" + MaHD + "', 0, No, " + real.ToString() + ", 'Tra lai ky " + (i+1).ToString();
                sqlStrL = sqlStrL + "', " + tientraL + ", '" + ngaytra + "', " + dtGridCF.Rows[i].Cells["Duno"].Value.ToString();
                sqlStrL = sqlStrL + ", " + laisuat + ")";
                CashDB.runSQLCmd(sqlStrG);
                CashDB.runSQLCmd(sqlStrL);

                if (chovay == false)
                {
                    difDays = DateTime.Parse(this.ngaytra).Subtract(DateTime.Parse(ngayvay));
                    ngaychiulai = (double)(difDays.Days);
                    lephiuythac_i = (double)Math.Round((decimal)(ngaychiulai * phiuythac * dunogoc) / (360 * 100));
                    sqlStrP = "INSERT INTO [TIENLAI] ([MaHD], NoQH, [Datra], [Real], [Mota], [Sotienlai], [Ngaytra], [Tienchiulai], [Laisuat]) VALUES";
                    sqlStrP = sqlStrP + "('" + MaHD + "', 0, No, " + real.ToString() + ", 'Phi uy thac quan ly von', ";
                    sqlStrP = sqlStrP + lephiuythac_i.ToString() + ", '" + ngaytra + "', " + Math.Abs(tongtien) + ", " + lephi.ToString() + ")";
                    CashDB.runSQLCmd(sqlStrP);
                }

            }

            //Neu la tien cho vay phi se duoc tinh dua tren so tien gui ban dau

            if (chovay == true)
            {
                difDays = DateTime.Parse(this.ngaytra).Subtract(DateTime.Parse(ngayvay));
                ngaychiulai = (double)(difDays.Days);
                lephiuythac_i = (double)Math.Round((decimal)(ngaychiulai * phiuythac * tongtien) / (360 * 100));
                lephiuythac_i = Math.Abs(lephiuythac_i);
                try
                {
                    sqlStrP = "INSERT INTO [TIENLAI] ([MaHD], [NoQH], [Datra], [Real], [Mota], [Sotienlai], [Ngaytra], [Tienchiulai], [Laisuat]) VALUES";
                    sqlStrP = sqlStrP + "('" + MaHD + "', 0, No, " + real.ToString() + ", 'Phi dich vu cho vay bang', ";
                    sqlStrP = sqlStrP + lephiuythac_i.ToString() + ", '" + ngaytra + "', " + Math.Abs(tongtien) + ", " + lephi.ToString() + ")";
                    CashDB.runSQLCmd(sqlStrP);
                }
                catch (Exception ex)
                {
                    return;
                }
            }
            CashDB.close();
        }
コード例 #21
0
 public void init(string user, string dbfile)
 {
     username = user;
     pwddb    = new db(dbfile);
 }
コード例 #22
0
 public NhapKyTraNo(string dbname)
 {
     InitializeComponent();
     CashDB = new db(dbname);
 }
コード例 #23
0
 public void init(string dbname)
 {
     CusDb               = new db(dbname);
     newuser             = true;
     chkPhanloai.Checked = true;
 }
コード例 #24
0
 public void init(string dbfilename, string dbuser, int dbport)
 {
     dbName   = dbfilename;
     hdbhData = new db(dbName, dbuser, dbport);
 }
コード例 #25
0
 public void init(string user, string dbfile, string dbuser, int dbport)
 {
     username = user;
     pwddb    = new db(dbfile, dbuser, dbport);
 }
コード例 #26
0
        public void init(string mahd, string dbname)
        {
            string          sqlStrG, sqlStrL, sqlStr;
            string          matien;
            OleDbDataReader oleReader;

            Mahd = mahd;
            int i;

            try
            {
                CashDB       = new db(dbname);
                DatraG       = new ArrayList();
                DatraL       = new ArrayList();
                KytraG       = new ArrayList();
                KytraL       = new ArrayList();
                txtMaHD.Text = mahd;
                sqlStr       = "SELECT [SoLuong], [MaTien] FROM [TIEN]";
                oleReader    = CashDB.genDataReader(sqlStr);
                if (oleReader == null)
                {
                    return;
                }
                while (oleReader.Read())
                {
                    matien = oleReader["Matien"].ToString();
                    if (matien == "TongTien")
                    {
                        tienmat = Int64.Parse(oleReader["SoLuong"].ToString());
                    }
                    if (matien == "Tienlai")
                    {
                        tienlai = Int64.Parse(oleReader["SoLuong"].ToString());
                    }
                }
                sqlStrG = "SELECT [MaDT], [Sotien], FORMAT([NgayTra], 'dd/mm/yyyy') AS Ngaytratien, [NoQH], [Datra], [Real] FROM [DONGTIEN] WHERE [MaHD] ='" + mahd + "'";
                sqlStrL = "SELECT [MaDT], [Sotienlai], FORMAT([NgayTra], 'dd/mm/yyyy') AS Ngaytratien, [NoQH], [Datra], [Real] FROM [TIENLAI] WHERE [MaHD] ='" + mahd + "'";
                FillDG(sqlStrG, ref dtGridCFG);
                FillDG(sqlStrL, ref dtGridCFL);

                if (dtGridCFL.Rows.Count == 0)
                {
                    return;
                }
                if (dtGridCFG.Rows.Count == 0)
                {
                    return;
                }
                dtGridCFL.Columns["MaDT"].ReadOnly        = true;
                dtGridCFL.Columns["Sotienlai"].ReadOnly   = true;
                dtGridCFL.Columns["Real"].ReadOnly        = true;
                dtGridCFL.Columns["Ngaytratien"].ReadOnly = true;
                dtGridCFL.Columns["NoQH"].ReadOnly        = true;

                dtGridCFG.Columns["MaDT"].ReadOnly        = true;
                dtGridCFG.Columns["Sotien"].ReadOnly      = true;
                dtGridCFG.Columns["Real"].ReadOnly        = true;
                dtGridCFG.Columns["Ngaytratien"].ReadOnly = true;
                dtGridCFG.Columns["NoQH"].ReadOnly        = true;

                for (i = 0; i < dtGridCFL.Rows.Count; i++)
                {
                    DateTime ngaytralai = DateTime.Parse(dtGridCFL.Rows[i].Cells["Ngaytratien"].Value.ToString());
                    TimeSpan difDay     = ngaytralai.Subtract(DateTime.Today);
                    if ((dtGridCFL.Rows[i].Cells["Datra"].Value.ToString() == "True") || (difDay.Days > 0))
                    {
                        KytraL.Add("False");
                    }
                    else
                    {
                        KytraL.Add("True");
                    }

                    if (dtGridCFL.Rows[i].Cells["Datra"].Value.ToString() == "True")
                    {
                        DatraL.Add("True");
                    }
                    else
                    {
                        DatraL.Add("False");
                    }
                }

                for (i = 0; i < dtGridCFG.Rows.Count; i++)
                {
                    DateTime ngaytralai = DateTime.Parse(dtGridCFG.Rows[i].Cells["Ngaytratien"].Value.ToString());
                    TimeSpan difDay     = ngaytralai.Subtract(DateTime.Today);
                    if ((dtGridCFG.Rows[i].Cells["Datra"].Value.ToString() == "True") || (difDay.Days > 0))
                    {
                        KytraG.Add("False");
                    }
                    else
                    {
                        KytraG.Add("True");
                    }

                    if (dtGridCFG.Rows[i].Cells["Datra"].Value.ToString() == "True")
                    {
                        DatraG.Add("True");
                    }
                    else
                    {
                        DatraG.Add("False");
                    }
                }
                this.ShowDialog();
            }
            catch (Exception ex)
            {
                return;
            }
        }
コード例 #27
0
 public void init(string user, string dbfile, string dbuser, int dbport)
 {
     username = user;
     pwddb = new db(dbfile, dbuser, dbport);
 }
コード例 #28
0
 public void init(string dbfilename, string dbuser, int dbport, Boolean administrator)
 {
     dbName = dbfilename;
     hdbhData = new db(dbName, dbuser, dbport);
     admin = administrator;
 }
コード例 #29
0
        public void Save_Data(Boolean real, string MaHD, string dbname, Boolean chovay, int laisuat, double phiuythac)
        {
            string   sqlStrG, sqlStrL, sqlStrP;
            string   tientraG, tientraL;
            int      i;
            int      lephi;
            double   lephiuythac_i, ngaychiulai, dunogoc;
            TimeSpan difDays;

            CashDB = new db(dbname);
            lephi  = (int)(phiuythac * 100);
            for (i = 0; i < dtGridCF.Rows.Count; i++)
            {
                string ngaytra;
                ngaytra  = dtGridCF.Rows[i].Cells["Ngaytra"].Value.ToString();
                tientraG = dtGridCF.Rows[i].Cells["Sotien"].Value.ToString();
                tientraL = dtGridCF.Rows[i].Cells["Tienlai"].Value.ToString();
                dunogoc  = double.Parse(dtGridCF.Rows[i].Cells["Duno"].Value.ToString());
                if (chovay == false)
                {
                    tientraG = "-" + tientraG;
                    tientraL = "-" + tientraL;
                }
                sqlStrG = "INSERT INTO [DONGTIEN] ([MaHD], [NoQH], [Datra], [Real], [MoTa], [Sotien], [NgayTra]) ";
                sqlStrG = sqlStrG + "VALUES ('" + MaHD + "', No, No, " + real.ToString() + ", 'Tra goc ky " + (i + 1).ToString();
                sqlStrG = sqlStrG + "', " + tientraG + ", '" + ngaytra + "')";

                sqlStrL = "INSERT INTO [TIENLAI] ([MaHD], [NoQH], [Datra], [Real], [MoTa], [Sotienlai], [NgayTra], [Tienchiulai], [Laisuat])";
                sqlStrL = sqlStrL + "VALUES ('" + MaHD + "', 0, No, " + real.ToString() + ", 'Tra lai ky " + (i + 1).ToString();
                sqlStrL = sqlStrL + "', " + tientraL + ", '" + ngaytra + "', " + dtGridCF.Rows[i].Cells["Duno"].Value.ToString();
                sqlStrL = sqlStrL + ", " + laisuat + ")";
                CashDB.runSQLCmd(sqlStrG);
                CashDB.runSQLCmd(sqlStrL);

                if (chovay == false)
                {
                    difDays       = DateTime.Parse(this.ngaytra).Subtract(DateTime.Parse(ngayvay));
                    ngaychiulai   = (double)(difDays.Days);
                    lephiuythac_i = (double)Math.Round((decimal)(ngaychiulai * phiuythac * dunogoc) / (360 * 100));
                    sqlStrP       = "INSERT INTO [TIENLAI] ([MaHD], NoQH, [Datra], [Real], [Mota], [Sotienlai], [Ngaytra], [Tienchiulai], [Laisuat]) VALUES";
                    sqlStrP       = sqlStrP + "('" + MaHD + "', 0, No, " + real.ToString() + ", 'Phi uy thac quan ly von', ";
                    sqlStrP       = sqlStrP + lephiuythac_i.ToString() + ", '" + ngaytra + "', " + Math.Abs(tongtien) + ", " + lephi.ToString() + ")";
                    CashDB.runSQLCmd(sqlStrP);
                }
            }

            //Neu la tien cho vay phi se duoc tinh dua tren so tien gui ban dau

            if (chovay == true)
            {
                difDays       = DateTime.Parse(this.ngaytra).Subtract(DateTime.Parse(ngayvay));
                ngaychiulai   = (double)(difDays.Days);
                lephiuythac_i = (double)Math.Round((decimal)(ngaychiulai * phiuythac * tongtien) / (360 * 100));
                lephiuythac_i = Math.Abs(lephiuythac_i);
                try
                {
                    sqlStrP = "INSERT INTO [TIENLAI] ([MaHD], [NoQH], [Datra], [Real], [Mota], [Sotienlai], [Ngaytra], [Tienchiulai], [Laisuat]) VALUES";
                    sqlStrP = sqlStrP + "('" + MaHD + "', 0, No, " + real.ToString() + ", 'Phi dich vu cho vay bang', ";
                    sqlStrP = sqlStrP + lephiuythac_i.ToString() + ", '" + ngaytra + "', " + Math.Abs(tongtien) + ", " + lephi.ToString() + ")";
                    CashDB.runSQLCmd(sqlStrP);
                }
                catch (Exception ex)
                {
                    return;
                }
            }
            CashDB.close();
        }
コード例 #30
0
        public void init(string dbname, string cusId)
        {
            string          sqlStr;
            OleDbDataReader oleReader;
            string          tenKH, dinhdanh, ngaycap, noicap, SoDT, Diachi, TKNH, TenNH, MaLoaiKH;

            CusDb              = new db(dbname);
            txtCusCode.Text    = cusId;
            txtCusCode.Enabled = false;
            sqlStr             = "SELECT [TenKH], [DinhDanh], [Ngaycap], [Noicap], [SoDT], [Diachi], [TaikhoanNH], [TenNH], [MaLoaiKH]";
            sqlStr             = sqlStr + "FROM [KHACHHANG] WHERE [MaKH] ='" + cusId + "'";
            oleReader          = CusDb.genDataReader(sqlStr);
            if (oleReader == null)
            {
                return;
            }
            if (oleReader.Read())
            {
                tenKH    = oleReader["TenKH"].ToString();
                dinhdanh = oleReader["DinhDanh"].ToString();
                ngaycap  = oleReader["Ngaycap"].ToString();
                noicap   = oleReader["Noicap"].ToString();
                SoDT     = oleReader["SoDT"].ToString();
                Diachi   = oleReader["Diachi"].ToString();
                TKNH     = oleReader["TaikhoanNH"].ToString();
                TenNH    = oleReader["TenNH"].ToString();
                MaLoaiKH = oleReader["MaLoaiKH"].ToString();
                if (tenKH.Length > 0)
                {
                    this.txtCusName.Text = tenKH;
                }
                if (dinhdanh.Length > 0)
                {
                    txtIdentCardNum.Text = dinhdanh;
                }
                if (ngaycap.Length > 0)
                {
                    txtIssDate.Text = ngaycap;
                }
                if (noicap.Length > 0)
                {
                    txtIssPlace.Text = noicap;
                }
                if (SoDT.Length > 0)
                {
                    txtPhoneNum.Text = SoDT;
                }
                if (Diachi.Length > 0)
                {
                    txtAddress.Text = Diachi;
                }
                if (TKNH.Length > 0)
                {
                    txtAccount.Text = TKNH;
                }
                if (tenKH.Length > 0)
                {
                    txtBank.Text = TenNH;
                }
                if (check_loai_KH(int.Parse(MaLoaiKH)))
                {
                    chkPhanloai.Checked = false;                //Khach hang doanh nghiep
                    lblIdenti.Text      = "So DKKD";
                }
                else                //Khach hang ca nhan
                {
                    chkPhanloai.Checked = true;
                    lblIdenti.Text      = "So CMT";
                }
                this.Text = "Chinh sua thong tin nguoi dung";
                newuser   = false;
            }
        }
コード例 #31
0
 public void init(string dbname)
 {
     CusDb = new db(dbname);
     newuser = true;
     chkPhanloai.Checked = true;
 }
コード例 #32
0
        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();
            }
        }
コード例 #33
0
 public void init(string dbfilename, string dbuser, int dbport)
 {
     dbName = dbfilename;
     hdbhData = new db(dbName, dbuser, dbport);
 }
コード例 #34
0
 public void init(string dbfilename)
 {
     dbName   = dbfilename;
     hdbhData = new db(dbName);
 }
コード例 #35
0
 public void init(string dbfilename, string dbuser, int dbport, Boolean administrator)
 {
     dbName   = dbfilename;
     hdbhData = new db(dbName, dbuser, dbport);
     admin    = administrator;
 }
コード例 #36
0
        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();
            }
        }
コード例 #37
0
 public void init(string dbfilename)
 {
     dbName = dbfilename;
     hdbhData = new db(dbName);
 }
コード例 #38
0
 public NhapKyTraNo(string dbname)
 {
     InitializeComponent();
     CashDB = new db(dbname);
 }
コード例 #39
0
        /*
         * Init function using to create object db for Quanlykhachhang
         * And this function is using to import list custommer from database to form
         */
        public void init(string dbFile)
        {
            string                   sqlString;
            OleDbDataReader          oleReader;
            string                   LoaiKH;
            int                      MaLoaiKH, i;
            DataGridViewButtonColumn dtGridBt = new DataGridViewButtonColumn();

            LoaiKHList = new ArrayList();
            QlkhDb     = new db(dbFile);
            dbname     = dbFile;
            sqlString  = "SELECT [MaLoaiKH], [TenLoaiKH] FROM [LOAIKH]";
            dtGridKH.AllowUserToAddRows = true;
            try
            {
                oleReader = QlkhDb.genDataReader(sqlString);
                if (oleReader == null)
                {
                    MessageBox.Show("Loi ket noi den database!");
                    this.Close();
                    return;
                }
                while (oleReader.Read())
                {
                    MaLoaiKH = int.Parse(oleReader.GetValue(0).ToString());
                    LoaiKH   = oleReader.GetString(1);
                    cbxLoaiKH.Items.Add(LoaiKH);
                    LoaiKHList.Add(MaLoaiKH);
                }
                cbxLoaiKH.Items.Add("All");
                cbxLoaiKH.Text = cbxLoaiKH.Items[0].ToString();
                sqlString      = "SELECT [MAKH], [TenKH], [TaikhoanNH], [TenNH], [DinhDanh],[SoDT], [Diachi] FROM [KHACHHANG]";
                QlkhDb.fillDtGridView(sqlString, dtGridKH);
                for (i = 0; i < dtGridKH.Columns.Count; i++)
                {
                    dtGridKH.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                }
                for (i = 0; i < dtGridKH.Rows.Count; i++)
                {
                    if (rowColor)
                    {
                        dtGridKH.Rows[i].DefaultCellStyle.BackColor = activeC;
                    }
                    else
                    {
                        dtGridKH.Rows[i].DefaultCellStyle.BackColor = NegativeC;
                    }
                    rowColor = !rowColor;
                }
                dtGridBt.Text       = "...";
                dtGridBt.Name       = "Capnhat";
                dtGridBt.Width      = 60;
                dtGridBt.HeaderText = "Cap nhat";
                dtGridBt.UseColumnTextForButtonValue = true;
                dtGridKH.Columns.Add(dtGridBt);
                dtGridKH.AllowUserToAddRows = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                QlkhDb.close();
                this.Close();
            }
        }
コード例 #40
0
 private void MainPoint_Load(object sender, EventArgs e)
 {
     string sqlString;
     OleDbDataReader oleReader;
     config();
     userdb = new db(dbFileName, dbuser, dbport);
     sqlString = "SELECT * FROM QUANLYUSER";
     oleReader = userdb.genDataReader(sqlString);
     if (oleReader == null)
     {
         this.Close();
         Application.Exit();
         return;
     }
     if (!oleReader.Read())
     {
         CreateUser frmCreateUser = new CreateUser();
         frmCreateUser.Text = "Khoi tao user admin cho he thong";
         frmCreateUser.init(dbFileName, dbuser, dbport, true);
         frmCreateUser.ShowDialog();
         if (frmCreateUser.created == false)
             this.Close();
         return;
     }
     Login frmLogin = new Login();
     frmLogin.init(dbFileName, dbuser, dbport);
     frmLogin.ShowDialog();
     if (frmLogin.logined == false)
         this.Close();
     username = frmLogin.user;
     check_role(username);
 }
コード例 #41
0
        public void init(string mahd, string dbname)
        {
            string sqlStrG, sqlStrL, sqlStr;
            string matien;
            OleDbDataReader oleReader;
            Mahd = mahd;
            int i;
            try
            {
                CashDB = new db(dbname);
                DatraG = new ArrayList();
                DatraL = new ArrayList();
                KytraG = new ArrayList();
                KytraL = new ArrayList();
                txtMaHD.Text = mahd;
                sqlStr = "SELECT [SoLuong], [MaTien] FROM [TIEN]";
                oleReader = CashDB.genDataReader(sqlStr);
                if (oleReader == null)
                    return;
                while (oleReader.Read())
                {
                    matien = oleReader["Matien"].ToString();
                    if (matien == "TongTien")
                        tienmat = Int64.Parse(oleReader["SoLuong"].ToString());
                    if (matien == "Tienlai") tienlai = Int64.Parse(oleReader["SoLuong"].ToString());
                }
                sqlStrG = "SELECT [MaDT], [Sotien], FORMAT([NgayTra], 'dd/mm/yyyy') AS Ngaytratien, [NoQH], [Datra], [Real] FROM [DONGTIEN] WHERE [MaHD] ='" + mahd + "'";
                sqlStrL = "SELECT [MaDT], [Sotienlai], FORMAT([NgayTra], 'dd/mm/yyyy') AS Ngaytratien, [NoQH], [Datra], [Real] FROM [TIENLAI] WHERE [MaHD] ='" + mahd + "'";
                FillDG(sqlStrG, ref dtGridCFG);
                FillDG(sqlStrL, ref dtGridCFL);

                if (dtGridCFL.Rows.Count == 0)
                    return;
                if (dtGridCFG.Rows.Count == 0)
                    return;
                dtGridCFL.Columns["MaDT"].ReadOnly = true;
                dtGridCFL.Columns["Sotienlai"].ReadOnly = true;
                dtGridCFL.Columns["Real"].ReadOnly = true;
                dtGridCFL.Columns["Ngaytratien"].ReadOnly = true;
                dtGridCFL.Columns["NoQH"].ReadOnly = true;

                dtGridCFG.Columns["MaDT"].ReadOnly = true;
                dtGridCFG.Columns["Sotien"].ReadOnly = true;
                dtGridCFG.Columns["Real"].ReadOnly = true;
                dtGridCFG.Columns["Ngaytratien"].ReadOnly = true;
                dtGridCFG.Columns["NoQH"].ReadOnly = true;

                for (i = 0; i < dtGridCFL.Rows.Count; i++)
                {
                    DateTime ngaytralai = DateTime.Parse(dtGridCFL.Rows[i].Cells["Ngaytratien"].Value.ToString());
                    TimeSpan difDay = ngaytralai.Subtract(DateTime.Today);
                    if ((dtGridCFL.Rows[i].Cells["Datra"].Value.ToString() == "True") || (difDay.Days > 0))
                    {
                        KytraL.Add("False");
                    }
                    else KytraL.Add("True");

                    if (dtGridCFL.Rows[i].Cells["Datra"].Value.ToString() == "True")
                        DatraL.Add("True");
                    else DatraL.Add("False");

                }

                for (i = 0; i < dtGridCFG.Rows.Count; i++)
                {
                    DateTime ngaytralai = DateTime.Parse(dtGridCFG.Rows[i].Cells["Ngaytratien"].Value.ToString());
                    TimeSpan difDay = ngaytralai.Subtract(DateTime.Today);
                    if ((dtGridCFG.Rows[i].Cells["Datra"].Value.ToString() == "True") || (difDay.Days > 0))
                    {
                        KytraG.Add("False");
                    }
                    else
                    {
                        KytraG.Add("True");
                    }

                    if (dtGridCFG.Rows[i].Cells["Datra"].Value.ToString() == "True")
                    {
                        DatraG.Add("True");
                    }
                    else DatraG.Add("False");
                }
                this.ShowDialog();
            }
            catch (Exception ex)
            {
                return;
            }
        }