Exemple #1
0
        public override async Task <bool> process()
        {
            xmlMsgOut = await Task.Run(() =>
            {
                var _xconn       = xmlMsgIn.Data.Element("connection");           //get the connection data
                string _dataBase = _xconn.Element("DataBase").Value.ToString();   //get the database
                var _server      = new cServer(_xconn.Element("server"));         //create the server object from the connection data
                string _sql      = xmlMsgIn.Data.Element("sql").Value.ToString(); //get the sql
                using (var _conn = new cAccesoDatosNet(_server, _dataBase))       //create the normal connection

                    using (var _rs = new DynamicRS(_sql, _conn))                  // create the normal recordset
                    {
                        try
                        {
                            _rs.Open();                //execute the recordset
                            var x       = _rs.XMLData; //create the msgout xml data
                            x.Root.Name = "result";
                            return(x);                 // returns
                        }
                        catch (Exception ex)
                        {
                            return(XDocument.Parse((new XElement("result", "ERROR: " + ex.Message)).ToString())); //returns error
                        }
                    }
            });

            MsgOut = xmlMsgOut.ToString();
            return(true);
        }
Exemple #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
         }
     }
 }
Exemple #3
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            if (txtHU.Text != "")
            {
                // Run the query and print the HU (if it exists)
                using (var _RS = new DynamicRS($"select HU,OrderType,Address1,Address2,Address3,Address4,CustomerOrderDate,Dealer,TrafficArea,GridLoc,Route,CarrierInformation from vHULabels where HU='{txtHU.Text}' and cod3='{Values.COD3}'", Values.gDatos))
                {
                    _RS.Open();
                    if (!_RS.EOF)
                    {
                        ZPLPrintLabels(_RS, "REFERRALSLABEL");
                    }
                    else
                    {
                        MessageBox.Show("HU not found.", "Print HU", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                //// Create and configurate label
                //var _HULabel = new DealerPickPackHULabel(new ZPLLabel(75, 50, 3, _printerResolution));
                //using (var _printer = new cRawPrinterHelper(_printerAddress))
                //{
                //    _HULabel.Parameters["HU"] = txtHU.Text;
                //    _HULabel.Parameters["ROUTE"] =cboRoute.Text;
                //    _HULabel.Parameters["DEALER"] = txtDealer.Text;
                //    _HULabel.Parameters["TYPE"] = cboHUType.Text;
                //    _HULabel.Parameters["DATE"] = txtDate.Text.Substring(0, 10);
                //    _printer.SendUTF8StringToPrinter(_HULabel.ToString(), 1);
                //}
            }
        }
Exemple #4
0
 public override void NotifyDataSetChanged()
 {
     base.NotifyDataSetChanged();
     _RS = null;
     _RS = new DynamicRS();
     _RS.Open(cSQL, Values.gDatos);
 }
Exemple #5
0
        //public void AddPK(string pDBParameter,pDBFieldName)
        //{
        //    VSPrimaryKey.Add(pDBParameter,pPK);
        //    mDA.AddParameter(pDBParameter,pPK);
        //}
        public void UpdateEspackControl()
        {
            string lSql;
            int    mNumRecords = 0;

            Page = 1;
            //mDA.SelectRS=new DynamicRS();
            mDA.SelectRS.DS.Dispose();
            DataSource = null;
            if (Paginate)
            {
                mDA.Open((Page - 1) * mPageSize, mPageSize);
                lSql = "SELECT NumRecords=count(*) FROM " + CtlQuery.Tablename.DBItemName + " WHERE " + CtlQuery.WhereString;
                DynamicRS lRS = (DynamicRS) new DynamicRS(lSql, Conn);
                foreach (CtlVSColumn lColumn in ColumnsExternalKeys)
                {
                    lRS.AddControlParameter(lColumn.Name, lColumn.LinkedControl);
                }
                lRS.Open();
                mNumRecords            = Convert.ToInt32(lRS["NumRecords"]);
                NumPages               = mNumRecords / mPageSize + ((mNumRecords % mPageSize) == 0 ? 0 : 1);
                mNavigationBar.Enabled = NumPages > 1;
                mNavigationBar.Items["Counter"].Text = "1/" + NumPages.ToString();
            }
            else
            {
                mDA.Open();
            }
            DataSource = mDA.Table;
            Refresh();
            Status = mStatus;
        }
Exemple #6
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show(string.Format("This will print {0} unit labels. Are you sure?", txtQty.Text), "SIMPLISTICA", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                int _labelInit = 0;

                txtPrinter.Text = Values.LabelPrinterAddress.ToString();

                using (var _conn = new cAccesoDatosNet(Values.gDatos.Server, "REPAIRS", Values.gDatos.User, Values.gDatos.Password))
                    using (var _sp = new SP(_conn, "pGetContador"))
                    {
                        _sp.AddParameterValue("@Contador", "");
                        _sp.AddParameterValue("@Serv", "");
                        _sp.AddParameterValue("@Codigo", cboService.Value + "_UNIT_ETIQ");
                        _sp.AddParameterValue("@Incremento", Convert.ToInt32(txtQty.Value));
                        _sp.Execute();
                        _labelInit = Convert.ToInt32(_sp.ReturnValues()["@Contador"]);
                    }

                if (txtCharacter.Text == "")
                {
                    throw (new Exception("Wrong character for labels."));
                }

                string _printerAddress    = "";
                int    _printerResolution = 0;
                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];
                }
                var _label     = new ZPLLabel(70, 32, 3, _printerResolution);
                var _unitLabel = new SingleBarcode(_label);

                //_label.addLine(35, 3, 0, "C", "", "[BC][UNITNUMBER]", 0, 2.5F, 1,true);
                //var _param = new Dictionary<string, string>();
                using (var _printer = new cRawPrinterHelper(_printerAddress))
                {
                    var _delimiterLabel = new ZPLLabel(_unitLabel.Label.width, _unitLabel.Label.height, 3, _unitLabel.Label.dpi);
                    delimiterLabel.delim(_delimiterLabel, "START UNIT LABELS", "-");
                    _printer.SendUTF8StringToPrinter(_delimiterLabel.ToString(), 1);
                    //for (var i = _labelInit; i < _labelInit + Convert.ToInt32(txtQty.Value); i++)
                    for (var i = _labelInit + Convert.ToInt32(txtQty.Value) - 1; i >= _labelInit; i--)
                    {
                        _unitLabel.Parameters["VALUE"] = txtCharacter.Text + i.ToString().PadLeft(8, '0');
                        for (var j = 0; j < Convert.ToInt32(txtQtyLabel.Text); j++)
                        {
                            _printer.SendUTF8StringToPrinter(_unitLabel.ToString(), 1);
                        }
                    }
                    delimiterLabel.delim(_delimiterLabel, "END UNIT LABLES", "-");
                    _printer.SendUTF8StringToPrinter(_delimiterLabel.ToString(), 1);
                }
            }
        }
