protected void SubmitButton_Click(object sender, EventArgs e)
        {
            CatalogManager manager = new CatalogManager();
            SpecialStationery specialStationery = new SpecialStationery();
            specialStationery.Description = NameTextBox.Text;
            int count = manager.GetSpecialStationeryCount();
            specialStationery.ItemCode = manager.GenerateItemCode(specialStationery.Description, count);
            specialStationery.Quantity = 0;
            specialStationery.UnitOfMeasure = UOMTextBox.Text;
            specialStationery.DateCreated = DateTime.Now;
            specialStationery.DateModified = DateTime.Now;
            specialStationery.CreatedBy = Utilities.Membership.GetCurrentLoggedInUser().UserID;
            specialStationery.ModifiedBy = Utilities.Membership.GetCurrentLoggedInUser().UserID;
            specialStationery.IsApproved = false;
            specialStationery.CategoryID = Convert.ToInt32(CategoryDDL.SelectedValue);

            try
            {
                manager.CreateSpecialStationery(specialStationery);
                DataBind();

            }
            catch (Exception)
            {
                ErrorLabel.Text = "Create Special Request Failed";
            }
        }
 public SpecialStationery CreateSpecialStationery(SpecialStationery specialStationery)
 {
     try
     {
         using (TransactionScope ts = new TransactionScope())
         {
             context.AddToSpecialStationeries(specialStationery);
             context.SaveChanges();
             ts.Complete();
             return specialStationery;
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        public SpecialStationery CreateSpecialStationery(SpecialStationery specialStationery)
        {
            try
            {
                if (specialStationery != null)
                {
                    var tempList = context.SpecialStationeries.ToList<SpecialStationery>();
                    SpecialStationery temp = tempList.Last<SpecialStationery>();
                    int num = 0;
                    if (temp != null)
                    {
                        num = Convert.ToInt32(temp.ItemCode.Substring(1, 3));

                    }
                    specialStationery.ItemCode = "S" + String.Format("{0:000}", num++);
                    catalogDAO.CreateSpecialStationery(specialStationery);
                }
            }
            catch (Exception)
            {
                throw new Exceptions.UserException("Catalog special stationery item creation failed.");
            }
            return specialStationery;
        }
        public SpecialStationery UpdateSpecialStationery(SpecialStationery specialStationery)
        {
            try
            {
                SpecialStationery tempSpecialStationery = (from ss in context.SpecialStationeries
                                                           where ss.SpecialStationeryID == specialStationery.SpecialStationeryID
                                                           select ss).First<SpecialStationery>();

                tempSpecialStationery.Category = specialStationery.Category;
                tempSpecialStationery.ItemCode = specialStationery.ItemCode;
                tempSpecialStationery.Description = specialStationery.Description;
                tempSpecialStationery.Quantity = specialStationery.Quantity;
                tempSpecialStationery.DateModified = specialStationery.DateModified;
                if (specialStationery.DateApproved != null)
                {
                    tempSpecialStationery.DateApproved = specialStationery.DateApproved;
                    tempSpecialStationery.ApprovedByUser = specialStationery.ApprovedByUser;
                    tempSpecialStationery.IsApproved = specialStationery.IsApproved;
                }
                tempSpecialStationery.ModifiedByUser = specialStationery.ModifiedByUser;

                tempSpecialStationery.UnitOfMeasure = specialStationery.UnitOfMeasure;

                using (TransactionScope ts = new TransactionScope())
                {
                    context.SaveChanges();
                    ts.Complete();
                    return tempSpecialStationery;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        public void DeleteSpecialStationery(SpecialStationery specialStationery)
        {
            try
            {
                SpecialStationery persistedSpecialStationery = (from ss in context.SpecialStationeries
                                                                where ss.SpecialStationeryID == specialStationery.SpecialStationeryID
                                                                select ss).First<SpecialStationery>();

                using (TransactionScope ts = new TransactionScope())
                {
                    context.SpecialStationeries.DeleteObject(persistedSpecialStationery);
                    context.SaveChanges();
                    ts.Complete();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the SpecialStationeries EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSpecialStationeries(SpecialStationery specialStationery)
 {
     base.AddObject("SpecialStationeries", specialStationery);
 }
 /// <summary>
 /// Create a new SpecialStationery object.
 /// </summary>
 /// <param name="specialStationeryID">Initial value of the SpecialStationeryID property.</param>
 /// <param name="categoryID">Initial value of the CategoryID property.</param>
 /// <param name="itemCode">Initial value of the ItemCode property.</param>
 /// <param name="description">Initial value of the Description property.</param>
 /// <param name="quantity">Initial value of the Quantity property.</param>
 /// <param name="dateCreated">Initial value of the DateCreated property.</param>
 /// <param name="dateModified">Initial value of the DateModified property.</param>
 /// <param name="createdBy">Initial value of the CreatedBy property.</param>
 /// <param name="modifiedBy">Initial value of the ModifiedBy property.</param>
 /// <param name="isApproved">Initial value of the IsApproved property.</param>
 /// <param name="unitOfMeasure">Initial value of the UnitOfMeasure property.</param>
 public static SpecialStationery CreateSpecialStationery(global::System.Int32 specialStationeryID, global::System.Int32 categoryID, global::System.String itemCode, global::System.String description, global::System.Int32 quantity, global::System.DateTime dateCreated, global::System.DateTime dateModified, global::System.Int32 createdBy, global::System.Int32 modifiedBy, global::System.Boolean isApproved, global::System.String unitOfMeasure)
 {
     SpecialStationery specialStationery = new SpecialStationery();
     specialStationery.SpecialStationeryID = specialStationeryID;
     specialStationery.CategoryID = categoryID;
     specialStationery.ItemCode = itemCode;
     specialStationery.Description = description;
     specialStationery.Quantity = quantity;
     specialStationery.DateCreated = dateCreated;
     specialStationery.DateModified = dateModified;
     specialStationery.CreatedBy = createdBy;
     specialStationery.ModifiedBy = modifiedBy;
     specialStationery.IsApproved = isApproved;
     specialStationery.UnitOfMeasure = unitOfMeasure;
     return specialStationery;
 }
 public SpecialStationery UpdateSpecialStationery(SpecialStationery specialStationery)
 {
     try
     {
         if (specialStationery != null)
         {
             specialStationery.DateModified = DateTime.Now;
             catalogDAO.UpdateSpecialStationery(specialStationery);
         }
     }
     catch (Exception)
     {
         throw new Exceptions.UserException("Catalog special stationery item updating failed.");
     }
     return specialStationery;
 }
 public void DeleteSpecialStationery(SpecialStationery specialStationery)
 {
     try
     {
         if (specialStationery != null)
         {
             catalogDAO.DeleteSpecialStationery(specialStationery);
         }
     }
     catch (Exception)
     {
         //throw new Exceptions.UserException("Catalog special stationery item deletion failed.");
     }
 }
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (requisition.RequisitionItems.Count > 0 || requisition.SpecialRequisitionItems.Count > 0)
                {
                    requisition.UrgencyID = Convert.ToInt32(UrgencyDDL.SelectedValue);

                    foreach (SpecialRequisitionItem item in requisition.SpecialRequisitionItems)
                    {
                        SpecialStationery spl = new SpecialStationery()
                        {
                            UnitOfMeasure = "",
                            Description = item.Name,
                            DateCreated = DateTime.Now,
                            DateModified = DateTime.Now,
                            CreatedBy = Utilities.Membership.GetCurrentLoggedInUser().UserID,
                            ModifiedBy = Utilities.Membership.GetCurrentLoggedInUser().UserID,
                            Quantity = 0,
                            CategoryID = 1,
                            IsApproved = false,

                        };
                        SpecialStationery spltemp = cManager.CreateSpecialStationery(spl);
                        if(spltemp!= null)
                        {
                        item.SpecialStationeryID = spltemp.SpecialStationeryID;
                        }
                    }

                    Requisition temp = requisitionManager.CreateRequisition(requisition);
                    // UtilityFunctions.SendEmail(temp.RequisitionID + " - Requisition Created Successfully ", "The requisition has been created successfully. You can view the status of requisition from the below link.<br /> <a href=>", temp.CreatedByUser);

                    if (temp != null)
                    {
                        Response.Redirect("~/RequestStationery/StationeryRequest.aspx?RequestID=" + temp.RequisitionID, false);
                        Session["Requisition"] = null;
                    }

                }
            }
            catch (Exception)
            {
            }
        }