public ActionResult Save(DepartmentCafeteriaTransaction department)
 {
     department.CheckTime = DateTime.Now.TimeOfDay.ToString();
     try
     {
         ViewBag.Message = _department.Save(department) ? "Departmen Cafeteria Transaction Saved Successfully" : "Departmen Cafeteria Transaction Save Failed";
     }
     catch (Exception exception)
     {
         ViewBag.Message = exception.Message;
     }
     return(View());
 }
        public int Save(DepartmentCafeteriaTransaction department)
        {
            try
            {
                double UnitRate = 0;
                Query =
                    "INSERT INTO DepartmentCafeteriaTransaction(DeptId,FoodItemCostId,ItemQuantity,CheckTime,CheckDate, UnitRate) VALUES(@DeptId, @FoodItemCostId, @ItemQuantity, @CheckTime, @CheckDate ,@UnitRate)";
                Command.CommandText = Query;
                Command.Connection  = Connection;
                Command.Parameters.Clear();
                Command.Parameters.Add("DeptId", SqlDbType.Int);
                Command.Parameters["DeptId"].Value = department.DeptId;
                Command.Parameters.Add("FoodItemCostId", SqlDbType.Int);
                Command.Parameters["FoodItemCostId"].Value = department.FoodItemCostId;
                Command.Parameters.Add("ItemQuantity", SqlDbType.Int);
                Command.Parameters["ItemQuantity"].Value = department.ItemQuantity;
                Command.Parameters.Add("CheckTime", SqlDbType.Time);
                Command.Parameters["CheckTime"].Value = department.CheckTime;
                Command.Parameters.Add("CheckDate", SqlDbType.Date);
                Command.Parameters["CheckDate"].Value = department.CheckDate;
                Command.Parameters.Add("UnitRate", SqlDbType.Decimal);
                Command.Parameters["UnitRate"].Value = UnitRate;

                Connection.Open();
                int rowsAffected = Command.ExecuteNonQuery();
                return(rowsAffected);
            }
            catch (Exception exception)
            {
                return(0);
            }
            finally
            {
                Connection.Close();
            }
        }
예제 #3
0
 public bool Save(DepartmentCafeteriaTransaction department)
 {
     return(_department.Save(department) > 0);
 }