public ActionResult Save(Models.InventoryModel data)
  
 {
      try
      {
          DateTime ToDate1;
          if (data.StartMonth > data.EndMonth)
          {
          ToDate1 = new DateTime(DateTime.Today.Year +1, data.EndMonth, data.EndDay);         
          }
          else
          {
              ToDate1 = new DateTime(DateTime.Today.Year, data.EndMonth, data.EndDay);             
          }            
          CLayer.Inventory d = new CLayer.Inventory()
          {                 
              AccommodationId = data.AccommodationId,
              InventoryId = data.InventoryId,
              Quantity = data.Quantity,
              FromDate = new DateTime(DateTime.Today.Year, data.StartMonth, data.StartDay),
              ToDate = ToDate1
          };
       long AccId  = BLayer.Inventory.save(d);
        return RedirectToAction("index", new { id = data.AccommodationId });
      }
      catch (Exception ex)
      {
          Common.LogHandler.HandleError(ex);
          return RedirectToAction("index", new { id = data.AccommodationId });
      }
  }    
Beispiel #2
0
        public long APIUpdate(CLayer.Inventory inventory)
        {
            List <DataPlug.Parameter> param = new List <DataPlug.Parameter>();

            param.Add(Connection.GetParameter("pAccommodationId", DataPlug.DataType._BigInt, inventory.AccommodationId));
            param.Add(Connection.GetParameter("pQuantity", DataPlug.DataType._Int, inventory.Quantity));
            param.Add(Connection.GetParameter("pFromDate", DataPlug.DataType._Date, inventory.FromDate));
            param.Add(Connection.GetParameter("pToDate", DataPlug.DataType._Date, inventory.ToDate));
            object result = Connection.ExecuteQueryScalar("SP_inventory_Save", param);

            return(Connection.ToLong(result));
        }
Beispiel #3
0
        public ActionResult Save(Models.InventoryModel data)

        {
            try
            {
                DateTime ToDate1;
                DateTime FromDate1;

                int days = DateTime.DaysInMonth(2014, data.StartMonth);
                if (days < data.StartDay)
                {
                    data.StartDay = days;
                }
                FromDate1 = new DateTime(DateTime.Today.Year, data.StartMonth, data.StartDay);
                days      = DateTime.DaysInMonth(2014, data.EndMonth);
                if (days < data.EndDay)
                {
                    data.EndDay = days;
                }
                //if (data.StartMonth > data.EndMonth)
                //   ToDate1 = new DateTime(2015, data.EndMonth, data.EndDay);
                //else
                ToDate1 = new DateTime(2014, data.EndMonth, data.EndDay);
                //{
                //ToDate1 = new DateTime(DateTime.Today.Year +1, data.EndMonth, data.EndDay);
                //}
                //else
                //{
                //    ToDate1 = new DateTime(DateTime.Today.Year, data.EndMonth, data.EndDay);
                //}
                CLayer.Inventory d = new CLayer.Inventory()
                {
                    AccommodationId = data.AccommodationId,
                    InventoryId     = data.InventoryId,
                    Quantity        = data.Quantity,
                    FromDate        = new DateTime(DateTime.Today.Year, data.StartMonth, data.StartDay),
                    ToDate          = ToDate1
                };
                long AccId = BLayer.Inventory.save(d);
                return(RedirectToAction("index", new { id = data.AccommodationId }));
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
                return(RedirectToAction("index", new { id = data.AccommodationId }));
            }
        }
Beispiel #4
0
 public ActionResult Details(long InventoryId)
 {
     Models.InventoryModel search = new Models.InventoryModel();
     CLayer.Inventory      get    = BLayer.Inventory.GetOnebyInventoryId(InventoryId);
     if (get != null)
     {
         search = new Models.InventoryModel
         {
             AccommodationId = get.AccommodationId,
             InventoryId     = get.InventoryId,
             Quantity        = get.Quantity,
             StartDay        = get.FromDate.Day,
             EndDay          = get.ToDate.Day,
             StartMonth      = get.FromDate.Month,
             EndMonth        = get.ToDate.Month
         };
     }
     return(PartialView("_Details", search));
 }
Beispiel #5
0
        public CLayer.Inventory GetOnAccommodationId(long InventoryId)
        {
            CLayer.Inventory          Inverntory = new CLayer.Inventory();
            List <DataPlug.Parameter> param      = new List <DataPlug.Parameter>();

            param.Add(Connection.GetParameter("pInventoryId", DataPlug.DataType._BigInt, InventoryId));
            DataTable dt = Connection.GetTable("inventory_GetOnInventoryId", param);

            foreach (DataRow dr in dt.Rows)
            {
                if (dt.Rows.Count > 0)
                {
                    Inverntory = new CLayer.Inventory();
                    Inverntory.AccommodationId = Connection.ToLong(dr["AccommodationId"]);
                    Inverntory.InventoryId     = Connection.ToLong(dr["InventoryId"]);
                    Inverntory.Quantity        = Connection.ToInteger(dr["Quantity"]);
                    Inverntory.FromDate        = Connection.ToDate(dr["FromDate"]);
                    Inverntory.ToDate          = Connection.ToDate(dr["ToDate"]);
                }
            }
            return(Inverntory);
        }
Beispiel #6
0
 public static long APIsave(CLayer.Inventory invenData)
 {
     DataLayer.Inventory task = new DataLayer.Inventory();
     return(task.APIUpdate(invenData));
 }