protected void uiGridViewOrders_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EditOrder") { IStock.BLL.PurchaseOrders objData = new IStock.BLL.PurchaseOrders(); objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())); uiTextBoxCode.Text = objData.PurchaseOrderNo; uiTextBoxDate.Text = objData.PurchaseOrderDate.ToString("dd/MM/yyy"); uiDropDownListSuppliers.SelectedValue = objData.SupplierID.ToString(); uiPanelAllOrders.Visible = false; uiPanelEditPurchaseOrder.Visible = true; uiPanelItems.Visible = true; CurrentPurchaseOrder = objData; BindItems(); EnableDisableControls(); } else if (e.CommandName == "DeleteOrder") { try { IStock.BLL.PurchaseOrders objData = new IStock.BLL.PurchaseOrders(); objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())); IStock.BLL.PurchaseOrderDetails details = new IStock.BLL.PurchaseOrderDetails(); details.GetPurchaseOrderDetails(objData.PurchaseOrderID); /* if (details.RowCount > 0) { for(int i=0;i<details.RowCount;i++) { IStock.BLL.Items item = new IStock.BLL.Items(); item.LoadByPrimaryKey(details.ItemID); item.Quantity -= details.NoOfPackages * details.ItemOnPackages; item.Save(); details.MoveNext(); } } */ details.MarkAsDeleted(); details.Save(); objData.MarkAsDeleted(); objData.Save(); CurrentPurchaseOrder = null; BindOrders(); } catch (Exception ex) { uipanelError.Visible = true; } } }
private void BindOrders() { IStock.BLL.PurchaseOrders Orders = new IStock.BLL.PurchaseOrders(); Orders.GetAllPurchaseOrders(); uiGridViewOrders.DataSource = Orders.DefaultView; uiGridViewOrders.DataBind(); }
protected void uiLinkButtonOK_Click(object sender, EventArgs e) { IStock.BLL.PurchaseOrders order = new IStock.BLL.PurchaseOrders(); if (CurrentPurchaseOrder == null) order.AddNew(); else order = CurrentPurchaseOrder; order.PurchaseOrderNo = uiTextBoxCode.Text; order.SupplierID= Convert.ToInt32(uiDropDownListSuppliers.SelectedValue); order.PurchaseOrderDate = DateTime.ParseExact(uiTextBoxDate.Text, "dd/MM/yyyy", null); order.Confirmed = false; order.Save(); //ClearFields(); CurrentPurchaseOrder = order; uiPanelEditPurchaseOrder.Visible = true; uiPanelAllOrders.Visible = false; uiPanelItems.Visible = true; BindItems(); EnableDisableControls(); }
protected void uiLinkButtonCancel_Click(object sender, EventArgs e) { ClearFields(); CurrentPurchaseOrder = null; uiPanelEditPurchaseOrder.Visible = false; uiPanelAllOrders.Visible = true; uiPanelItems.Visible = false; }
protected void uiLinkButtonAdd_Click(object sender, EventArgs e) { ClearFields(); CurrentPurchaseOrder = null; uipanelError.Visible = false; uiPanelEditPurchaseOrder.Visible = true; IStock.BLL.PurchaseOrders d = new IStock.BLL.PurchaseOrders(); uiTextBoxCode.Text = d.getNewSerial(); uiPanelAllOrders.Visible = false; /////// uiLinkButtonConfirm.Enabled = true; uiGridViewItems.Enabled = true; uiDropDownListSuppliers.Enabled = true; uiTextBoxDate.Enabled = true; uiTextBoxItemOnPackages.Enabled = true; uiTextBoxItems.Enabled = true; uiTextBoxNoOfPackages.Enabled = true; uiTextBoxPrice.Enabled = true; /////// }
protected void uiLinkButtonPurchaseOrders_Click(object sender, EventArgs e) { uiReportViewerMain.Reset(); uiReportViewerMain.LocalReport.ReportPath = BaseReportPath + "Report_GetPurchaseOrders.rdlc"; IStock.BLL.PurchaseOrders purchaseOrder = new IStock.BLL.PurchaseOrders(); DateTime? From = null, To = null; if (!string.IsNullOrEmpty(uiTextBoxFrom.Text)) From = DateTime.ParseExact(uiTextBoxFrom.Text, "dd/MM/yyyy", null); if (!string.IsNullOrEmpty(uiTextBoxTo.Text)) To = DateTime.ParseExact(uiTextBoxTo.Text, "dd/MM/yyyy", null); int SupID = 0; if (!string.IsNullOrEmpty(uiDropDownListSuppliers.SelectedValue)) SupID = Convert.ToInt32(uiDropDownListSuppliers.SelectedValue); int ItemID = 0; if (!string.IsNullOrEmpty(uiHiddenFieldCurrentItem.Value)) ItemID = Convert.ToInt32(uiHiddenFieldCurrentItem.Value); purchaseOrder.Report_PurchaseOrders(ItemID, SupID,From, To); uiReportViewerMain.LocalReport.DataSources.Clear(); uiReportViewerMain.LocalReport.DataSources.Add(new ReportDataSource("Report_GetPurchaseOrdersDataSet", purchaseOrder.DefaultView)); uiReportViewerMain.LocalReport.Refresh(); }