Пример #1
0
 private void btnACheck_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("This will check and if possible store all the received parts. Are you sure?", "SIMPLISTICA", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         using (var _sp = new SP(Values.gDatos, "pProcessSimpleReceival"))
         {
             _sp.AddParameterValue("@Recepcion", txtEntrada.Value.ToString());
             try
             {
                 _sp.Execute();
             }
             catch (Exception ex)
             {
                 CTWin.MsgError(ex.Message);
                 return;
             }
             if (_sp.LastMsg.Substring(0, 2) != "OK")
             {
                 CTWin.MsgError(_sp.LastMsg);
                 return;
             }
             //lstFlags["RECEIVED"] = true;
         }
         CTLM.StatusMsg("Process completed.");
     }
 }
Пример #2
0
 private void generateCM(int pReceival, int pLine)
 {
     //sp preparation
     using (var _sp = new SP(Values.gDatos, "PGenerar_Paletags_linea"))
     {
         using (var _rs = new DynamicRS(string.Format("Select 0 from CMS_PALETAGS where Entrada='{0}' and Linea='{1}'", pReceival, pLine), Values.gDatos))
         {
             _rs.Open();
             //if no paletags for the line
             if (_rs.RecordCount == 0)
             {
                 CTLM.StatusMsg(string.Format("Generating paletags for line {0}", pLine));
                 _sp.AddParameterValue("@Entrada", pReceival);
                 _sp.AddParameterValue("@Linea", pLine);
                 try
                 {
                     //generate them
                     _sp.Execute();
                 }
                 catch (Exception ex)
                 {
                     throw new Exception(ex.Message);
                 }
                 if (_sp.LastMsg.Substring(0, 2) != "OK")
                 {
                     throw new Exception(_sp.LastMsg);
                 }
             }
             //now we print them
         }
     }
 }
Пример #3
0
 private void ipChecker(object sender, EventArgs e)
 {
     if (_changes)
     {
         _changes = false;
         var text = (MaskedTextBox)sender;
         try
         {
             Convert.ToByte(text.Text);
         }
         catch
         {
             CTLM.StatusMsg("Wrong IP block data.");
             text.Text = "";
         }
         txtSubNet.Text = txtSubnet1.Text + "." + txtSubnet2.Text + "." + txtSubnet3.Text + "." + txtSubnet4.Text;
         if (txtSubNet.Text == "...")
         {
             txtSubNet.Text = "";
         }
         txtMask.Text = txtMask1.Text + "." + txtMask2.Text + "." + txtMask3.Text + "." + txtMask4.Text;
         if (txtMask.Text == "...")
         {
             txtMask.Text = "";
         }
         if (text.Text.Length == 3)
         {
             SendKeys.Send("{TAB}");
         }
         _changes = true;
     }
 }
