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(Поступление); }
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); }
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(Журнал_выдач); }
public ActionResult Index3(String id) { Выдача av = new Выдача(); av.Код_продукции = id; av.Дата_и_время = DateTime.Now; return(View(av)); }
public ActionResult Delete(int id, Выдача выдача) { try { if (ВыдачаDAO.Удалить_выдачу(id, выдача)) { return(RedirectToAction("Index")); } else { return(View("Delete")); } } catch { return(View()); } }
public ActionResult Edit(int id, Выдача выдача) { try { if (ВыдачаDAO.Изменить_выдачу(id, выдача)) { return(RedirectToAction("Index")); } else { return(View("Edit")); } } catch { return(View()); } }
public ActionResult Index3(String id, Выдача b) { try { if (ВыдачаDAO.Добавить_выдачу(id, b)) { return(RedirectToAction("Index", "Категория")); } else { return(View("Index3")); } } catch { return(View()); } }
public ActionResult Create(String id, Выдача выдача) { try { // TODO: Add insert logic here if (ВыдачаDAO.Добавить_выдачу(id, выдача)) { return(RedirectToAction("Index", "Категория")); } else { return(View("Create")); } } catch { return(View()); } }
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); }
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); }