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> 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); } }
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); } }