2 using System.Collections.Generic;
9 using System.ComponentModel;
34 private DataTable dtAuxClientes = null;
35 private DataTable dtAuxAgencia = null;
36 private DataTable dtAuxCanal = null;
37 private DataTable dtAuxFormaPago = null;
38 private DataTable dtAuxRuta = null;
39 private DataTable dtAuxTipoFacturacion = null;
40 private DataTable dtAuxVendedor = null;
41 private DataTable dtAuxZona = null;
42 private DataTable dtAuxCatastral = null;
47 private readonly
int lnLenCliente = Convert.ToInt32(EW_GLOBAL._GetLenCampo(
KeyDiccionarioLenCampos.wn_digitos));
50 private readonly
int lnLenVendedor = Convert.ToInt32(EW_GLOBAL._GetLenCampo(
KeyDiccionarioLenCampos.wn_vendedor));
51 private readonly
int lnLenDigitos = Convert.ToInt32(EW_GLOBAL._GetLenCampo(
KeyDiccionarioLenCampos.wn_digitos));
52 private readonly
int lnLenAgencia = 3;
60 private bool cuentaIBAN =
false;
62 private bool lbMandatos =
false;
63 private bool lbDireccFac =
false;
64 private bool lbDireccAdi =
false;
65 private bool lbTelefPre =
false;
66 private bool lbTelefAdi =
false;
70 #endregion PROPIEDADES 86 string clave =
"CodigoCliente%";
88 int idCampoNombreCli = 76;
89 List<Int32> noProcesar =
new List<Int32>();
99 dtAuxClientes = PrepararDtAux(
"CLIENTES");
100 dtAuxAgencia = PrepararDtAux(
"AGENCIA");
101 dtAuxCanal = PrepararDtAux(
"CANALES",
"TPV");
102 dtAuxFormaPago = PrepararDtAux(
"FPAG");
103 dtAuxRuta = PrepararDtAux(
"RUTAS");
104 dtAuxTipoFacturacion = PrepararDtAux(
"TIPO_FAC");
105 dtAuxVendedor = PrepararDtAux(
"VENDEDOR");
106 dtAuxZona = PrepararDtAux(
"ZONAS",
"COMUNES",
"ZONA",
"DESCRIPCIO");
107 dtAuxCatastral = PrepararDtAux(
"MODREFEC",
"COMUNES");
113 base.Importar(dtcsv, codigoGuia, _infoFields, dtcsvlines, tcFichero, clave, idCampoCli, idCampoNombreCli, noProcesar, tnModo);
118 #endregion CONSTRUCTORES 120 #region METODOS PRIVADOS 125 private void PrepararDtColumns()
143 private bool ExisteCliente(
string codigo)
145 DataTable tmp =
new DataTable();
146 string lcSql =
"SELECT COUNT(*) AS TOTAL FROM " + DB.SQLDatabase(
"GESTION",
"CLIENTES") +
147 " WHERE CODIGO = " + DB.SQLString(codigo);
148 DB.SQLExec(lcSql, ref tmp);
150 return tmp.Rows.Count > 0 && Convert.ToInt32(tmp.Rows[0][
"total"]) > 0;
153 private void CrearCuentaIBAN()
155 DataTable ldPlid =
new DataTable();
156 DataTable ldPlid_D1 =
new DataTable();
158 string lcSql =
"SELECT * FROM " + DB.SQLDatabase(
"IDATOS",
"PLINTER_D") +
159 " WHERE CODIGO = " + DB.SQLString(codigoGuia);
160 DB.SQLExec(lcSql, ref ldPlid);
162 if (ldPlid != null || ldPlid.Rows.Count > 0)
164 string nombreColumnaCodigo = ldPlid.Rows.OfType<DataRow>().Where(F => Convert.ToInt32(F[
"IDCAMPO"]) == 18).First()[
"COLUMNA"].ToString().Trim();
165 string nombreColumnaNombre = ldPlid.Rows.OfType<DataRow>().Where(F => Convert.ToInt32(F[
"IDCAMPO"]) == 76).First()[
"COLUMNA"].ToString().Trim();
166 string columnaIBAN = ldPlid.Rows.OfType<DataRow>().Where(F => Convert.ToInt32(F[
"IDTABLA"]) == 64).First()[
"COLUMNA"].ToString().Trim();
168 if (columnaIBAN != null)
170 string lcSql_D1 =
"SELECT * FROM " + DB.SQLDatabase(
"IDATOS",
"PLINTER_D1") +
171 " WHERE CODIGO = " + DB.SQLString(codigoGuia);
172 DB.SQLExec(lcSql_D1, ref ldPlid_D1);
174 if (ldPlid_D1 == null || ldPlid_D1.Rows.Count == 0)
179 List<string> idColumnaIBAN =
new List<string>();
182 idColumnaIBAN = ldPlid_D1.Rows.OfType<DataRow>().Where(F => Convert.ToInt32(F[
"IDCAMPO"]) == 50006)
183 .Select(dr => dr.Field<
string>(
"ID_D").Trim()).ToList();
190 List<string> nombreColumnaIBAN =
new List<string>();
191 if (idColumnaIBAN.Count() > 0)
193 foreach (
string loColumnBarras
in idColumnaIBAN)
195 nombreColumnaIBAN.Add(ldPlid.Rows.OfType<DataRow>().Where(F => Convert.ToString(F[
"ID_RELA"]).Trim() == loColumnBarras).First()[
"COLUMNA"].ToString().Trim().ToString());
199 if (nombreColumnaIBAN.Count == 0)
202 foreach (
System.Data.DataRow filaCliente in dtCSV.Rows)
206 string codigoCliente =
string.Empty;
207 string nombreCliente =
string.Empty;
210 posic = posicionColumna(nombreColumnaCodigo);
211 codigoCliente = filaCliente.ItemArray[posic].ToString();
215 cont = dtImportar.Rows.OfType<DataRow>().Where(dr => dr.Field<
string>(
"CODIGO").Trim().ToUpper() == codigoCliente.Trim().ToUpper())
216 .Select(dr => dr.Field<
string>(
"CODIGO").Trim()).ToList().FirstOrDefault().Count();
224 if (!
string.IsNullOrWhiteSpace(nombreColumnaCodigo))
226 int posic2 = posicionColumna(nombreColumnaNombre);
227 nombreCliente = filaCliente.ItemArray[posic2].ToString();
230 if (
string.IsNullOrEmpty(codigoCliente) || cont == 0)
232 string codigo =
string.Empty;
233 codigo = dtCodigos.AsEnumerable().Where(g => g.Field<Int32>(
"idtabla") == idTablaNegocio
234 && g.Field<
string>(
"idpropuesto") == codigoCliente.Trim()
235 && g.Field<
string>(
"nombrepropuesto") == nombreCliente.Trim()).Select(g => g.Field<
string>(
"idasignado")).FirstOrDefault();
236 codigoCliente = codigo;
237 if (!
string.IsNullOrEmpty(codigo))
245 if (nombreColumnaIBAN.Count > 0)
247 foreach (
string loColumnRela
in nombreColumnaIBAN)
249 int posicR = posicionColumna(loColumnRela);
250 string codIBAN = filaCliente.ItemArray[posicR].ToString().Trim();
252 if (codIBAN.Length >= 24)
256 bool bExiste =
false;
257 bool bPreder =
false;
261 if (banco._CtaCuenta.Trim() == codIBAN.Substring(14, 10))
273 loBanco = loBancos[num];
278 loBanco._TipoCta =
"IBAN";
281 loBanco._Iban = codIBAN.Substring(0, 4);
282 loBanco._CtaBanco = codIBAN.Substring(4, 4);
283 loBanco._CtaSucur = codIBAN.Substring(8, 4);
284 loBanco._DigCon = codIBAN.Substring(12, 2);
285 loBanco._CtaCuenta = codIBAN.Substring(14, 10);
286 loBanco._CuentaIban = codIBAN.Substring(4, 20);
287 loBanco._Orden = loBancos.Count == 0 || bPreder;
288 loBanco._Direccion =
"";
296 if (codIBAN.Length != 0)
298 incidenc =
"La cuenta bancaria IBAN " + codIBAN.ToString() +
" indicada para el cliente " + codigoCliente +
" no tiene el formato correcto. " + Environment.NewLine;
300 GestionIncidencias();
319 int lnTablaVir = (tlAdicional ? 60003 : 60002);
329 foreach (
System.Data.DataRow filaCliente in dtCSV.Rows)
334 string codigoCliente = imC.
getValue(
"CODIGO",
"");
335 string lcTelefono = im.
getValue(
"TELEFONO", lnTablaVir,
"");
336 string lcCargo = im.
getValue(
"CARGO", lnTablaVir,
"");
337 string lcObserva = im.
getValue(
"OBSERVA", lnTablaVir,
"");
338 string lcEmail = im.
getValue(
"EMAIL", lnTablaVir,
"");
339 string lcFacebook = im.
getValue(
"FACEBOOK", lnTablaVir,
"");
340 string lcSkype = im.
getValue(
"SKYPE", lnTablaVir,
"");
341 string lcTwitter = im.
getValue(
"TWITTER", lnTablaVir,
"");
342 string lcPersona = im.
getValue(
"PERSONA", lnTablaVir,
"");
354 if (loCon._Telefono.Trim() == lcTelefono.Trim() && loCon._Persona.Trim() == lcPersona.Trim())
368 loContacTelef = loContactos[num];
369 linea = loContacTelef.
_Linia;
374 linea = loContactos.Count + 1;
376 if (lbActualizar && lnTablaVir != 60003 && loContactos.Count > 0)
378 incidenc =
" Se ha dado de alta un nuevo teléfono y/o contacto para el cliente " + codigoCliente +
", pero no se ha podido definir como predeterminado porque ya tenía un teléfono o contacto definido como predeterminado. Revise los teléfonos y contactos del cliente para modificarlo manualmente si lo desea." + Environment.NewLine;
380 GestionIncidencias();
385 loContacTelef._Cliente = codigoCliente;
386 loContacTelef._Cargo = lcCargo;
387 loContacTelef._Email = lcEmail;
388 loContacTelef._Facebook = lcFacebook;
389 loContacTelef._Observa = lcObserva;
390 loContacTelef._Persona = lcPersona;
391 loContacTelef._Skype = lcSkype;
392 loContacTelef._Telefono = lcTelefono;
393 loContacTelef._Twitter = lcTwitter;
394 loContacTelef._Linia = linea;
398 loContacTelef._Predet = !tlAdicional;
411 CrearTelefonoContactoCliente2(tlAdicional);
421 bool esCuenta =
true;
423 DataTable ldPlid =
new DataTable();
424 DataTable ldPlid_D1 =
new DataTable();
426 string lcSql =
"SELECT * FROM " + DB.SQLDatabase(
"IDATOS",
"PLINTER_D") +
427 " WHERE CODIGO = " + DB.SQLString(codigoGuia);
429 DB.SQLExec(lcSql, ref ldPlid);
431 if (ldPlid != null || ldPlid.Rows.Count > 0)
433 DataTable ldtTemp =
new DataTable();
435 string nombreColumnaCodigo = ldPlid.Rows.OfType<DataRow>().Where(F => Convert.ToInt32(F[
"IDCAMPO"]) == 18).First()[
"COLUMNA"].ToString().Trim();
436 string incidenc =
string.Empty;
437 string codigoCliente =
string.Empty;
440 List<DataRow> vacios =
new List<DataRow>();
441 List<String> codigos =
new List<string>();
443 int posic = posicionColumna(nombreColumnaCodigo);
445 foreach (
System.Data.DataRow filaCliente in dtCSV.Rows)
449 codigoCliente = filaCliente.ItemArray[posic].ToString();
452 if (
string.IsNullOrWhiteSpace(codigoCliente))
454 vacios.Add(filaCliente);
458 string cuenta = codigoCliente.Substring(0, 3);
462 lcSql =
"SELECT CODIGO, CLIENTE " +
463 " FROM " + DB.SQLDatabase(
"gestion",
"nivel3") +
464 " WHERE CLIENTE=1 AND CODIGO=" + DB.SQLString(cuenta) +
467 DB.SQLExec(lcSql, ref ldtTemp);
469 if (ldtTemp.Rows.Count == 0)
474 int lenCodigo = codigoCliente.Length;
479 if (lenCodigo < lnLenCliente)
481 codigoCliente = codigoCliente.Substring(0, 3) +
new String(
'0', lnLenCliente - lenCodigo) + codigoCliente.Substring(3);
482 filaCliente.ItemArray[posic] = codigoCliente;
483 codigos.Add(codigoCliente);
487 if (lenCodigo < lnLenCliente)
489 incidenc = MensajeIncidencia(fila.ToString(), posic.ToString(), codigoCliente,
"La longitud del campo es mayor del tamaño que la del campo destino. Campo ampliable mediante configuración de " + Convert.ToString(EW_GLOBAL._GetVariable(
"wc_nameproducto")));
490 RegistrarIncidencia(fila, incidenc, 2);
491 GestionIncidencias();
497 if (lenCodigo + 3 < lnLenCliente)
499 codigoCliente =
"430" +
new String(
'0', lnLenCliente - lenCodigo + 3) + codigoCliente;
500 filaCliente.ItemArray[posic] = codigoCliente;
501 codigos.Add(codigoCliente);
505 if (lenCodigo < lnLenCliente)
507 incidenc = MensajeIncidencia(fila.ToString(), posic.ToString(), codigoCliente,
"La longitud del campo es mayor del tamaño que la del campo destino.Campo ampliable mediante configuración de " + Convert.ToString(EW_GLOBAL._GetVariable(
"wc_nameproducto")));
508 RegistrarIncidencia(fila, incidenc, 2);
509 GestionIncidencias();
515 foreach (DataRow filaCliente
in vacios)
517 codigoCliente = CrearCodigo(107, codigos);
518 filaCliente.ItemArray[posic] = codigoCliente;
519 codigos.Add(codigoCliente);
529 private List<string> Direccion_old(Int32 fila)
532 List<string> CodClienteIncid =
new List<string>();
534 string codigoCliente =
string.Empty;
535 string nombreColumnaCodigo =
string.Empty;
536 string nombreColumnaNombre =
string.Empty;
538 DataTable ldTemp =
new DataTable();
539 DataTable ldPlid =
new DataTable();
540 DataTable ldPlid_D1 =
new DataTable();
541 DataTable ldCampos =
new DataTable();
544 string lcSql =
"SELECT * FROM " + DB.SQLDatabase(
"COMUNES",
"CAMPOS");
545 DB.SQLExec(lcSql, ref ldCampos);
546 Dictionary<Int32, DataRow>
campos =
new Dictionary<Int32, DataRow>();
547 foreach (DataRow row
in ldCampos.Rows)
549 Int32 idcampo = Convert.ToInt32(row[
"idcampo"]);
550 if (!
campos.ContainsKey(idcampo))
552 campos.Add(Convert.ToInt32(row[
"idcampo"]), row);
556 lcSql =
"SELECT * FROM " + DB.SQLDatabase(
"IDATOS",
"PLINTER_D") +
" WHERE CODIGO = " + DB.SQLString(codigoGuia);
557 DB.SQLExec(lcSql, ref ldPlid);
559 if (ldPlid != null || ldPlid.Rows.Count > 0)
561 nombreColumnaCodigo = ldPlid.Rows.OfType<DataRow>().Where(F => Convert.ToInt32(F[
"IDCAMPO"]) == 18).First()[
"COLUMNA"].ToString().Trim();
562 nombreColumnaNombre = ldPlid.Rows.OfType<DataRow>().Where(F => Convert.ToInt32(F[
"IDCAMPO"]) == 76).First()[
"COLUMNA"].ToString().Trim();
564 string lcSql_D1 =
"SELECT * FROM " + DB.SQLDatabase(
"IDATOS",
"PLINTER_D1") +
" WHERE CODIGO = " + DB.SQLString(codigoGuia) +
565 " AND (IDTABLA = 60000 OR IDTABLA = 60001)";
567 DB.SQLExec(lcSql_D1, ref ldPlid_D1);
568 if (ldPlid_D1 == null || ldPlid_D1.Rows.Count == 0)
570 return CodClienteIncid;
573 Int32[] tablas =
new Int32[] { 60000, 60001 };
575 foreach (Int32 table
in tablas)
577 DataView view =
new DataView(ldPlid_D1);
578 view.RowFilter =
"idtabla = " + table;
580 Dictionary<string, ArrayList> nombresCampos =
new Dictionary<string, ArrayList>();
582 foreach (DataRowView rowView
in view)
584 Int32 idcampo = Convert.ToInt32(rowView[
"idcampo"]);
585 Int32 idtabla = c.
idTablaVirtual(Convert.ToInt32(rowView[
"idtabla"]));
586 string fieldname = Convert.ToString(campos[idcampo][
"campo"]).Trim();
588 string id_d = rowView[
"ID_D"].ToString().Trim();
589 string nombreColumnaEnCSV = ldPlid.Rows.OfType<DataRow>().Where(F => Convert.ToString(F[
"ID_RELA"]).Trim() == id_d).First()[
"COLUMNA"].ToString().Trim().ToString();
590 ArrayList x =
new ArrayList();
592 x.Add(nombreColumnaEnCSV);
594 nombresCampos.Add(fieldname, x);
597 Dictionary<string, object> valores =
new Dictionary<string, object>();
601 foreach (DataRow row
in dtCSV.Rows)
605 string nombreCliente =
string.Empty;
607 posic = posicionColumna(nombreColumnaCodigo);
608 codigoCliente = row.ItemArray[posic].ToString();
612 cont = dtImportar.Rows.OfType<DataRow>().Where(dr => dr.Field<
string>(
"CODIGO").Trim().ToUpper() == codigoCliente.Trim().ToUpper())
613 .Select(dr => dr.Field<
string>(
"CODIGO").Trim()).ToList().FirstOrDefault().Count();
621 if (!
string.IsNullOrWhiteSpace(nombreColumnaCodigo))
623 int posic2 = posicionColumna(nombreColumnaNombre);
624 nombreCliente = row.ItemArray[posic2].ToString();
627 if (
string.IsNullOrEmpty(codigoCliente) || cont == 0)
629 string codigo =
string.Empty;
630 codigo = dtCodigos.AsEnumerable().Where(g => g.Field<Int32>(
"idtabla") == idTablaNegocio
631 && g.Field<
string>(
"idpropuesto") == codigoCliente.Trim()
632 && g.Field<
string>(
"nombrepropuesto") == nombreCliente.Trim()).Select(g => g.Field<
string>(
"idasignado")).FirstOrDefault();
633 codigoCliente = codigo;
634 if (!
string.IsNullOrEmpty(codigo))
642 foreach (KeyValuePair<string, ArrayList> entry
in nombresCampos)
644 string tipocampo = entry.Value[0].ToString();
645 object valorEnCSV = row[posicionColumna(entry.Value[1].ToString())];
646 string fieldname = entry.Value[2].ToString();
652 valores.Add(fieldname, Convert.ChangeType(valorEnCSV, typeof(
string)));
655 valores.Add(fieldname, Convert.ChangeType(valorEnCSV, typeof(
bool)));
658 valores.Add(fieldname, Convert.ChangeType(valorEnCSV, typeof(Int32)));
661 valores.Add(fieldname, Convert.ChangeType(valorEnCSV, typeof(DateTime)));
664 valores.Add(fieldname, Convert.ChangeType(valorEnCSV, typeof(
double)));
671 if (valores.ContainsKey(
"PAIS"))
673 string pais =
string.Empty;
674 string tcPais = (string)(valores.ContainsKey(
"PAIS") ? valores[
"PAIS"] :
string.Empty);
676 if (!
string.IsNullOrEmpty(tcPais))
678 pais = ValidarRegla(PaisCta(tcPais));
681 CodClienteIncid.Add(codigoCliente);
683 incidenc =
"El cliente " + codigoCliente +
" no ha sido traspasado porque el país informado " + tcPais +
" no se encuentra en " + Convert.ToString(EW_GLOBAL._GetVariable(
"wc_nameproducto")) +
". Debe crearlo en " + Convert.ToString(EW_GLOBAL._GetVariable(
"wc_nameproducto")) +
" antes de realizar la importación. " + Environment.NewLine;
684 GestionIncidencias();
685 WriteCSVOut(dtCSVLines.Rows[fila][
"LINE"].ToString());
690 if (!dtImportar.Columns.Contains(
"PAIS"))
691 dtImportar.Columns.Add(
"PAIS");
694 dtImportar.Rows[nfila][
"PAIS"] = pais;
698 if (valores.ContainsKey(
"CODPOS"))
700 string tcCodPos = (string)(valores.ContainsKey(
"CODPOS") ? valores[
"CODPOS"] :
string.Empty);
701 string tcPoblacion = (string)(valores.ContainsKey(
"POBLACION") ? valores[
"POBLACION"] :
string.Empty);
702 string tcProvincia = (string)(valores.ContainsKey(
"PROVINCIA") ? valores[
"PROVINCIA"] :
string.Empty);
704 CodigoPostal(tcCodPos, tcPoblacion, tcProvincia);
707 if (valores.ContainsKey(
"DIRECCION"))
715 lcSql =
"SELECT * FROM " + DB.SQLDatabase(
"GESTION",
"ENV_CLI") +
" WHERE CLIENTE = " + DB.SQLString(codigoCliente);
716 DB.SQLExec(lcSql, ref ldTemp);
719 linea = Convert.ToInt32(ldTemp.Rows.Count) + 1;
722 string lcCliente = codigoCliente;
724 string tcDireccion = (string)(valores.ContainsKey(
"DIRECCION") ? valores[
"DIRECCION"] :
string.Empty);
725 string tcCodPos = (string)(valores.ContainsKey(
"CODPOS") ? valores[
"CODPOS"] :
string.Empty);
726 string tcPoblacion = (string)(valores.ContainsKey(
"POBLACION") ? valores[
"POBLACION"] :
string.Empty);
727 string tcProvincia = (string)(valores.ContainsKey(
"PROVINCIA") ? valores[
"PROVINCIA"] :
string.Empty);
728 string tcHorario = (string)(valores.ContainsKey(
"HORARIO") ? valores[
"HORARIO"] :
string.Empty);
729 string tcPais = (string)(valores.ContainsKey(
"PAIS") ? valores[
"PAIS"] :
string.Empty);
733 bool bExiste =
false;
736 List<DataRow> row0 = ldTemp.Rows.OfType<DataRow>().Where(F => Convert.ToString(F[
"DIRECCION"]).Trim() == tcDireccion &&
737 Convert.ToString(F[
"CODPOS"]).Trim() == tcCodPos &&
738 Convert.ToString(F[
"POBLACION"]).Trim() == tcPoblacion &&
739 Convert.ToString(F[
"PROVINCIA"]).Trim() == tcProvincia &&
740 Convert.ToString(F[
"PAIS"]).Trim() == tcPais).ToList();
741 bExiste = row0.Count > 0;
745 lcSql =
"UPDATE " + DB.SQLDatabase(
"env_cli") +
" SET cliente = " + DB.SQLString(lcCliente) +
746 ", direccion = " + DB.SQLString(tcDireccion) +
747 ", codpos = " + DB.SQLString(tcCodPos) +
748 ", poblacion = " + DB.SQLString(tcPoblacion) +
749 ", provincia = " + DB.SQLString(tcProvincia) +
750 ", pais = " + DB.SQLString(tcPais) +
751 ", tipo = " + DB.SQLString(tipo);
758 if (lbActualizar && table == 60000)
765 lcSql =
"INSERT INTO " + DB.SQLDatabase(
"env_cli") +
"(cliente, linea, direccion, codpos, poblacion, provincia, horario, pais, tipo ) " +
766 "VALUES(" + DB.SQLString(lcCliente) +
", " +
767 DB.SQLString(linea) +
", " +
768 DB.SQLString(tcDireccion) +
", " +
769 DB.SQLString(tcCodPos) +
", " +
770 DB.SQLString(tcPoblacion) +
", " +
771 DB.SQLString(tcProvincia) +
", " +
772 DB.SQLString(tcHorario) +
", " +
773 DB.SQLString(tcPais) +
", " +
774 DB.SQLString(tipo) +
")";
778 if (lbActualizar && table == 60000)
780 incidenc =
"Se ha dado de alta nueva dirección para el cliente, pero no se ha podido definir como tipo facturación porque ya tenía una dirección definida con ese tipo. Revise las direcciones del cliente para modificarlo manualmente si lo desea." + Environment.NewLine;
781 GestionIncidencias();
783 WriteCSVOut(dtCSVLines.Rows[fila][
"LINE"].ToString());
799 return CodClienteIncid;
805 #endregion METODOS PRIVADOS 807 #region METODOS PROTECTED 817 protected override DataTable
PrepararDtImportar(
int idTablaCampo,
bool linfadi, Int32 idCampo,
string nombre)
819 switch (idTablaCampo)
823 if (!dtImportar.Columns.Contains(nombre))
824 dtImportar.Columns.Add(nombre);
828 DataTable dtPlinter_D1 =
new DataTable();
830 string lcSql =
"SELECT * FROM " + DB.SQLDatabase(
"IDATOS",
"PLINTER_D1") +
" WHERE codigo = " + DB.SQLString(codigoGuia) +
831 " AND IDCAMPO = 50007";
833 DB.SQLExec(lcSql, ref dtPlinter_D1);
835 if (dtPlinter_D1 != null && dtPlinter_D1.Rows.Count > 0)
837 nombre =
"FPAG_GIRO";
842 if (idCampo == 100 || idCampo == 117)
844 DataTable dtPlinter_D1 =
new DataTable();
846 string lcSql =
"SELECT * FROM " + DB.SQLDatabase(
"IDATOS",
"PLINTER_D1") +
" WHERE codigo = " + DB.SQLString(codigoGuia) +
847 " AND IDCAMPO = 669 OR IDCAMPO = 451";
849 DB.SQLExec(lcSql, ref dtPlinter_D1);
851 if (dtPlinter_D1 != null && dtPlinter_D1.Rows.Count == 2)
861 if (idCampo == 50006)
867 if (idCampo == 50007)
869 nombre =
"FPAG_GIRO";
879 if (idCampo == 60000 || idCampo == 60001 || idCampo == 60002 || idCampo == 60003)
887 return base.PrepararDtImportar(idTablaCampo, linfadi, idCampo, nombre);
911 List<string> valoresCodigo = null;
913 valoresCodigo = dtAuxClientes.Rows.OfType<DataRow>().Select(dr => dr.Field<
string>(
"CODIGO").Trim()).ToList();
915 if (!valoresCodigo.Contains(codigo))
917 valoresCodigo = dtImportar.Rows.OfType<DataRow>().Where(dr => !
string.IsNullOrEmpty(dr.Field<
string>(
"CODIGO")))
918 .Select(dr => dr.Field<
string>(
"CODIGO").Trim()).ToList();
920 if (valoresCodigo.Contains(codigo))
977 ltablaImportar =
false;
986 protected override DataTable
ValoresDtAux(
string nombreTabla, ref DataTable dtMomen)
992 dtMomen = dtAuxClientes;
997 dtMomen = dtAuxAgencia;
1002 dtMomen = dtAuxCanal;
1007 dtMomen = dtAuxFormaPago;
1012 dtMomen = dtAuxRuta;
1017 dtMomen = dtAuxTipoFacturacion;
1022 dtMomen = dtAuxVendedor;
1027 dtMomen = dtAuxZona;
1032 dtMomen = dtAuxCatastral;
1036 return base.ValoresDtAux(nombreTabla, ref dtMomen);
1046 textos.Add(70,
"Formas de pago");
1047 textos.Add(18,
"Rutas");
1048 textos.Add(4,
"Vendedores");
1049 textos.Add(107,
"Clientes");
1050 textos.Add(129,
"Agencias");
1051 textos.Add(1538,
"Canal");
1052 textos.Add(291,
"Letras");
1053 textos.Add(356,
"Referencias catastrales de inmuebles");
1058 iLen2 = lnLenFormaPago;
1064 iLen2 = lnLenVendedor;
1067 iLen2 = lnLenCliente;
1070 iLen2 = lnLenAgencia;
1106 protected override string ValidarRegla(
string regla, Int32 idTabla = 0, List<string> valorespreexistentes = null,
string codigo =
"",
string valor =
"", DataTable dtImportar = null,
string nombreNegocio =
"",
bool nombreValDef =
false,
string valor2 =
"",
string valor3 =
"", Int32 fila = 0)
1108 string valret =
string.Empty;
1110 switch (regla.Trim())
1112 case "CodigoCliente":
1113 case "CodigoTercero":
1114 valorespreexistentes = this.valorespreexistentes;
1115 valret = CrearCodigo(idTabla, valorespreexistentes,
true,
"",
false,
true, nombreNegocio, nombreValDef);
1118 case "CrearMandato":
1123 valret = base.ValidarRegla(regla, idTabla, valorespreexistentes, codigo, valor, dtImportar, nombreNegocio, nombreValDef, valor2, valor3, fila);
1143 if (columnaMandato != null)
1155 im.
AddItem(
"CLI_IBAN", 50006);
1156 im.
AddItem(
"FECHA_CART", 221);
1158 im.
AddItem(
"POBLAC_FIR", 236);
1163 im.
AddItem(
"MANDATORIG", 234);
1166 foreach (
System.Data.DataRow filaCliente in dtCSV.Rows)
1170 string codigoCliente =
string.Empty;
1171 string nombreCliente =
string.Empty;
1173 codigoCliente = valorEnCSV(filaCliente, nombreColumnaCodigo);
1177 cont = dtImportar.Rows.OfType<DataRow>().Where(dr => dr.Field<
string>(
"CODIGO").Trim().ToUpper() == codigoCliente.Trim().ToUpper())
1178 .Select(dr => dr.Field<
string>(
"CODIGO").Trim()).ToList().FirstOrDefault().Count();
1185 nombreCliente = valorEnCSV(filaCliente, nombreColumnaNombre);
1187 if (
string.IsNullOrEmpty(codigoCliente) || cont == 0)
1189 string codigo =
string.Empty;
1190 codigo = dtCodigos.AsEnumerable().Where(g => g.Field<Int32>(
"idtabla") == idTablaNegocio
1191 && g.Field<
string>(
"idpropuesto") == codigoCliente.Trim()
1192 && g.Field<
string>(
"nombrepropuesto") == nombreCliente.Trim()).Select(g => g.Field<
string>(
"idasignado")).FirstOrDefault();
1193 codigoCliente = codigo;
1194 if (!
string.IsNullOrEmpty(codigo))
1200 foreach (KeyValuePair<string, actItem> o
in im.
campos)
1205 string codigoMandato = im.
campos[
"MANDATO"].ToString();
1206 bool MandatoDefecto = im.
campos[
"DEFECTO"].ToBoolean(
true);
1207 DateTime FechaFinMandato = im.
campos[
"FECHA_FIN"].ToDateTime();
1208 DateTime FechaFirma = im.
campos[
"FECHA_FIR"].ToDateTime();
1209 DateTime FechaEnv = im.
campos[
"FECHA_CART"].ToDateTime();
1210 string codigoMandatoOrigen = im.
campos[
"MANDATORIG"].ToString();
1211 string codigoPoblacFirma = im.
campos[
"POBLAC_FIR"].ToString();
1212 string codigoPersonaPago = im.
campos[
"PERSPAGO"].ToString();
1213 Int32 TipoPago = im.
campos[
"TIPO_PAGO"].ToInt32(1);
1214 Int32 TipoMandato = im.
campos[
"TIPO"].ToInt32(1);
1215 string cli_IBAN = im.
campos[
"CLI_IBAN"].ToString();
1216 Int32 NumEfecProc = im.
campos[
"NUMEFE"].ToInt32();
1217 Int32 NumEfecMax = im.
campos[
"NUMEFPRO"].ToInt32();
1218 bool MandatoProc = im.
campos[
"ESTPRO"].ToBoolean();
1222 if (!
string.IsNullOrEmpty(codigoMandato))
1224 DataTable ldtTemp =
new DataTable();
1226 string sql =
"SELECT CODIGO FROM " + DB.SQLDatabase(
"GESTION",
"BANC_CLI") +
1227 " WHERE CLIENTE = " + DB.SQLString(codigoCliente) +
" AND (IBAN + CUENTAIBAN) = " + DB.SQLString(cli_IBAN);
1229 DB.SQLExec(sql, ref ldtTemp);
1231 if (ldtTemp != null && ldtTemp.Rows.Count > 0)
1233 banc_cli = Convert.ToInt32(ldtTemp.Rows[0][
"CODIGO"]);
1236 DataTable ldtMandato =
new DataTable();
1238 string lcSql =
"SELECT * FROM " + DB.SQLDatabase(
"COMUNES",
"MANDATOS") +
1239 " WHERE CLIENTE = " + DB.SQLString(codigoCliente) +
" And MANDATO = " + DB.SQLString(codigoMandato.ToString().Trim());
1242 DB.SQLExec(lcSql, ref ldtMandato);
1244 if (ldtMandato == null || ldtMandato.Rows.Count == 0)
1246 DB.SQLExec(
"Insert Into " + DB.SQLDatabase(
"COMUNES",
"MANDATOS") +
1247 "(CLIENTE, LINIA, MANDATO, DEFECTO, FECHA_FIN, FECHA_CART, FECHA_FIR," +
1248 " MANDATORIG, POBLAC_FIR, PERSPAGO, TIPO, CLI_IBAN, TIPO_PAGO, NUMEFE, NUMEFPRO, ESTPRO, BANC_CLI) " +
1249 "Values (" + DB.SQLString(codigoCliente) +
"," + 1 +
"," + DB.SQLString(codigoMandato) +
"," + DB.SQLString(MandatoDefecto) +
"," +
1250 DB.SQLString(FechaFinMandato) +
"," + DB.SQLString(FechaEnv) +
"," + DB.SQLString(FechaFirma) +
"," +
1251 DB.SQLString(codigoMandatoOrigen) +
"," + DB.SQLString(codigoPoblacFirma) +
"," + DB.SQLString(codigoPersonaPago) +
"," +
1252 DB.SQLString(TipoMandato) +
"," + DB.SQLString(cli_IBAN) +
"," + DB.SQLString(TipoPago) +
"," +
1253 DB.SQLString(NumEfecProc) +
"," + DB.SQLString(NumEfecMax) +
"," + DB.SQLString(MandatoProc) +
", " +
1254 DB.SQLString(banc_cli) +
")");
1258 DB.SQLExec(
"Update " + DB.SQLDatabase(
"COMUNES",
"MANDATOS") +
" " +
1259 "Set FECHA_FIN = " + DB.SQLString(FechaFinMandato) +
", DEFECTO = " + DB.SQLString(MandatoDefecto) +
", FECHA_CART = " + DB.SQLString(FechaEnv) +
1260 ", FECHA_FIR = " + DB.SQLString(FechaFirma) +
", MANDATORIG = " + DB.SQLString(codigoMandatoOrigen) +
1261 ", POBLAC_FIR = " + DB.SQLString(codigoPoblacFirma) +
", PERSPAGO = " + DB.SQLString(codigoPersonaPago) +
1262 ", TIPO = " + DB.SQLString(TipoMandato) +
", CLI_IBAN = " + DB.SQLString(cli_IBAN) +
", TIPO_PAGO = " + DB.SQLString(TipoPago) +
1263 ", NUMEFE = " + DB.SQLString(NumEfecProc) +
", NUMEFPRO = " + DB.SQLString(NumEfecMax) +
", ESTPRO = " + DB.SQLString(MandatoProc) +
1264 " WHERE CLIENTE = " + DB.SQLString(codigoCliente) +
" AND MANDATO = " + DB.SQLString(codigoMandato) +
" AND BANC_CLI = " + DB.SQLString(banc_cli));
1279 base.ImportarNegocio();
1281 List<string> lImportados =
new List<string>();
1284 int posic = PosColumna(107, 18);
1289 if (dtImportar != null && dtImportar.Rows.Count > 0)
1292 int lnRows = dtImportar.Rows.Count;
1293 bool llUpdate =
false;
1300 DataRow ldr = dtImportar.Rows[lnRows];
1302 string lcCodigo = Convert.ToString(ldr[
"CODIGO"]).Trim();
1303 string lcIdioma = Convert.ToString(ldr[
"IDIOMA"]).Trim();
1304 Int32 filaenproceso = Convert.ToInt32(ldr[
"filafichero"]);
1306 string divisa =
string.Empty;
1308 if (!
string.IsNullOrEmpty(lcIdioma) && lcIdioma !=
"000")
1310 divisa = ValidarRegla(
"Divisa", 0, null, null, lcIdioma);
1312 if (
string.IsNullOrEmpty(divisa))
1314 incidenc = MensajeIncidencia(filaenproceso.ToString(), (posic + 1).ToString(), lcCodigo,
"No ha sido traspasado porque la divisa informada " + lcIdioma +
" no se encuentra en " + Convert.ToString(EW_GLOBAL._GetVariable(
"wc_nameproducto")) +
". Debe crear las divisas en " + Convert.ToString(EW_GLOBAL._GetVariable(
"wc_nameproducto")) +
" antes de realizar la importación. ");
1315 RegistrarIncidencia(filaenproceso, incidenc, 3);
1316 GestionIncidencias();
1317 WriteCSVOut(dtCSVLines.Rows[fila][
"LINE"].ToString());
1319 if (!lstNoImportados.Contains(lcCodigo))
1320 lstNoImportados.Add(lcCodigo);
1332 dtImportar.AcceptChanges();
1339 if (lbDireccFac || lbDireccAdi)
1341 if (dtImportar != null && dtImportar.Rows.Count > 0)
1344 foreach (DataRow lnRows
in dtImportar.Rows)
1348 List<string> codCliInc = CrearDireccion(lstNoImportados, fila);
1356 ValidarRegla(
"CrearCuentaContable");
1361 ewprogressbar.Maximum = dtImportar.Rows.Count;
1363 if (lbFormaPago) ewprogressbar.Maximum++;
1364 if (lbVendedor) ewprogressbar.Maximum++;
1365 if (lbTelefPre || lbTelefAdi) ewprogressbar.Maximum++;
1366 if (cuentaIBAN) ewprogressbar.Maximum++;
1367 if (lbGiros) ewprogressbar.Maximum++;
1368 if (lbMandatos) ewprogressbar.Maximum++;
1369 if (lbCatastral) ewprogressbar.Maximum++;
1371 foreach (DataRow row
in dtImportar.Rows)
1375 ewprogressbar.PerformStep();
1377 string valor = row[
"CODIGO"].ToString();
1378 string valornombre = row[
"NOMBRE"].ToString().Trim();
1379 Int32 filaenproceso = Convert.ToInt32(row[
"filafichero"]);
1381 if (lImportados.Contains(valor))
1384 if (ExisteCliente(valor) && !lbActualizar)
1386 incidenc = MensajeIncidencia(filaenproceso.ToString(), (posic + 1).ToString(), valor,
"El cliente no ha sido traspasado porque ya existe en " + Convert.ToString(EW_GLOBAL._GetVariable(
"wc_nameproducto")));
1388 if (!lstNoImportados.Contains(valor))
1389 lstNoImportados.Add(valor);
1391 RegistrarIncidencia(filaenproceso, incidenc, 3);
1392 GestionIncidencias();
1393 WriteCSVOut(dtCSVLines.Rows[fila][
"LINE"].ToString());
1397 if (!ExisteCliente(valor) && !lbInsertar)
1399 incidenc = MensajeIncidencia(filaenproceso.ToString(), (posic + 1).ToString(), valor,
"El cliente no ha sido actualizado porque no existe en " + Convert.ToString(EW_GLOBAL._GetVariable(
"wc_nameproducto")));
1401 if (!lstNoImportados.Contains(valor))
1402 lstNoImportados.Add(valor);
1404 RegistrarIncidencia(filaenproceso, incidenc, 3);
1405 GestionIncidencias();
1406 WriteCSVOut(dtCSVLines.Rows[fila][
"LINE"].ToString());
1419 historicoGuia._Importados++;
1425 historicoGuia._Actualizados++;
1430 foreach (DataColumn columna
in dtImportar.Columns)
1432 switch (columna.ColumnName.Trim())
1435 if (
string.IsNullOrEmpty(rnCliente.
_Codigo))
1439 if (ImportarCampo(row[
"NOMBRE"].ToString(),
"NOMBRE", loEstado))
1440 rnCliente.
_Nombre = row[
"NOMBRE"].ToString();
1443 if (ImportarCampo(row[
"IDIOMA"].ToString(),
"IDIOMA", loEstado))
1445 string valCSV = row[
"IDIOMA"].ToString();
1446 string divisa =
"000";
1447 if (!
string.IsNullOrEmpty(valCSV) && valCSV !=
"000")
1448 divisa = ValidarRegla(
"Divisa", 0, null, null, valCSV);
1455 string pais = row[
"PAIS"].ToString().Trim();
1456 string codPais =
" ";
1457 if (!
string.IsNullOrEmpty(pais))
1458 codPais = ValidarRegla(
"Pais", 0, null, null, pais);
1460 if (codPais ==
"-1")
1462 incidenc = MensajeIncidencia(filaenproceso.ToString(),
"", valor,
"El código ISO del país " + pais +
" no ha sido traspasado porque no se encuentra en " + Convert.ToString(EW_GLOBAL._GetVariable(
"wc_nameproducto")) +
". Debe crearlo en " + Convert.ToString(EW_GLOBAL._GetVariable(
"wc_nameproducto")) +
" y asignar al proveedor. ");
1463 RegistrarIncidencia(filaenproceso, incidenc, 2);
1464 GestionIncidencias();
1465 WriteCSVOut(dtCSVLines.Rows[fila][
"LINE"].ToString());
1469 rnCliente.
_Pais = codPais;
1474 rnCliente.
_NIF = row[
"CIF"].ToString();
1480 rnCliente.
_Email = row[
"EMAIL"].ToString();
1483 if (row[
"FRAESI"].ToString().Trim() ==
".T." || row[
"FRAESI"].ToString().Trim().ToUpper() == cs._BooleanoTrue.ToUpper())
1490 rnCliente.
_FormaPago = row[
"FPAG"].ToString();
1493 string dpago = row[
"DIAPAG"].ToString().Trim();
1494 if (!
string.IsNullOrEmpty(dpago))
1496 rnCliente.
_DiaPago1 = Convert.ToInt32(row[
"DIAPAG"].ToString());
1504 string dpago2 = row[
"DIAPAG2"].ToString().Trim();
1505 if (!
string.IsNullOrEmpty(dpago2))
1507 rnCliente.
_DiaPago2 = Convert.ToInt32(row[
"DIAPAG2"].ToString());
1515 string fecha = row[
"F_ALTA"].ToString().Trim();
1516 if (
string.IsNullOrEmpty(fecha) || fecha ==
"DATE()")
1519 string fmtFecha =
sage.
ew.
functions.
FUNCTIONS._GetEnumDescription(formatoFecha).ToString().Replace(
"a",
"y").Replace(
"m",
"M");
1520 fecha = DateTime.Now.ToString(fmtFecha);
1522 rnCliente.
_FechaAlta = Convert.ToDateTime(fecha);
1525 string dto1 = row[
"DESCU1"].ToString().Trim();
1526 if (!
string.IsNullOrEmpty(dto1))
1528 rnCliente.
_Dto1 = Convert.ToDecimal(row[
"DESCU1"].ToString());
1532 rnCliente.
_Dto1 = 0;
1537 string dto2 = row[
"DESCU2"].ToString().Trim();
1538 if (!
string.IsNullOrEmpty(dto2))
1540 rnCliente.
_Dto2 = Convert.ToDecimal(row[
"DESCU2"].ToString());
1544 rnCliente.
_Dto2 = 0;
1548 string pronto = row[
"PRONTO"].ToString().Trim();
1549 if (!
string.IsNullOrEmpty(pronto))
1551 rnCliente.
_ProntoPago = Convert.ToDecimal(row[
"PRONTO"].ToString());
1559 rnCliente.
_Agencia = row[
"AGENCIA"].ToString();
1562 rnCliente.
_Vendedor = row[
"VENDEDOR"].ToString();
1565 rnCliente.
_Ruta = row[
"RUTA"].ToString();
1568 rnCliente.
_Zona = row[
"ZONA"].ToString();
1571 rnCliente.
_Canal = row[
"CANAL"].ToString();
1574 if (row[
"CONTADO"].ToString().Trim() ==
".T." || row[
"CONTADO"].ToString().Trim().ToUpper() == cs._BooleanoTrue.ToUpper())
1593 string nCopias = row[
"COPIA_FRA"].ToString().Trim();
1594 if (!
string.IsNullOrEmpty(nCopias))
1607 rnCliente.
_TipoIVA = row[
"TIPO_IVA"].ToString();
1610 rnCliente.
_TipoIVA = row[
"IVAPORCEN"].ToString();
1613 if (row[
"RECARGO"].ToString().Trim() ==
".T." || row[
"RECARGO"].ToString().Trim().ToUpper() == cs._BooleanoTrue.ToUpper())
1623 if (row[
"RECC"].ToString().Trim() ==
".T." || row[
"RECC"].ToString().Trim().ToUpper() == cs._BooleanoTrue.ToUpper())
1625 rnCliente.
_RECC =
true;
1629 rnCliente.
_RECC =
false;
1636 if (row[
"PVERDE"].ToString().Trim() ==
".T." || row[
"PVERDE"].ToString().Trim().ToUpper() == cs._BooleanoTrue.ToUpper())
1646 string nCredito = row[
"CREDITO"].ToString().Trim();
1647 if (!
string.IsNullOrEmpty(nCredito))
1649 rnCliente.
_Credito = Convert.ToDecimal(row[
"CREDITO"].ToString());
1657 rnCliente.
_Facebook = row[
"FACEBOOK"].ToString();
1660 rnCliente.
_Skype = row[
"SKYPE"].ToString();
1663 rnCliente.
_Twitter = row[
"TWITTER"].ToString();
1666 rnCliente.
_PaginaWeb = row[
"HTTP"].ToString();
1669 rnCliente.
_Guid_Id = row[
"GUID_ID"].ToString();
1672 if (!lbActualizar || (lbActualizar &&
string.IsNullOrEmpty(rnCliente.
_Direccion)))
1673 rnCliente.
_Direccion = row[
"DIRECCION"].ToString();
1676 if (!lbActualizar || (lbActualizar &&
string.IsNullOrEmpty(rnCliente.
_Poblacion)))
1677 rnCliente.
_Poblacion = row[
"POBLACION"].ToString();
1680 if (!lbActualizar || (lbActualizar &&
string.IsNullOrEmpty(rnCliente.
_Provincia)))
1681 rnCliente.
_Provincia = row[
"PROVINCIA"].ToString();
1684 if (!lbActualizar || (lbActualizar &&
string.IsNullOrEmpty(rnCliente.
_CodPost)))
1685 rnCliente.
_CodPost = row[
"CODPOST"].ToString();
1688 rnCliente.
_Telefono = row[
"TELEFONO"].ToString();
1691 if (!
string.IsNullOrWhiteSpace(row[
"REFER_CAT"].ToString()))
1693 rnCliente.
_ReferCatastral = DB.SQLValor(
"MODREFEC",
"REFERENCIA", row[
"REFER_CAT"].ToString().TrimEnd(),
"CODIGO",
"COMUNES").ToString();
1698 if (!
string.IsNullOrWhiteSpace(row[
"TIPO_RET"].ToString()))
1703 DataTable ldPlid_D2 =
new DataTable();
1704 string lcSql_D2 =
"SELECT a.val_def FROM " + DB.SQLDatabase(
"IDATOS",
"PLINTER_D2") +
" a " +
1705 " WHERE a.CODIGO = " + DB.SQLString(codigoGuia) +
1706 " AND a.IDTABLA = " + DB.SQLString(107) +
1707 " AND a.IDCAMPO = " + DB.SQLString(70);
1708 DB.SQLExec(lcSql_D2, ref ldPlid_D2);
1710 if (ldPlid_D2 != null && ldPlid_D2.Rows.Count == 1)
1712 if (ldPlid_D2.Rows[0][
"VAL_DEF"].ToString().Trim() ==
".T." || ldPlid_D2.Rows[0][
"VAL_DEF"].ToString().Trim().ToUpper() == cs._BooleanoTrue.ToUpper())
1725 if (!
string.IsNullOrWhiteSpace(row[
"RETPORCEN"].ToString()))
1730 DataTable ldPlid_D2 =
new DataTable();
1731 string lcSql_D2 =
"SELECT a.val_def FROM " + DB.SQLDatabase(
"IDATOS",
"PLINTER_D2") +
" a " +
1732 " WHERE a.CODIGO = " + DB.SQLString(codigoGuia) +
1733 " AND a.IDTABLA = " + DB.SQLString(107) +
1734 " AND a.IDCAMPO = " + DB.SQLString(70);
1735 DB.SQLExec(lcSql_D2, ref ldPlid_D2);
1737 if (ldPlid_D2 != null && ldPlid_D2.Rows.Count == 1)
1739 if (ldPlid_D2.Rows[0][
"VAL_DEF"].ToString().Trim() ==
".T." || ldPlid_D2.Rows[0][
"VAL_DEF"].ToString().Trim().ToUpper() == cs._BooleanoTrue.ToUpper())
1761 string guidid =
string.Empty;
1768 if (!
string.IsNullOrEmpty(rnCliente.
_Guid_Id) && !
string.IsNullOrEmpty((guidid = DB.SQLValor(
"CLIENTES",
"GUID_ID", rnCliente.
_Guid_Id.ToString().Trim(),
"GUID_ID",
"GESTION").ToString().Trim())))
1770 incidenc = MensajeIncidencia(filaenproceso.ToString(), (posic + 1).ToString(), rnCliente.
_Codigo,
"El cliente no ha sido traspasado porque su GUID_ID: " + rnCliente.
_Guid_Id +
", ya existe.");
1772 RegistrarIncidencia(filaenproceso, incidenc, 3);
1773 GestionIncidencias();
1774 WriteCSVOut(dtCSVLines.Rows[fila][
"LINE"].ToString());
1776 if (!lstNoImportados.Contains(rnCliente.
_Codigo))
1777 lstNoImportados.Add(rnCliente.
_Codigo);
1783 if (rnCliente.
_Save())
1789 incidenc = MensajeIncidencia(filaenproceso.ToString(), (posic + 1).ToString(), rnCliente.
_Codigo,
"El cliente no ha sido traspasado. Error al salvar.");
1791 RegistrarIncidencia(filaenproceso, incidenc, 3);
1792 GestionIncidencias();
1793 WriteCSVOut(dtCSVLines.Rows[fila][
"LINE"].ToString());
1795 if (!lstNoImportados.Contains(rnCliente.
_Codigo))
1796 lstNoImportados.Add(rnCliente.
_Codigo);
1803 ValidarRegla(
"FormaPago");
1804 ewprogressbar.PerformStep();
1809 ValidarRegla(
"Vendedor");
1810 ewprogressbar.PerformStep();
1815 ValidarRegla(
"ReferenciaCatastral");
1816 ewprogressbar.PerformStep();
1819 if (lbTelefPre || lbTelefAdi)
1821 ValidarRegla(
"CrearTelefonoContacto", 0, lstNoImportados);
1822 ewprogressbar.PerformStep();
1826 ValidarRegla(
"CuentaBancaria");
1827 ewprogressbar.PerformStep();
1832 ValidarRegla(
"CrearGiros", 0, lstNoImportados);
1833 ewprogressbar.PerformStep();
1838 ValidarRegla(
"CrearMandato");
1839 ewprogressbar.PerformStep();
1848 incidenc = MensajeIncidencia(
"",
"",
"",
"Los clientes ya existen en " + Convert.ToString(EW_GLOBAL._GetVariable(
"wc_nameproducto")));
1849 RegistrarIncidencia(0, incidenc, 3);
1850 GestionIncidencias();
1851 historicoGuia._Resultado = 2;
1863 return base.ImportarCampo(valor, nombre, loEstado);
1866 #endregion METODOS PROTECTED 1868 #region METODOS PRIVADOS 1870 private void RegistrosTablasVir(Int32 IdCampoVir)
1872 DataTable ldPlid =
new DataTable();
1873 DataTable ldPlid_D1 =
new DataTable();
1875 string lcSql =
"SELECT * FROM " + DB.SQLDatabase(
"IDATOS",
"PLINTER_D") +
1876 " WHERE CODIGO = " + DB.SQLString(codigoGuia);
1878 DB.SQLExec(lcSql, ref ldPlid);
1880 if (ldPlid != null || ldPlid.Rows.Count > 0)
1882 string nombreColumnaCodigo = ldPlid.Rows.OfType<DataRow>().Where(F => Convert.ToInt32(F[
"IDCAMPO"]) == 18).First()[
"COLUMNA"].ToString().Trim();
1884 string lcSql_D1 =
"SELECT * FROM " + DB.SQLDatabase(
"IDATOS",
"PLINTER_D1") +
1885 " WHERE CODIGO = " + DB.SQLString(codigoGuia);
1887 DB.SQLExec(lcSql_D1, ref ldPlid_D1);
1889 if (ldPlid_D1 == null || ldPlid_D1.Rows.Count == 0)
1894 List<string> idColumnas =
new List<string>();
1897 idColumnas = ldPlid_D1.Rows.OfType<DataRow>().Where(F => Convert.ToString(F[
"IDTABLA"]) == Convert.ToString(IdCampoVir))
1898 .Select(dr => dr.Field<
string>(
"ID_D").Trim()).ToList();
1905 List<string> nombreColumnaTablaVir =
new List<string>();
1906 List<string> idColumnaTablaVir =
new List<string>();
1908 if (idColumnas.Count() > 0)
1910 foreach (
string loColumn
in idColumnas)
1912 nombreColumnaTablaVir.Add(ldPlid.Rows.OfType<DataRow>().Where(F => Convert.ToString(F[
"ID_RELA"]).Trim() == loColumn).First()[
"COLUMNA"].ToString().Trim().ToString());
1913 idColumnaTablaVir.Add(ldPlid_D1.Rows.OfType<DataRow>().Where(F => Convert.ToString(F[
"ID_D"]).Trim() == loColumn).First()[
"IDCAMPO"].ToString().Trim().ToString());
1918 if (nombreColumnaTablaVir.Count == 0 && nombreColumnaTablaVir == null)
1921 foreach (
System.Data.DataRow filaCliente in dtCSV.Rows)
1929 #endregion METODOS PRIVADOS decimal _Dto1
Nos permitirá asignar un primer descuento en % El valor entrado debe ser un valor entre 0 y 100 ...
Definir la estructura de las líneas de contactos-teléfonos de clientes
Clase de negocio base para mantenimientos
string _Telefono
Teléfono predeterminado de la ficha del cliente, sera el que tenga el campo PREDET.
Datos bancarios de clientes
string _Observaciones
Observaciones
string _Skype
Skype del cliente
override int AsignoTextosLongitud(Dictionary< int, string > textos, int idMante)
AsignoTextosLongitud
string obtenerTipoColumna(int idtabla, string campo)
Obtener el tipo de columna accediendo por el idtabla y el nombre del campo
string _SerieRectificativaDefecto
Serie rectificativa por defecto
Decimal _Credito
Retorna el límite de credito del cliente
TipoRetencion _RetencionBaseFactura
Nos permitirá asignar el tipo de retención al cliente Ojo: el campo MOD_RET =.T. –> es retención sob...
Clase para manejar los campos del CSV en la importación
DataTable ldPlid_D1
Datos de plinterD1 para la plantilla en curso
override void ImportarNegocio()
Importamos el negocio según tipo de guía (Artículos, Clientes, ...)
override string _Codigo
PE-102491: override de _Codigo para que en el Set podamos convertir el número que nos llega a código ...
override bool _Save()
Al guardar todos los registros de CONTLF_CLI, se debe actualizar todos los registros de CONT_CLI y TE...
string _RetencionTipo
Nos permitirá aplicar el código de retención al cliente. En caso que se le aplique un código de reten...
bool _NoApli_Impuesto_Artic
No aplicar impuesto articulo
decimal _Dto2
Nos permitirá asignar un segundo descuento en % El valor entrado debe ser un valor entre 0 y 100 ...
string _ReferCatastral
Referencia catastral
bool _ImprimirFacturaElectronica
Nos permite indicar si el cliente permite generar factura electrónica
Clase sage.ew.objetos.ewprogressbar
string _Provincia
Provincia del cliente
string _Twitter
Url de Twitter del cliente
override void InicializarVariables(DataTable dtPlinter_D)
Inicializar variables para proceso de importación
string _Agencia
Nos permitirá asignar el código del agencia al cliente.
override bool ImportarCampo(string valor, string nombre, sage.ew.ewbase.ewMante._EstadosMantenimiento loEstado)
override bool ComprobarExiste(string codigo)
Comprobamos si existe el artículo en Sage 50 o en los registros de CSV que hemos validado ...
override string _Nombre
Nombre del cliente a partir del campo NOMBRE de la tabla CLIENTES de la base de datos de GESTION de E...
Es como el tipo de entrada asientos pero por negocio, sin formulario, pq quiero que me haga las propu...
string _TipoIVA
Nos permitirá indicar el código de TIPO DE IVA aplicado a este cliente
string _CodPost
Código postal del cliente
BindingList< _LinTRel > _Items
Lista bindable de todos los items de la tabla relacionada
_LinTRel _NewItem(int tnInsertLinea=-1)
Añade un nuevo item a la colección Items y rellena los valores de la claves
string getValue(string nombreCampo, string def)
Obtener valor cadena
override void _Load()
Al cargar los datos ponemos la propiedad interna _llModificado a false. Solo propagaremos cambios a T...
KeyDiccionarioLenCampos
Clave del diccionario LenCampos
_EstadosMantenimiento _Estado
Estado en que se encuentra el registro
void AddItem(string field, Int32 id)
override DataTable ValoresDtAux(string nombreTabla, ref DataTable dtMomen)
bool _RetencionFiscal
Nos indicará si el cliente tiene retención fiscal o no.
ImportacionClientes()
Constructor
string _Facebook
Url de Facebook del cliente
override void _Load()
Load
override string ValidarRegla(string regla, Int32 idTabla=0, List< string > valorespreexistentes=null, string codigo="", string valor="", DataTable dtImportar=null, string nombreNegocio="", bool nombreValDef=false, string valor2="", string valor3="", Int32 fila=0)
ValidarRegla
string _Guid_Id
Ens retorna el valor que hi ha al camp GUID_ID de la taula
string nombreColumna(Int32 idCampo, Int32 idVirtual=0)
nombreColumna
string _TipoFacturacion
Código de tipo de facturación que se establece al cliente
void CrearTelefonoContactoCliente(bool tlAdicional=false)
Crear telefonos y contactos al cliente
Clase para uso de funciones genéricas
string _Contrapartida
Código de la contrapartida asociada al cliente
void CodigoDeCliente()
Función CodigoDeCliente
string _Zona
Nos permitirá asignar el código del zona asignado al cliente
Definir la estructura de las direcciones de clientes
bool _ClienteContado
Nos indicará si el cliente es contado
string _Direccion
Dirección del cliente
string _Poblacion
Población del cliente
void CrearTelefonoContactoCliente2(bool tlAdicional=false)
CrearTelefonoContactoCliente2
DateTime _FechaAlta
Nos permitirá indicar la fecha de Alta del cliente Cada vez que se cree un nuevo cliente, esta propiedad deberá tener la fecha del día
ImportacionClientes(DataTable dtcsv, string codigoGuia, List< CargarDatos.stInfoFields > _infoFields, DataTable dtcsvlines, string tcFichero, int tnModo=0, sage.ew.objetos.ewprogressbar bar=null)
Constructor sobrecargado
string _Ruta
Nos permitirá asignar el código del ruta al cliente.
override bool _Save()
Save
string _Moneda
Nos indicará la moneda del cliente
DataTable ldPlid_D
Datos de plinterD para la plantilla en curso
override bool _Save()
Actualización de los datos bancarios del cliente y actualización de los bancos de los mandatos ...
bool _Orden
Predeterminado
Dictionary< string, actItem > campos
Obsoleta. Acumula la información de los campos accediendo por el nombre de campo. Sólo utilizado para...
_EstadosMantenimiento
Declaro un enum para los estados del mantenimiento.
string _FormaPago
Nos permitirá asignar el código de forma de pago al cliente
bool _Recargo
Nos permitirá asignar si un cliente permite trabajar con retención fiscal
override DataTable PrepararDtImportar(int idTablaCampo, bool linfadi, Int32 idCampo, string nombre)
Rellenamos el datatable de trabajo dtImportar con columnas a importar
TipoRetencion
Posibles tipos de retencion
string _RazonComercial
Razón comercial del cliente a partir del campo NOMBRE2 de la tabla CLIENTES de la base de datos de GE...
int _ImprimirCopiasFRA
Nos permitirá establecer el número de copias de Facturas
override void RegistroTablaRelacionada(RegistroPlinter_D registroD, ref Int32 fila, ref string codImportar, ref string valorColumnaCSV, ref bool ltablaImportar, ref Int32 colDt)
Registros de tabla relacionada (no pertenecen a tablas principales: 68, 107, ...) ...
string _NIF
CIF del cliente
int idTablaVirtual(Int32 idtabla)
Obtener el idtabla virtual correspondiente a un idtabla
Clase para la importación de datos
string _Vendedor
Código de vendedor del cliente
int _DiaPago2
Nos indicará el primer dia de pago del cliente El dia de Pago2 nunca podrá tener un valor inferior al...
ContacTelefs _TRelContacTelefs
ManteTRel de teléfonos y contactos de cliente.
void CrearMandato()
CrearMandato
DatosBancarios _TRelDatosBancarios
ManteTRel de datos bancarios de cliente.
string _PaginaWeb
Pagina web que tiene asociada el cliente
int _DiaPago1
Nos indicará el primer dia de pago del cliente
string _Canal
Nos permitirá asignar el código del canal asignado al cliente
decimal _ProntoPago
Nos permitirá asignar un % de descuento de pronto pago El valor entrado debe ser un valor entre 0 y 1...
decimal _RecargoFinanciero
Nos permite indicar el recargo financiero para este cliente El valor entrado nunca podrá ser negativo...
string _Email
Email predeterminado de la ficha del cliente
bool _RECC
Nos indica si al cliente se le aplica el criterio de caja en ventas Si el cliente no es nacional ento...
string _SerieDefecto
Serie por defecto
override void NoImportarNegocio()
No hay registros para importar en negocio según tipo de guía (Artículos, Clientes, ...)
string _Pais
Código de país que se establece al cliente
string _EmailFacturacion
Email que tiene asignado el cliente para la facturación
Contactos y teléfonos de clientes, clase de negocio de la nueva tabla GESTION!CONTLF_CLI resultado de...
void SetDataRow(DataRow dr)
SetDataRow
string _BancoPrevisto
Banco previsto para el cliente, se utiliza en las previsiones de cobro