public void Execute()
 {
     PhieuMuaHang.Domain.PhieuMuaHang check = null;
     using (var cmd = new PhieuMuaHangViewBusiness())
     {
         cmd.item = item;
         check    = cmd.Execute();
     }
     if (check != null) // da co du lieu
     {
         using (var cmd = new PhieuMuaHangUpdateBusiness())
         {
             cmd.item = item;
             cmd.Execute();
         }
     }
     else
     {
         using (var cmd = new PhieuMuaHangAddRepository())
         {
             cmd.item = item;
             cmd.Execute();
         }
     }
 }
Beispiel #2
0
 public PhieuMuaHang.Domain.PhieuMuaHang Execute()
 {
     PhieuMuaHang.Domain.PhieuMuaHang data = null;
     using (var conn = new SqlConnection(ConnectionString))
     {
         using (var cmd = conn.CreateCommand())
         {
             conn.Open();
             cmd.CommandText = "SELECT * FROM PhieuMuaHang WHERE MaHD='" + item.MaHD + "'";
             using (var reader = cmd.ExecuteReader())
             {
                 while (reader.Read())
                 {
                     data = new PhieuMuaHang.Domain.PhieuMuaHang
                     {
                         MaHD         = Convert.ToString(reader["MaHD"]),
                         Khachhang    = Convert.ToString(reader["Khachhang"]),
                         Ngaytao      = Convert.ToDateTime(reader["Ngaytao"]),
                         Tongtien     = Convert.ToInt32(reader["Tongtien"]),
                         Ghichu       = Convert.ToString(reader["Ghichu"]),
                         SoLuongMua1N = Convert.ToInt32(reader["SoLuongMua1N"])
                     };
                 }
             }
             conn.Close();
         }
     }
     return(data);
 }