private void RecordContext_Saving(object sender, CancelEventArgs e)
 {
     try
     {
         Init();
         AirportObject = RecordContext.GetWorkspaceRecord("CO$Airports") as IGenericObject;
         RecordContext.RefreshWorkspace();
         if (AirportObject != null)
         {
             int IdAirport = Convert.ToInt32(AirportObject.Id);
             if (IdAirport != 0)
             {
                 if (!Allday(IdAirport))
                 {
                     if (!boolGetHours(IdAirport))
                     {
                         MessageBox.Show("You must have at least one normal hour");
                         e.Cancel = true;
                     }
                     if (!CheckExtraordinary(IdAirport))
                     {
                         MessageBox.Show("Extraordinary hours are not under the normal hours.");
                         e.Cancel = true;
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
         throw ex;
     }
 }
Beispiel #2
0
 public new void Click()
 {
     try
     {
         OrgRecord = RecordContext.GetWorkspaceRecord(WorkspaceRecordType.Organization) as IOrganization;
         IList <IOrgAddr> list = OrgRecord.Oaddr;
         if (list != null)
         {
             foreach (IOrgAddr ad in list)
             {
                 if (ad.OatID == 1)
                 {
                     Init();
                     MessageBox.Show(getIsoCode(Convert.ToInt32(ad.AddrCountryID)));
                     MessageBox.Show(getEstado(Convert.ToInt32(ad.AddrCountryID), Convert.ToInt32(ad.AddrProvID)));
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error en Click" + ex.Message);
     }
 }
Beispiel #3
0
        private void RecordContext_Saving(object sender, CancelEventArgs e)
        {
            try
            {
                Init();
                string validate = "";
                OrgRecord = RecordContext.GetWorkspaceRecord(WorkspaceRecordType.Organization) as IOrganization;
                CustomerComplete customerComplete   = new CustomerComplete();
                IList <ICfVal>   orgCustomFieldList = OrgRecord.CustomField;
                foreach (ICfVal orgcampos in orgCustomFieldList)
                {
                    if (orgcampos.CfId == 56)
                    {
                        validate = orgcampos.ValStr;
                    }
                }
                if (GlobalContext != null)
                {
                    if (String.IsNullOrEmpty(validate))
                    {
                        validate = "0";
                    }

                    if (validate == "0")
                    {
                        customerComplete.NombreOrg = OrgRecord.Name;
                        IList <IOrgAddr> list = OrgRecord.Oaddr;
                        foreach (IOrgAddr ad in list)
                        {
                            if (ad.OatID == 1)
                            {
                                customerComplete.Calle        = ad.AddrStreet;
                                customerComplete.Colonia      = ad.AddrCity;
                                customerComplete.CodigoPostal = ad.AddrPostalCode;
                                customerComplete.Pais         = getIsoCode(Convert.ToInt32(ad.AddrCountryID));
                                customerComplete.Estado       = getEstado(Convert.ToInt32(ad.AddrCountryID), Convert.ToInt32(ad.AddrProvID));
                            }
                        }
                        //Obtiene los valores
                        List <CustomFields> customFields = new List <CustomFields>();
                        foreach (ICfVal orgcampos in orgCustomFieldList)
                        {
                            CustomFields custom = new CustomFields();
                            custom.FieldDataType = GetDataType((int)orgcampos.DataType);
                            custom.FieldID       = orgcampos.CfId;
                            custom.FieldName     = GetName(orgcampos.CfId);


                            if ((int)orgcampos.DataType == 1)
                            {
                                custom.FieldValueInt = Convert.ToInt32(orgcampos.ValInt);

                                custom.FieldValueString = GetValue(orgcampos.CfId, Convert.ToInt32(orgcampos.ValInt));
                            }
                            if ((int)orgcampos.DataType == 2)
                            {
                                custom.FieldValueInt = (int)orgcampos.ValInt;
                                if (custom.FieldValueInt == 0)
                                {
                                    custom.FieldValueString = "No";
                                }
                                else
                                {
                                    custom.FieldValueString = "Yes";
                                }
                            }
                            if ((int)orgcampos.DataType == 5)
                            {
                                custom.FieldValueString = orgcampos.ValStr;
                            }
                            customFields.Add(custom);
                        }
                        foreach (CustomFields custom in customFields)
                        {
                            switch (custom.FieldID)
                            {
                            case 16:
                                customerComplete.RFCPM = custom.FieldValueString;
                                break;

                            case 17:
                                customerComplete.TaxId = custom.FieldValueString;
                                break;

                            case 18:
                                customerComplete.Foreing = custom.FieldValueString;
                                break;

                            case 19:
                                customerComplete.Email = custom.FieldValueString;
                                break;

                            case 20:
                                customerComplete.Telefono = custom.FieldValueString;
                                break;

                            case 21:
                                customerComplete.ClientType = custom.FieldValueString;
                                break;

                            case 23:
                                customerComplete.RFCPF = custom.FieldValueString;
                                break;

                            case 49:
                                customerComplete.Classification = custom.FieldValueString;
                                break;

                            case 50:
                                customerComplete.Subclassification = custom.FieldValueString;
                                break;
                            }
                        }
                        customerComplete.RFC = customerComplete.RFCPM;
                        if (customerComplete.ClientType == "Person")
                        {
                            customerComplete.RFC = customerComplete.RFCPF;
                        }
                        if (customerComplete.Foreing == "Yes")
                        {
                            customerComplete.RFC = customerComplete.TaxId;
                        }
                        customerComplete.RFC = String.IsNullOrEmpty(customerComplete.RFC) ? "." : customerComplete.RFC;
                        customerComplete     = CallCreateLocation(customerComplete);
                        customerComplete     = CallCreateOrganization(customerComplete);
                        customerComplete     = CallCreateCustomerAccount(customerComplete);
                        customerComplete     = CallCreateCustomerProfile(customerComplete);
                        if (customerComplete.CustomerProfileCreated)
                        {
                            MessageBox.Show("Cliente dado de alta en el ERP");
                        }
                        foreach (ICfVal orgcampos in orgCustomFieldList)
                        {
                            switch (orgcampos.CfId)
                            {
                            case 52:
                                orgcampos.ValStr = customerComplete.LocationId.ToString();
                                break;

                            case 53:
                                orgcampos.ValStr = customerComplete.PartyId.ToString();
                                break;

                            case 54:
                                orgcampos.ValStr = customerComplete.PartySiteId.ToString();
                                break;

                            case 55:
                                orgcampos.ValStr = customerComplete.AccountNumber.ToString();
                                break;

                            case 56:
                                orgcampos.ValStr = customerComplete.CustomerAccountId.ToString();
                                break;
                            }
                        }
                        //RecordContext.ExecuteEditorCommand(EditorCommand.Refresh);
                        RecordContext.RefreshWorkspace();
                    }
                }
                else
                {
                    MessageBox.Show("No hay global");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                throw ex;
            }
        }