コード例 #1
0
ファイル: TaiKhoan.cs プロジェクト: mrk29vn/vna-accounting
        public bool deleteTaiKhoan(Entities.TaiKhoan tk1)
        {
            try
            {
                bool kt = false;
                tk = new Constants.TaiKhoan();
                Sql = new Constants.Sql();
                string sql = Sql.deleteTaiKhoan;
                Connection conn = new Connection();
                SqlConnection cn = conn.openConnection();
                SqlCommand cmd = new SqlCommand(sql, cn);

                cmd.Parameters.Add(tk.TenDangNhap, SqlDbType.VarChar, 200).Value = tk1.TenDangNhap;

                int i = cmd.ExecuteNonQuery();
                if (i >= 0)
                    kt = true;
                else
                    kt = false;
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
                cn = null;
                conn = null;
                return kt;
            }
            catch (Exception ex)
            {
                string s = ex.Message;
                return false;
            }
        }
コード例 #2
0
ファイル: TaiKhoan.cs プロジェクト: mrk29vn/vna-accounting
 /// <summary>
 /// khoi tao gia tri
 /// </summary>
 public TaiKhoan()
 {
     tk = null;
     Sql = null;
     conn = null;
     cmd = null;
     arr = null;
     dr = null;
     taikhoan = null;
     cn = null;
 }
コード例 #3
0
ファイル: TaiKhoan.cs プロジェクト: mrk29vn/vna-accounting
        public bool insertTaiKhoan(Entities.TaiKhoan tk1)
        {
            try
            {
                bool kt = false;
                tk = new Constants.TaiKhoan();
                Sql = new Constants.Sql();
                string sql = Sql.insertTaiKhoan;
                Connection conn = new Connection();
                SqlConnection cn = conn.openConnection();
                SqlCommand cmd = new SqlCommand(sql, cn);

                cmd.Parameters.Add(tk.TenDangNhap, SqlDbType.VarChar, 200).Value = tk1.TenDangNhap;
                cmd.Parameters.Add(tk.MatKhauDangNhap, SqlDbType.VarChar, 200).Value = tk1.MatKhauDangNhap;
                cmd.Parameters.Add(tk.KhoaTaiKhoan, SqlDbType.Bit).Value = tk1.KhoaTaiKhoan;
                cmd.Parameters.Add(tk.NhanVienID, SqlDbType.VarChar, 20).Value = tk1.NhanVienID;
                cmd.Parameters.Add(tk.Administrator, SqlDbType.VarChar, 20).Value = tk1.Administrator;
                cmd.Parameters.Add(tk.TenNhomQuyen, SqlDbType.VarChar, 50).Value = tk1.TenNhomQuyen;

                int i = cmd.ExecuteNonQuery();
                if (i >= 1)
                    kt = true;
                else
                    kt = false;
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
                cn = null;
                conn = null;
                return kt;
            }
            catch (Exception ex)
            {
                string s = ex.Message;
                return false;
            }
        }
コード例 #4
0
ファイル: TaiKhoan.cs プロジェクト: mrk29vn/vna-accounting
        public Entities.TaiKhoan[] selectTaiKhoan()
        {
            Entities.TaiKhoan[] arrC = null;
            try
            {
                tk = new Constants.TaiKhoan();
                Sql = new Constants.Sql();
                string sql = Sql.selectTaiKhoan;
                conn = new Connection();
                cn = conn.openConnection();
                cmd = new SqlCommand(sql, cn);
                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                arr = new ArrayList();
                while (dr.Read())
                {
                    taikhoan = new Entities.TaiKhoan();
                    taikhoan.TenDangNhap = dr[tk.TenDangNhap].ToString();
                    taikhoan.MatKhauDangNhap = dr[tk.MatKhauDangNhap].ToString();
                    taikhoan.KhoaTaiKhoan = (bool)dr[tk.KhoaTaiKhoan];
                    taikhoan.NhanVienID = dr[tk.NhanVienID].ToString();
                    taikhoan.Administrator = (bool)dr[tk.Administrator];
                    taikhoan.TenNhomQuyen = dr[tk.TenNhomQuyen].ToString();
                    taikhoan.TenNhanVien = dr[tk.TenNhanVien].ToString();
                    arr.Add(taikhoan);
                }
                int n = arr.Count;
                if (n == 0) { return null; }
                arrC = new Entities.TaiKhoan[n];
                for (int i = 0; i < n; i++)
                {
                    arrC[i] = (Entities.TaiKhoan)arr[i];
                }
            }

            catch (Exception ex)
            { string s = ex.Message.ToString(); }
            finally
            {
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
            }
            return arrC;
        }