コード例 #1
0
ファイル: QuanLiXe.cs プロジェクト: tonyjohnson1910/DoAn_DBMS
        public bool addChoThueXe(String cmnd, String bienso, String loaixe, String hieuxe, MemoryStream pic, DateTime ngayhd, DateTime ngaygiaoxe, DateTime ngayhethanthue, double trigiahd)
        {
            SqlCommand command = new SqlCommand("Exec pro_ThemXeVaoDanhSachChoThue @bienso , @loaixe , @hieuxe, @hinhanh, @oid, @ngayhd, @ngayhieuluc, @ngayhethan, @trigiahd", mydb.getConnection);

            command.Parameters.Add("@bienso", SqlDbType.VarChar).Value   = bienso;
            command.Parameters.Add("@loaixe", SqlDbType.VarChar).Value   = loaixe;
            command.Parameters.Add("@hieuxe", SqlDbType.VarChar).Value   = hieuxe;
            command.Parameters.Add("@hinhanh", SqlDbType.Image).Value    = pic.ToArray();
            command.Parameters.Add("@oid", SqlDbType.VarChar).Value      = cmnd;
            command.Parameters.Add("@ngayhd", SqlDbType.Date).Value      = ngayhd;
            command.Parameters.Add("@ngayhieuluc", SqlDbType.Date).Value = ngaygiaoxe;
            command.Parameters.Add("@ngayhethan", SqlDbType.Date).Value  = ngayhethanthue;
            command.Parameters.Add("@trigiahd", SqlDbType.Money).Value   = trigiahd;
            mydb.openConnection();
            if (command.ExecuteNonQuery() == 1)
            {
                mydb.closeConnection();
                return(true);
            }
            else
            {
                mydb.closeConnection();
                return(false);
            }
        }
コード例 #2
0
        public void ExecuteNonQuery(string query)
        {
            dbconn = new My_DB();

            using (SqlConnection conn = dbconn.getConnection)
            {
                dbconn.openConnection();

                SqlCommand command = new SqlCommand(query, conn);
                command.ExecuteNonQuery();
                dbconn.closeConnection();
            }
        }
コード例 #3
0
        public void ExecuteNonQueryIncludeImage(string query, MemoryStream pic)
        {
            dbconn = new My_DB();

            using (SqlConnection conn = dbconn.getConnection)
            {
                dbconn.openConnection();

                SqlCommand command = new SqlCommand(query + " @img", conn);
                command.Parameters.Add("@img", SqlDbType.Image).Value = pic.ToArray();
                command.ExecuteNonQuery();
                dbconn.closeConnection();
            }
        }
コード例 #4
0
        public DataTable ExecuteQuery(string query)
        {
            dbconn = new My_DB();

            DataTable dataTable = new DataTable();

            using (SqlConnection conn = dbconn.getConnection)
            {
                dbconn.openConnection();

                SqlCommand     command = new SqlCommand(query, conn);
                SqlDataAdapter adapter = new SqlDataAdapter(command);
                adapter.Fill(dataTable);

                dbconn.closeConnection();
            }
            return(dataTable);
        }
コード例 #5
0
        public bool insertKhachHang(String cmnd, String fname, String lname)
        {
            SqlCommand command = new SqlCommand("exec pro_ThemKhachHang @cmnd, @fname, @lname", mydb.getConnection);

            command.Parameters.Add("@cmnd", SqlDbType.VarChar).Value   = cmnd;
            command.Parameters.Add("@fname", SqlDbType.NVarChar).Value = fname;
            command.Parameters.Add("@lname", SqlDbType.NVarChar).Value = lname;

            mydb.openConnection();
            if (command.ExecuteNonQuery() == 1)
            {
                mydb.closeConnection();
                return(true);
            }
            else
            {
                mydb.closeConnection();
                return(false);
            }
        }