public ActionResult Create(асход расход) { try { // TODO: Add insert logic here return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(String id, асход расход) { try { // TODO: Add update logic here if (асходDAO.Обновить_статус(id, расход)) { return(RedirectToAction("Index")); } else { return(View("Create")); } } catch { return(View()); } }
public bool Обновить_статус(String id, асход расход) { Connect(); bool result = true; try { String sql = string.Format("UPDATE Список_продукции SET расход_по_норме='{0}', статус= 'черновик'" + "WHERE код_продукции='{1}'", расход.асход_по_норме, id); SqlCommand cmd = new SqlCommand(sql, Сonnection); cmd.ExecuteNonQuery(); } catch (Exception) { result = false; } finally { Disconnect(); } return(result); }
public List <асход> Табель_расхода(String sql) { Connect(); List <асход> Табель_расхода = new List <асход>(); try { SqlCommand command = new SqlCommand(sql, Сonnection); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { асход товар = new асход(); товар.Код_продукции = Convert.ToString(reader["a"]); товар.Название = Convert.ToString(reader["b"]); товар.Приход_за_сутки = Convert.ToInt32(reader["c"]); товар.асход_за_сутки = Convert.ToInt32(reader["d"]); товар.асход_по_норме = Convert.ToUInt32(reader["e"]); //товар.Код_продукции = reader.GetString(0); //товар.Название = reader.GetString(1); //товар.Приход_за_сутки = reader.GetInt32(6); //товар.Расход_за_сутки = reader.GetInt32(4); //товар.Расход_по_норме= reader.GetFloat(2); товар.Коэффициент_расхода = (float )товар.асход_за_сутки / (float)товар.Приход_за_сутки; Табель_расхода.Add(товар); } reader.Close(); } catch (Exception ex) { String a = ex.Message; a = ""; } finally { Disconnect(); } return(Табель_расхода); }