Exemplo n.º 1
0
        public OrderPartner GetOrderPartnet(OrderPartnerType _PartnerType)
        {
            List <OrderPartner> _returnval = this._OrderPartners.OfType <OrderPartner>().Where(o => o.Type == _PartnerType).ToList();

            if (_returnval.Count > 0)
            {
                return(_returnval[0]);
            }
            return(null);
        }
Exemplo n.º 2
0
        public OrderPartner(String ErpID, string Org_id, OrderPartnerType partnerType)
        {
            LoadPartner(ErpID, Org_id, partnerType);

            // Add for exception case
            if (String.IsNullOrEmpty(this.ErpID))
            {
                this.Type  = partnerType;
                this.ErpID = ErpID;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 建立EQPartner表資料
        /// Sold_to(SOLD_TO), Ship_to(S), Bill_to(B) 三種type傳入ERPID後撈取地址資訊進行設定,相關設定與地址不可留空
        /// EndCustomer(EM)與Employee(E)僅需設定ERPID欄位即可,無設定時ERPID欄位留白
        /// </summary>
        /// <param name="_ERPID"></param>
        /// <param name="_QuoteID"></param>
        /// <param name="_PartnerTypes"></param>
        public static void CreateEQPartnerByERPID(String _ERPID, String _QuoteID, OrderPartnerType _PartnerTypes)
        {
            if (String.IsNullOrEmpty(_QuoteID))
            {
                return;
            }

            SAP_DIMCOMPANY SAPDimCompany = MyAdvantechContext.Current.SAP_DIMCOMPANY.Where(d => d.COMPANY_ID.Equals(_ERPID, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
            DataTable      dt            = DataAccess.SAPDAL.GetSAPCompanyAddressByID(_ERPID);
            EQPARTNER      e             = new EQPARTNER();

            e.QUOTEID = _QuoteID;
            e.ERPID   = _ERPID;
            e.ROWID   = "";

            switch (_PartnerTypes)
            {
            case OrderPartnerType.SoldTo:
            case OrderPartnerType.ShipTo:
            case OrderPartnerType.BillTo:

                // These three types are now allowed to leave fields blank.
                if (SAPDimCompany == null || dt == null || dt.Rows.Count == 0)
                {
                    return;
                }

                String type = String.Empty;

                if (_PartnerTypes == OrderPartnerType.SoldTo)
                {
                    type = "SOLDTO";
                }
                else if (_PartnerTypes == OrderPartnerType.ShipTo)
                {
                    type = "S";
                }
                else if (_PartnerTypes == OrderPartnerType.BillTo)
                {
                    type = "B";
                }

                e.TYPE      = type;
                e.NAME      = SAPDimCompany.COMPANY_NAME;
                e.ADDRESS   = SAPDimCompany.ADDRESS;
                e.ATTENTION = SAPDimCompany.ATTENTION;
                e.TEL       = SAPDimCompany.TEL_NO;
                e.MOBILE    = "";
                e.ZIPCODE   = SAPDimCompany.ZIP_CODE;
                e.COUNTRY   = SAPDimCompany.COUNTRY;
                e.CITY      = SAPDimCompany.CITY;
                e.STREET    = dt.Rows[0]["STREET"].ToString();     // STREET2 is not in SAP_DIMCOMPANY... use dt
                e.STREET2   = dt.Rows[0]["STR_SUPPL3"].ToString(); // STREET2 is not in SAP_DIMCOMPANY... use dt
                e.STATE     = SAPDimCompany.REGION_CODE;
                e.DISTRICT  = "";
                e.FAX       = SAPDimCompany.FAX_NO;

                break;

            case OrderPartnerType.EndCoutomer:
                e.NAME      = "";
                e.ADDRESS   = "";
                e.ATTENTION = "";
                e.TEL       = "";
                e.MOBILE    = "";
                e.ZIPCODE   = "";
                e.COUNTRY   = "";
                e.CITY      = "";
                e.STATE     = "";
                e.DISTRICT  = "";
                e.STREET    = "";
                e.STREET2   = "";
                e.FAX       = "";
                e.TYPE      = "EM";
                break;

            case OrderPartnerType.Employee1:
                e.NAME      = "";
                e.ADDRESS   = "";
                e.ATTENTION = "";
                e.TEL       = "";
                e.MOBILE    = "";
                e.ZIPCODE   = "";
                e.COUNTRY   = "";
                e.CITY      = "";
                e.STATE     = "";
                e.DISTRICT  = "";
                e.STREET    = "";
                e.STREET2   = "";
                e.FAX       = "";
                e.TYPE      = "E";
                break;
            }
            eQuotationContext.Current.EQPARTNER.Add(e);
            eQuotationContext.Current.SaveChanges();
        }
Exemplo n.º 4
0
        public void LoadPartner(String ErpID, string Org_id, OrderPartnerType partnerType)
        {
            string        CompanyName = string.Empty; string Division = string.Empty; string SalesGroup = string.Empty;
            string        SalesOffice = string.Empty;
            DataTable     dt          = new DataTable();
            StringBuilder sb          = new StringBuilder();

            sb.AppendLine(" SELECT A.KUNN2 AS company_id ");
            sb.AppendLine(" , A.VKORG as ORG_ID ");
            sb.AppendLine(" , case A.PARVW when 'WE' then 'Ship-To' when 'AG' then 'Sold-To' when 'RE' then 'Bill-To' end as PARTNER_FUNCTION ");
            sb.AppendLine(" FROM saprdp.knvp A ");
            sb.AppendLine(" Where A.Kunnr = '" + ErpID + "' ");
            sb.AppendLine(" AND A.KUNN2 like '%" + ErpID + "%' ");
            sb.AppendLine(" AND A.VKORG = '" + Org_id + "' ");
            if (partnerType != null)
            {
                switch (partnerType)
                {
                case OrderPartnerType.SoldTo:
                    sb.Append(" AND A.PARVW = 'AG' ");
                    break;

                case OrderPartnerType.ShipTo:
                    sb.Append(" AND A.PARVW ='WE' ");
                    break;

                case OrderPartnerType.BillTo:
                    sb.Append(" AND A.PARVW ='RE' ");
                    break;
                }
            }
            dt = OracleProvider.GetDataTable("SAP_PRD", sb.ToString());
            if (dt.Rows.Count > 0)
            {
                var dr = dt.Rows[0];
                this.District = "";
                this.ErpID    = dr["company_id"].ToString();
                this.TaxJuri  = "";
                this.Type     = partnerType;
            }

            sb.Clear();
            sb.AppendLine(" SELECT B.NAME1 AS COMPANY_NAME ");
            sb.AppendLine(" , B.Land1 AS  COUNTRY ");
            sb.AppendLine(" , B.Ort01 AS CITY ");
            sb.AppendLine(" , B.STRAS as STREET ");
            sb.AppendLine(" , B.PSTLZ AS ZIP_CODE ");
            sb.AppendLine(" , B.TELF1 AS TEL_NO ");
            sb.AppendLine(" , B.TELFX AS FAX_NO ");
            sb.AppendLine(" , B.adrnr ");
            sb.AppendLine(" FROM saprdp.kna1 B ");
            sb.AppendLine(" Where B.KUNNR='" + this.ErpID + "' ");
            sb.AppendLine(" AND B.loevm<>'X' ");
            dt = OracleProvider.GetDataTable("SAP_PRD", sb.ToString());

            string b_adrsr = string.Empty;

            if (dt.Rows.Count > 0)
            {
                var dr = dt.Rows[0];
                this.City    = dr["CITY"].ToString();
                this.Country = dr["COUNTRY"].ToString();
                this.Name    = dr["COMPANY_NAME"].ToString();
                this.Mobile  = dr["FAX_NO"].ToString();
                this.Street  = dr["STREET"].ToString();
                this.Tel     = dr["TEL_NO"].ToString();
                this.ZipCode = dr["ZIP_CODE"].ToString();
                b_adrsr      = dr["adrnr"].ToString();
            }

            sb.Clear();
            sb.AppendLine(" SELECT D.street  ||' '|| D.city1 ||' '|| D.region ||' '|| D.post_code1 ||' '|| ");
            sb.Append(" (select e.landx from saprdp.t005t e where e.land1='" + this.Country + "' and e.spras='E' and rownum=1) AS Address  ");
            sb.AppendLine(", D.region AS STATE ");
            sb.AppendLine(", D.NAME_CO as Attention ");
            sb.AppendLine(",D.STR_SUPPL3 ");
            sb.AppendLine(" FROM saprdp.adrc D ");
            sb.AppendLine(" Where D.country='" + this.Country + "' ");
            sb.AppendLine(" AND D.addrnumber='" + b_adrsr + "' ");
            dt = OracleProvider.GetDataTable("SAP_PRD", sb.ToString());


            if (dt.Rows.Count > 0)
            {
                var dr = dt.Rows[0];
                this.State     = dr["STATE"].ToString();
                this.Address   = dr["Address"].ToString();
                this.Attention = dr["Attention"].ToString();
            }

            this.TaxJuri = this.State + this.ZipCode;
        }