public Boolean SalesOrderWasDeleted(Document order) { try { Command.Connection = new SqlConnection(CurCompany.ErpConnection.CnnString); Command.Connection.Open(); //string sWhere = " SOPNUMBE='" + order.DocNumber + "'"; ds = ReturnDataSet("SELECT SOPNUMBE FROM SOP10100 WHERE SOPTYPE IN (2,4) AND VOIDSTTS = 0 AND SOPNUMBE='" + order.DocNumber + "'", "", "SOP10100", Command.Connection); if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { return(false); } //AND VOIDSTTS = 0 ds = ReturnDataSet("SELECT SOPNUMBE FROM SOP30200 WHERE SOPTYPE IN (2,4) AND SOPNUMBE='" + order.DocNumber + "'", "", "SOP30200", Command.Connection); if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { return(true); } return(false); } catch (Exception ex) { ExceptionMngr.WriteEvent("SalesOrderWasDeleted", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); //throw; return(false); } }
public IList <Label> GenerateLabelsToPrint(IList <DocumentBalance> printList, String printLot, UserByRol userByRol) { Factory.IsTransactional = true; this.listOfLabels = new List <Label>(); Node node = WType.GetNode(new Node { NodeID = NodeType.PreLabeled }); Bin bin = WType.GetBin(new Bin { BinCode = DefaultBin.MAIN, Location = userByRol.Location }); try { foreach (DocumentBalance printLine in printList) { ProcessPrintingLine(printLine, printLot, node, bin, userByRol); } Factory.Commit(); } catch (Exception ex) { Factory.Rollback(); ExceptionMngr.WriteEvent("GenerateLabelsToPrint:", ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Business); throw new Exception(WriteLog.GetTechMessage(ex)); } return((this.listOfLabels.Count > 0) ? this.listOfLabels : null); }
public Boolean AssemblyOrderWasDeleted(Document order) { try { Command.Connection = new SqlConnection(CurCompany.ErpConnection.CnnString); Command.Connection.Open(); string sWhere = " TRX_ID='" + order.DocNumber + "'"; ds = ReturnDataSet("SELECT * FROM BM10200 WHERE 1=1 ", sWhere, "BM10200", Command.Connection); if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { return(false); } /* YA POSTEADAS * ds = ReturnDataSet("SELECT * FROM BM30200 WHERE 1=1 ", sWhere, "BM30200", Command.Connection); * * if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) * return false; */ return(true); } catch (Exception ex) { ExceptionMngr.WriteEvent("AssemblyOrderWasDeleted", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); //throw; return(false); } }
public static String ReturnScalar(string Query, string sWhere, SqlConnection connection) { try { sWhere = string.IsNullOrEmpty(sWhere) ? sWhere : " AND " + sWhere; SqlCommand xCommand = new SqlCommand(); xCommand.Connection = connection; xCommand.CommandText = Query + sWhere; if (connection.State != ConnectionState.Open) { connection.Open(); } string rs = ""; try { rs = xCommand.ExecuteScalar().ToString(); } catch { } return((rs == null) ? "" : rs); } catch (Exception ex) { ExceptionMngr.WriteEvent("ReturnScalar:", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); return(""); } finally { connection.Close(); } }
public Boolean GetErpShippingDocumentsSince(Company company, DateTime sinceDate) { if (company == null) { ExceptionMngr.WriteEvent("GetErpShippingDocumentsSince Company " + company.Name, ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Business); return(false); } SetConnectMngr(company); bool useRemain = GetCompanyOption(company, "USEREMQTY").Equals("T"); ProcessDocuments(ErpFactory.Documents().GetShippingDocumentsSince(sinceDate, 2, useRemain), company); ProcessDocuments(ErpFactory.Documents().GetShippingDocumentsSince(sinceDate, 4, false), company); //Get BackOrders if (GetCompanyOption(company, "GETBO").Equals("T")) { Console.WriteLine("Processing BackOrders"); ProcessDocuments(ErpFactory.Documents().GetShippingDocumentsSince(sinceDate, 5, false), company); } return(true); }
public IList <Location> GetLocations(string sWhere) { Location tmpData; IList <Location> list = new List <Location>(); try { //Lamar los documents que necesita del Erp usando econnect ds = DynamicsGP_ec.GetDataSet(DynamicsGP_ec.RetreiveData("WSWarehouse", false, 2, 0, sWhere, true)); if (ds.Tables.Count == 0) { return(null); } Status status = WType.GetStatus(new Status { StatusID = EntityStatus.Active }); //En el dataset, Tables: 1 - Locations foreach (DataRow dr in ds.Tables[1].Rows) { if (string.IsNullOrEmpty(dr["LOCNCODE"].ToString())) { continue; } //Map Properties tmpData = new Location(); tmpData.Company = CurCompany; tmpData.ErpCode = dr["LOCNCODE"].ToString(); tmpData.Name = dr["LOCNDSCR"].ToString(); tmpData.AddressLine1 = dr["ADDRESS1"].ToString(); tmpData.AddressLine2 = dr["ADDRESS2"].ToString(); tmpData.AddressLine3 = dr["ADDRESS3"].ToString(); tmpData.City = dr["CITY"].ToString(); tmpData.State = dr["STATE"].ToString(); tmpData.ZipCode = dr["ZIPCODE"].ToString(); tmpData.Phone1 = dr["PHONE1"].ToString(); tmpData.Phone2 = dr["PHONE2"].ToString(); tmpData.Phone3 = dr["FAXNUMBR"].ToString(); //tmpData.ContactPerson = dr[""].ToString(); tmpData.IsDefault = false; tmpData.Status = status; tmpData.IsFromErp = true; list.Add(tmpData); } return(list); } catch (Exception ex) { ExceptionMngr.WriteEvent("GetLocations", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); //throw; return(null); } }
private IList <UnitProductRelation> GetProductUnits(Product product, IList <Unit> unitList) { IList <UnitProductRelation> productUnits = new List <UnitProductRelation>(); UnitProductRelation curId; try { foreach (Unit e in unitList) { curId = new UnitProductRelation(); curId.BaseAmount = e.BaseAmount; curId.IsBasic = (e.BaseAmount == 1) ? true : false; curId.Product = product; curId.Unit = WType.GetUnit(e); curId.UnitErpCode = e.ErpCode; curId.Status = product.Status; curId.CreatedBy = WmsSetupValues.SystemUser; curId.CreationDate = DateTime.Now; productUnits.Add(curId); } return(productUnits); } catch (Exception ex) { ExceptionMngr.WriteEvent("GetProductUnits", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); //throw; return(null); } }
public static DataTable ReturnDataTable(string Query, string sWhere, string tableName, SqlConnection connection) { try { if (connection.State != ConnectionState.Open) { connection.Open(); } DataTable ds = new DataTable(tableName); sWhere = string.IsNullOrEmpty(sWhere) ? sWhere : " AND " + sWhere; SqlDataAdapter objAdapter = new SqlDataAdapter(Query + sWhere, connection); //Console.WriteLine(Query + sWhere); objAdapter.Fill(ds); return(ds); } catch (Exception ex) { ExceptionMngr.WriteEvent("ReturnDataTable: " + Query + sWhere, ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); return(null); } finally { connection.Close(); } }
public IList <Location> GetLocations(string sWhere) { Location tmpData; IList <Location> list = new List <Location>(); try { Command.Connection = new SqlConnection(CurCompany.ErpConnection.CnnString); // CAA ????? Query = "select DEP_CODE,DESCRIPT,STREET_ADDRESS,CITY,STATE,ZIP,TEL1,TEL2,FAX " + " from DEPART where ACTIVE ='T'"; ds = ReturnDataSet(Query, sWhere, "DEPART", Command.Connection); if (ds == null || ds.Tables.Count == 0) { return(null); } Status status = WType.GetStatus(new Status { StatusID = EntityStatus.Active }); //En el dataset, Tables: 1 - Locations foreach (DataRow dr in ds.Tables[0].Rows) { //Map Properties tmpData = new Location(); tmpData.Company = CurCompany; tmpData.ErpCode = dr["DEP_CODE"].ToString(); tmpData.Name = dr["DESCRIPT"].ToString(); tmpData.AddressLine1 = dr["STREET_ADDRESS"].ToString(); //tmpData.AddressLine2 = dr["ADDRESS2"].ToString(); //tmpData.AddressLine3 = dr["ADDRESS3"].ToString(); tmpData.City = dr["CITY"].ToString(); tmpData.State = dr["STATE"].ToString(); tmpData.ZipCode = dr["ZIP"].ToString(); tmpData.Phone1 = dr["TEL1"].ToString(); tmpData.Phone2 = dr["TEL2"].ToString(); tmpData.Phone3 = dr["FAX"].ToString(); //tmpData.ContactPerson = dr[""].ToString(); tmpData.IsDefault = false; tmpData.Status = status; tmpData.IsFromErp = true; list.Add(tmpData); } return(list); } catch (Exception ex) { ExceptionMngr.WriteEvent("GetLocations", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); //throw; return(null); } }
private void ProcessBusinessAlert(MessageRuleByCompany rule) { //Console.WriteLine("Entre BA"); try { //Si se vencio el next runtime lo ejecute if (rule.NextRunTime != null && rule.NextRunTime > DateTime.Now) { return; } //Sace el data set y guarda el resultado en Message Pool MessagePool msg = new MessagePool { CreationDate = DateTime.Now, CreatedBy = WmsSetupValues.SystemUser }; //Console.WriteLine("Get Message"); msg.Message = GetBusinessAlertMessage(rule); //Console.WriteLine("Message: " + msg.Message); if (string.IsNullOrEmpty(msg.Message)) { return; } msg.Entity = new ClassEntity { ClassEntityID = EntityID.BusinessAlert }; msg.IsHtml = rule.IsHtml; msg.MailFrom = rule.MailFrom; msg.MailTo = rule.MailTo; msg.Subject = rule.Template.Name; msg.AlreadySent = false; msg.Rule = rule; //Save the record. //Console.WriteLine("Saving BA:"); Factory.DaoMessagePool().Save(msg); //Setea el next runtime rule.NextRunTime = DateTime.Now.AddSeconds(rule.FrequencyNumber * rule.FrequencyType); rule.LastUpdate = DateTime.Now; Factory.DaoMessageRuleByCompany().Update(rule); } catch (Exception ex) { Console.WriteLine(ex.Message); ExceptionMngr.WriteEvent(" BusinessAlert:" + rule.RuleName, ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Messages); } }
/// <summary> /// Recibe producto, sin etiqueta (recibo manual) crea labels virtuales para cada unidad basica de producto /// </summary> /// <param name="document">Task Document in Process</param> /// <param name="product"></param> /// <param name="logisticUnit">Unidad Logistica Que contiene las packUnits</param> /// <param name="packUnit">Unidad minima no necesariamente la unidad basica</param> /// <param name="quantity">Cantidad de unidades minimas</param> public void ReceiveProduct(DocumentLine receivingLine, Unit logisticUnit, Bin destLocation, Node recNode) { Factory.IsTransactional = true; try { //Se debe ejecutar proceso para saber si la company permite //recibir producto no existente en el documento, Si es receiving Task se permiten //hacer un bypass a ambas reglas //Valida si el docuemnto no es nulo Rules.ValidateDocument(receivingLine.Document, true); //status del Bin donde se Recibira. Rules.ValidateBinStatus(destLocation, true); //Validar Product Restriction Rules.ValidateRestrictedProductInBin(receivingLine.Product, destLocation, true); if (receivingLine.Document.DocType.DocTypeID != SDocType.ReceivingTask) { //Valida si el producto esta en ese documento DocumentLine docLine = new DocumentLine { Document = receivingLine.Document, Product = receivingLine.Product, LineStatus = new Status { StatusID = DocStatus.New }, Unit = receivingLine.Unit, Quantity = receivingLine.Quantity }; Rules.ValidateProductInDocument(docLine, true); //Valida si hay saldo pendiente por recibir Rules.ValidateBalanceQuantityInDocument(docLine, recNode, true, false); } //Obteniendo el factor logistico antes de enviar a crear los labels double logisticFactor = (logisticUnit != null) ? receivingLine.QtyPending : 1; //double logisticFactor = (logisticUnit != null) ? (double)(logisticUnit.BaseAmount / receivingLine.Unit.BaseAmount) : 0; //Manda a Crear los Labels CreateProductLabels(logisticUnit, receivingLine, recNode, destLocation, logisticFactor, receivingLine.Note, "", DateTime.Now); Factory.Commit(); } catch (Exception ex) { Factory.Rollback(); ExceptionMngr.WriteEvent("ReceiveProduct:", ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Business); throw new Exception(WriteLog.GetTechMessage(ex)); } }
private IList <AccountAddress> GetCustomerAddress(Account account, string personId) { AccountAddress tmpData; IList <AccountAddress> list = new List <AccountAddress>(); Status lineStatus = WType.GetStatus(new Status { StatusID = EntityStatus.Active }); try { Command.Connection = new SqlConnection(CurCompany.ErpConnection.CnnString); Query = GetErpQuery("CUSTOMER_ADDRESS").Replace("__ACCOUNT", personId); ds = ReturnDataSet(Query, "", "t015_mm_contactos", Command.Connection); if (ds == null || ds.Tables.Count == 0) { return(null); } foreach (DataRow dr in ds.Tables[0].Rows) { tmpData = new AccountAddress(); tmpData.Account = account; tmpData.Name = dr["f201_descripcion_sucursal"].ToString(); tmpData.ErpCode = dr["f201_id_sucursal"].ToString(); tmpData.AddressLine1 = dr["f015_direccion1"].ToString(); tmpData.AddressLine2 = dr["f015_direccion2"].ToString(); tmpData.AddressLine3 = dr["f015_direccion3"].ToString(); tmpData.City = dr["city"].ToString(); tmpData.State = dr["dpto"].ToString(); tmpData.ZipCode = dr["f015_cod_postal"].ToString(); tmpData.Country = dr["pais"].ToString(); tmpData.Phone1 = dr["f015_telefono"].ToString(); //tmpData.Phone2 = dr["PHNUMBR2"].ToString(); //tmpData.Phone3 = dr["FAXNUMBR"].ToString(); tmpData.Email = dr["f015_email"].ToString(); tmpData.Status = lineStatus; tmpData.IsMain = false; tmpData.ContactPerson = account.ContactPerson; tmpData.CreationDate = DateTime.Now; tmpData.CreatedBy = WmsSetupValues.SystemUser; tmpData.IsFromErp = true; list.Add(tmpData); } return(list); } catch (Exception ex) { ExceptionMngr.WriteEvent("GetCustomerAddress", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); //throw; return(null); } }
private IList <ProductAccountRelation> GetProductVendors(Product product) { IList <ProductAccountRelation> productVendor = new List <ProductAccountRelation>(); ProductAccountRelation curId = null; AccountType accType = WType.GetAccountType(new AccountType { AccountTypeID = 2 }); string curItemVendor = ""; try { //Ask for the vendor Item record string sWhere = " ITEMNMBR = '" + product.ProductCode + "'"; ds = DynamicsGP_ec.GetDataSet(DynamicsGP_ec.RetreiveData("VendorItem", false, 2, 0, sWhere, true)); if (ds.Tables.Count > 0) { foreach (DataRow dr in ds.Tables[1].Rows) { curId = new ProductAccountRelation(); curId.ItemNumber = dr["VNDITNUM"].ToString(); //Si esta vacio se sale al proximo if (string.IsNullOrEmpty(curId.ItemNumber)) { continue; } curItemVendor = dr["VENDORID"].ToString() + ":" + curId.ItemNumber; curId.IsFromErp = true; curId.AccountType = accType; curId.Account = WType.GetAccount(new Account { AccountCode = dr["VENDORID"].ToString(), BaseType = new AccountType { AccountTypeID = AccntType.Vendor } }); curId.Product = product; curId.CreatedBy = WmsSetupValues.SystemUser; curId.CreationDate = DateTime.Now; productVendor.Add(curId); } } return(productVendor); } catch (Exception ex) { ExceptionMngr.WriteEvent("GetProductVendors:" + curItemVendor, ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); //throw; return(null); } }
private void ProcessCategories(IList <ProductCategory> list) { if (list == null) { return; } ProductCategory curRecord = null; foreach (ProductCategory e in list) { try { //Evalua si el elemento ya existe curRecord = new ProductCategory { Company = new Company { CompanyID = e.Company.CompanyID }, ErpCode = e.ErpCode }; IList <ProductCategory> exList = Factory.DaoProductCategory().Select(curRecord); e.ModDate = DateTime.Now; e.ModifiedBy = WmsSetupValues.SystemUser; if (exList.Count == 0) { e.CreatedBy = WmsSetupValues.SystemUser; e.CreationDate = DateTime.Now; Factory.DaoProductCategory().Save(e); } else { e.CategoryID = exList.First().CategoryID; e.CreatedBy = exList.First().CreatedBy; e.CreationDate = exList.First().CreationDate; e.ModifiedBy = WmsSetupValues.SystemUser; e.ModDate = DateTime.Now; e.ExplodeKit = exList.First().ExplodeKit; Factory.DaoProductCategory().Update(e); } } catch (Exception ex) { Factory.Rollback(); ExceptionMngr.WriteEvent("ProcessCategories:" + curRecord.Name, ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Business); ////throw; } } }
//SHIPPING METHGODS public Boolean GetErpAllShippingMethods(Company company) { if (company == null) { ExceptionMngr.WriteEvent("GetErpAllShippingMethods Company " + company.Name, ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Business); return(false); } SetConnectMngr(company); ProcessShippingMethods(ErpFactory.References().GetAllShippingMethods()); return(true); }
public Boolean GetErpProductById(Company company, string code) { if (company == null) { ExceptionMngr.WriteEvent("GetErpProductById Company " + company.Name, ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Business); return(false); } SetConnectMngr(company); ProcessProducts(ErpFactory.References().GetProductById(code)); return(true); }
private void SpecificCompanyProcess(Company company) { string sQuery = ""; //procesos Especificos a ejecutar para algunas companias ej Manzo que se deben traer //informacion para popular Servicios. //Se debe disenar mas elegante, sacando los queries de base de datos //Con una frecuenca de ejecucion y ultima ejecucion, next execution //Como un Schedule. string routineCommand = ""; try { routineCommand = Factory.DaoConfigOption().Select(new ConfigOption { Code = "ROUTINES" }) .First().DefValue; try { if (!string.IsNullOrEmpty(routineCommand)) { Factory.DaoObject().PerformSpecificQuery(routineCommand); } } catch (Exception ex) { ExceptionMngr.WriteEvent("SpecificCompanyProcess: ", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.Business); } } catch { } /* * if (company.Name.Contains("MANZO")) * { * try * { * /*sQuery = "UPDATE p SET p.UnitsPerPack = gag.CASESPP " + * "FROM Master.Product p INNER JOIN " + * "MAN01.dbo.GAGItemMainOP gag ON p.ProductCode = gag.ITEMNUMBER"; * * * sQuery = "EXEC [dbo].[spWMSRoutines] 4"; * Factory.DaoObject().PerformSpecificQuery(sQuery); * } * catch (Exception ex) { * ExceptionMngr.WriteEvent("SpecificCompanyProcess: ", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.Business); * } * } */ }
public IList <Unit> GetAllUnits() { Unit tmpData; IList <Unit> list = new List <Unit>(); try { Command.Connection = new SqlConnection(CurCompany.ErpConnection.CnnString); Query = GetErpQuery("UNITS"); ds = ReturnDataSet(Query, null, "UNITS", Command.Connection); if (ds == null || ds.Tables.Count == 0) { return(null); } //En el dataset, Tables: 1 - UOFM foreach (DataRow dr in ds.Tables[0].Rows) { //Solo para unidades equivalentes en unidad base if (Double.Parse(dr["factor"].ToString(), new NumberFormatInfo { NumberDecimalSeparator = Separator }) > 0) { //Map Properties tmpData = new Unit(); tmpData.Company = CurCompany; // WType.GetDefaultCompany(); tmpData.Name = dr["f101_descripcion"].ToString(); tmpData.ErpCode = dr["f101_id"].ToString(); tmpData.ErpCodeGroup = WmsSetupValues.DEFAULT; tmpData.BaseAmount = double.Parse(dr["factor"].ToString(), new NumberFormatInfo { NumberDecimalSeparator = Separator }); tmpData.IsFromErp = true; list.Add(tmpData); } } return(list); } catch (Exception ex) { ExceptionMngr.WriteEvent("GetUnits", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); //throw; return(null); } }
//Envia un archivo de templates a imprimir public static bool PrintLabels(string labelData, string printerPort) { //TODO: Módulo de impresión bool result = false; string printPort = printerPort; string filePath = CreatePrintTemporaryFile("", labelData); batFile = AppPath + "\\PRINT.BAT"; batFile = batFile.Replace("\\\\", "\\"); if (!File.Exists(batFile)) { //throw new Exception("Setup file " + batFile + " does not exists.\n"); ExceptionMngr.WriteEvent("Setup file " + batFile + " does not exists.\n", ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Printer); } batFile = "\"" + batFile + "\""; //Comillas para que el DOS lo reconozca try { if (File.Exists(filePath) == false) { //throw new Exception("Please setup the temporary printing file."); ExceptionMngr.WriteEvent("Please setup the temporary printing file.", ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Printer); } //TEST FILE TO SEE THE COMMAND //CreatePrintTemporaryFile("Command" + Guid.NewGuid().ToString(), batFile + " \"" + filePath + "\" " + printPort); string printCommand = "\"" + filePath + "\" \"" + printPort + "\""; //////Asynchronously start the Thread to process the Execute command request. //Thread objThread = new Thread(new ParameterizedThreadStart(SendPrintProcess)); //////Make the thread as background thread. //objThread.IsBackground = true; //////Set the Priority of the thread. //objThread.Priority = ThreadPriority.AboveNormal; //////Start the thread. //objThread.Start(printCommand); SendPrintProcess(printCommand); } catch (Exception ex) { result = true; //throw ex; } return(result); }
public Boolean GetErpReceivingDocumentsLastXDays(Company company, int days) { if (company == null) { ExceptionMngr.WriteEvent("GetErpReceivingDocumentsLastXDays Company " + company.Name, ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Business); return(false); } SetConnectMngr(company); ProcessDocuments(ErpFactory.Documents().GetReceivingDocumentsLastXDays(days), company); return(true); }
public Boolean GetErpLocationsSince(Company company, DateTime sinceDate) { if (company == null) { ExceptionMngr.WriteEvent("GetErpLocationsSince Company " + company.Name, ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Business); return(false); } SetConnectMngr(company); ProcessLocations(ErpFactory.References().GetLocationsSince(sinceDate)); return(true); }
//Imprime en impresora mandando la lineas de comando PCL private static void PrintLabelByPL(LabelTemplate template, IList <Label> listLabels, Printer printer) { LabelMngr lblMngr = new LabelMngr(); string templateReplaced = lblMngr.GetReplacedTemplateForLabels(listLabels, template, ""); if (string.IsNullOrEmpty(templateReplaced)) { //throw new Exception("Error creating Printer Template."); ExceptionMngr.WriteEvent("Error creating Printer Template. " + template.Header, ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Printer); } PrintLabels(templateReplaced, printer.PrinterPath); }
public void GetErpLocationTransferDocumentsSince(Company company, DateTime sinceDate) { if (company == null) { ExceptionMngr.WriteEvent("GetErpLocationTransferDocumentsSince Company " + company.Name, ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Business); return; } SetConnectMngr(company); ProcessDocuments(ErpFactory.Documents().GetLocationTransferDocumentsSince(sinceDate), company); return; }
public Boolean GetErpKitAssemblyDocumentsSince(Company company, DateTime sinceDate) { if (company == null) { ExceptionMngr.WriteEvent("GetErpAllKitAssemblyDocumentsSince Company " + company.Name, ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Business); return(false); } SetConnectMngr(company); ProcessDocuments(ErpFactory.Documents().GetKitAssemblyDocumentsSince(sinceDate), company); return(true); }
public bool ReceiveProductAsUnique(DocumentLine receivingLine, Bin destLocation, Node recNode) { Factory.IsTransactional = true; try { //Valida si el docuemnto no es nulo Rules.ValidateDocument(receivingLine.Document, true); //status del Bin donde se Recibira. Rules.ValidateBinStatus(destLocation, true); //Validar Product Restriction Rules.ValidateRestrictedProductInBin(receivingLine.Product, destLocation, true); if (receivingLine.Document.DocType.DocTypeID != SDocType.ReceivingTask) { //Valida si el producto esta en ese documento DocumentLine docLine = new DocumentLine { Document = receivingLine.Document, Product = receivingLine.Product, LineStatus = new Status { StatusID = DocStatus.New }, Unit = receivingLine.Unit, Quantity = receivingLine.Quantity }; Rules.ValidateProductInDocument(docLine, true); //Valida si hay saldo pendiente por recibir Rules.ValidateBalanceQuantityInDocument(docLine, recNode, true, false); } //Manda a Crear los Labels CreateProductUniqueTrackLabels(receivingLine, recNode, destLocation, receivingLine.Note, "", DateTime.Now); Factory.Commit(); return(true); } catch (Exception ex) { Factory.Rollback(); ExceptionMngr.WriteEvent("ReceiveProductAsUnique:", ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Business); throw new Exception(WriteLog.GetTechMessage(ex)); } }
public Boolean GetErpShippingDocumentById(Company company, string code) { if (company == null) { ExceptionMngr.WriteEvent("GetErpShippingDocumentById Company " + company.Name, ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Business); return(false); } SetConnectMngr(company); bool useRemain = GetCompanyOption(company, "USEREMQTY").Equals("T"); ProcessDocuments(ErpFactory.Documents().GetShippingDocumentById(code, 2, useRemain), company); return(true); }
public void GetErpAllLocationTransferDocuments(Company company) { if (company == null) { ExceptionMngr.WriteEvent("GetErpAllLocationTransferDocuments Company " + company.Name, ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Business); return; } SetConnectMngr(company); //ProcessDocuments(ErpFactory.Documents().GetAllReceivingDocuments()); //return true; ProcessDocuments(ErpFactory.Documents().GetLocationTransferDocumentsSince(DateTime.Today.AddDays(-1 * this.historicDays)), company); return; }
public IList <Entities.Master.Unit> GetAllUnits() { Unit tmpData; IList <Unit> list = new List <Unit>(); try { Command.Connection = new SqlConnection(CurCompany.ErpConnection.CnnString); Query = "SELECT Code, descript, 1 factor " + " FROM MEASURE WHERE code = 'EA' "; ds = ReturnDataSet(Query, null, "MEASURE", Command.Connection); if (ds == null || ds.Tables.Count == 0) { return(null); } //En el dataset, Tables: 1 - UOFM foreach (DataRow dr in ds.Tables[0].Rows) { //Solo para unidades equivalentes en unidad base //if (Double.Parse(dr["factor"].ToString(), ListValues.DoubleFormat()) > 0) //{ //Map Properties tmpData = new Unit(); tmpData.Company = CurCompany; // WType.GetDefaultCompany(); tmpData.Name = dr["descript"].ToString(); tmpData.ErpCode = dr["Code"].ToString(); tmpData.ErpCodeGroup = WmsSetupValues.DEFAULT; tmpData.BaseAmount = double.Parse(dr["factor"].ToString(), ListValues.DoubleFormat()); tmpData.IsFromErp = true; list.Add(tmpData); //} } return(list); } catch (Exception ex) { ExceptionMngr.WriteEvent("GetUnits", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); //throw; return(null); } }
private void ProcessLocations(IList <Location> list) { if (list == null) { return; } Location qLoc = null; foreach (Location e in list) { try { qLoc = new Location(); qLoc.Company = e.Company; qLoc.ErpCode = e.ErpCode; //Evalua si el elemento ya existe IList <Location> exList = Factory.DaoLocation().Select(qLoc); e.ModDate = DateTime.Now; e.ModifiedBy = WmsSetupValues.SystemUser; if (exList.Count == 0) { e.CreationDate = DateTime.Now; e.CreatedBy = WmsSetupValues.SystemUser; Factory.DaoLocation().Save(e); } else { e.LocationID = exList.First().LocationID; e.CreatedBy = exList.First().CreatedBy; e.CreationDate = exList.First().CreationDate; e.BatchNo = exList.First().BatchNo; Factory.DaoLocation().Update(e); } } catch (Exception ex) { Factory.Rollback(); ExceptionMngr.WriteEvent("ProcessLocations:" + qLoc.Company.Name + "," + qLoc.Name, ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Business); //throw; } } }
private void ProcessShippingMethods(IList <ShippingMethod> list) { if (list == null) { return; } ShippingMethod curShp; foreach (ShippingMethod e in list) { try { curShp = new ShippingMethod(); curShp.Company = e.Company; curShp.ErpCode = e.ErpCode; //Evalua si el elemento ya existe IList <ShippingMethod> exList = Factory.DaoShippingMethod().Select(curShp); e.ModDate = DateTime.Now; e.ModifiedBy = WmsSetupValues.SystemUser; if (exList.Count == 0) { e.CreationDate = DateTime.Now; e.CreatedBy = WmsSetupValues.SystemUser; Factory.DaoShippingMethod().Save(e); } else { e.ShpMethodID = exList.First().ShpMethodID; e.CreatedBy = exList.First().CreatedBy; e.CreationDate = exList.First().CreationDate; Factory.DaoShippingMethod().Update(e); } } catch (Exception ex) { Factory.Rollback(); ExceptionMngr.WriteEvent("ProcessShippingMethods:", ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Business); //throw; } } }