private static DocumentConcept GetDocumentConcept(int docId, string filePath) { DocumentConcept response = null; int connDocos, dbResponse, fqResponse; StringBuilder sConceptCode = new StringBuilder(31); StringBuilder sConceptName = new StringBuilder(61); string key, conceptCode, conceptName; connDocos = AdminPaqLib.dbLogIn("", filePath); if (connDocos == 0) { ErrLogger.Log("Unable to open connection to concepts table from [" + filePath + "]"); return(response); } key = docId.ToString().PadLeft(11); dbResponse = AdminPaqLib.dbGetNoLock(connDocos, TableNames.CONCEPTOS_DOCUMENTOS, IndexNames.PRIMARY_KEY, key); if (dbResponse == 0) { fqResponse = AdminPaqLib.dbFieldChar(connDocos, TableNames.CONCEPTOS_DOCUMENTOS, 2, sConceptCode, 31); conceptCode = sConceptCode.ToString().Substring(0, 30).Trim(); fqResponse = AdminPaqLib.dbFieldChar(connDocos, TableNames.CONCEPTOS_DOCUMENTOS, 3, sConceptName, 61); conceptName = sConceptName.ToString().Substring(0, 60).Trim(); response = new DocumentConcept(); response.Id = docId; response.Code = conceptCode; response.Name = conceptName; } AdminPaqLib.dbLogOut(connDocos); return(response); }
public override IQuery GetHsql(Object data) { StringBuilder sql = new StringBuilder("select a from DocumentConcept a where "); DocumentConcept docconcept = (DocumentConcept)data; if (docconcept != null) { Parms = new List <Object[]>(); if (docconcept.DocConceptID != 0) { sql.Append(" a.DocConceptID = :id and "); Parms.Add(new Object[] { "id", docconcept.DocConceptID }); } if (docconcept.DocClass != null && docconcept.DocClass.DocClassID != 0) { sql.Append(" a.DocClass.DocClassID = :id1 and "); Parms.Add(new Object[] { "id1", docconcept.DocClass.DocClassID }); } if (!String.IsNullOrEmpty(docconcept.Name)) { sql.Append(" a.Name = :nom and "); Parms.Add(new Object[] { "nom", docconcept.Name }); } } sql = new StringBuilder(sql.ToString()); sql.Append(" 1=1 order by a.DocConceptID asc "); IQuery query = Factory.Session.CreateQuery(sql.ToString()); SetParameters(query); return(query); }
public IList<DocumentConcept> Select(DocumentConcept data) { IList<DocumentConcept> datos = new List<DocumentConcept>(); datos = GetHsql(data).List<DocumentConcept>(); if (!Factory.IsTransactional) Factory.Commit(); return datos; }
public DocumentConcept GetDefaultConcept(DocumentClass docClass) { try { DocumentConcept data = new DocumentConcept(); data.DocClass = docClass; data.Name = "Default"; return Factory.DaoDocumentConcept().Select(data).First(); } catch { return new DocumentConcept { DocConceptID = 401 }; } //task by default }
public IList <DocumentConcept> Select(DocumentConcept data) { IList <DocumentConcept> datos = new List <DocumentConcept>(); datos = GetHsql(data).List <DocumentConcept>(); if (!Factory.IsTransactional) { Factory.Commit(); } return(datos); }
public DocumentConcept GetDefaultConcept(DocumentClass docClass) { try { DocumentConcept data = new DocumentConcept(); data.DocClass = docClass; data.Name = "Default"; return(Factory.DaoDocumentConcept().Select(data).First()); } catch { return(new DocumentConcept { DocConceptID = 401 }); } //task by default }
public Boolean Update(DocumentConcept data) { return(base.Update(data)); }
public DocumentConcept Save(DocumentConcept data) { return((DocumentConcept)base.Save(data)); }
public DocumentConcept SelectById(DocumentConcept data) { return (DocumentConcept)base.SelectById(data); }
public DocumentConcept GetDocumentConcept(DocumentConcept data) { return(Factory.DaoDocumentConcept().Select(data).First()); }
public IList <Document> GetShippingDocuments(string sWhere, int docType, bool useRemain) { IList <Document> list = new List <Document>(); DocumentClass docClass = new DocumentClass(); Document tmpData = null; string pos = "0"; try { sWhere = ""; Command.Connection = new SqlConnection(CurCompany.ErpConnection.CnnString); Query = GetErpQuery("SALESORDER"); //Console.WriteLine(Query); DataSet ds = ReturnDataSet(Query, null, "SALESORDER", Command.Connection); pos = "1"; if (ds.Tables.Count == 0) { return(null); } DocumentConcept docConcept = WType.GetDefaultConcept(new DocumentClass { DocClassID = SDocClass.Shipping }); //Definiendo los tipos de documento de shipping DocumentType soType = WType.GetDocumentType(new DocumentType { DocTypeID = SDocType.SalesOrder }); DocumentType siType = WType.GetDocumentType(new DocumentType { DocTypeID = SDocType.SalesInvoice }); DocumentType bkType = WType.GetDocumentType(new DocumentType { DocTypeID = SDocType.BackOrder }); DocumentType returnType = WType.GetDocumentType(new DocumentType { DocTypeID = SDocType.Return }); //Status docStatus = WType.GetStatus(new Status { StatusID = DocStatus.New }); Account defAccount = WType.GetAccount(new Account { AccountCode = WmsSetupValues.DEFAULT }); SysUser user = WType.GetUser(new SysUser { UserName = WmsSetupValues.AdminUser }); Company company = CurCompany; // WType.GetDefaultCompany(); Status cancelled = WType.GetStatus(new Status { StatusID = DocStatus.Cancelled }); //En el dataset, Tables: 1 - DocumentHeader, 2 - DocumentLine, 3 - DocumentComments foreach (DataRow dr in ds.Tables[0].Rows) { try { //Map Properties tmpData = new Document(); tmpData.Date1 = DateTime.Parse(dr["f430_id_fecha"].ToString()); tmpData.Date2 = DateTime.Parse(dr["f430_fecha_entrega"].ToString()); tmpData.Date3 = DateTime.Parse(dr["f430_fecha_ts_cumplido"].ToString()); tmpData.DocNumber = dr["documento"].ToString(); tmpData.ErpMaster = int.Parse(dr["f430_rowid"].ToString()); tmpData.DocStatus = GetShippingStatus(0); tmpData.Comment = dr["f430_notas"].ToString(); tmpData.SalesPersonName = dr["f200_razon_social"].ToString(); //LAs ordenes con status void en GP, salen como canceladas. try { if (int.Parse(dr["f430_ind_estado"].ToString()) == 9) //9 Anulado. { tmpData.DocStatus = cancelled; } } catch { } tmpData.CreatedBy = dr["f430_usuario_creacion"].ToString(); tmpData.CustPONumber = dr["f430_num_docto_referencia"].ToString(); tmpData.DocConcept = docConcept; tmpData.Vendor = defAccount; tmpData.Customer = WType.GetAccount( new Account { AccountCode = dr["id_cliente"].ToString(), BaseType = new AccountType { AccountTypeID = AccntType.Customer }, Company = company }); try { if (!string.IsNullOrEmpty(dr["id_ruta"].ToString())) { tmpData.ShippingMethod = WType.GetShippingMethod( new ShippingMethod { ErpCode = dr["id_ruta"].ToString(), Company = company }); } } catch { } //tmpData.User = user; tmpData.IsFromErp = true; tmpData.CrossDocking = false; tmpData.Company = CurCompany; tmpData.Reference = dr["f430_referencia"].ToString(); //tmpData.Notes = dr["BACHNUMB"].ToString(); //Asignacion de Address tmpData.DocumentAddresses = GetShippingDocumentAddress(tmpData, null, dr); DocumentAddress billAddress = null; if (!string.IsNullOrEmpty(dr["f430_id_sucursal_fact"].ToString())) { billAddress = GetBillAddress(tmpData, dr["f430_id_sucursal_fact"].ToString(), dr["id_cliente"].ToString(), AccntType.Customer); } if (billAddress != null) { tmpData.DocumentAddresses.Add(billAddress); } tmpData.DocType = soType; tmpData.PickMethod = soType.PickMethod; //Asignacion de Lines - Seguen el tipo de orden tmpData.DocumentLines = GetShippingDocumentLines(tmpData, company, dr["f430_rowid"].ToString(), useRemain); if (tmpData.DocumentLines != null && tmpData.DocumentLines.Count > 0) { if (tmpData.Location == null) { tmpData.Location = tmpData.DocumentLines[0].Location; } list.Add(tmpData); } } catch (Exception ex) { ExceptionMngr.WriteEvent("GetShippingDocuments: " + tmpData.DocNumber, ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); } } //retornar la lista return(list); } catch (Exception ex) { ExceptionMngr.WriteEvent("GetShippingDocuments:" + pos + ":", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); //throw; return(null); } }
public DocumentConcept GetDocumentConcept(DocumentConcept data) { return Factory.DaoDocumentConcept().Select(data).First(); }
public DocumentConcept SaveDocumentConcept(DocumentConcept data) { try { SetService(); return SerClient.SaveDocumentConcept(data); } finally { SerClient.Close(); if (SerClient.State == CommunicationState.Faulted) SerClient.Abort(); } }
private IList <Document> GetLocationTransferDocuments(string sWhere) { IList <Document> list = new List <Document>(); DocumentClass docClass = new DocumentClass(); Document tmpData = null; try { /* * 401 0 En elaboraciĂłn * 401 1 Aprobado * 401 2 Parcial * 401 3 Cumplido * 401 9 Anulado */ sWhere = string.IsNullOrEmpty(sWhere) ? "" : " AND " + sWhere; Command.Connection = new SqlConnection(CurCompany.ErpConnection.CnnString); Query = GetErpQuery("TRANSFER"); DataSet ds = ReturnDataSet(Query, null, "TRANSFER", Command.Connection); if (ds == null || ds.Tables.Count == 0) { return(null); } DocumentConcept docConcept = WType.GetDefaultConcept(new DocumentClass { DocClassID = SDocClass.Receiving }); DocumentType docType = WType.GetDocumentType(new DocumentType { DocTypeID = SDocType.InTransitShipment }); Status docStatus = WType.GetStatus(new Status { StatusID = DocStatus.New }); Account defAccount = WType.GetAccount(new Account { AccountCode = WmsSetupValues.DEFAULT }); SysUser user = WType.GetUser(new SysUser { UserName = WmsSetupValues.AdminUser }); Company company = CurCompany; //En el dataset, Tables: 1 - DocumentHeader foreach (DataRow dr in ds.Tables[0].Rows) { try { //Map Properties tmpData = new Document(); tmpData.Date1 = DateTime.Parse(dr["f450_id_fecha"].ToString()); tmpData.DocNumber = dr["numero_doc"].ToString(); tmpData.DocStatus = docStatus; //GetReceivingStatus(int.Parse(dr["POSTATUS"].ToString())); tmpData.DocType = docType; tmpData.PickMethod = docType.PickMethod; tmpData.DocConcept = docConcept; tmpData.Vendor = defAccount; //Vendor Account; tmpData.Customer = defAccount; tmpData.CreatedBy = WmsSetupValues.SystemUser; tmpData.Reference = dr["f450_docto_alterno"].ToString(); tmpData.UserDef1 = dr["co_salida"].ToString(); //CO Origen - SALIDA tmpData.UserDef2 = dr["bodega_salida"].ToString(); //Bodega Origen - SALIDA //try { tmpData.LastChange = DateTime.Parse(dr["f450_ts"].ToString()); } //catch { } tmpData.IsFromErp = true; tmpData.CrossDocking = false; tmpData.Location = WType.GetLocation(new Location { ErpCode = dr["bodega_entrada"].ToString(), Company = company }); //location; tmpData.Company = CurCompany; //Asignacion de Lines tmpData.DocumentLines = GetLocationTransferDocumentLines(tmpData, company, dr["f450_rowid_docto"].ToString()); if (tmpData.DocumentLines != null && tmpData.DocumentLines.Count > 0) { //El location debe ser el de la primera linea if (tmpData.Location == null) { tmpData.Location = tmpData.DocumentLines[0].Location; } list.Add(tmpData); } } catch (Exception ex) { ExceptionMngr.WriteEvent("GetLocationTransferDocuments: " + tmpData.DocNumber, ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); } } //retornar la lista return(list); } catch (Exception ex) { ExceptionMngr.WriteEvent("GetLocationTransferDocuments", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); //throw; return(null); } }
private IList <Document> GetKitAssemblyDocuments(String sWhere) { //retorna la lista de Documentos de Assembly Document tmpData = null; try { Command.Connection = new SqlConnection(CurCompany.ErpConnection.CnnString); Query = GetErpQuery("KITDOC"); //Console.WriteLine(Query); DataSet ds = ReturnDataSet(Query, null, "KITDOC", Command.Connection); //Console.WriteLine(ds.Tables.Count); if (ds == null || ds.Tables.Count == 0) { return(null); } if (ds == null || ds.Tables.Count == 0) { return(null); } List <Document> list = new List <Document>(); Status status = WType.GetStatus(new Status { StatusID = DocStatus.New }); Account defAccount = WType.GetAccount(new Account { AccountCode = WmsSetupValues.DEFAULT }); SysUser user = WType.GetUser(new SysUser { UserName = WmsSetupValues.AdminUser }); Company company = CurCompany; DocumentConcept docConcept = WType.GetDefaultConcept(new DocumentClass { DocClassID = SDocClass.Inventory }); DocumentType docType = WType.GetDocumentType(new DocumentType { DocTypeID = SDocType.KitAssemblyTask }); foreach (DataRow dr in ds.Tables[0].Rows) { try { //Map Properties tmpData = new Document(); tmpData.Date1 = DateTime.Parse(dr["f350_fecha"].ToString()); //Tran date //tmpData.Date2 = DateTime.Parse(dr["BM_Start_Date"].ToString()); //BM_Start_Date //tmpData.Date3 = DateTime.Parse(dr["PSTGDATE"].ToString()); //PSTGDATE tmpData.DocNumber = dr["docnumber"].ToString(); tmpData.CreatedBy = dr["f350_usuario_creacion"].ToString(); try { tmpData.Location = WType.GetLocation(new Location { Company = CurCompany, ErpCode = dr["cod_bodega"].ToString() }); } catch { } tmpData.DocStatus = status; tmpData.DocConcept = docConcept; tmpData.Vendor = defAccount; tmpData.Customer = defAccount; tmpData.IsFromErp = true; tmpData.CrossDocking = false; tmpData.ErpMaster = int.Parse(dr["f350_rowid"].ToString()); tmpData.Company = CurCompany; tmpData.Reference = dr["f350_referencia"].ToString(); tmpData.DocType = docType; tmpData.PickMethod = docType.PickMethod; //Asignacion de Lines - Seguen el tipo de orden tmpData.DocumentLines = GetKitAssemblyDocumentLines(tmpData); if (tmpData.DocumentLines != null && tmpData.DocumentLines.Count > 0) { list.Add(tmpData); } } catch (Exception ex) { ExceptionMngr.WriteEvent("GetKitAssemblyDocuments: " + tmpData.DocNumber, ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); } } return(list); } catch (Exception ex) { ExceptionMngr.WriteEvent("GetKitAssemblyDocuments:", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); return(null); } }
public IList <Document> GetReceivingDocuments(string sWhere) { IList <Document> list = new List <Document>(); DocumentClass docClass = new DocumentClass(); Document tmpData = null; try { sWhere = string.IsNullOrEmpty(sWhere) ? "POSTATUS IN (1,2,3,4,5,6)" : "POSTATUS IN (1,2,3,4,5,6) AND " + sWhere; //Lamar los documents que necesita del Erp usando econnect ds = DynamicsGP_ec.GetDataSet(DynamicsGP_ec.RetreiveData("Purchase_Order_Transaction", false, 2, 0, sWhere, true)); if (ds.Tables.Count == 0) { return(null); } DocumentConcept docConcept = WType.GetDefaultConcept(new DocumentClass { DocClassID = SDocClass.Receiving }); DocumentType docType = WType.GetDocumentType(new DocumentType { DocTypeID = SDocType.PurchaseOrder }); //Status docStatus = WType.GetStatus(new Status { StatusID = DocStatus.New }); Account defAccount = WType.GetAccount(new Account { AccountCode = WmsSetupValues.DEFAULT }); SysUser user = WType.GetUser(new SysUser { UserName = WmsSetupValues.AdminUser }); Company company = CurCompany; //WType.GetDefaultCompany(); //Location location = WType.GetDefaultLocation(); //En el dataset, Tables: 1 - DocumentHeader, 2 - DocumentLine, 3 - DocumentComments foreach (DataRow dr in ds.Tables[1].Rows) { try { //Map Properties tmpData = new Document(); tmpData.Date1 = DateTime.Parse(dr["DOCDATE"].ToString()); tmpData.Date2 = DateTime.Parse(dr["PRMDATE"].ToString()); tmpData.Date3 = DateTime.Parse(dr["PRMSHPDTE"].ToString()); tmpData.Date4 = DateTime.Parse(dr["REQDATE"].ToString()); //tmpData.Date5 = DateTime.Parse(dr["DUEDATE"].ToString()); //USADA PARA NOtification en IMAGE tmpData.DocNumber = dr["PONUMBER"].ToString(); tmpData.DocStatus = GetReceivingStatus(int.Parse(dr["POSTATUS"].ToString())); tmpData.DocType = docType; tmpData.PickMethod = docType.PickMethod; tmpData.DocConcept = docConcept; try { tmpData.CustPONumber = dr["POPCONTNUM"].ToString(); } catch { } tmpData.LastChange = GetDocumentLastChange("POP10100", "PONUMBER", dr["PONUMBER"].ToString()); try { tmpData.Comment = GetDocumentNotesPurchase("", dr["COMMNTID"].ToString(), dr["PONUMBER"].ToString()); } catch { } tmpData.Vendor = WType.GetAccount( new Account { AccountCode = dr["VENDORID"].ToString(), BaseType = new AccountType { AccountTypeID = AccntType.Vendor }, Company = company }); //Vendor Account; tmpData.Customer = defAccount; tmpData.CreatedBy = dr["USER2ENT"].ToString(); try { tmpData.ShippingMethod = WType.GetShippingMethod(new ShippingMethod { ErpCode = dr["SHIPMTHD"].ToString(), Company = company }); } catch { } tmpData.IsFromErp = true; tmpData.CrossDocking = false; //tmpData.Location = WType.GetLocation(new Location { ErpCode = dr["LOCNCODE"].ToString(), Company = company }); //location; tmpData.Company = CurCompany; //Asignacion de Lines tmpData.DocumentLines = GetReceivingDocumentLines(tmpData, company, ds.Tables[2].Select("PONUMBER='" + dr["PONUMBER"].ToString() + "'")); if (tmpData.DocumentLines != null && tmpData.DocumentLines.Count > 0) { if (tmpData.Location == null) { tmpData.Location = tmpData.DocumentLines[0].Location; } list.Add(tmpData); } } catch (Exception ex) { ExceptionMngr.WriteEvent("GetReceiptDocuments: " + tmpData.DocNumber, ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); } } //retornar la lista return(list); } catch (Exception ex) { ExceptionMngr.WriteEvent("GetReceiptDocuments", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); //throw; return(null); } }
public IList <Document> GetPurchaseReturns(string sWhere, int docType) { IList <Document> list = new List <Document>(); DocumentClass docClass = new DocumentClass(); Document tmpData = null; string pos = "0"; try { //Lamar los documents que necesita del Erp usando econnect sWhere = string.IsNullOrEmpty(sWhere) ? "POPTYPE IN (7,6,5,4)" : "POPTYPE IN (7,6,5,4) AND " + sWhere; string xmlData = DynamicsGP_ec.RetreiveData("PO_Receiving_Transaction", false, 2, 0, sWhere, true); pos = "1"; int rem = 0x02; xmlData = xmlData.Replace((char)rem, ' '); ds = DynamicsGP_ec.GetDataSet(xmlData); pos = "2"; Console.WriteLine("\t" + ds.Tables.Count); if (ds.Tables.Count == 0) { return(null); } DocumentConcept docConcept = WType.GetDefaultConcept(new DocumentClass { DocClassID = SDocClass.Shipping }); //Definiendo los tipos de documento de return DocumentType prtType = WType.GetDocumentType(new DocumentType { DocTypeID = SDocType.PurchaseReturn }); //Status docStatus = WType.GetStatus(new Status { StatusID = DocStatus.New }); Account defAccount = WType.GetAccount(new Account { AccountCode = WmsSetupValues.DEFAULT }); SysUser user = WType.GetUser(new SysUser { UserName = WmsSetupValues.AdminUser }); Company company = CurCompany; // WType.GetDefaultCompany(); Status cancelled = WType.GetStatus(new Status { StatusID = DocStatus.Cancelled }); //Console.WriteLine(ds.GetXml()); //En el dataset, Tables: 1 - DocumentHeader, 2 - DocumentLine, 3 - DocumentComments foreach (DataRow dr in ds.Tables[1].Rows) { try { //Map Properties tmpData = new Document(); tmpData.Date1 = DateTime.Parse(dr["receiptdate"].ToString()); tmpData.Date2 = DateTime.Parse(dr["DUEDATE"].ToString()); tmpData.DocNumber = dr["POPRCTNM"].ToString(); tmpData.DocStatus = GetShippingStatus(0); //try //{ // tmpData.Comment = GetDocumentNotes(dr["NOTEINDX"].ToString(), dr["COMMNTID"].ToString()); //} //catch { } tmpData.CreatedBy = dr["USER2ENT"].ToString(); tmpData.CustPONumber = dr["VNDDOCNM"].ToString(); tmpData.DocConcept = docConcept; tmpData.Vendor = tmpData.Customer = WType.GetAccount(new Account { AccountCode = dr["VENDORID"].ToString(), BaseType = new AccountType { AccountTypeID = AccntType.Vendor }, Company = company }); //Console.WriteLine("1"); try { if (!string.IsNullOrEmpty(dr["SHIPMTHD"].ToString())) { tmpData.ShippingMethod = WType.GetShippingMethod( new ShippingMethod { ErpCode = dr["SHIPMTHD"].ToString(), Company = company }); } } catch { } //tmpData.User = user; tmpData.IsFromErp = true; tmpData.CrossDocking = false; tmpData.Company = CurCompany; tmpData.Reference = dr["REFRENCE"].ToString(); tmpData.Notes = dr["BACHNUMB"].ToString(); //Console.WriteLine("2"); //Asignacion de Address //tmpData.DocumentAddresses = GetPurchaseReturnsAddress(tmpData, null, dr); DocumentAddress billAddress = null; try { billAddress = GetBillAddress(tmpData, "", dr["VENDORID"].ToString(), AccntType.Vendor); } catch { } tmpData.DocumentAddresses = new List <DocumentAddress>(); if (billAddress != null) { tmpData.DocumentAddresses.Add(billAddress); } tmpData.DocType = prtType; try { tmpData.PickMethod = prtType.PickMethod; } catch { } //Console.WriteLine("3"); //Asignacion de Lines - Seguen el tipo de orden tmpData.DocumentLines = GetPurchaseReturnsLines(tmpData, ds.Tables[2].Select("POPRCTNM='" + dr["POPRCTNM"].ToString() + "'"), ds.Tables[3]); //Console.WriteLine("4"); if (tmpData.DocumentLines != null && tmpData.DocumentLines.Count > 0) { if (tmpData.Location == null) { tmpData.Location = tmpData.DocumentLines[0].Location; } list.Add(tmpData); } } catch (Exception ex) { ExceptionMngr.WriteEvent("GetPurchaseReturns: " + tmpData.DocNumber, ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); } } //retornar la lista return(list); } catch (Exception ex) { ExceptionMngr.WriteEvent("GetPurchaseReturns:" + pos + ":", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); //throw; return(null); } }
public IList <Document> GetReceivingDocuments(string sWhere) { IList <Document> list = new List <Document>(); DocumentClass docClass = new DocumentClass(); Document tmpData = null; try { /* * 401 0 En elaboraciĂłn * 401 1 Aprobado * 401 2 Parcial * 401 3 Cumplido * 401 9 Anulado */ //Console.WriteLine("Entramos"); sWhere = string.IsNullOrEmpty(sWhere) ? " t420.f420_ind_estado IN (1,2,3,9) " : " t420.f420_ind_estado IN (1,2,3,9) AND " + sWhere; Command.Connection = new SqlConnection(CurCompany.ErpConnection.CnnString); Query = GetErpQuery("PURCHASEORDER"); //Console.WriteLine(Query); DataSet ds = ReturnDataSet(Query, null, "PURCHASEORDER", Command.Connection); Console.WriteLine(ds.Tables.Count); if (ds == null || ds.Tables.Count == 0) { return(null); } DocumentConcept docConcept = WType.GetDefaultConcept(new DocumentClass { DocClassID = SDocClass.Receiving }); DocumentType docType = WType.GetDocumentType(new DocumentType { DocTypeID = SDocType.PurchaseOrder }); //Status docStatus = WType.GetStatus(new Status { StatusID = DocStatus.New }); Account defAccount = WType.GetAccount(new Account { AccountCode = WmsSetupValues.DEFAULT }); SysUser user = WType.GetUser(new SysUser { UserName = WmsSetupValues.AdminUser }); Company company = CurCompany; //WType.GetDefaultCompany(); //Location location = WType.GetDefaultLocation(); //En el dataset, Tables: 1 - DocumentHeader, 2 - DocumentLine, 3 - DocumentComments foreach (DataRow dr in ds.Tables[0].Rows) { try { //Map Properties tmpData = new Document(); tmpData.Date1 = DateTime.Parse(dr["f420_fecha"].ToString()); //tmpData.Date2 = DateTime.Parse(dr["PRMDATE"].ToString()); //tmpData.Date3 = DateTime.Parse(dr["PRMSHPDTE"].ToString()); //tmpData.Date4 = DateTime.Parse(dr["REQDATE"].ToString()); //tmpData.Date5 = DateTime.Parse(dr["DUEDATE"].ToString()); //USADA PARA NOtification en IMAGE tmpData.DocNumber = dr["ponumber"].ToString(); tmpData.DocStatus = GetReceivingStatus(int.Parse(dr["f420_ind_estado"].ToString())); tmpData.DocType = docType; tmpData.PickMethod = docType.PickMethod; tmpData.DocConcept = docConcept; tmpData.QuoteNumber = dr["f420_id_sucursal_prov"].ToString(); tmpData.Reference = dr["f420_num_docto_referencia"].ToString(); tmpData.SalesPersonName = dr["id_comprador"].ToString(); tmpData.UserDef1 = dr["f420_id_moneda_docto"].ToString(); //try { tmpData.LastChange = DateTime.Parse(dr["f420_fecha_ts_actualizacion"].ToString()); } //catch { } tmpData.Comment = dr["f420_notas"].ToString(); tmpData.Vendor = WType.GetAccount( new Account { AccountCode = dr["id_proveedor"].ToString(), BaseType = new AccountType { AccountTypeID = AccntType.Vendor }, Company = company }); //Vendor Account; tmpData.Customer = defAccount; tmpData.CreatedBy = dr["f420_usuario_creacion"].ToString(); //try { tmpData.ShippingMethod = WType.GetShippingMethod(new ShippingMethod { ErpCode = dr["SHIPMTHD"].ToString(), Company = company }); } //catch { } tmpData.IsFromErp = true; tmpData.CrossDocking = false; //tmpData.Location = WType.GetLocation(new Location { ErpCode = dr["LOCNCODE"].ToString(), Company = company }); //location; tmpData.Company = CurCompany; //Asignacion de Lines tmpData.DocumentLines = GetReceivingDocumentLines(tmpData, company, dr["f420_rowid"].ToString()); if (tmpData.DocumentLines != null && tmpData.DocumentLines.Count > 0) { if (tmpData.Location == null) { tmpData.Location = tmpData.DocumentLines[0].Location; } list.Add(tmpData); } } catch (Exception ex) { ExceptionMngr.WriteEvent("GetReceiptDocuments: " + tmpData.DocNumber, ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); } } //retornar la lista return(list); } catch (Exception ex) { ExceptionMngr.WriteEvent("GetReceiptDocuments", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); //throw; return(null); } }
public Boolean Delete(DocumentConcept data) { return(base.Delete(data)); }
public IList<DocumentConcept> GetDocumentConcept(DocumentConcept data) { return Factory.DaoDocumentConcept().Select(data); }
public DocumentConcept SelectById(DocumentConcept data) { return((DocumentConcept)base.SelectById(data)); }
public void UpdateDocumentConcept(DocumentConcept data) { Factory.DaoDocumentConcept().Update(data); }
public DocumentConcept Save(DocumentConcept data) { return (DocumentConcept)base.Save(data); }
public void Execute(Empresa empresa, string[] conceptosFactura, string[] conceptosAbono, string[] codigosVenta, string[] codigosDevolucion, EventLog log) { int connDocos, dbResponse, fieldResponse; DateTime today = DateTime.Today; DateTime fromDate = today.AddYears(-1); DateTime toDate = today; DateTime dueDate = today; string sFromDate = fromDate.ToString("yyyyMMdd"); Dictionary <int, string> currencies = new Dictionary <int, string>(); Dictionary <int, DimClientes> customers = new Dictionary <int, DimClientes>(); int cancelado = 0, devuelto = 0, impreso = 0, conceptId = 0, companyId = 0, currencyId = 0, idAgente = 0; StringBuilder sbFechaDoc = new StringBuilder(9); StringBuilder sbFechaVto = new StringBuilder(9); string sFechaDoc, sFechaVto, companyCode, currencyName; double saldo = 0, cambio = 0; bool esVenta = false, esDevolucion = false, esCredito = false, esPago = false; connDocos = AdminPaqLib.dbLogIn("", empresa.Ruta); if (connDocos == 0) { throw new Exception("Unable to work with route [" + empresa.Ruta + "]"); } dbResponse = AdminPaqLib.dbGetTopNoLock(connDocos, TABLE_NAME, INDEX); log.WriteEntry("Downloading documents from AdminPaq"); if (dbResponse != 0) { AdminPaqLib.dbLogOut(connDocos); log.WriteEntry("No data found in database, the following exception code was reported: " + dbResponse.ToString() + " on path: " + empresa.Ruta, EventLogEntryType.Warning); throw new Exception("No data found in database, the following exception code was reported: " + dbResponse.ToString()); } int cancelados = 0, devueltos = 0, otros = 0, no_impresos = 0, no_co = 0, no_cliente = 0, valido = 0; while (dbResponse == 0) { esVenta = false; esDevolucion = false; esCredito = false; esPago = false; AdminPaqLib.dbFieldLong(connDocos, TABLE_NAME, 26, ref cancelado); if (cancelado != 0) { dbResponse = AdminPaqLib.dbSkip(connDocos, TABLE_NAME, INDEX, 1); cancelados++; continue; } AdminPaqLib.dbFieldLong(connDocos, TABLE_NAME, 27, ref devuelto); if (devuelto != 0) { dbResponse = AdminPaqLib.dbSkip(connDocos, TABLE_NAME, INDEX, 1); devueltos++; continue; } AdminPaqLib.dbFieldLong(connDocos, TABLE_NAME, 3, ref conceptId); DocumentConcept concept = GetDocumentConcept(conceptId, empresa.Ruta); if (concept == null) { dbResponse = AdminPaqLib.dbSkip(connDocos, TABLE_NAME, INDEX, 1); otros++; continue; } esVenta = codigosVenta != null && codigosVenta.Contains(concept.Code); esDevolucion = codigosDevolucion != null && codigosDevolucion.Contains(concept.Code); esCredito = conceptosFactura.Contains(concept.Code); esPago = conceptosAbono.Contains(concept.Code); if (!esVenta && !esDevolucion && !esCredito && !esPago) { dbResponse = AdminPaqLib.dbSkip(connDocos, TABLE_NAME, INDEX, 1); otros++; continue; } if (esVenta) { AdminPaqLib.dbFieldLong(connDocos, TABLE_NAME, 25, ref impreso); if (impreso == 0) { dbResponse = AdminPaqLib.dbSkip(connDocos, TABLE_NAME, INDEX, 1); no_impresos++; continue; } } if (esCredito) { AdminPaqLib.dbFieldDouble(connDocos, TABLE_NAME, 44, ref saldo); } else { AdminPaqLib.dbFieldDouble(connDocos, TABLE_NAME, 31, ref saldo); } AdminPaqLib.dbFieldLong(connDocos, TABLE_NAME, 15, ref currencyId); if (!currencies.ContainsKey(currencyId)) { currencyName = CurrencyName(currencyId, empresa.Ruta); if (currencyName != null) { currencies.Add(currencyId, currencyName); } } currencyName = currencies[currencyId]; if (!currencyName.ToUpper().Contains("PESO")) { AdminPaqLib.dbFieldDouble(connDocos, TABLE_NAME, 16, ref cambio); saldo = saldo * cambio; } if (esDevolucion) { saldo = saldo * -1; } AdminPaqLib.dbFieldChar(connDocos, TABLE_NAME, 6, sbFechaDoc, 9); sFechaDoc = sbFechaDoc.ToString().Substring(0, 8).Trim(); AdminPaqLib.dbFieldLong(connDocos, TABLE_NAME, 10, ref idAgente); AdminPaqDocument doco = new AdminPaqDocument(); doco.IsCredit = esCredito; doco.IsSale = esVenta || esDevolucion; doco.IsPayment = esPago; doco.Amount = saldo; doco.SellerId = idAgente; doco.DocumentDate = DateTime.ParseExact(sFechaDoc, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None); // SI ES CREDITO NECESITO LA FECHA DE VTO. if (esCredito) { AdminPaqLib.dbFieldChar(connDocos, TABLE_NAME, 11, sbFechaVto, 9); sFechaVto = sbFechaVto.ToString().Substring(0, 8).Trim(); doco.DueDate = DateTime.ParseExact(sFechaVto, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None); // detect client assignment fieldResponse = AdminPaqLib.dbFieldLong(connDocos, TABLE_NAME, 7, ref companyId); if (!customers.ContainsKey(companyId)) { companyCode = GetCompanyCode(companyId, empresa.Ruta); if (companyCode == null) { dbResponse = AdminPaqLib.dbSkip(connDocos, TABLE_NAME, INDEX, 1); no_co++; continue; } DimClientes cliente = DimClientes.GetCliente(empresa.Id, companyCode, null); if (cliente == null) { dbResponse = AdminPaqLib.dbSkip(connDocos, TABLE_NAME, INDEX, 1); no_cliente++; continue; } customers.Add(companyId, cliente); } DimClientes customer = customers[companyId]; doco.Client = customer; } OrganizeDoco(doco, log); valido++; dbResponse = AdminPaqLib.dbSkip(connDocos, TABLE_NAME, INDEX, 1); } log.WriteEntry("Data collection summary: cancelled=" + cancelados + ";returns=" + devueltos + ";other=" + otros + ";not printed=" + no_impresos + ";no_co=" + no_co + ";no_cliente=" + no_cliente + ";valid=" + valido); AdminPaqLib.dbLogOut(connDocos); }
public void DeleteDocumentConcept(DocumentConcept data) { try { SetService(); SerClient.DeleteDocumentConcept(data); } finally { SerClient.Close(); if (SerClient.State == CommunicationState.Faulted) SerClient.Abort(); } }
public Boolean Update(DocumentConcept data) { return base.Update(data); }
public DocumentConcept SaveDocumentConcept(DocumentConcept data) { return Factory.DaoDocumentConcept().Save(data); }
public Boolean Delete(DocumentConcept data) { return base.Delete(data); }
public void DeleteDocumentConcept(DocumentConcept data) { Factory.DaoDocumentConcept().Delete(data); }
private IList <Document> GetKitAssemblyDocuments(String sWhere) { //retorna la lista de Documentos de Assembly Document tmpData = null; try { Command.Connection = new SqlConnection(CurCompany.ErpConnection.CnnString); // BM00101 - KitAssemblyHeader DataSet ds = ReturnDataSet("SELECT h.*,d.LOCNCODE FROM BM10200 h INNER JOIN BM10300 d ON h.TRX_ID=d.TRX_ID AND d.Parent_Component_ID=-1 WHERE h.BM_Trx_Status=3 AND h.USERDEF1 <> 'WMSEXPRESS'", sWhere, "BM10200", Command.Connection); if (ds == null || ds.Tables.Count == 0) { return(null); } List <Document> list = new List <Document>(); Status status = WType.GetStatus(new Status { StatusID = DocStatus.New }); Account defAccount = WType.GetAccount(new Account { AccountCode = WmsSetupValues.DEFAULT }); SysUser user = WType.GetUser(new SysUser { UserName = WmsSetupValues.AdminUser }); Company company = CurCompany; DocumentConcept docConcept = WType.GetDefaultConcept(new DocumentClass { DocClassID = SDocClass.Inventory }); DocumentType docType = WType.GetDocumentType(new DocumentType { DocTypeID = SDocType.KitAssemblyTask }); foreach (DataRow dr in ds.Tables[0].Rows) { try { //Map Properties tmpData = new Document(); tmpData.Date1 = DateTime.Parse(dr["TRXDATE"].ToString()); //Tran date tmpData.Date2 = DateTime.Parse(dr["BM_Start_Date"].ToString()); //BM_Start_Date tmpData.Date3 = DateTime.Parse(dr["PSTGDATE"].ToString()); //PSTGDATE tmpData.DocNumber = dr["TRX_ID"].ToString(); tmpData.CreatedBy = dr["USER2ENT"].ToString(); try { tmpData.Location = WType.GetLocation(new Location { Company = CurCompany, ErpCode = dr["LOCNCODE"].ToString() }); } catch { } tmpData.DocStatus = status; tmpData.DocConcept = docConcept; tmpData.Vendor = defAccount; tmpData.Customer = defAccount; tmpData.IsFromErp = true; tmpData.CrossDocking = false; tmpData.Company = CurCompany; tmpData.Reference = dr["REFRENCE"].ToString(); tmpData.DocType = docType; tmpData.PickMethod = docType.PickMethod; //Asignacion de Lines - Seguen el tipo de orden tmpData.DocumentLines = GetKitAssemblyDocumentLines(tmpData); if (tmpData.DocumentLines != null && tmpData.DocumentLines.Count > 0) { list.Add(tmpData); } } catch (Exception ex) { ExceptionMngr.WriteEvent("GetKitAssemblyDocuments: " + tmpData.DocNumber, ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); } } return(list); } catch (Exception ex) { ExceptionMngr.WriteEvent("GetKitAssemblyDocuments:", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); return(null); } }