예제 #1
0
        public NV_NhaDauTu_ChiTiet GetById(int id)
        {
            using (SqlConnection myConnection = new SqlConnection(ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("NV_NhaDauTu_getByID", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;

                    SqlParameter pID = new SqlParameter("@ID", SqlDbType.Int);
                    pID.Value = id;
                    myCommand.Parameters.Add(pID);

                    DataTable           dt;
                    NV_NhaDauTu_ChiTiet model = new NV_NhaDauTu_ChiTiet();

                    myConnection.Open();
                    using (SqlDataAdapter mData = new SqlDataAdapter(myCommand))
                    {
                        dt = new DataTable();
                        mData.Fill(dt);
                    }
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        model = new NV_NhaDauTu_ChiTiet(dt.Rows[0]);
                    }
                    return(model);
                }
            }
        }
예제 #2
0
        public bool update(NV_NhaDauTu_ChiTiet model)
        {
            using (SqlConnection myConnection = new SqlConnection(ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("NV_NhaDauTu_update", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;

                    SqlParameter pID = new SqlParameter("@ID", SqlDbType.NVarChar, 100);
                    pID.Value = model.ID;
                    myCommand.Parameters.Add(pID);

                    SqlParameter pTen = new SqlParameter("@Ten", SqlDbType.NVarChar, 200);
                    pTen.Value = model.Ten;
                    myCommand.Parameters.Add(pTen);

                    SqlParameter pSodienthoai = new SqlParameter("@DienThoai", SqlDbType.NVarChar, 50);
                    pSodienthoai.Value = model.DienThoai;
                    myCommand.Parameters.Add(pSodienthoai);

                    SqlParameter pDiachi = new SqlParameter("@DiaChi", SqlDbType.NVarChar, 200);
                    pDiachi.Value = model.DiaChi;
                    myCommand.Parameters.Add(pDiachi);

                    SqlParameter pGhiChu = new SqlParameter("@MoTa", SqlDbType.NVarChar, 1000);
                    pGhiChu.Value = model.MoTa;
                    myCommand.Parameters.Add(pGhiChu);

                    SqlParameter pEmail = new SqlParameter("@Email", SqlDbType.NVarChar, 50);
                    pEmail.Value = model.Email;
                    myCommand.Parameters.Add(pEmail);


                    try
                    {
                        myConnection.Open();
                        myCommand.ExecuteNonQuery();
                        return(true);
                    }
                    catch
                    {
                        return(false);
                    }
                }
            }
        }