示例#1
0
        /// <summary>
        /// Hàm lấy danh sách dịch vụ của học sinh theo tháng
        /// </summary>
        /// <param name="mahocsinh"></param>
        /// <param name="thang"></param>
        /// <returns></returns>
        public List <DichVuNgoai> GetListDichVuHocSinh(string mahocsinh, string thang)
        {
            List <DichVuNgoai> list;

            using (conn = new SqlConnection(connString))
            {
                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }
                SqlCommand command = conn.CreateCommand();
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "getListDichVuNgoai_HocSinh";
                command.Parameters.AddWithValue("@MaHocSinh", mahocsinh);
                command.Parameters.AddWithValue("@Thang", thang);
                SqlDataAdapter adapter = new SqlDataAdapter(command);
                DataTable      dt      = new DataTable();
                adapter.Fill(dt);
                DichVuNgoai hs;
                list = new List <DichVuNgoai>();
                foreach (DataRow dr in dt.Rows)
                {
                    hs          = new DichVuNgoai();
                    hs.MaDichVu = Convert.ToString(dr["MaDichVu"]);
                    hs.TenDV    = Convert.ToString(dr["TenDV"]);
                    hs.ChiPhi   = Convert.ToDecimal(dr["ChiPhi"]);
                    hs.GhiChu   = Convert.ToString(dr["GhiChu"]);
                    list.Add(hs);
                }
            }
            return(list);
        }
示例#2
0
 /// <summary>
 /// add
 /// </summary>
 /// <param name="dichvu"></param>
 public void AddDichVu(DichVuNgoai dichvu)
 {
     using (conn )
     {
         if (conn.State != ConnectionState.Open)
         {
             conn.Open();
         }
         SqlCommand command = conn.CreateCommand();
         command.CommandType = CommandType.StoredProcedure;
         command.CommandText = "InsertUpdateDichVuNgoai";
         command.Parameters.Add("@MaDichVu", SqlDbType.VarChar, 20).Value   = dichvu.MaDichVu;
         command.Parameters.Add("@TenDichVu", SqlDbType.NVarChar, 50).Value = dichvu.TenDV;
         command.Parameters.Add("@ChiPhi", SqlDbType.Int).Value             = dichvu.ChiPhi;
         command.Parameters.Add("@GhiChu", SqlDbType.Decimal).Value         = dichvu.GhiChu;
         command.Parameters.Add("@Action", SqlDbType.VarChar, 10).Value     = "Insert";
         try
         {
             command.ExecuteNonQuery();
         }
         catch (Exception ex)
         {
             throw ex;
         }
         finally
         {
             command.Dispose();
             conn.Dispose();
         }
     }
 }