protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { using(CatalogManager cm = new CatalogManager()) { this.StationeriesGridView.DataSource = cm.GetAllStationeries(); this.StationeriesGridView.DataBind(); } Stationery stationery = new Stationery(); StationeryPrice stationeryPrice = new StationeryPrice(); } }
protected void SubmitButton_Click(object sender, EventArgs e) { CatalogManager Manager = new CatalogManager(); Stationery stationery = new Stationery(); StationeryPrice[] stationeryPrice = new StationeryPrice[3]; stationery.ItemCode = NameTextBox.Text; stationery.Description = DescriptionTextBox.Text; stationery.UnitOfMeasure = UOMTextBox.Text; stationery.CategoryID = Convert.ToInt32(CategoryDDL.SelectedValue); stationery.LocationID = Convert.ToInt32(LocationDDL.SelectedValue); stationery.ReorderLevel = Convert.ToInt32(ReorderLevelTextBox.Text); stationery.ReorderQuantity = Convert.ToInt32(ReorderQtyTextBox.Text); stationery.CreatedBy = Utilities.Membership.GetCurrentLoggedInUser().UserID; stationery.ModifiedBy = Utilities.Membership.GetCurrentLoggedInUser().UserID; stationery.DateCreated = DateTime.Now; stationery.DateModified = DateTime.Now; stationery.IsApproved = false; stationeryPrice[0] = new StationeryPrice(); stationeryPrice[0].SupplierID = Convert.ToInt32(Supplier1DDL.SelectedValue); stationeryPrice[0].Price = Convert.ToInt32(Price1TextBox.Text); stationeryPrice[1] = new StationeryPrice(); stationeryPrice[1].SupplierID = Convert.ToInt32(Supplier2DDL.SelectedValue); stationeryPrice[1].Price = Convert.ToInt32(Price2TextBox.Text); stationeryPrice[2] = new StationeryPrice(); stationeryPrice[2].SupplierID = Convert.ToInt32(Supplier3DDL.SelectedValue); stationeryPrice[2].Price = Convert.ToInt32(Price3TextBox.Text); try { Stationery temp = Manager.CreateStationery(stationery); foreach (StationeryPrice st in stationeryPrice) { st.StationeryID = temp.StationeryID; Manager.CreateStationeryPrice(st); } } catch (Exception) { ErrorLabel.Text = "Create Stationery Failed"; } }
public StationeryPrice UpdateStationeryPrice(StationeryPrice stationeryPrice) { try { StationeryPrice tempStationeryPrice = (from p in context.StationeryPrices where p.StationeryPriceID == stationeryPrice.StationeryPriceID select p).First<StationeryPrice>(); tempStationeryPrice.Stationery = stationeryPrice.Stationery; tempStationeryPrice.Supplier = stationeryPrice.Supplier; tempStationeryPrice.Price = stationeryPrice.Price; using (TransactionScope ts = new TransactionScope()) { // context.Attach(tempStationeryPrice); //context.ObjectStateManager.ChangeObjectState(tempStationeryPrice, EntityState.Modified); context.SaveChanges(); ts.Complete(); return tempStationeryPrice; } } catch (Exception) { throw; } }
public void DeleteStationeryPrice(StationeryPrice stationeryPrice) { try { StationeryPrice persistedStationeryPrice = (from p in context.StationeryPrices where p.StationeryPriceID == stationeryPrice.StationeryPriceID select p).First<StationeryPrice>(); using (TransactionScope ts = new TransactionScope()) { context.StationeryPrices.DeleteObject(persistedStationeryPrice); context.SaveChanges(); ts.Complete(); } } catch (Exception) { throw; } }
public StationeryPrice CreateStationeryPrice(StationeryPrice stationeryPrice) { try { using (TransactionScope ts = new TransactionScope()) { context.StationeryPrices.AddObject(stationeryPrice); context.SaveChanges(); ts.Complete(); return stationeryPrice; } } catch (Exception) { throw; } }
/// <summary> /// Deprecated Method for adding a new object to the StationeryPrices EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToStationeryPrices(StationeryPrice stationeryPrice) { base.AddObject("StationeryPrices", stationeryPrice); }
/// <summary> /// Create a new StationeryPrice object. /// </summary> /// <param name="stationeryPriceID">Initial value of the StationeryPriceID property.</param> /// <param name="stationeryID">Initial value of the StationeryID property.</param> /// <param name="supplierID">Initial value of the SupplierID property.</param> /// <param name="price">Initial value of the Price property.</param> public static StationeryPrice CreateStationeryPrice(global::System.Int32 stationeryPriceID, global::System.Int32 stationeryID, global::System.Int32 supplierID, global::System.Decimal price) { StationeryPrice stationeryPrice = new StationeryPrice(); stationeryPrice.StationeryPriceID = stationeryPriceID; stationeryPrice.StationeryID = stationeryID; stationeryPrice.SupplierID = supplierID; stationeryPrice.Price = price; return stationeryPrice; }
public StationeryPrice UpdateStationeryPrice(StationeryPrice stationeryPrice) { try { if (stationeryPrice != null) { catalogDAO.UpdateStationeryPrice(stationeryPrice); } } catch (Exception) { throw new Exceptions.UserException("Catalog stationery item price updating failed."); } return stationeryPrice; }
public void DeleteStationeryPrice(StationeryPrice stationeryPrice) { try { if (stationeryPrice != null) { catalogDAO.DeleteStationeryPrice(stationeryPrice); } } catch (Exception) { //throw new Exceptions.UserException("Catalog stationery item price deletion failed."); } }