Exemplo n.º 1
0
        public Выдача Выдача(int id)
        {
            Connect();
            Выдача Поступление = new Выдача();

            try
            {
                SqlCommand command = new SqlCommand("SELECT * FROM Журнал_выдач WHERE номер =" + id, Сonnection);

                SqlDataReader reader = command.ExecuteReader();
                reader.Read();
                Поступление.Код_выдачи    = Convert.ToInt32(reader["номер"]);
                Поступление.Код_продукции = Convert.ToString(reader["код продукции"]);
                Поступление.Дата_и_время  = Convert.ToDateTime(reader["дата_и_время"]);
                Поступление.Количество    = Convert.ToInt32(reader["количество"]);
                reader.Close();
            }
            catch (Exception)
            {
            }
            finally
            {
                Disconnect();
            }
            return(Поступление);
        }
Exemplo n.º 2
0
        public bool Добавить_выдачу(String id, Выдача выдача)
        {
            Connect();
            bool result = true;

            try
            {
                SqlCommand cmd = new SqlCommand(
                    "INSERT INTO Журнал_выдач (код_продукции, дата_и_время, " +
                    "количество) " +
                    "VALUES (@код_продукции, @дата_и_время, @количество)", Сonnection);
                cmd.Parameters.Add(new SqlParameter("@код_продукции", id));
                cmd.Parameters.Add(new SqlParameter("@дата_и_время", DateTime.Now));
                cmd.Parameters.Add(new SqlParameter("@количество", выдача.Количество));
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                String a = ex.Message;
                result = false;
            }
            finally
            {
                Disconnect();
            }
            return(result);
        }
Exemplo n.º 3
0
        public List <Выдача> Журнал_выдач()
        {
            Connect();
            List <Выдача> Журнал_выдач = new List <Выдача>();

            try
            {
                SqlCommand    command = new SqlCommand("SELECT * FROM Журнал_выдач", Сonnection);
                SqlDataReader reader  = command.ExecuteReader();
                while (reader.Read())
                {
                    Выдача выдача = new Выдача
                    {
                        Код_выдачи    = Convert.ToInt32(reader["номер"]),
                        Код_продукции = Convert.ToString(reader["код_продукции"]),
                        Дата_и_время  = Convert.ToDateTime(reader["дата_и_время"]),
                        Количество    = Convert.ToInt32(reader["количество"])
                    };
                    Журнал_выдач.Add(выдача);
                }
                reader.Close();
            }
            catch (Exception)
            {
            }
            finally
            {
                Disconnect();
            }
            return(Журнал_выдач);
        }
Exemplo n.º 4
0
        public ActionResult Index3(String id)
        {
            Выдача av = new Выдача();

            av.Код_продукции = id;
            av.Дата_и_время  = DateTime.Now;
            return(View(av));
        }
Exemplo n.º 5
0
 public ActionResult Delete(int id, Выдача выдача)
 {
     try
     {
         if (ВыдачаDAO.Удалить_выдачу(id, выдача))
         {
             return(RedirectToAction("Index"));
         }
         else
         {
             return(View("Delete"));
         }
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 6
0
 public ActionResult Edit(int id, Выдача выдача)
 {
     try
     {
         if (ВыдачаDAO.Изменить_выдачу(id, выдача))
         {
             return(RedirectToAction("Index"));
         }
         else
         {
             return(View("Edit"));
         }
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 7
0
 public ActionResult Index3(String id, Выдача b)
 {
     try
     {
         if (ВыдачаDAO.Добавить_выдачу(id, b))
         {
             return(RedirectToAction("Index", "Категория"));
         }
         else
         {
             return(View("Index3"));
         }
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 8
0
 public ActionResult Create(String id, Выдача выдача)
 {
     try
     {
         // TODO: Add insert logic here
         if (ВыдачаDAO.Добавить_выдачу(id, выдача))
         {
             return(RedirectToAction("Index", "Категория"));
         }
         else
         {
             return(View("Create"));
         }
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 9
0
        public bool Удалить_выдачу(int id, Выдача выдача)
        {
            Connect();
            bool result = true;

            try
            {
                SqlCommand cmd = new SqlCommand(
                    "DELETE FROM Журнал_выдач WHERE номер=" + id, Сonnection);
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                result = false;
            }
            finally
            {
                Disconnect();
            }
            return(result);
        }
Exemplo n.º 10
0
        public bool Изменить_выдачу(int id, Выдача выдача)
        {
            Connect();
            bool result = true;

            try
            {
                String sql = string.Format("UPDATE Журнал_выдач SET код_продукции='{0}', дата_и_время='{1}', количество='{2}' " +
                                           "WHERE номер={3}", выдача.Код_продукции, выдача.Дата_и_время, выдача.Количество, id);
                SqlCommand cmd = new SqlCommand(sql, Сonnection);
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                result = false;
            }
            finally
            {
                Disconnect();
            }
            return(result);
        }