/// <summary> /// Create a new AllowedStore object from a Company object. /// </summary> /// <param name="customer_">customer_</param> /// <returns>The newly created AllowedStore object.</returns> public static AllowedStore CreateAllowedStoreBycustomer_(Company @customer_) { AllowedStore allowedStore = InitializeNew <AllowedStore>(); allowedStore.customer_id = @customer_.company_id; allowedStore.customer_ = @customer_; return(allowedStore); }
/// <summary> /// Create a new AllowedStore object from a Company object. /// </summary> /// <param name="supplier_">supplier_</param> /// <returns>The newly created AllowedStore object.</returns> public static AllowedStore CreateAllowedStoreBysupplier_(Company @supplier_) { AllowedStore allowedStore = InitializeNew <AllowedStore>(); allowedStore.supplier_id = @supplier_.company_id; allowedStore.supplier_ = @supplier_; return(allowedStore); }
public static List <Company> GetCustomers(int supplierID) { List <SqlParameter> parameters = new List <SqlParameter>(); parameters.Add(new SqlParameter("@supplier_id", supplierID)); string where = "where supplier_id = @supplier_id"; EntityList <AllowedStore> permissions = AllowedStore.GetAllowedStores(where, parameters); List <Company> customers = new List <Company>(); foreach (var permission in permissions) { customers.Add(permission.customer_); } return(customers); }
public static AllowedStore GetAllowedStoreByCustomerSupplier(int customerID, int supplierID) { List <SqlParameter> parameters = new List <SqlParameter>(); parameters.Add(new SqlParameter("@customer_id", customerID)); parameters.Add(new SqlParameter("@supplier_id", supplierID)); string where = "where customer_id = @customer_id and supplier_id = @supplier_id"; EntityList <AllowedStore> permissions = AllowedStore.GetAllowedStores(where, parameters); if (permissions.Count > 0) { return(permissions[0]); } else { return(null); } }
protected void Page_Load(object sender, EventArgs e) { loggedInAdmin = Helpers.GetLoggedInAdmin(); homeCompany = Helpers.GetCurrentCompany(); currentInvoice = Helpers.GetRequestedInvoice(); permission = AllowedStore.GetAllowedStoreByCustomerSupplier(homeCompany.company_id, currentInvoice.supplier_id); if (!(Helpers.IsAuthorizedAdmin(loggedInAdmin, homeCompany))) { Response.Redirect("/status.aspx?error=notadmin"); } else if (!(currentInvoice.customer_id == homeCompany.company_id || currentInvoice.supplier_id == homeCompany.company_id)) { Response.Redirect("/status.aspx?error=genericerror"); } if (!IsPostBack) { PopulateDetails(); PopulateInvoiceItems(); } }
protected void Page_Load(object sender, EventArgs e) { loggedInAdmin = Helpers.GetLoggedInAdmin(); homeCompany = Helpers.GetCurrentCompany(); currentOrder = Helpers.GetRequestedPurchaseOrder(); permission = AllowedStore.GetAllowedStoreByCustomerSupplier(homeCompany.company_id, currentOrder.supplier_id); if (!(Helpers.IsAuthorizedAdmin(loggedInAdmin, homeCompany))) { Response.Redirect("/status.aspx?error=notadmin"); } else if (!(currentOrder.customer_id == homeCompany.company_id || currentOrder.supplier_id == homeCompany.company_id)) { Response.Redirect("/status.aspx?error=genericerror"); } if (!IsPostBack) { PopulateDetails(); PopulateOrderItems(); PopulaterInvoices(); } if (currentOrder.is_submitted) { StatusLabel.Text = "Submitted and waiting for fulfillment"; EditableOrderItemsGridView.Visible = false; } else if (currentOrder.InvoicesBypurchaseorder_.Count > 0) { StatusLabel.Text = "Fulfilled"; EditableOrderItemsGridView.Visible = false; } else { StatusLabel.Text = "Waiting to submit"; if (currentOrder.customer_id == homeCompany.company_id) { SubmitButton.Visible = true; FindProductPanel.Visible = true; } EditableOrderItemsGridView.Visible = true; FrozenOrderItemsGridView.Visible = false; } }
public String createEDI() { XmlDocument XDoc = new XmlDocument(); XmlDeclaration dec = XDoc.CreateXmlDeclaration("1.0", "utf-8", null); XDoc.AppendChild(dec); // Create root node. XmlElement XElemRoot = XDoc.CreateElement("JiwaDocument"); XElemRoot.SetAttribute("Type", "SalesOrder"); //Add the node to the document. XDoc.AppendChild(XElemRoot); XmlElement XDate = XDoc.CreateElement("InitiatedDate"); XDate.InnerText = this.creation_datetime.ToString("yyyy-MM-dd"); XElemRoot.AppendChild(XDate); XmlElement XDeliveryDate = XDoc.CreateElement("ExpectedDeliveryDate"); XDeliveryDate.InnerText = this.creation_datetime.AddDays(10).ToString("yyyy-MM-dd"); XElemRoot.AppendChild(XDeliveryDate); XmlElement XOrderNo = XDoc.CreateElement("OrderNo"); string orderNumber = ""; if (String.IsNullOrEmpty(this.local_code)) { orderNumber = "HS_" + this.purchaseorder_id.ToString(); } else { orderNumber = this.local_code; } XOrderNo.InnerText = orderNumber; XElemRoot.AppendChild(XOrderNo); XmlElement XSoReference = XDoc.CreateElement("SoReference"); XSoReference.InnerText = "EDI/" + orderNumber + "/" + this.creation_datetime.ToString("yyyy-MM-dd HH:mm:ss"); XElemRoot.AppendChild(XSoReference); XmlElement XDebtor = XDoc.CreateElement("Debtor"); XmlElement XAccountNo = XDoc.CreateElement("AccountNo"); XAccountNo.InnerText = AllowedStore.GetAllowedStoreByCustomerSupplier(this.customer_id, this.supplier_id).account_number; XDebtor.AppendChild(XAccountNo); XElemRoot.AppendChild(XDebtor); XmlElement XLines = XDoc.CreateElement("Lines"); foreach (var item in this.PurchaseOrderItemsBypurchaseorder_) { XmlElement Xline = XDoc.CreateElement("Line"); XmlElement XPartNo = XDoc.CreateElement("PartNo"); XPartNo.InnerText = item.product_code; XmlElement XQuantityOrdered = XDoc.CreateElement("QuantityOrdered"); XQuantityOrdered.InnerText = item.quantity.ToString("#0.00"); Xline.AppendChild(XPartNo); Xline.AppendChild(XQuantityOrdered); XLines.AppendChild(Xline); } XElemRoot.AppendChild(XLines); return(FormatXML(XDoc)); }