public Boolean Update(lot id) { string ConnectionString = IDManager.connection(); SqlConnection con = new SqlConnection(ConnectionString); try { con.Open(); SqlCommand cmd = new SqlCommand("SP_DMCS_UPDATE_LOT", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@lot_id", id.lot_id); cmd.Parameters.AddWithValue("@product_id", id.product_id); cmd.Parameters.AddWithValue("@manufactured_date", id.manufactured_date); cmd.Parameters.AddWithValue("@expiration_date", id.expiration_date); cmd.Parameters.AddWithValue("@manufacture_name", id.manufacture_name); cmd.ExecuteReader(); con.Close(); return(true); } catch (Exception ex) { return(false); } finally { con.Close(); } }
public lot Insert(lot id) { string ConnectionString = IDManager.connection(); SqlConnection con = new SqlConnection(ConnectionString); try { con.Open(); SqlCommand cmd = new SqlCommand("SP_DMCS_INSERT_LOT", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@product_id", id.product_id); cmd.Parameters.AddWithValue("@manufactured_date", id.manufactured_date); cmd.Parameters.AddWithValue("@expiration_date", id.expiration_date); cmd.Parameters.AddWithValue("@manufacture_name", id.manufacture_name); cmd.ExecuteReader(); con.Close(); con.Open(); cmd = new SqlCommand("SP_DMCS_GET_LOT", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@product_id", id.product_id); cmd.Parameters.AddWithValue("@manufactured_date", id.manufactured_date); cmd.Parameters.AddWithValue("@expiration_date", id.expiration_date); cmd.Parameters.AddWithValue("@manufacture_name", id.manufacture_name); SqlDataReader rdr = cmd.ExecuteReader(); if (rdr.HasRows) { rdr.Read(); id.lot_id = rdr.GetInt32(0); } } catch (Exception ex) { id.SetColumnDefaults(); } finally { con.Close(); } return(id); }
public lot Insert(lot id) { string ConnectionString = IDManager.connection(); SqlConnection con = new SqlConnection(ConnectionString); try { con.Open(); SqlCommand cmd = new SqlCommand("SP_DMCS_INSERT_LOT", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@product_id", id.product_id); cmd.Parameters.AddWithValue("@manufactured_date", id.manufactured_date); cmd.Parameters.AddWithValue("@expiration_date", id.expiration_date); cmd.Parameters.AddWithValue("@manufacture_name", id.manufacture_name); cmd.ExecuteReader(); con.Close(); con.Open(); cmd = new SqlCommand("SP_DMCS_GET_LOT", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@product_id", id.product_id); cmd.Parameters.AddWithValue("@manufactured_date", id.manufactured_date); cmd.Parameters.AddWithValue("@expiration_date", id.expiration_date); cmd.Parameters.AddWithValue("@manufacture_name", id.manufacture_name); SqlDataReader rdr = cmd.ExecuteReader(); if (rdr.HasRows) { rdr.Read(); id.lot_id = rdr.GetInt32(0); } } catch (Exception ex) { id.SetColumnDefaults(); } finally { con.Close(); } return id; }
public Boolean Update(lot id) { string ConnectionString = IDManager.connection(); SqlConnection con = new SqlConnection(ConnectionString); try { con.Open(); SqlCommand cmd = new SqlCommand("SP_DMCS_UPDATE_LOT", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@lot_id", id.lot_id); cmd.Parameters.AddWithValue("@product_id", id.product_id); cmd.Parameters.AddWithValue("@manufactured_date", id.manufactured_date); cmd.Parameters.AddWithValue("@expiration_date", id.expiration_date); cmd.Parameters.AddWithValue("@manufacture_name", id.manufacture_name); cmd.ExecuteReader(); con.Close(); return true; } catch (Exception ex) { return false; } finally { con.Close(); } }
public lot Select(int id) { lot lot = new lot(); string ConnectionString = IDManager.connection(); SqlConnection con = new SqlConnection(ConnectionString); try { con.Open(); SqlCommand cmd = new SqlCommand("SP_DMCS_SELECT_LOT", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@lot_id", id); SqlDataReader rdr = cmd.ExecuteReader(); if (rdr.HasRows) { rdr.Read(); if (!rdr.IsDBNull(0)) { lot.lot_id = rdr.GetInt32(0); } else { lot.lot_id = 0; } if (!rdr.IsDBNull(1)) { lot.product_id = rdr.GetInt32(1); } else { lot.product_id = 0; } if (!rdr.IsDBNull(2)) { lot.manufactured_date = rdr.GetDateTime(2); } else { lot.manufactured_date = DateTime.Now; } if (!rdr.IsDBNull(3)) { lot.expiration_date = rdr.GetDateTime(3); } else { lot.expiration_date = DateTime.Now; } if (!rdr.IsDBNull(4)) { lot.manufacture_name = rdr.GetString(4); } else { lot.manufacture_name = " "; } } else { lot.SetColumnDefaults(); } } catch (Exception ex) { lot.SetColumnDefaults(); return lot; } finally { con.Close(); } return lot; }
public lot Select(int id) { lot lot = new lot(); string ConnectionString = IDManager.connection(); SqlConnection con = new SqlConnection(ConnectionString); try { con.Open(); SqlCommand cmd = new SqlCommand("SP_DMCS_SELECT_LOT", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@lot_id", id); SqlDataReader rdr = cmd.ExecuteReader(); if (rdr.HasRows) { rdr.Read(); if (!rdr.IsDBNull(0)) { lot.lot_id = rdr.GetInt32(0); } else { lot.lot_id = 0; } if (!rdr.IsDBNull(1)) { lot.product_id = rdr.GetInt32(1); } else { lot.product_id = 0; } if (!rdr.IsDBNull(2)) { lot.manufactured_date = rdr.GetDateTime(2); } else { lot.manufactured_date = DateTime.Now; } if (!rdr.IsDBNull(3)) { lot.expiration_date = rdr.GetDateTime(3); } else { lot.expiration_date = DateTime.Now; } if (!rdr.IsDBNull(4)) { lot.manufacture_name = rdr.GetString(4); } else { lot.manufacture_name = " "; } } else { lot.SetColumnDefaults(); } } catch (Exception ex) { lot.SetColumnDefaults(); return(lot); } finally { con.Close(); } return(lot); }