public IList<DocumentClass> Select(DocumentClass data) { IList<DocumentClass> datos = new List<DocumentClass>(); datos = GetHsql(data).List<DocumentClass>(); 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 }
//[DataMember] //public virtual IList<DocumentType> DocumentTypes { get; set; } public override Boolean Equals(object obj) { if ((obj == null) || (obj.GetType() != this.GetType())) { return(false); } DocumentClass castObj = (DocumentClass)obj; return((castObj != null) && (this.DocClassID == castObj.DocClassID)); }
public Boolean Delete(DocumentClass data) { return base.Delete(data); }
public Boolean Update(DocumentClass data) { return base.Update(data); }
public DocumentClass Save(DocumentClass data) { return (DocumentClass)base.Save(data); }
public void DeleteDocumentClass(DocumentClass data) { Factory.DaoDocumentClass().Delete(data); }
public void UpdateDocumentClass(DocumentClass data) { Factory.DaoDocumentClass().Update(data); }
public DocumentClass SaveDocumentClass(DocumentClass data) { return Factory.DaoDocumentClass().Save(data); }
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 { //Lamar los documents que necesita del Erp usando econnect sWhere = string.IsNullOrEmpty(sWhere) ? "SOPTYPE IN (" + docType + ")" : "SOPTYPE IN (" + docType + ") AND " + sWhere; string xmlData = DynamicsGP_ec.RetreiveData("Sales_Transaction", false, 2, 0, sWhere, true); pos = "1"; int rem = 0x02; xmlData = xmlData.Replace((char)rem,' '); ds = DynamicsGP_ec.GetDataSet(xmlData); pos = "2"; 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[1].Rows) { try { //Map Properties tmpData = new Document(); tmpData.Date1 = DateTime.Parse(dr["DOCDATE"].ToString()); tmpData.Date2 = DateTime.Parse(dr["ReqShipDate"].ToString()); tmpData.Date3 = DateTime.Parse(dr["ACTLSHIP"].ToString()); tmpData.Date4 = DateTime.Parse(dr["BACKDATE"].ToString()); tmpData.Date5 = DateTime.Parse(dr["DUEDATE"].ToString()); tmpData.DocNumber = dr["SOPNUMBE"].ToString(); tmpData.ErpMaster = int.Parse(dr["MSTRNUMB"].ToString()); tmpData.DocStatus = GetShippingStatus(0); //Oct 24 - Manejo de la sincronizacion traer cada ves menos records, solo lo nuevo //tmpData.LastChange = DateTime.Parse(dr["DEX_ROW_TS"].ToString()); tmpData.LastChange = GetDocumentLastChange("SOP10100", "SOPNUMBE", dr["SOPNUMBE"].ToString()); try { tmpData.Comment = GetDocumentNotes(dr["NOTEINDX"].ToString(), dr["COMMNTID"].ToString()); } catch { } //LAs ordenes con status void en GP, salen como canceladas. try { if (int.Parse(dr["VOIDSTTS"].ToString()) > 0) tmpData.DocStatus = cancelled; } catch { } tmpData.CreatedBy = dr["USER2ENT"].ToString(); tmpData.CustPONumber = dr["CSTPONBR"].ToString(); tmpData.DocConcept = docConcept; tmpData.Vendor = defAccount; Location location = WType.GetLocation(new Location { ErpCode = dr["LOCNCODE"].ToString(), Company = company }); tmpData.Customer = WType.GetAccount(new Account { AccountCode = dr["CUSTNMBR"].ToString(), BaseType = new AccountType { AccountTypeID = AccntType.Customer }, Company = company }); 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.Location = location; tmpData.Company = CurCompany; tmpData.Reference = dr["REFRENCE"].ToString(); tmpData.Notes = dr["BACHNUMB"].ToString(); //Asignacion de Address tmpData.DocumentAddresses = GetShippingDocumentAddress(tmpData, null, dr); DocumentAddress billAddress = null; if (!string.IsNullOrEmpty(dr["PRBTADCD"].ToString())) billAddress = GetBillAddress(tmpData, dr["PRBTADCD"].ToString(), dr["CUSTNMBR"].ToString(), AccntType.Customer); if (billAddress != null) tmpData.DocumentAddresses.Add(billAddress); switch (dr["SOPTYPE"].ToString()) { case "2": tmpData.DocType = soType; tmpData.PickMethod = soType.PickMethod; break; case "3": tmpData.DocType = siType; tmpData.PickMethod = siType.PickMethod; break; case "6": tmpData.DocType = siType; tmpData.PickMethod = siType.PickMethod; break; case "5": tmpData.DocType = bkType; tmpData.PickMethod = bkType.PickMethod; tmpData.UserDef1 = dr["USDOCID1"].ToString(); break; case "4": //RETURN en realidad es un Receiving Document tmpData.DocType = returnType; //tmpData.Customer = defAccount; tmpData.Vendor = WType.GetAccount(new Account { AccountCode = dr["CUSTNMBR"].ToString(), BaseType = new AccountType { AccountTypeID = AccntType.Customer }, Company = company }); tmpData.PickMethod = returnType.PickMethod; break; } //Asignacion de Lines - Seguen el tipo de orden tmpData.DocumentLines = GetShippingDocumentLines(tmpData, ds.Tables["Line"].Select("SOPNUMBE='" + dr["SOPNUMBE"].ToString() + "'"), useRemain); if (tmpData.DocumentLines != null && tmpData.DocumentLines.Count > 0) 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 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 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; } }
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; } }
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 DocumentClass SelectById(DocumentClass data) { return (DocumentClass)base.SelectById(data); }
public IList<DocumentClass> GetDocumentClass(DocumentClass data) { //Factory.IsTransactional = true; IList<DocumentClass> list = Factory.DaoDocumentClass().Select(data); //foreach (DocumentClass docClass in list) // docClass.Reports.ToList(); return list; }
private IList<Document> GetLocationTransferDocuments(string sWhere) { IList<Document> list = new List<Document>(); DocumentClass docClass = new DocumentClass(); Document tmpData = null; try { sWhere = string.IsNullOrEmpty(sWhere) ? "TrxState IN (1) AND IVDOCTYP = 3 " : "TrxState IN (1) AND IVDOCTYP = 3 AND " + sWhere; //Lamar los documents que necesita del Erp usando econnect ds = DynamicsGP_ec.GetDataSet(DynamicsGP_ec.RetreiveData("WSInventoryTransfer", false, 2, 0, sWhere, true)); if (ds.Tables.Count == 0) return null; DocumentConcept docConcept = WType.GetDefaultConcept(new DocumentClass { DocClassID = SDocClass.Shipping }); DocumentType docType = WType.GetDocumentType(new DocumentType { DocTypeID = SDocType.WarehouseTransferShipment }); 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.DocNumber = dr["IVDOCNBR"].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["BACHNUMB"].ToString(); tmpData.LastChange = GetDocumentLastChange("ReqIVHeaderView", "IVDOCNBR", dr["IVDOCNBR"].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 = GetLocationTransferDocumentLines(tmpData, company, ds.Tables[2].Select("IVDOCNBR='" + dr["IVDOCNBR"].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; } }