private void EditCompany(Company company)
        {
            CustomerDetailsControl details = new CustomerDetailsControl(company.CompanyType.Type);
            details.DataContext = company;

            if (details.ShowDialog() == true)
            {
                DBResources.Instance.Save();
            }
        }
Ejemplo n.º 2
0
        public static string GetPurchaseOrderNumber(Company supplier, Order order)
        {
            string startYear = string.Empty;
            string endYear = string.Empty;
            int currentYear = int.Parse(DateTime.Now.ToString("yy"));
            string poUniqueNumber = order.OrderID.ToString() + "-" + (order.PurchaseOrders.Count + 1).ToString();
            string customerCode = order.Customer.Name.Substring(0, 2).ToUpper();
            if (DateTime.Now.Month >= 4)
            {
                startYear = currentYear.ToString();
                endYear = (currentYear + 1).ToString();
            }
            else
            {
                startYear = (currentYear - 1).ToString();
                endYear = currentYear.ToString();
            }

            return string.Format("TCIPL/{0}-{1}/{2}/{3}",startYear, endYear, customerCode, poUniqueNumber);
        }
Ejemplo n.º 3
0
        public static string GetSupplierInformation(Company supplier)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine(supplier.Name + ",");
            if (!string.IsNullOrEmpty(supplier.Address1))
                sb.AppendLine(supplier.Address1 + ",");

            if (!string.IsNullOrEmpty(supplier.Address2))
                sb.AppendLine(supplier.Address2 + ",");

            sb.AppendLine(supplier.City + "," + supplier.State + ",");
            sb.AppendLine(supplier.Country + ".");

            sb.AppendLine("TIN No: ");
            sb.Append(supplier.TIN);

            sb.AppendLine("CST No: ");
            sb.AppendLine(supplier.CST);

            return sb.ToString();

        }
Ejemplo n.º 4
0
        private Company NewCompany(string type, string companyName)
        {

            CustomerDetailsControl details = new CustomerDetailsControl(type);
            Company newCompany = new Company();
            newCompany.Name = companyName;
            details.DataContext = newCompany;
            if (details.ShowDialog() == true)
            {
                return DBResources.Instance.SaveNewCompany(newCompany, type);
            }
           
            return null;
        }
Ejemplo n.º 5
0
 private string GetPurchaseOrderNumber(Company supplier)
 {
     return Constants.GetPurchaseOrderNumber(supplier, Order);
 }
Ejemplo n.º 6
0
        public Company SaveNewCompany(Company company, string type)
        {
            OrderManagerDBEntities localContext = new OrderManagerDBEntities();
            try
            {
                var companyType = localContext.CompanyTypes.Where(c => c.Type == type).Select(c => c).FirstOrDefault();
                company.CompanyTypeID = companyType.CompanyTypeID;
                company.CompanyType = companyType;
                localContext.Companies.Add(company);
                localContext.SaveChanges();
                localContext.Dispose();
            }
            catch { throw; }
            Companies = new ObservableCollection<Company>(dbContext.Companies.ToList());
            Company newCompany = null;
            if (Companies != null)
            {
                newCompany = Companies.Where(c => (c.CompanyType.Type == company.CompanyType.Type && c.Name == company.Name)).Select(c => c).FirstOrDefault();
            }
            else return null;

            switch (company.CompanyType.Type)
            {
                case "Customer":
                    Customers = UpdateCompaniesCollection("Customer");
                    break;
                case "Agent":
                    Agents = UpdateCompaniesCollection("Agent");
                    break;
                case "Supplier":
                    Suppliers = UpdateCompaniesCollection("Supplier");
                    break;
            }
            return newCompany;
        }
Ejemplo n.º 7
0
        //Create a new Company of type passed in the arguments
        public Company CreateNewCompany(string type)
        {
            Company newCompany = new Company();


            var companyType = dbContext.CompanyTypes.Where(c => c.Type == type)
                                                      .Select(c => c)
                                                      .FirstOrDefault();

            newCompany.CompanyTypeID = companyType.CompanyTypeID;
            //newCompany.CompanyType = companyType;

            return newCompany;
        }
Ejemplo n.º 8
0
        public PurchaseOrder CreateNewPurchaseOrder(Order order, Company supplier, string purchseOrderNumber)
        {
            PurchaseOrder newPO = new PurchaseOrder();
            newPO.PurchaseOrderNumber = purchseOrderNumber;
            newPO.SupplierID = supplier.CompanyID;
            newPO.OrderID = order.OrderID;
            newPO.PurchaseOrderStatusID = 1;

            OrderManagerDBEntities newManager = new OrderManagerDBEntities();
            newManager.PurchaseOrders.Add(newPO);
            newManager.SaveChanges();
            newManager.Dispose();

            newPO = GetPurchaseOrder(purchseOrderNumber);

            return newPO;
        }
 private bool EditSupplier(Company company)
 {
     CustomerDetailsControl details = new CustomerDetailsControl("Supplier");
     details.DataContext = company;
     if (details.ShowDialog() == true)
     {
         DBResources.Instance.Save();
         return true;
     }
     return false;
 }
 public PurchaseOrderNumberInfo(Company supplier, Order order)
 {
     Supplier = supplier;
     PurchaseOrderNumber = Constants.GetPurchaseOrderNumber(supplier, order);
 }
        private string GetAddress(Company supplier)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine(supplier.Name + ",");
            if (!string.IsNullOrEmpty(supplier.Address1))
                sb.AppendLine(supplier.Address1 + ",");

            if (!string.IsNullOrEmpty(supplier.Address2))
                sb.AppendLine(supplier.Address2 + ",");

            sb.AppendLine(supplier.City + "," + supplier.State + ",");
            sb.AppendLine(supplier.Country + ".");

            return sb.ToString();
        }