Exemple #7
0
 private void CboService_SelectedIndexChanged(object sender, EventArgs e)
 {
     using (var _rs = new DynamicRS(string.Format("Select cmp_integer,letter=left(cmp_varchar,1),cmp_varchar from REPAIRS..datosEmpresa where codigo='{0}_UNIT_QTY'", cboService.Value), Values.gDatos))
     {
         _rs.Open();
         txtQtyLabel.Text  = _rs.EOF ? "1" : _rs["cmp_integer"].ToString();
         txtCharacter.Text = _rs.EOF ? "" : _rs["letter"].ToString();
         txtPrinter.Text   = Values.LabelPrinterAddress.ToString();
     }
 }
Exemple #8
0
 public void ReQuery()
 {
     if (Query != "" && Conn != null)
     {
         var _RS = new DynamicRS(Query, Conn);
         _RS.Open();
         DataSource    = _RS.DataObject;
         DisplayMember = _RS.Fields[0];
         ValueMember   = DisplayMember;
     }
 }
Exemple #9
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show(string.Format("This will print {0} unit labels. Are you sure?", txtLOCATION.Text), "SIMPLISTICA", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                string _printerAddress    = "";
                int    _printerResolution = 0;
                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"]);
                }
                var _label     = new ZPLLabel(75, 150, 3, _printerResolution);
                var _racklabel = new RackLabelWOL(_label);

                using (var _printer = new cRawPrinterHelper(_printerAddress))

                    if (txtAISLE.Text == "")
                    {
                        using (var _rs = new DynamicRS(string.Format("select cod3,location,alias from sistemas..whmapaliases where cod3='{0}' and location='{1}'", Convert.ToString(txtCOD3.Text), Convert.ToString(txtLOCATION.Text)), Values.gDatos))
                        {
                            _rs.Open();
                            //iterate labels
                            _rs.ToList().ForEach(row =>
                            {
                                _racklabel.Parameters["VALUE"]   = row["location"].ToString();
                                _racklabel.Parameters["HASHVAL"] = row["alias"].ToString();
                                if (!_printer.SendUTF8StringToPrinter(_racklabel.ToString(), 1))
                                {
                                    CTWin.MsgError(string.Format("Error printing label {}.", row["VALUE"]));
                                }
                            });
                        }
                    }
                    else
                    {
                        using (var _rs = new DynamicRS(string.Format("select cod3,location,alias from sistemas..whmapaliasess where cod3='{0}' and location like('{1}'+'%')", Convert.ToString(txtCOD3.Text), Convert.ToString(txtAISLE.Text)), Values.gDatos))
                        {
                            _rs.Open();
                            //iterate labels
                            _rs.ToList().ForEach(row =>
                            {
                                _racklabel.Parameters["VALUE"]   = row["location"].ToString();
                                _racklabel.Parameters["HASHVAL"] = row["alias"].ToString();
                                if (!_printer.SendUTF8StringToPrinter(_racklabel.ToString(), 1))
                                {
                                    CTWin.MsgError(string.Format("Error printing label {}.", row["VALUE"]));
                                }
                            });
                        }
                    }
            }
        }
