public NV_LuongXuLy_ChiTiet GetLast(int idQuytrinh) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NV_LuongXuLy_getLast", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pID = new SqlParameter("@IDQuyTrinh", SqlDbType.Int); pID.Value = idQuytrinh; myCommand.Parameters.Add(pID); DataTable dt; NV_LuongXuLy_ChiTiet model = new NV_LuongXuLy_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_LuongXuLy_ChiTiet(dt.Rows[0]); } return(model); } } }
public bool update(NV_LuongXuLy_ChiTiet model) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NV_LuongXuLy_update", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pID = new SqlParameter("@ID", SqlDbType.Int); pID.Value = model.ID; myCommand.Parameters.Add(pID); SqlParameter pIDLuong = new SqlParameter("@IDLuong", SqlDbType.Int); pIDLuong.Value = model.IDLuong; myCommand.Parameters.Add(pIDLuong); SqlParameter pIDQTCuThe = new SqlParameter("@IDQTCuThe", SqlDbType.Int); pIDQTCuThe.Value = model.IDQTCuThe; myCommand.Parameters.Add(pIDQTCuThe); SqlParameter pNguoiXuLy = new SqlParameter("@NguoiXuLy", SqlDbType.Int); pNguoiXuLy.Value = model.NguoiXuLy; myCommand.Parameters.Add(pNguoiXuLy); SqlParameter pMoTa = new SqlParameter("@MoTa", SqlDbType.NVarChar, 1000); pMoTa.Value = model.MoTa; myCommand.Parameters.Add(pMoTa); SqlParameter pNgayXuLy = new SqlParameter("@NgayXuLy", SqlDbType.DateTime); pNgayXuLy.Value = model.NgayXuLy; myCommand.Parameters.Add(pNgayXuLy); SqlParameter pTrangThai = new SqlParameter("@TrangThai", SqlDbType.Int); pTrangThai.Value = model.TrangThai; myCommand.Parameters.Add(pTrangThai); SqlParameter pFileLienQuan = new SqlParameter("@FileLienQuan", SqlDbType.NVarChar, 50); pFileLienQuan.Value = model.FileLienQuan; myCommand.Parameters.Add(pFileLienQuan); try { myConnection.Open(); myCommand.ExecuteNonQuery(); return(true); } catch { return(false); } } } }