コード例 #1
0
        private void PopulateFieldsFromCompany()
        {
            if (Job_header.CompanyId == 0)
            {
                return;
            }

            Job_header.ReferenceShort1  = SelectedCompany.RepCode;
            Job_header.ReferenceShort2  = SelectedCompany.SalesmanCode;
            Job_header.ContactPerson    = SelectedCompany.SalesContact;
            Job_header.ContactTelephone = SelectedCompany.SalesTelephone;

            DB.VW_Address billingAddress  = DataContext.ReadonlyContext.VW_Address.FirstOrDefault(n => n.CompanyId == Job_header.CompanyId && n.TypeId == (byte)BL.SYS.SYS_Type.BillingAddress);
            DB.VW_Address shippingAddress = DataContext.ReadonlyContext.VW_Address.FirstOrDefault(n => n.CompanyId == Job_header.CompanyId && n.TypeId == (byte)BL.SYS.SYS_Type.ShippingAddress);

            Job_header.BillingAddressLine1 = billingAddress.Line1;
            Job_header.BillingAddressLine2 = billingAddress.Line2;
            Job_header.BillingAddressLine3 = billingAddress.Line3;
            Job_header.BillingAddressLine4 = billingAddress.Line4;
            Job_header.BillingAddressCode  = billingAddress.Code;

            Job_header.ShippingAddressLine1 = shippingAddress.Line1;
            Job_header.ShippingAddressLine2 = shippingAddress.Line2;
            Job_header.ShippingAddressLine3 = shippingAddress.Line3;
            Job_header.ShippingAddressLine4 = shippingAddress.Line4;
            Job_header.ShippingAddressCode  = shippingAddress.Code;
        }
コード例 #2
0
        private void btnNewSalesQuote_Click(object sender, EventArgs e)
        {
            try
            {
                if (apt.Id == null)
                {
                    UpdateChanges();
                    controller.ApplyChanges();
                    return;
                }

                DB.VW_Company company;

                if (ddlCompany.Properties.View.GetFocusedRow() == null)
                {
                    company = DataContext.ReadonlyContext.VW_Company.FirstOrDefault(n => n.EntityId == controller.CustomEntity && n.TypeId == (int)BL.ORG.ORG_Type.Customer);
                }
                else
                {
                    company = ((DevExpress.Data.Async.Helpers.ReadonlyThreadSafeProxyForObjectFromAnotherThread)(ddlCompany.Properties.View.GetFocusedRow())).OriginalRow as DB.VW_Company;
                }


                DB.SYS_DOC_Header header = BL.SYS.SYS_DOC_Document.New(BL.SYS.SYS_DOC_Type.Quote);
                header.ORG_TRX_Header                  = BL.ORG.ORG_TRX_Header.New;
                header.ORG_TRX_Header.CompanyId        = company.Id;
                header.ORG_TRX_Header.ContactPerson    = company.SalesContact;
                header.ORG_TRX_Header.ContactTelephone = company.SalesTelephone;
                header.ORG_TRX_Header.VatNumber        = company.VatNumber;

                header.ORG_TRX_Header.ReferenceLong2 = apt.Subject;
                header.Comment = apt.Description;
                header.ORG_TRX_Header.ContactPerson    = Convert.ToString(controller.CustomContact);
                header.ORG_TRX_Header.ContactTelephone = Convert.ToString(controller.CustomTelephone);

                DB.VW_Address billingAddress  = DataContext.ReadonlyContext.VW_Address.FirstOrDefault(n => n.CompanyId == header.ORG_TRX_Header.CompanyId && n.TypeId == (byte)BL.SYS.SYS_Type.BillingAddress);
                DB.VW_Address shippingAddress = DataContext.ReadonlyContext.VW_Address.FirstOrDefault(n => n.CompanyId == header.ORG_TRX_Header.CompanyId && n.TypeId == (byte)BL.SYS.SYS_Type.ShippingAddress);

                header.ORG_TRX_Header.BillingAddressLine1 = billingAddress.Line1;
                header.ORG_TRX_Header.BillingAddressLine2 = billingAddress.Line2;
                header.ORG_TRX_Header.BillingAddressLine3 = billingAddress.Line3;
                header.ORG_TRX_Header.BillingAddressLine4 = billingAddress.Line4;
                header.ORG_TRX_Header.BillingAddressCode  = billingAddress.Code;

                header.ORG_TRX_Header.ShippingAddressLine1 = shippingAddress.Line1;
                header.ORG_TRX_Header.ShippingAddressLine2 = shippingAddress.Line2;
                header.ORG_TRX_Header.ShippingAddressLine3 = shippingAddress.Line3;
                header.ORG_TRX_Header.ShippingAddressLine4 = shippingAddress.Line4;
                header.ORG_TRX_Header.ShippingAddressCode  = shippingAddress.Code;

                header.CalendarId = Convert.ToInt64(apt.Id);

                ShowDocumentForm(header);

                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();

                // company = (CompleteDataLayer.Company)CompleteDataLayer.CompanyProvider.Instance.Load(Convert.ToInt32(controller.CustomCompany));

                //// Create new job card
                //CompleteDataLayer.SalesQuote quote = (CompleteDataLayer.SalesQuote)CompleteDataLayer.SalesQuoteProvider.Instance.CreateNew();
                //quote.BeginLoad();

                //if (company != null)
                //{
                //    quote.CompanyGuid = company.CompanyGuid;
                //    quote.VatNumber = company.VatNumber;
                //    quote.BillingAddress = company.BillingAddress.AddressFull;
                //    quote.ShippingAddress = company.ShippingAddress.AddressFull;
                //}

                //quote.TotalAmount = 0M;
                //quote.TotalAmountBeforeTax = 0M;
                //quote.TotalTax = 0M;

                //quote.ReferenceOurs = apt.Subject;
                //quote.Message = apt.Description;
                //quote.Contact = Convert.ToString(controller.CustomContact);
                //quote.Telephone = Convert.ToString(controller.CustomTelephone);
                ////jobquote.Technition = ddlResource.Text;
                //quote.EndLoad();

                //this.DialogResult = System.Windows.Forms.DialogResult.OK;
                //this.Close();

                //CompleteDistribution.SalesQuote.SalesQuoteForm childForm = new CompleteDistribution.SalesQuote.SalesQuoteForm(quote, (Int64)apt.Id);
                //childForm.EnableEvents = false;
                //STD.MainForm.Instance.ShowForm(childForm);
                //childForm.EnableEvents = true;
            }
            catch (Exception ex)
            {
                if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex))
                {
                    throw ex;
                }
            }
        }