Exemple #10
0
        // Add the results of a query to the current area
        public bool AddQuery(string pSQL, cAccesoDatosNet pConn, EspackFont pFont = null, bool pHideTitles = false)
        {
            using (var _rs = new DynamicRS(pSQL, pConn))
            {
                _rs.Open();
                if (_rs.RecordCount == 0)
                {
                    MessageBox.Show("The query returned no data.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
                else
                {
                    Dictionary <string, List <string> > _matrix = new Dictionary <string, List <string> >();

                    foreach (var _item in _rs.Fields)
                    {
                        _matrix[_item.ToString()] = new List <string>();
                    }

                    int _col;

                    _rs.ToList().ForEach(_row =>
                    {
                        _col = 0;
                        _row.ItemArray.ToList().ForEach(_column =>
                        {
                            _matrix[_matrix.Keys.ToList()[_col]].Add(_column.ToString());
                            _col++;
                        });
                    });

                    foreach (var _key in _matrix.Keys)
                    {
                        Areas.Add(CurrentArea = new EspackPrintingArea(EnumDocumentZones.BODY, pFont, pDocking: EnumZoneDocking.RIGHTWARDS));

                        // Add current column title
                        if (!pHideTitles)
                        {
                            AddText(true, _key.ToString(), true);
                            CurrentArea.PermanentRows++;
                        }
                        // Add data for current column
                        foreach (var _item in _matrix[_key])
                        {
                            AddText(_item.ToString(), true);
                            CurrentArea.DataRows++;
                        }
                    }
                }
            }
            return(true);
        }
Exemple #11
0
 public ListRepairs2LoadAdapter(Context context)
 {
     this.context = context;
     using (var recordset = new DynamicRS(query, Values.gDatos))
     {
         recordset.Open();
         ListElements = recordset.ToList().Select(r => new Repair()
         {
             UnitNumber = r["UnitNumber"].ToString().Trim(), RepairCode = r["RepairCode"].ToString().Trim(), Flags = r["Flags"].ToString().Trim()
         }).ToList();                                                                                                                                                                                                   //(from r in _RS.ToList() select r["RepairCode"] + "|" + r["UnitNumber"]).ToList<string>();
         recordset.Close();
     }
 }
Exemple #12
0
 public override void NotifyDataSetChanged()
 {
     base.NotifyDataSetChanged();
     LoadLabel.Text = Loads.Label;
     using (var recordset = new DynamicRS(query, Values.gDatos))
     {
         recordset.Open();
         ListElements = recordset.ToList().Select(r => new Repair()
         {
             UnitNumber = r["UnitNumber"].ToString().Trim(), RepairCode = r["RepairCode"].ToString().Trim(), Flags = r["Flags"].ToString().Trim()
         }).ToList();                                                                                                                                                                                                   //(from r in _RS.ToList() select r["RepairCode"] + "|" + r["UnitNumber"]).ToList<string>();
         recordset.Close();
     }
 }
Exemple #13
0
        private void ShowDetails()
        {
            vsLabels.ClearEspackControl();
            vsLabels.ColumnCount = 0;
            vsLabels.Conn        = Values.gDatos;

            string _group = "";

            if (vsGroups.CurrentCell != null)
            {
                _group = (vsGroups.CurrentCell.Value.ToString() != "" ? " and grupo='" + vsGroups.CurrentCell.Value + "'" : "");
            }


            List <string> _SelectFields = new List <string>();

            _SelectFields.Add("IDREG");
            _SelectFields.AddRange(SQLSelect.Split('|'));
            _SelectFields.Add("QTY");
            _SelectFields.Add("PRINTED");
            for (int i = 0; i < _SelectFields.Count; i++)
            {
                vsLabels.AddColumn(_SelectFields[i].ToUpper());
            }

            SQLPrintable.Split('|').ToList().ForEach(x => ((CtlVSColumn)vsLabels.Columns[x.ToString()]).Print = true);

            ((CtlVSColumn)vsLabels.Columns[0]).Aggregate     = AggregateOperations.COUNT;
            ((CtlVSColumn)vsLabels.Columns["QTY"]).Aggregate = AggregateOperations.SUM;

            var _Sql = string.Format("SELECT IDREG,DATA=datos,QTY,PRINTED=impreso FROM etiquetas_detalle WHERE codigo='{0}' and parametros='{1}'{2} order by datos,idreg", txtCode.Text, SQLParameterString.Replace("'", "#"), _group);

            using (var _RS = new DynamicRS(_Sql, Values.gDatos))
            {
                _RS.Open();
                _RS.ToList().ForEach(x =>
                {
                    List <string> row = new List <string>();
                    row.Add(x["IDREG"].ToString());
                    row.AddRange(x["DATA"].ToString().Split('|'));
                    row.Add(x["QTY"].ToString());
                    row.Add(x["PRINTED"].ToString());
                    vsLabels.Rows.Add(row.ToArray());
                    //Application.DoEvents();
                    //vsLabels.Rows.Add(x["IDREG"].ToString(), x["DATA"].ToString(), x["QTY"].ToString(), x["PRINTED"]);
                });
            };
            //vsLabels.UpdateEspackControl();
        }
Exemple #14
0
 // Print HU labels
 private void btnPrintPendingHUs_Click(object sender, EventArgs e)
 {
     using (var _RS = new DynamicRS($"select v.HU,v.OrderType,v.Address1,v.Address2,v.Address3,v.Address4,v.CustomerOrderDate,v.Dealer,v.TrafficArea,v.GridLoc,v.Route,v.CarrierInformation from vHULabels v inner join (select distinct ReceivalCode,Route,Dealer,OrderType=left(OrderNumber,1),cod3 from vPendingLines where cod3='{Values.COD3}' and (Route='{cboRoute.Text}' or '{cboRoute.Text}'='')) vp on vp.ReceivalCode=v.ReceivalCode and vp.Dealer=v.Dealer and vp.OrderType=v.OrderType and right(vp.Route,3)=v.Route and vp.cod3=v.cod3 where (vp.Route='{cboRoute.Text}' or '{cboRoute.Text}'='') and vp.cod3='{Values.COD3}' order by v.Route,v.Dealer,v.OrderType,v.HU", Values.gDatos))
     {
         _RS.Open();
         if (!_RS.EOF)
         {
             ZPLPrintLabels(_RS, "REFERRALSLABEL");
         }
         else
         {
             MessageBox.Show("HU not found.", "Print HU", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Exemple #15
0
 private void FillApps()
 {
     using (var _RS = new DynamicRS("select Code=ServiceCode,Description,DB,ExeName=s.app,Zone=s.location,s.ServiceCode,s.version from general..Permiso_Servicios p inner join services s on s.ServiceCode=p.codigo where p.LoginSql= '" + Values.User + "' and general.dbo.checkFlag(flags,'OBS')=0", Values.gDatos))
     {
         _RS.Open();
         _RS.ToList()
         //.Where(a => a["Code"].ToString()=="LOGISTICA").ToList()
         .ForEach(x =>
         {
             var _app          = new cAppBot(x["Code"].ToString(), x["Description"].ToString(), x["DB"].ToString(), x["ExeName"].ToString(), x["Zone"].ToString(), Values.DBServerList[x["Zone"].ToString()], Values.ShareServerList[Values.COD3], x["ServiceCode"].ToString(), pVersion: x["version"].ToString());
             _app.AfterLaunch += _app_AfterLaunch;;
             Values.AppList.Add(_app);
         });
     }
     Values.AppList.Add(new cAppBot("Tools", "TOOLS", "", "", "", null, Values.ShareServerList[Values.COD3], "", true));
     //Values.AppList.Add(new cAppBot("lib", "lib", "", "", "", null, Values.ShareServerList[Values.COD3], true));
 }
Exemple #16
0
        public void Source(string pSQL, cAccesoDatosNet pConn)
        {
            noChange = true;
            _SQL     = pSQL;
            _RS      = new DynamicRS(_SQL, pConn);
            _RS.Open();
            DataSource = null;
            DataSource = _RS.DataObject;

            if (_RS.FieldCount > 1)
            {
                DisplayMember = _RS.Fields[1];
            }
            ValueMember  = _RS.Fields[0];
            SelectedItem = null;
            noChange     = false;
        }
Exemple #17
0
        public fDNS()
        {
            InitializeComponent();
            var _RS = new DynamicRS("Select server=cmp_varchar from datosEmpresa where codigo='BIND_SERVER'", Values.gDatos);

            try
            {
                _RS.Open();
            } catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            txtServerName.Value = _RS["server"];
            _RS.Close();
            _RS = null;
            txtUser.Focus();
        }
Exemple #18
0
 public void ReQuery()
 {
     if (aQuery != "" && Conn != null)
     {
         AutoCompleteCustomSource = new AutoCompleteStringCollection();
         using (DynamicRS _RS = new DynamicRS(aQuery, Conn))
         {
             _RS.Open();
             while (!_RS.EOF)
             {
                 AutoCompleteCustomSource.Add(_RS[0].ToString());
                 if (!_RS.EOF)
                 {
                     _RS.MoveNext();
                 }
             }
         }
     }
 }
Exemple #19
0
 private void cboCOD3_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cboCOD3.Value.ToString() != "")
     {
         try
         {
             var _RS = new DynamicRS("Select DHCP_Path,ServerShareIP from General..Sedes where COD3='" + cboCOD3.Text + "'", Values.gDatos);
             _RS.Open();
             if (_RS.EOF)
             {
                 throw new Exception("Wrong COD3 code.");
             }
             txtServerName.Text = _RS["ServerShareIP"].ToString();
             txtUser.Text       = "root";
             txtPassword.Focus();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Exemple #20
0
        public Form1()
        {
            InitializeComponent();
            CTLM.Conn = new cAccesoDatosNet("DB01", "SISTEMAS", "sa", "5380");
            txtUserCode.AutoCompleteMode   = AutoCompleteMode.Suggest;
            txtUserCode.AutoCompleteSource = AutoCompleteSource.CustomSource;
            //txtUserCode.TextBox.Multiline = false;
            var autoCompleteCustomSource = new AutoCompleteStringCollection();

            txtText.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
            txtText.AutoCompleteSource = AutoCompleteSource.CustomSource;
            using (DynamicRS rs = new DynamicRS("Select UserCode from Users", CTLM.Conn))
            {
                rs.Open();
                rs.ToList().ForEach(r => autoCompleteCustomSource.Add(r[0].ToString()));
            }
            txtUserCode.AutoCompleteCustomSource = autoCompleteCustomSource;
            txtText.AutoCompleteCustomSource     = autoCompleteCustomSource;
            CTLM.DBTable = "vUsers";
            CTLM.AddItem(txtUserCode, "UserCode", CTLMControlTypes.Search);
            CTLM.AddItem(txtUserNumber, "UserNumber", CTLMControlTypes.Search);
            CTLM.AddItem(txtPwdExp, "PasswordEXP", CTLMControlTypes.NoSearch);
            CTLM.AddItem(cboMainCOD3, "MainCOD3", CTLMControlTypes.Search);
            CTLM.AddItem(lstCOD3, "COD3", CTLMControlTypes.Search);
            CTLM.AddItem(txtDesCod3, "desCOD3", CTLMControlTypes.NoSearch);

            lstCOD3.Source("select n.COD3,Descripcion=n.cod3 from NetworkSedes n inner join general..sedes g on g.cod3=n.COD3 order by n.Cod3");
            cboMainCOD3.Source("select n.COD3,g.Descripcion from NetworkSedes n inner join general..sedes g on g.cod3=n.COD3 order by n.Cod3", txtDesCod3);
            CTLM.Start();

            VS.Conn = CTLM.Conn;
            VS.SQL  = "Select UserCode, Area, COD3 from Users where usercode!='' order by UserCode";
            VS.Start();
            VS.UpdateEspackControl();

            //VS.FilterRowEnabled = true;
        }
Exemple #21
0
 public ListLoadsAdapter(Context context)
 {
     this.context = context;
     _RS.Open();
 }
Exemple #22
0
 public ListRepairAdapter(Context context)
 {
     this.context = context;
     _RS.Open();
 }
Exemple #23
0
        private void btnProcess_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("This will update the DNS server assignments and will restart the service.\n Are you sure? ", "Info", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                {
                    string _serverDNS = txtServerName.Text;
                    var    _SP        = new SP(Values.gDatos, "pGetContador");
                    _SP.AddParameterValue("@Contador", 0);
                    _SP.AddParameterValue("@Serv", "");
                    _SP.AddParameterValue("@Codigo", "BIND_SERIAL");
                    _SP.Execute();
                    var _serial = _SP.Parameters["@Contador"].Value.ToString();
                    _SP = null;

                    string _tmpFile    = System.IO.Path.GetTempPath() + "local.hosts";
                    string _configFile = "$ttl 38400\n";
                    _configFile += "local.	IN	SOA	valsrv02. informatica.espackeuro.com. (\n";
                    _configFile += "			"+ _serial + "\n";
                    _configFile += "			10800\n";
                    _configFile += "			3600\n";
                    _configFile += "			604800\n";
                    _configFile += "			38400 )\n";
                    _configFile += "local.	IN	NS	valsrv02.\n";
                    //create the temp File
                    var _RSD = new DynamicRS("Select entry from vDNSFile order by entry", Values.gDatos);
                    _RSD.Open();
                    while (!_RSD.EOF)
                    {
                        _configFile += _RSD["entry"] + "\n";
                        _RSD.MoveNext();
                    }
                    //_configFile += "\t}\n";
                    _RSD.Close();
                    File.WriteAllText(_tmpFile, _configFile);
                    lblMsg.Text = "File created OK.";
                    //move the file to the server
                    using (var client = new SftpClient(_serverDNS, txtUser.Text, txtPassword.Text))
                    {
                        lblMsg.Text = "Connecting the server.";
                        client.Connect();
                        lblMsg.Text = "Server Connected!";
                        client.ChangeDirectory("/var/lib/bind/");
                        using (var fileStream = new FileStream(_tmpFile, FileMode.Open))
                        {
                            client.BufferSize = 4 * 1024; // bypass Payload error large files
                            client.UploadFile(fileStream, Path.GetFileName(_tmpFile));
                        }
                        lblMsg.Text = "File updated!";
                        client.Disconnect();
                    }
                    //restart the dhcp service
                    using (var client = new SshClient(_serverDNS, txtUser.Text, txtPassword.Text))
                    {
                        client.Connect();
                        client.RunCommand("service bind9 reload");
                        lblMsg.Text = "DNS Service reloaded!";
                        client.Disconnect();
                    }
                    MessageBox.Show("The process has finished correctly.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #24
0
 public ListServicesAdapter(Context context)
 {
     this.context = context;
     _RS.Open();
 }
Exemple #25
0
 private void btnProcess_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageBox.Show("This will update the DHCP server assignments and will restart the service.\n Are you sure? ", "Info", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
         {
             string _serverDHCP = txtServerName.Text;
             string _tmpFile    = System.IO.Path.GetTempPath() + cboCOD3.Text + "_NET.conf";
             string _configFile = "";
             //create the temp File
             var _RSD = new DynamicRS("Select * from vDHCPConfig where COD3='" + cboCOD3.Text + "'", Values.gDatos);
             _RSD.Open();
             string _group = "";
             while (!_RSD.EOF)
             {
                 if (_RSD["Group"].ToString() != _group)
                 {
                     if (_group != "")
                     {
                         _configFile += "\t}\n";
                     }
                     _group       = _RSD["Group"].ToString();
                     _configFile += "# " + _group + '\n' + "group " + _group + "{" + '\n';
                 }
                 _configFile += "\t# " + _RSD["Comment"].ToString() + '\n';
                 _configFile += "\thost " + _RSD["Host"].ToString() + " {" + '\n';
                 _configFile += "\t\thardware ethernet " + _RSD["MAC"].ToString() + ";" + '\n';
                 _configFile += "\t\tfixed-address " + _RSD["IP"].ToString() + ";" + '\n';
                 _configFile += "\t\t}\n";
                 _RSD.MoveNext();
             }
             _configFile += "\t}\n";
             _RSD.Close();
             File.WriteAllText(_tmpFile, _configFile);
             lblMsg.Text = "File created OK.";
             //move the file to the server
             using (var client = new SftpClient(_serverDHCP, txtUser.Text, txtPassword.Text))
             {
                 lblMsg.Text = "Connecting the server.";
                 client.Connect();
                 lblMsg.Text = "Server Connected!";
                 client.ChangeDirectory("/etc/dhcp/");
                 using (var fileStream = new FileStream(_tmpFile, FileMode.Open))
                 {
                     client.BufferSize = 4 * 1024; // bypass Payload error large files
                     client.UploadFile(fileStream, Path.GetFileName(_tmpFile));
                 }
                 lblMsg.Text = "File updated!";
                 client.Disconnect();
             }
             //restart the dhcp service
             using (var client = new SshClient(_serverDHCP, txtUser.Text, txtPassword.Text))
             {
                 client.Connect();
                 client.RunCommand("service isc-dhcp-server restart");
                 lblMsg.Text = "DHCP Service restarted!";
                 client.Disconnect();
             }
             MessageBox.Show("The process has finished correctly.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #26
0
        // Print all "unprinted" labels of the selected group
        private void btnPrint_Click(object sender, EventArgs e)
        {
            SetFormEnabled(false);
            if (cboPrinters.Value.ToString() == "")
            {
                SetFormEnabled(true);
                CTWin.MsgError("Select a printer first.");
                return;
            }
            string _printerType       = "";
            string _printerAddress    = "";
            int    _printerResolution = 0;

            using (var _RS = new DynamicRS(string.Format("select descripcion,cmp_varchar,cmp_integer from datosEmpresa where codigo='{0}'", cboPrinters.Value), Values.gDatos))
            {
                _RS.Open();
                _printerAddress    = _RS["cmp_varchar"].ToString();
                _printerType       = _RS["descripcion"].ToString().Split('|')[0];
                _printerResolution = Convert.ToInt32(_RS["cmp_integer"]);
            }
            cLabel _delimiterLabel;
            cLabel _label;

            if (_printerType == "ZPL")
            {
                _delimiterLabel = new ZPLLabel(labelHeight, labelWidth, 3, _printerResolution);
                if (!NoDelim)
                {
                    delimiterLabel.delim(_delimiterLabel, "START", SQLParameterString.Replace(" WHERE ", ""));
                }
                _label = new ZPLLabel(labelHeight, labelWidth, 3, _printerResolution);
            }
            else
            {
                SetFormEnabled(true);
                throw new NotImplementedException();
            }
            using (var _printer = new cRawPrinterHelper(_printerAddress))
            {
                //print delimiter start
                if (!NoDelim)
                {
                    _printer.SendUTF8StringToPrinter(_delimiterLabel.ToString(), 1);
                }
                using (var _RS = new DynamicRS(string.Format("Select * from Campos_CS where codigo='{0}'", txtCode.Text), Values.gDatos))
                {
                    _RS.Open();
                    _RS.ToList().ForEach(z =>
                    {
                        float _bh = z["barcodeHeight"] is DBNull ? 0 : Convert.ToSingle(z["barcodeHeight"]);
                        float _bm = z["barcodeWidthmult"] is DBNull ? 0 : Convert.ToSingle(z["barcodeWidthmult"]);
                        float _cs = z["charSize"] is DBNull ? 0 : Convert.ToSingle(z["charSize"]);
                        _label.addLine(Convert.ToInt32(z["Col"]), Convert.ToInt32(z["Fila"]), Convert.ToSingle(CT.Qnuln(z["TamTexto"])), z["Orientacion"].ToString(), z["Estilo"].ToString(), z["Texto"].ToString(), _cs, _bh, _bm);
                    });
                }
                Dictionary <string, string> _parameters = new Dictionary <string, string>();
                SQLSelect.Split('|').ToList().ForEach(x => _parameters.Add(x, ""));
                string _group = "";
                vsLabels.ToList().Where(line => line.Cells["PRINTED"].Value.ToString() == "N").ToList().ForEach(line =>
                {
                    _parameters.ToList().ForEach(p => _parameters[p.Key] = line.Cells[p.Key].Value.ToString());
                    if (SQLGroup != "" && _group != line.Cells[SQLGroup].Value.ToString())
                    {
                        _group = line.Cells[SQLGroup].Value.ToString();
                        if (!NoDelim)
                        {
                            delimiterLabel.delim(_delimiterLabel, "GROUP", SQLGroup + "|" + _group);
                            _printer.SendUTF8StringToPrinter(_delimiterLabel.ToString(), 1);
                        }
                    }
                    _printer.SendUTF8StringToPrinter(_label.ToString(_parameters, Convert.ToInt32(line.Cells["QTY"].Value)), 1);
                    //cRawPrinterHelper.SendUTF8StringToPrinter(_printerAddress, _label.ToString(_parameters), Convert.ToInt32("2"));
                    ChangeLineStatus(line);
                });
                if (!NoDelim)
                {
                    delimiterLabel.delim(_delimiterLabel, "END", "***");
                    _printer.SendUTF8StringToPrinter(_delimiterLabel.ToString(), 1);
                }
                SetFormEnabled(true);
            }
        }
Exemple #27
0
        // Get/Generate the labels
        private void btnObtain_Click(object sender, EventArgs e)
        {
            SetFormEnabled(false);
            clearing = true;
            vsGroups.ClearEspackControl();
            vsParameters.ToList().ForEach(z =>
            {
                Parameters[z.Cells[0].Value.ToString()] = z.Cells[1].Value.ToString();
            });

            //
            var s = Parameters.Where(x => x.Value == "").ToDictionary(a => a.Key, a => a.Value);

            //Dictionary<string, string>)
            if (s.Count != 0)
            {
                MessageBox.Show("Parameter " + s.First().Key + " must be entered.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                SetFormEnabled(true);
                clearing = false;
                return;
            }
            ;

            var _Sql = "SELECT " + SQLSelect.Replace("|", ",") + " FROM " + SQLView;

            SQLParameterString = "";
            Parameters.ToList().ForEach(x =>
            {
                Parameters[x.Key]   = x.Value;
                SQLParameterString += x.Key + (x.Value != "NOTHING" ? "='" + x.Value + "'" : "") + " and ";
            });
            if (SQLParameterString != "")
            {
                SQLParameterString = " WHERE " + SQLParameterString.Substring(0, SQLParameterString.Length - 5);
            }

            _Sql += SQLParameterString;
            if (SQLOrder != "")
            {
                _Sql += " ORDER BY " + SQLOrder.Replace("|", ",");
            }

            using (var _RS = new DynamicRS(_Sql, Values.gDatos))
            {
                _RS.Open();
                if (_RS.EOF)
                {
                    SetFormEnabled(true);
                    MessageBox.Show("No rows returned.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }


                ShowDetails();
                GenerateGroups(_RS.ToList());
                if (_RS.RecordCount != vsLabels.RowCount)
                {
                    GenerateNewLabels(_RS.ToList());
                    ShowDetails();
                }
            }
            SetFormEnabled(true);
            clearing = false;
        }
Exemple #28
0
        private void TxtCode_Validating(object sender, System.ComponentModel.CancelEventArgs e)
        {
            //return;
            SetFormEnabled(false);
            //vsGroups.SelectionChanged -= VsGroups_SelectionChanged;
            clearing = true;
            Application.DoEvents();


            // Clean things
            vsParameters.ClearEspackControl();
            vsParameters.Rows.Clear();
            Parameters.Clear();
            vsLabels.ClearEspackControl();
            vsLabels.Columns.Clear();
            vsGroups.ClearEspackControl();
            vsGroups.Columns.Clear();
            Application.DoEvents();
            SQLParameterString = "";

            if (txtCode.Text == "")
            {
                clearing = false;
                SetFormEnabled(true);
                return;
            }

            using (var _RS = new DynamicRS("select *,NoDelim=dbo.checkflag(flags,'NODELIM') from etiquetas where codigo='" + txtCode.Text + "'", Values.gDatos))
            {
                _RS.Open();
                if (_RS.RecordCount == 0)
                {
                    SetFormEnabled(true);
                    MessageBox.Show("Unknown label code.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtCode.Text = "";
                    e.Cancel     = true;
                    return;
                }
                SQLSelect    = _RS["Campos_SELECT"].ToString();
                SQLView      = _RS["Vista"].ToString();
                SQLWhere     = _RS["Campos_WHERE"].ToString();
                SQLQty       = _RS["Campo_QTY"].ToString();
                SQLGroup     = _RS["Campo_GROUP"].ToString();
                SQLOrder     = _RS["Campos_ORDER"].ToString();
                SQLPrintable = _RS["Campos_PRINT"].ToString();
                labelHeight  = Convert.ToInt32(_RS["Alto"]);
                labelWidth   = Convert.ToInt32(_RS["Ancho"]);
                NoDelim      = (_RS["NoDelim"].ToInt() == 1);
                if (SQLGroup != "")
                {
                    vsGroups.AddColumn(SQLGroup);
                    SQLSelect += "|" + SQLGroup;
                }
                else
                {
                    vsGroups.AddColumn("");
                }

                SQLWhere.Split('|').ToList().ForEach(x =>
                {
                    //var _row = (DataGridViewRow) vsParameters.Rows[0].Clone();
                    //_row.Cells[0].Value = x;
                    //_row.Cells[1].Value = "";
                    var _param = x.Split('=');
                    if (_param.Count() > 1)
                    {
                        if (_param[1] == "ASK")
                        {
                            Parameters.Add(_param[0], "");
                            vsParameters.Rows.Add(_param[0], "");
                            //vsParameters.Rows[vsParameters.RowCount-1].Cells[1].ReadOnly = false;
                        }
                        else
                        {
                            Parameters.Add(_param[0], _param[1]);
                        }
                    }
                    else
                    {
                        Parameters.Add(_param[0], "NOTHING");
                    }
                });
                //
                if (vsParameters.RowCount != 0)
                {
                    vsParameters.CurrentCell = vsParameters.Rows[0].Cells[1];
                    vsParameters.BeginEdit(true);
                }

                cboPrinters.Source("select Codigo from datosEmpresa where descripcion like '%" + txtCode.Text + "%' order by cmp_integer", Values.gDatos);
            }
            clearing = false;
            SetFormEnabled(true);
        }
Exemple #29
0
 public ListLoadsRepairsAdapter(Context context, string SQL)
 {
     this.context = context;
     cSQL         = SQL;
     _RS.Open(SQL, Values.gDatos);
 }
Exemple #30
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);
        }