Пример #4
0
        private void btnLabelCMs_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("This will generate and print all CMs. Are you sure?", "SIMPLISTICA", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                //printer preparation

                string _printerAddress    = "";
                int    _printerResolution = 0;
                if (Values.LabelPrinterAddress == "")
                {
                    CTWin.MsgError("Select a label printer first in preferences.");
                    return;
                }
                using (var _RS = new DynamicRS(string.Format("select descripcion,cmp_varchar,cmp_integer from ETIQUETAS..datosEmpresa where codigo='{0}'", Values.LabelPrinterAddress), Values.gDatos))
                {
                    _RS.Open();
                    _printerAddress    = _RS["cmp_varchar"].ToString();
                    _printerResolution = Convert.ToInt32(_RS["cmp_integer"]);
                    //_printerType = _RS["descripcion"].ToString().Split('|')[0];
                }
                //label preparation
                var _label   = new ZPLLabel(70, 31, 3, _printerResolution);
                var _CMLabel = new MicroCM(_label);
                //sp preparation
                using (var _printer = new cRawPrinterHelper(_printerAddress))
                    using (var _sp = new SP(Values.gDatos, "PGenerar_Paletags_linea"))
                    {
                        var _delimiterLabel = new ZPLLabel(_CMLabel.Label.width, _CMLabel.Label.height, 3, _CMLabel.Label.dpi);
                        delimiterLabel.delim(_delimiterLabel, "START RECEIVAL", txtEntrada.Text);
                        _printer.SendUTF8StringToPrinter(_delimiterLabel.ToString(), 1);
                        //we will check line by line
                        VS.ToList().Where(r => r.Cells[0].Value.ToString() != "").ToList().ForEach(r =>
                        {
                            //first we generate the cms
                            try
                            {
                                generateCM(Convert.ToInt32(txtEntrada.Value), Convert.ToInt32(r.Cells[1].Value));
                            }
                            catch (Exception ex)
                            {
                                CTWin.MsgError(ex.Message);
                                CTLM.StatusMsg(ex.Message);
                            }
                            //delimiter
                            delimiterLabel.delim(_delimiterLabel, "LINE", r.Cells[1].Value.ToString());
                            _printer.SendUTF8StringToPrinter(_delimiterLabel.ToString(), 1);
                            // then we print the labels
                            using (var _rs = new DynamicRS(string.Format("Select cp.CM,cp.Entrada,cp.Linea,cp.Partnumber,cp.QTY,cp.xfec,c.Doc_Proveedor from CMS_PALETAGS cp inner join cab_Recepcion c on c.entrada=cp.entrada where cp.Entrada='{0}' and Linea='{1}'", Convert.ToInt32(txtEntrada.Value), Convert.ToInt32(r.Cells[1].Value)), Values.gDatos))
                            {
                                _rs.Open();
                                _rs.ToList().ForEach(row =>
                                {
                                    _CMLabel.Parameters["CM"]            = row["CM"].ToString();
                                    _CMLabel.Parameters["RECEIVAL"]      = row["Entrada"].ToString();
                                    _CMLabel.Parameters["RECEIVAL_DATE"] = row["xfec"].ToString();
                                    _CMLabel.Parameters["PARTNUMBER"]    = row["Partnumber"].ToString();
                                    _CMLabel.Parameters["QTY"]           = row["QTY"].ToString();
                                    if (!_printer.SendUTF8StringToPrinter(_CMLabel.ToString(), 1))
                                    {
                                        CTWin.MsgError(string.Format("Error printing label {0}.", row["CM"]));
                                    }
                                });
                            }
                            delimiterLabel.delim(_delimiterLabel, "END RECEIVAL", txtEntrada.Text);
                            _printer.SendUTF8StringToPrinter(_delimiterLabel.ToString(), 1);
                        });

                        lstFlags["PALETAGS"] = true;
                        CTLM.StatusMsg("CMs generated OK.");
                    }
            }
            MessageBox.Show("Label printing task finished.", "SIMPLISTICA", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Пример #5
0
        private bool generateXMLSystems()
        {
            Cursor.Current = Cursors.WaitCursor;
            int    contador = 0;
            string servidor = "";

            // lets get the counter for the XML file version
            using (var getContador = new SP(Values.gDatos, "pGetContador"))
            {
                getContador.AddParameterValue("Contador", contador);
                getContador.AddParameterValue("Serv", servidor);
                getContador.AddParameterValue("Codigo", "XMLSystems");
                try
                {
                    getContador.Execute();
                }
                catch (Exception ex)
                {
                    CTWin.MsgError(ex.Message);
                    return(false);
                }
                if (getContador.LastMsg.Substring(0, 2) != "OK")
                {
                    CTWin.MsgError(getContador.LastMsg);
                    return(false);
                }
                contador = Convert.ToInt32(getContador.ReturnValues()["@Contador"]);
            }
            // create the root of the XML doc
            XDocument xmlDocument;
            string    _xml = string.Format(
                @"<?xml version='1.0' encoding='utf - 8'?>
<!--{0} systems file-->
<systemsfile version='{0}'>
<specials>
</specials>
<systems>
</systems>
</systemsfile>", contador);

            xmlDocument = XDocument.Parse(_xml);
            var serverSystemsPath = "\\\\VALSRV02\\APPS_CS";
            //get files in apps directory
            var serverSystemsDir = Directory.GetFiles(serverSystemsPath).Where(f => Path.GetExtension(f) == ".zip");

            //create the rootDir element
            foreach (var filePath in serverSystemsDir)
            {
                var fileInfo        = new FileInfo(filePath);
                var xSpecialElement = new XElement("special", new XAttribute("name", Path.GetFileNameWithoutExtension(filePath)));
                var xSElement       = new XElement("File", new XAttribute("path", filePath.Replace(serverSystemsPath, "").Replace(fileInfo.Name, "").Substring(1)), new XAttribute("fileName", fileInfo.Name), new XAttribute("fileSize", fileInfo.Length), new XAttribute("fileTime", fileInfo.LastWriteTime));
                xSpecialElement.Add(xSElement);
                xmlDocument.Descendants("specials").FirstOrDefault().Add(xSpecialElement);
            }
            var directories = Directory.GetDirectories(serverSystemsPath);

            foreach (var directoryPath in directories.Where(x => !x.Contains(".svn")))
            {
                var dirInfo        = new DirectoryInfo(directoryPath);
                var xSystemElement = new XElement("system", new XAttribute("name", dirInfo.Name));
                xSystemElement.Add(xmlFromDirectory(directoryPath, serverSystemsPath));
                xmlDocument.Descendants("systems").FirstOrDefault().Add(xSystemElement);
            }
            var localXmlFile = "d:\\APPS_CS\\systems.xml";

            xmlDocument.Save(localXmlFile);
            // commit new file to svn
            SvnCommitArgs args = new SvnCommitArgs();

            args.LogMessage = string.Format("systems.xml file version {0} Commit", contador);
            SvnCommitResult result;

            using (var client = new SvnClient())
            {
                try
                {
                    SvnUI.Bind(client, this);
                    client.Commit(localXmlFile, args, out result);
                    if (result != null)
                    {
                        CTLM.StatusMsg("Successfully commited revision " + result.Revision);
                    }
                    else
                    {
                        CTLM.StatusMsg("No changes have been made to working copy since it was checked out.");
                    }
                }
                catch (SvnException se)
                {
                    CTLM.StatusMsg(se.Message + "Error: " + se.SvnErrorCode);
                }
            }
            return(true);
        }
Пример #6
0
        // Do the stuff to check things before launching the robot process and then, launch it.
        private void btnRobotProcess_Click(object sender, EventArgs e)
        {
            if (txtContainer.Text == "")
            {
                MessageBox.Show("Wrong container number.", "SIMPLISTICA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (txtPackingSlip.Text == "")
            {
                MessageBox.Show("Wrong packing slip.", "SIMPLISTICA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (CTLM.Status != EnumStatus.NAVIGATE && CTLM.Status != EnumStatus.SEARCH)
            {
                MessageBox.Show("Not allowed while current status is " + CTLM.Status.ToString() + ".", "SIMPLISTICA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (getROBOT_Status() == EnumROBOT_Status.RUN || getROBOT_Status() == EnumROBOT_Status.INI)
            {
                MessageBox.Show("ROBOT process already launched. Please wait for it to finish.", "SIMPLISTICA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (VS.Rows.Count != 0)
            {
                MessageBox.Show("This receival already has detail lines.", "SIMPLISTICA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (MessageBox.Show("Do you really want to execute IDC_RECEP_AX HSA process for receival " + txtReceivalCode.Text + "?", "SIMPLISTICA", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                int _numProceso;

                // Add spaces to the left of the container and get the last 7 chars.
                string _container = new String(' ', 7) + txtContainer.Text;
                _container = _container.Substring(_container.Length - 7);

                // Launch the robot process.
                using (var _sp = new SP(Values.gDatos, "AUTOMATIZACION..pAddEjecucion"))
                {
                    _sp.AddParameterValue("@Proceso", "IDC_RECEP_AX");
                    _sp.AddParameterValue("@Fase", 1);
                    _sp.AddParameterValue("@Variables", "CONTAINER=" + _container + "|RECEP=" + txtReceivalCode.Text + "|PKGSLIP=" + txtPackingSlip.Text + "|HSA=1");
                    try
                    {
                        _sp.Execute();
                    }
                    catch (Exception ex)
                    {
                        CTWin.MsgError("Error launching robot process: " + ex.Message);
                        return;
                    }
                    if (_sp.LastMsg.Substring(0, 2) != "OK")
                    {
                        CTWin.MsgError("Error launching robot process: " + _sp.LastMsg);
                        return;
                    }
                    // Get the process number.
                    _numProceso = _sp.LastMsg.Substring(4).ToInt();
                }
                // Change the receival status.
                setROBOT_Status(EnumROBOT_Status.INI);
                ROBOT_SetReceivalStatus(_numProceso, txtReceivalCode.Text, EnumROBOT_Status.INI);

                // Inform the user.
                CTLM.StatusMsg("Process launched.");
                MessageBox.Show("Process launched OK.", "SIMPLISTICA", MessageBoxButtons.OK, MessageBoxIcon.Information);

                // Enable timer.
                tmrRobot.Enabled = true;
            }
        }