protected void btnAdd_Click(object sender, EventArgs e) { int stationeryID = int.Parse(ddlDescription.SelectedValue); using (CatalogManager cm = new CatalogManager()) { Stationery stationery = cm.FindStationeryByID(stationeryID); List<Stationery> stationeries = new List<Stationery>(); stationeries.Add(stationery); dvStockCard.DataSource = stationeries; dvStockCard.DataBind(); } using (AdjustmentVoucherManager avm = new AdjustmentVoucherManager()) { List<StockLogTransaction> trans = avm.GetAllStockLogTransactionByCriteria(new AdjustmentVoucherTransactionSearchDTO { StationeryID = stationeryID }); this.gvTransactions.DataSource = trans; this.gvTransactions.DataBind(); } btnPrint.Enabled = true; btnPrint.Visible = true; }
protected void btnAdd_Click(object sender, EventArgs e) { bool existing = false; using (CatalogManager cm = new CatalogManager()) { Stationery stationery = cm.FindStationeryByID(int.Parse(ddlDescription.SelectedValue)); foreach (StockLogTransaction adj in adjustments) { if (adj.StationeryID == stationery.StationeryID) existing = true; } if (!existing) { StockLogTransaction adj = new StockLogTransaction(); adj.Reason = txtReason.Text.ToString(); adj.Quantity = int.Parse(txtQuantity.Text.ToString()); adj.StationeryID = stationery.StationeryID; adj.Balance = stationery.QuantityInHand; adj.Price = 0.0m; adj.DateCreated = DateTime.Now; adj.Type = int.Parse(ddlType.SelectedValue); adjustments.Add(adj); } txtQuantity.Text = ""; txtReason.Text = ""; Populate(); } }
protected void gvAdjustmentItems_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { int stationeryID = (int)DataBinder.Eval(e.Row.DataItem, "StationeryID"); DAL.AdjustmentType adjType = (AdjustmentType) DataBinder.Eval(e.Row.DataItem, "Type"); if (stationeryID != 0) { Literal ltl = e.Row.FindControl("ltlDescription") as Literal; Literal type = e.Row.FindControl("ltlType") as Literal; if (ltl != null) { using (CatalogManager cm = new CatalogManager()) { Stationery s = cm.FindStationeryByID(stationeryID); if (s != null) ltl.Text = s.Description; } } if (type != null) using (AdjustmentVoucherManager avm = new AdjustmentVoucherManager()) { type.Text = adjType.ToString(); } } } }
protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e) { CatalogManager manager = new CatalogManager(); RequisitionItem item = new RequisitionItem(); item.StationeryID = Convert.ToInt32(((DropDownList)DetailsView1.FindControl("stDDL")).SelectedValue); item.QuantityRequested = Convert.ToInt32(((TextBox)DetailsView1.FindControl("stTextBox")).Text); item.QuantityIssued = 0; item.Price = 0; if (requisition.RequisitionItems.Count == 0) { requisition.RequisitionItems.Add(item); } else { foreach (var req in requisition.RequisitionItems) { if (item.StationeryID == req.StationeryID) { req.QuantityRequested += item.QuantityRequested; break; } else { requisition.RequisitionItems.Add(item); break; } } } GridDataBind(); }
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"; } }
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(); } }
// create Purchase Order and together with Purchase Order Items protected void btnSubmit_Click(object sender, EventArgs e) { //justify how many suppliers involed List<Supplier> suppliers = SupplierInvolved(); using (PurchaseOrderManager pom = new PurchaseOrderManager()) { foreach (Supplier s in suppliers) { PurchaseOrder purchaseOrder = new PurchaseOrder(); purchaseOrder.PONumber = pom.CreatePONumber(); purchaseOrder.DateOfOrder = DateTime.Now; purchaseOrder.AttentionTo = Convert.ToInt32(ddlAttentionTo.SelectedValue); purchaseOrder.CreatedBy = Membership.GetCurrentLoggedInUser().UserID; purchaseOrder.IsDelivered = false; DateTimeFormatInfo dtfi = new DateTimeFormatInfo(); dtfi.ShortDatePattern = "MM/dd/yyyy"; dtfi.DateSeparator = "/"; purchaseOrder.DateToSupply = Convert.ToDateTime(txtDateToSupply.Text, dtfi); purchaseOrder.SupplierID = s.SupplierID; foreach (GridViewRow r in gvPOItems.Rows) { if (Convert.ToInt32(((DropDownList)r.FindControl("ddlSupplier")).SelectedValue.ToString()) == s.SupplierID) { PurchaseOrderItem item = new PurchaseOrderItem(); item.PurchaseOrder = purchaseOrder; item.StationeryID = (int)gvPOItems.DataKeys[r.RowIndex].Value; //item.QuantityToOrder = 5; item.QuantityToOrder = Convert.ToInt32(((TextBox)r.FindControl("txtRecommend")).Text.ToString()); using (CatalogManager cm = new CatalogManager()) { StationeryPriceSearchDTO criteria = new StationeryPriceSearchDTO(); criteria.SupplierID = Convert.ToInt32(((DropDownList)r.FindControl("ddlSupplier")).SelectedValue.ToString()); criteria.StationeryID = (int)item.StationeryID; item.Price = cm.FindStationeryPricesByCriteria(criteria)[0].Price; // record supplier ID for the PO purchaseOrder.SupplierID = criteria.SupplierID; } purchaseOrder.PurchaseOrderItems.Add(item); // only this way works } } pom.CreatePurchaseOrder(purchaseOrder); } } }
protected void CategoryGridView_SelectedIndexChanged(object sender, EventArgs e) { int selectedIndex = (int) CategoryGridView.SelectedDataKey.Value; Category category = null; using (CatalogManager cm = new CatalogManager()) { category = cm.GetCategoryByID(selectedIndex); if (category != null) { List<Stationery> stationeries = category.Stationeries.ToList(); this.StationeryGridView.DataSource = stationeries; this.StationeryGridView.DataBind(); } } }
protected void btnConfirm_Click(object sender, EventArgs e) { using (PurchaseOrderManager pom = new PurchaseOrderManager()) { PurchaseOrder po = pom.FindPurchaseOrderByID(int.Parse(Request.QueryString["ID"])); po.DONumber = txtDONumber.Text.ToString(); po.IsDelivered = true; po.DateReceived = Convert.ToDateTime(txtReceivedDate.Text.ToString()); po.ReceivedBy = Membership.GetCurrentLoggedInUser().UserID; pom.UpdatePurchaseOrder(po); using (AdjustmentVoucherManager avm = new AdjustmentVoucherManager()) { SA33.Team12.SSIS.DAL.AdjustmentVoucher av = new SA33.Team12.SSIS.DAL.AdjustmentVoucher(); av.VoucherNumber = avm.GenerateVoucherNumber(); av.CreatedBy = Membership.GetCurrentLoggedInUser().UserID; av.DateIssued = po.DateOfOrder; av.DateApproved = DateTime.Now; av.ApprovedBy = Membership.GetCurrentLoggedInUser().UserID; foreach (PurchaseOrderItem item in po.PurchaseOrderItems) { // generate stocklog for each poItem StockLog log = new StockLog(); log.AdjustmentVoucher = av; log.Balance = item.Stationery.QuantityInHand; log.Quantity = item.QuantityToOrder; log.Reason = "Supplier - " + po.Supplier.CompanyName; log.StationeryID = item.StationeryID; log.Type = 3; // "replenishment" accroding to enu in DAL.AdjustmentVoucherDAO log.Price = item.Price; log.DateCreated = DateTime.Now; av.StockLogs.Add(log); // update replensih stationery stock using (CatalogManager cm = new CatalogManager()) { item.Stationery.QuantityInHand = item.Stationery.QuantityInHand + item.QuantityToOrder; cm.UpdateStationery(item.Stationery); } } avm.CreateAdjustmentVoucher(av); } } Response.Redirect("ViewPurchaseOrder.aspx"); }
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"; } }
protected void SubmitButton_Click(object sender, EventArgs e) { Location location = new Location(); location.Name = NameTextBox.Text; location.CreatedBy = Utilities.Membership.GetCurrentLoggedInUser().UserID; location.CreatedDate = DateTime.Now; CatalogManager manager = new CatalogManager(); try { manager.CreateLocation(location); } catch (Exception) { ErrorLabel.Text = "Create Location Failed"; } }
protected void StationeriesGridView_RowDataBound(object sender, GridViewRowEventArgs e) { if(e.Row.RowType == DataControlRowType.DataRow) { List<Supplier> suppliers = new List<Supplier>(); int stationeryID = (int) DataBinder.Eval(e.Row.DataItem, "StationeryID"); DropDownList SupplierDrowDownList = e.Row.FindControl("SupplierDrowDownList") as DropDownList; using (CatalogManager cm = new CatalogManager()) { List<StationeryPrice> prices = cm.GetStationeryPricesByStationeryID(stationeryID); foreach (StationeryPrice p in prices) { suppliers.Add(p.Supplier); } SupplierDrowDownList.DataSource = suppliers; SupplierDrowDownList.DataBind(); } } }
protected void SubmitButton_Click(object sender, EventArgs e) { Supplier supplier = new Supplier(); supplier.SupplierCode = SupplierCodeTextBox.Text; supplier.CompanyName = NameTextBox.Text; supplier.TenderedYear = TenderYearCalender.SelectedDate; supplier.PreferredRank = Convert.ToInt32(RankingDDL.SelectedValue); CatalogManager manager = new CatalogManager(); try { manager.CreateSupplier(supplier); SupplierGridView.DataBind(); } catch (Exception) { ErrorLabel.Text = "Create Supplier Failed"; } }
private List<Supplier> SupplierInvolved() { List<Supplier> suppliers = new List<Supplier>(); foreach (GridViewRow r in gvPOItems.Rows) { bool existing = false; int SupplierId = Convert.ToInt32(((DropDownList)r.FindControl("ddlSupplier")).SelectedValue.ToString()); foreach (Supplier s in suppliers) { if (SupplierId == s.SupplierID) existing = true; } if (!existing) using (CatalogManager cm = new CatalogManager()) { Supplier supplier = cm.GetSupplierByID(SupplierId); suppliers.Add(supplier); } } return suppliers; }
private void Populate() { using (CatalogManager cm = new CatalogManager()) { List<SpecialStationery> stationeries = cm.GetSpecialStationeryToBeOrdered(); this.gvPOItems.DataSource = stationeries; this.gvPOItems.DataBind(); } lblCreatedBy.Text = Membership.GetCurrentLoggedInUser().UserName; lblDate.Text = DateTime.Now.ToShortDateString(); }
protected void UpdateRetrievedQuantity() { GridView StationeryRetrievalFormItemGridView = StationeryRetrievalFormView.FindControl("StationeryRetrievalFormItemGridView") as GridView; if (StationeryRetrievalFormItemGridView != null) { try { int srfID = Convert.ToInt32(this.StationeryRetrievalFormView.DataKey.Value); AdjustmentVoucherTransaction adj = new AdjustmentVoucherTransaction(); List<Stationery> stationeries = new List<Stationery>(); List<SpecialStationery> specialStationeries = new List<SpecialStationery>(); using (StationeryRetrievalManager srm = new StationeryRetrievalManager()) { DAL.StationeryRetrievalForm srf = srm.GetStationeryRetrievalFormByID(srfID); List<StationeryRetrievalFormItem> srfis = srf.StationeryRetrievalFormItems.ToList(); foreach (GridViewRow row in StationeryRetrievalFormItemGridView.Rows) { HiddenField StationeryRetrievalFormItemIDHiddenField = row.FindControl("StationeryRetrievalFormItemIDHiddenField") as HiddenField; int srfiID = Convert.ToInt32(StationeryRetrievalFormItemIDHiddenField.Value); TextBox QtyRetrieved = row.FindControl("QuantityRetrievedTextBox") as TextBox; StationeryRetrievalFormItem srfi = (from s in srfis where s.StationeryRetrievalFormItemID == srfiID select s).FirstOrDefault(); int quantityRetrieved = Convert.ToInt32(QtyRetrieved.Text); srfi.QuantityRetrieved = quantityRetrieved; StockLogTransaction stockLogTransaction = new StockLogTransaction(); stockLogTransaction.Reason = ""; stockLogTransaction.Quantity = quantityRetrieved; if (srfi.Stationery != null) { Stationery stationery = srfi.Stationery; stockLogTransaction.StationeryID = srfi.Stationery.StationeryID; StationeryPrice price = stationery.StationeryPrices.First(); stockLogTransaction.Price = price.Price; stationery.QuantityInHand -= quantityRetrieved; stationeries.Add(stationery); stockLogTransaction.Balance = stationery.QuantityInHand; } else { SpecialStationery specialStationery = srfi.SpecialStationery; stockLogTransaction.SpecialStationeryID = srfi.SpecialStationery.SpecialStationeryID; stockLogTransaction.Price = 0.0m; specialStationery.Quantity -= quantityRetrieved; stockLogTransaction.Balance = specialStationery.Quantity; specialStationeries.Add(specialStationery); } stockLogTransaction.DateCreated = DateTime.Now; stockLogTransaction.Type = (int) AdjustmentType.Consumption; adj.StockLogTransactions.Add(stockLogTransaction); } StationeryRetrievalForm newSRF = srm.UpdateReceivedQuantity(srf); newSRF = srm.SetRecommendedQuantity(newSRF.StationeryRetrievalFormID); using(CatalogManager cm = new CatalogManager()) { foreach (Stationery stationery in stationeries) { cm.UpdateStationery(stationery); } foreach (SpecialStationery specialStationery in specialStationeries) { cm.UpdateSpecialStationery(specialStationery); } } } } catch (Exception exception) { this.ErrorMessage.Text = exception.Message; } } }
protected void SubmitButton_Click(object sender, EventArgs e) { Category category = new Category(); category.Name = NameTextBox.Text; category.CreatedBy = Utilities.Membership.GetCurrentLoggedInUser().UserID; category.ModifiedBy = Utilities.Membership.GetCurrentLoggedInUser().UserID; CatalogManager categoryManager = new CatalogManager(); try { categoryManager.CreateCategory(category); CategoryGridView.DataBind(); } catch (Exception) { ErrorLabel.Text = "Category Creation Failed"; } }
protected void Populate() { UserManager um = new UserManager(); ddlAttentionTo.DataSource = um.GetUserByDepartment(Utilities.Membership.GetCurrentLoggedInUser().DepartmentID); DataBind(); using (CatalogManager cm = new CatalogManager()) { List<Stationery> stationeries = cm.GetStationeriesByQuantityInHandLessThanReorderLevel(); this.gvPOItems.DataSource = stationeries; this.gvPOItems.DataBind(); } lblCreatedBy.Text = Membership.GetCurrentLoggedInUser().UserName; lblDate.Text = DateTime.Now.ToShortDateString(); }
protected void Page_Load(object sender, EventArgs e) { requisitionManager = new RequisitionManager(); cManager = new CatalogManager(); CancelButton.Visible = false; if (!IsPostBack) { UrgencyDDL.DataSource = requisitionManager.GetAllUrgencies(); UrgencyDDL.DataTextField = "Name"; UrgencyDDL.DataValueField = "UrgencyID"; DataBind(); foreach (ListItem item in UrgencyDDL.Items) { if (item.Text == "Normal") { item.Selected = true; } } requisition = CreateRequisition(); Session["Requisition"] = requisition; } if (Session["Requisition"] != null) { requisition = (Requisition)Session["Requisition"]; } string key = string.Empty; int val = 0; NameValueCollection nv = Request.QueryString; if (nv.HasKeys()) { key = nv.GetKey(0); try { val = Convert.ToInt32(nv.Get(0)); } catch (Exception) { } } if (key == "RequestID" && val > 0) { requisition = requisitionManager.GetRequisitionByID(val); if (requisition != null) { Panel1.Visible = false; Panel2.Visible = false; RequestItemGridView.Columns[0].Visible = false; RequestItemGridView.Columns[1].Visible = false; SpecialRequestItemGridView.Columns[0].Visible = false; Panel4.Visible = false; SubmitButton.Visible = false; if (requisition.Status.Name == "Pending") { CancelButton.Visible = true; } GridDataBind(); } } }
// to show recommended order quantity protected void gvPOItems_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { int stationeryID = (int)DataBinder.Eval(e.Row.DataItem, "StationeryID"); if (stationeryID != 0) { TextBox tb = e.Row.FindControl("txtRecommend") as TextBox; DropDownList SupplierDrowDownList = e.Row.FindControl("ddlSupplier") as DropDownList; List<Supplier> suppliers = new List<Supplier>(); using (CatalogManager cm = new CatalogManager()) { List<StationeryPrice> prices = cm.GetStationeryPricesByStationeryID(stationeryID); Stationery stationery = cm.FindStationeryByID(stationeryID); foreach (StationeryPrice p in prices) { suppliers.Add(p.Supplier); } SupplierDrowDownList.DataSource = suppliers; SupplierDrowDownList.DataBind(); if (tb != null) { using (PurchaseOrderManager pom = new PurchaseOrderManager()) { tb.Text = (pom.GetQuantityToOrder(stationeryID) - stationery.QuantityInHand + stationery.ReorderLevel + stationery.ReorderQuantity).ToString(); } } } } } }