Example #1
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            using (var _rs = new StaticRS($"select Route,Date=convert(varchar(10),Date,103) from ContainersCab where ContainerCode='{txtContainer.Text}' and cod3='{Values.COD3}'", Values.gDatos))
            {
                _rs.Open();
                if (_rs.RecordCount == 0)
                {
                    return;
                }

                // Refresh the form data from DB values
                cboRoute.Text = _rs["Route"].ToString();
                txtDate.Text  = _rs["Date"].ToString();
            }

            SetFormEnabled(false);
            using (var pd = new PrintDialog())
            {
                if (pd.ShowDialog() == DialogResult.OK)
                {
                    using (var _printIt = new PrintContainer())
                    {
                        // Copy values into the object properties & print
                        _printIt.ContainerCode   = txtContainer.Text;
                        _printIt.Route           = cboRoute.Text;
                        _printIt.Date            = txtDate.Text.Substring(0, 10);
                        _printIt.PrinterSettings = pd.PrinterSettings;
                        pd.Document = _printIt;
                        _printIt.Print();
                    }
                }
            }
            SetFormEnabled(true);
        }
Example #2
0
        public fLocalHolidays()
        {
            InitializeComponent();
            var iniYear   = DateTime.Now.Year - 1;
            var yearRange = 11;

            cboYear.DataSource = Enumerable.Range(iniYear, yearRange).ToList();
            cboCOD3.Source($"Select valor from dbo.Split((Select COD3 from SISTEMAS.dbo.Users where UserCode='{conn.User}'),'|') order by Valor", conn);
            var _mainCOD3 = new StaticRS($"Select MainCOD3 from SISTEMAS.dbo.Users where UserCode='{conn.User}'", conn);

            _mainCOD3.Open();
            cboCOD3.Update();
            cboCOD3.Value = _mainCOD3["MainCOD3"].ToString();
            _mainCOD3.Close();
            _mainCOD3 = null;

            /*
             * yearCalendar.MinDate = new System.DateTime(DateTime.Now.Year, 1, 1, 0, 0, 0, 0);
             * yearCalendar.MaxDate = new System.DateTime(DateTime.Now.Year, 12, 31, 23, 59, 59, 100);
             */

            cboYear.ValueChanged           += CboYear_ValueChanged;
            cboYear.Value                   = DateTime.Now.Year;
            yearCalendar.CalendarDimensions = new Size(4, 3);
            yearCalendar.DateSelected      += YearCalendar_DateSelected;
            conn.Open();
        }
Example #3
0
 private void VS_CellEndEdit(object sender, DataGridViewCellEventArgs e)
 {
     if (VS.Columns[e.ColumnIndex].Name == "Reference")
     {
         if (VS.CurrentCell.Value != "")
         {
             using (var _rs = new StaticRS(string.Format("Select Description from MasterRepairReferences where reference='{0}' and service='{1}'", VS[e.ColumnIndex, e.RowIndex].Value, cboService.Value), Values.gDatos))
             {
                 _rs.Open();
                 if (_rs.RecordCount == 0)
                 {
                     MessageBox.Show("Wrong partnumber", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     VS[e.ColumnIndex, e.RowIndex].Value = "";
                     VS[VS.Columns["Description"].Index, e.RowIndex].Value = "";
                     VS.CurrentCell = VS[e.ColumnIndex, e.RowIndex];
                 }
                 else
                 {
                     VS[VS.Columns["Description"].Index, e.RowIndex].Value = _rs["Description"].ToString();
                     VS.CurrentCell = VS[VS.Columns["Description"].Index, e.RowIndex];
                 }
             }
         }
         else
         {
             VS[VS.Columns["Description"].Index, e.RowIndex].Value = "";
         }
     }
 }
Example #4
0
 private void VS_CellEndEdit(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == VS.Columns["Partnumber"].Index)
     {
         if (VS[e.ColumnIndex, e.RowIndex].Value?.ToString() != "")
         {
             using (var _rs = new StaticRS(string.Format("Select Descripcion from Referencias where partnumber='{0}' and Servicio='{1}'", VS[e.ColumnIndex, e.RowIndex].Value, cboServicio.Value), Values.gDatos))
             {
                 _rs.Open();
                 if (_rs.RecordCount == 0)
                 {
                     CTWin.MsgError("Wrong partnumber");
                     VS[e.ColumnIndex, e.RowIndex].Value = "";
                     //VS.CurrentCell = VS[e.ColumnIndex, e.RowIndex];
                     //e.Cancel = true;
                 }
                 else
                 {
                     VS[VS.Columns["Description"].Index, e.RowIndex].Value = _rs["Descripcion"].ToString();
                     //VS.CurrentCell = VS[e.ColumnIndex + 2, e.RowIndex];
                 }
             }
         }
         if (VS[e.ColumnIndex, e.RowIndex].Value.ToString() == "")
         {
             VS[VS.Columns["Description"].Index, e.RowIndex].Value = "";
         }
     }
 }
Example #5
0
        private bool isEspackIP(ref string COD3)
        {
            //#if DEBUG
            //            COD3 = "OUT";
            //            return false;
            //#else
            int _zone;
            var _IP = Values.gDatos.IP.GetAddressBytes();

            if (_IP[0] == 10)
            {
                _zone = _IP[1];
            }
            else
            {
                _zone = _IP[2];
            }
            using (var _RS = new StaticRS(string.Format("Select COD3 from GENERAL..Sedes where zone='{0}'", _zone), Values.gDatos))
            {
                _RS.Open();
                if (_RS.RecordCount == 0)
                {
                    COD3 = "OUT";
                    return(false);
                }
                COD3 = _RS["COD3"].ToString();
            }
            return(true);
            //#endif
        }
Example #6
0
        private void VS_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == (VS.Columns["PartNumber"].Index))
            {
                if (VS[e.ColumnIndex, e.RowIndex].Value.ToString() != "")
                {
                    using (var _rs = new StaticRS(string.Format("Select Descripcion,Destination=isnull((select top 1 s.planta+' ('+s.Descripcion2+') '+s.Descripcion1 from servicios_destinos s inner join referencias_destinos rd on rd.servicio=s.servicio and rd.ruta=s.ruta where rd.servicio=r.servicio and rd.partnumber=r.partnumber order by s.planta),'') from Referencias r where partnumber='{0}' and Servicio='{1}'", VS[e.ColumnIndex, e.RowIndex].Value, cboService.Value), Values.gDatos))
                    //select s.planta+' ('+s.Descripcion2+') '+s.Descripcion1 from servicios_destinos s inner join referencias_destinos r on r.servicio=s.servicio and r.ruta=s.ruta where s.servicio='{0}' and r.partnumber='{1}' order by s.planta
                    {
                        _rs.Open();
                        if (_rs.RecordCount == 0)
                        {
                            MsgError("Wrong partnumber");
                            VS[e.ColumnIndex, e.RowIndex].Value = "";
                        }
                        else
                        {
                            VS[VS.Columns["Description"].Index, e.RowIndex].Value = _rs["Descripcion"].ToString();
                            //VS.CurrentCell = VS[VS.Columns["Description"].Index, e.RowIndex];
                            VS[VS.Columns["Destination"].Index, e.RowIndex].Value = _rs["Destination"].ToString();;
                        }
                    }
                }

                if (VS[e.ColumnIndex, e.RowIndex].Value.ToString() == "")
                {
                    VS[VS.Columns["Description"].Index, e.RowIndex].Value = "";
                }
            }
        }
Example #7
0
        private void VSHUCab_Show(string HU = "")
        {
            //// Get the selected route in VS Grid
            //string _route = (VS.CurrentRow == null ? String.Empty : VS["ROUTE", VS.CurrentRow.Index].Value.ToString());

            string _dates = chkHUDisplayOld.Checked ? "" : "and xfec>dateadd(month,-1,getdate()) ";

            // Add the results of the query to the DataGrid
            using (var _rs = new StaticRS($"select HU,ROUTE,TYPE=HUTYPE,DEALER,DATE from HUCab where InDelivery is null and cod3='{Values.COD3}' and (Route='{cboRoute.Text}' or '{cboRoute.Text}'='') {_dates}order by HU,Route,Dealer", Values.gDatos))
            {
                _rs.Open();
                VSHUCab.DataSource = _rs.DataObject;
            }
            VSHUCab.CurrentCell = null;

            // Select the given HU in the grid
            try
            {
                if (HU != "" && VSHUCab.Rows.Count != 0)
                {
                    DataGridViewRow _row = VSHUCab.Rows.Cast <DataGridViewRow>().FirstOrDefault(r => r.Cells["HU"].Value.ToString().Equals(HU));
                    VSHUCab.CurrentCell = VSHUCab.Rows[_row.Index].Cells["HU"];
                }
            }
            catch { }
            VSHUCab.Refresh();
        }
Example #8
0
 private void CboService_SelectedValueChanged(object sender, EventArgs e)
 {
     if (cboService.Value.ToString() != "")
     {
         try
         {
             using (var _RS = new StaticRS(string.Format("Select Description from MasterRepairServices where ServiceCode='{0}' and Cod3='{1}'", cboService.Value, Values.COD3), Values.gDatos))
             {
                 _RS.Open();
                 if (_RS.RecordCount != 0)
                 {
                     //txtDescService.Text = _RS["Description"].ToString();
                 }
                 else
                 {
                     cboService.Value     = "";
                     txtDescService.Value = "";
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
             cboService.Value     = "";
             txtDescService.Value = "";
         }
     }
     else
     {
         txtDescService.Value = "";
     }
 }
Example #9
0
 private void VSHUDet_Show()
 {
     // Add the results of the query to the DataGrid
     using (var _rs = new StaticRS($"select HU,FINIS,QTY,[RECEIVAL CODE]=ReceivalCode,[RECEIVAL LINE]=ReceivalLine from HUDet where cod3='{Values.COD3}' and HU='{(VSHUCab.CurrentRow == null ? String.Empty : VSHUCab[0, VSHUCab.CurrentRow.Index].Value)}' order by Finis,Qty,ReceivalCode,ReceivalLine", Values.gDatos))
     {
         _rs.Open();
         VSHUDet.DataSource            = _rs.DataObject;
         VSHUDet.Columns["HU"].Visible = false;
     }
     VSHUDet.CurrentCell = null;
     VSHUDet.Refresh();
 }
Example #10
0
 private void LoadCalendar()
 {
     yearCalendar.RemoveAllBoldedDates();
     using (var dates = new StaticRS($"Select DIA from general..calendario_laboral where year(DIA)='{cboYear.Text}' and COD3='{cboCOD3.Text}'", conn))
     {
         dates.Open();
         dates.ToList().ForEach(r =>
         {
             DateTime elDia = (DateTime)r["DIA"];
             yearCalendar.AddBoldedDate(elDia);
         });
     };
 }
Example #11
0
        private void CTLM_AfterButtonClick(object sender, CTLMEventArgs e)
        {
            string          _COD3 = "";
            FileVersionInfo _localFileVersion;

            switch (CTLM.Status)
            {
            case EnumStatus.NAVIGATE:
            case EnumStatus.SEARCH:
            {
                if (isEspackIP(ref _COD3) && txtSystemCode.Text != "")
                {
                    using (var _RS = new StaticRS(string.Format("Select APPServer from sistemas..NetworkSedes where COD3='{0}'", _COD3), Values.gDatos))
                    {
                        _RS.Open();
                        if (!_RS.EOF)
                        {
                            string _pathToExe = string.Format(@"\\{0}\raiz\media\shares\APPS_CS\{1}\{2}", _RS["AppServer"].ToString(), txtSystemCode.Text.ToLower(), txtApp.Text.ToString().ToLower());
                            //_pathToExe = @"\\valsrv02\raiz\media\shares\APPS_CS\almacenaje\almacenaje.exe";
                            try
                            {
                                _localFileVersion  = FileVersionInfo.GetVersionInfo(_pathToExe);
                                txtNetVersion.Text = _localFileVersion.FileVersion.ToString();
                                if (txtNetVersion.Text != txtVersion.Text)
                                {
                                    txtNetVersion.BackColor = Color.LightSalmon;
                                }
                                else
                                {
                                    txtNetVersion.BackColor = txtVersion.BackColor;
                                }
                            }
                            catch (SecurityException se)
                            {
                                MessageBox.Show(se.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            catch
                            {
                                // MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                txtNetVersion.Text      = "";
                                txtNetVersion.BackColor = txtVersion.BackColor;
                            }
                        }
                    }
                }
            }
            break;
            }
        }
Example #12
0
 ////////// FUNCTIONS //////////
 private void VS_Show()
 {
     // Add the results of the query to the DataGrid
     using (var _rs = new StaticRS($"select ROUTE,FINIS,QTY,[PENDING QTY]=QtyPending,DEALER,[DESCRIPTION]=DealerDesc,[ORDER NUMBER]=OrderNumber,[ORDER LINE]=OrderItemNumber,[RECEIVAL CODE]=ReceivalCode,[RECEIVAL LINE]=Line from vPendingLines where cod3='{Values.COD3}' and (Route='{cboRoute.Text}' or '{cboRoute.Text}'='') order by Route,Dealer,OrderNumber,OrderItemNumber,Finis", Values.gDatos))
     {
         _rs.Open();
         VS.DataSource = _rs.DataObject;
     }
     VS.CurrentCell = null;
     VS.Refresh();
     if (VS.Rows.Count == 0)
     {
         VS.Tag = "";
     }
 }
Example #13
0
        // Timer for ROBOT stuff.
        private void tmrRobot_Tick(object sender, EventArgs e)
        {
            tmrRobot.Enabled = false;
            ROBOT_GetReceivalStatus(txtReceivalCode.Text);
            if (getROBOT_Status() == EnumROBOT_Status.OK)
            {
                using (var _rs = new StaticRS(string.Format("select PortDepartureDate from HSAReceivalsCab where RecCode='{0}'", txtReceivalCode.Value), Values.gDatos))
                {
                    _rs.Open();
                    if (_rs.RecordCount != 0)
                    {
                        txtPortDepartureDate.Text = _rs["PortDepartureDate"].ToString();
                    }
                }

                VS.UpdateEspackControl();
            }
        }
Example #14
0
        static void Main(string[] args)
        {
            string pe;
            string pa;

            pe = IntToLetters(128);

            pa = IntToLettersRec(128);

            using (var _conn = new cAccesoDatosNet("DB01", "SISTEMAS", "sa", "5380"))
            {
                using (var _rs = new StaticRS("select UserCode,Name,Surname1,Surname2,EmailAddress from Users", _conn))
                {
                    _rs.Open();
                    _rs.SaveExcelFile(@"D:\text.xlsx");
                }
            }
        }
Example #15
0
        // Getting the status of a receival.
        private void ROBOT_GetReceivalStatus(string receivalCode)
        {
            EnumROBOT_Status _status = EnumROBOT_Status.NONE;

            if (receivalCode != "")
            {
                using (var _rs = new StaticRS(string.Format("Select status=case when dbo.CheckFlag(flags,'PREC_OK')=1 then 'OK' when dbo.CheckFlag(flags,'PREC_INI')=1 then 'INI' when dbo.CheckFlag(flags,'PREC_RUN')=1 then 'RUN' when dbo.CheckFlag(flags,'PREC_ERR')=1 then 'ERR' else '' end from HSAReceivalsCab where RecCode='{0}'", receivalCode), Values.gDatos))
                {
                    _rs.Open();
                    if (_rs.RecordCount == 0)
                    {
                        CTWin.MsgError("Receival does not exist.");
                    }
                    else
                    {
                        switch (_rs["status"].ToString())
                        {
                        case "OK":
                            _status = EnumROBOT_Status.OK;
                            break;

                        case "RUN":
                            _status = EnumROBOT_Status.RUN;
                            break;

                        case "ERR":
                            _status = EnumROBOT_Status.ERR;
                            break;

                        case "INI":
                            _status = EnumROBOT_Status.INI;
                            break;

                        default:
                            _status = EnumROBOT_Status.NONE;
                            break;
                        }
                    }
                }
            }
            // Set the obtained status.
            setROBOT_Status(_status);
        }
Example #16
0
 private void btnClose_Click(object sender, EventArgs e)
 {
     if (txtDelivery.Text != "")
     {
         if (txtClosedDate.Text.Trim() != "")
         {
             CTWin.MsgError("The delivery is already closed.");
             return;
         }
         if (MessageBox.Show("This action can't be undone. Are you sure?", "Close Delivery", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             using (var _sp = new SP(Values.gDatos, "pDeliveryClose"))
             {
                 _sp.AddParameterValue("@DeliveryCode", txtDelivery.Value.ToString());
                 _sp.AddParameterValue("@cod3", Values.COD3);
                 try
                 {
                     _sp.Execute();
                 }
                 catch (Exception ex)
                 {
                     CTWin.MsgError(ex.Message);
                     return;
                 }
                 if (_sp.LastMsg.Substring(0, 2) != "OK")
                 {
                     CTWin.MsgError(_sp.LastMsg);
                     return;
                 }
             }
             using (var _rs = new StaticRS(string.Format("select ClosedDate from DeliveriesCab where DeliveryCode='{0}' and cod3='{1}'", txtDelivery.Text, Values.COD3), Values.gDatos))
             {
                 _rs.Open();
                 if (_rs.RecordCount != 0)
                 {
                     txtClosedDate.Text = _rs["ClosedDate"].ToString();
                 }
             }
             MessageBox.Show("Delivery closed correctly.", "Close Delivery", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }
Example #17
0
 private void CboService_SelectedValueChanged(object sender, EventArgs e)
 {
     if (cboService.Value.ToString() != "")
     {
         using (var _RS = new StaticRS(string.Format("Select flags from servicios where codigo='{0}' and dbo.checkflag(flags,'HSA')=1 and cod3='{1}'", cboService.Value, Values.COD3), Values.gDatos))
         {
             _RS.Open();
             if (_RS.RecordCount != 0)
             {
             }
             else
             {
                 cboService.Value     = "";
                 txtDescService.Value = "";
             }
         }
     }
     else
     {
         txtDescService.Value = "";
     }
 }
Example #18
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            using (var _rs = new StaticRS(string.Format("select dc.Route,ClosedDate=convert(varchar(10),dc.ClosedDate,103),dc.Plate,dc.CarrierDesc from DeliveriesCab dc inner join DeliveriesDet dd on dd.DeliveryCode=dc.DeliveryCode and dd.cod3=dc.cod3 where dc.DeliveryCode='{0}' and dc.cod3='{1}'", txtDelivery.Text, Values.COD3), Values.gDatos))
            {
                _rs.Open();
                if (_rs.RecordCount == 0)
                {
                    return;
                }

                // Refresh the form data from DB values
                cboRoute.Text              = _rs["Route"].ToString();
                txtClosedDate.Text         = _rs["ClosedDate"].ToString();
                txtPlate.Text              = _rs["Plate"].ToString();
                txtCarrierDescription.Text = _rs["CarrierDesc"].ToString();
            }

            SetFormEnabled(false);
            using (var pd = new PrintDialog())
            {
                if (pd.ShowDialog() == DialogResult.OK)
                {
                    using (var _printIt = new PrintDelivery())
                    {
                        // Copy values into the object properties & print
                        _printIt.DeliveryCode    = txtDelivery.Text;
                        _printIt.Route           = cboRoute.Text;
                        _printIt.ClosedDate      = txtClosedDate.Text.Substring(0, 10);
                        _printIt.Plate           = txtPlate.Text;
                        _printIt.CarrierDesc     = txtCarrierDescription.Text;
                        _printIt.PrinterSettings = pd.PrinterSettings;
                        pd.Document = _printIt;
                        _printIt.Print();
                    }
                }
            }
            SetFormEnabled(true);
        }
Example #19
0
 private void CboServicio_SelectedValueChanged(object sender, EventArgs e)
 {
     if (cboServicio.Value.ToString() != "")
     {
         using (var _RS = new StaticRS(string.Format("Select flags from servicios where codigo='{0}'", cboServicio.Value), Values.gDatos))
         {
             _RS.Open();
             if (_RS.RecordCount != 0)
             {
                 toolStrip.Enabled   = true;
                 ServiceFlags        = _RS["flags"].ToString().Split('|');
                 btnLabelCMs.Enabled = !ServiceFlags.Contains("AUTOCHECK");
                 btnACheck.Enabled   = ServiceFlags.Contains("AUTOCHECK");
                 ((EspackDataGridViewColumn)VS.Columns["PartNumber"]).AutoCompleteQuery = string.Format("select partnumber from referencias where servicio='{0}' order by partnumber", cboServicio.Value);
                 //((EspackDataGridViewColumn)VS.Columns["PartNumber"]).ReQuery();
             }
         }
     }
     else
     {
         toolStrip.Enabled = false;
     }
 }
Example #20
0
        private void CTLM_BeforeButtonClick(object sender, EspackFormControlsNS.CTLMEventArgs e)
        {
            //(new string[]{"btnOk" }).Contains(e.ButtonClick)

            switch (e.ButtonClick)
            {
            case "btnUpp":
            case "btnDel":
                if (getROBOT_Status() == EnumROBOT_Status.RUN || getROBOT_Status() == EnumROBOT_Status.INI)
                {
                    MessageBox.Show(string.Format("Action not allowed: ROBOT process is running."), "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    e.Cancel = true;
                    return;
                }
                break;

            case "btnOK":
                tmrRobot.Enabled = false;
                if (CTLM.Status == EnumStatus.EDIT || CTLM.Status == EnumStatus.ADDNEW)
                {
                    using (var _RS = new StaticRS(string.Format("Select 0 from servicios where codigo='{0}' and dbo.checkflag(flags,'HSA')=1 and cod3='{1}'", cboService.Value, Values.COD3), Values.gDatos))
                    {
                        _RS.Open();
                        if (_RS.RecordCount == 0)
                        {
                            MessageBox.Show(string.Format("Wrong service."), "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            e.Cancel = true;
                        }
                    }
                }
                break;

            default:
                tmrRobot.Enabled = false;
                break;
            }
        }
Example #21
0
        // Body
        public void Body()
        {
            // Loop through each row of the recordset
            using (var _rs = new StaticRS(string.Format("select dd.HU,dd.InContainer,hd.Finis,hd.qty from DeliveriesDet dd inner join HUDet hd on hd.HU=dd.HU and hd.cod3=dd.cod3 where dd.DeliveryCode='{0}' and dd.cod3='{1}' order by dd.InContainer,dd.HU,hd.finis", Program.fDeliveries.Delivery, Values.COD3), Values.gDatos))
            {
                _rs.Open();
                if (_rs.RecordCount != 0)
                {
                    // Set font & add column names
                    this.CurrentFont = new Font("Courier New", 12, FontStyle.Bold);
                    NewLine(true);
                    Add(string.Format(" {0,-12} {1,-10} {2,-7} {3,5} ", "HU", "CONTAINER", "FINIS", "QTY"));

                    // Set font & add data lines
                    this.CurrentFont = new Font("Courier New", 12, FontStyle.Regular);
                    while (!_rs.EOF)
                    {
                        NewLine(true);
                        Add(string.Format(" {0,-12} {1,-10} {2,-7} {3,5:G} ", _rs["HU"], _rs["INCONTAINER"], _rs["FINIS"], _rs["QTY"]));
                        _rs.MoveNext();
                    }
                }
            }
        }
Example #22
0
        public static void FillServers(string pCOD3)
        {
            using (var _RS = new StaticRS("select COD3,ServerDB,ServerShare,zone,UserShare,PasswordShare,servershareip,ServerDBIP from general..sedes", Values.gDatos))
            {
                _RS.Open();
                _RS.ToList().ForEach(r =>
                {
                    Values.DBServerList.Add(new cServer()
                    {
                        Resolve  = false,
                        HostName = r[pCOD3 == "OUT" ? "ServerDBIP" : "ServerDB"].ToString(),
                        IP       = IPAddress.Parse(r["ServerDBIP"].ToString()), COD3 = r["COD3"].ToString(),
                        Type     = ServerTypes.DATABASE,
                        User     = Values.User,
                        Password = Values.Password
                    });
                    Values.ShareServerList.Add(new cServer()
                    {
                        Resolve  = false,
                        HostName = r[pCOD3 == "OUT" ? "ServerShareIP" : "ServerShare"].ToString(),
                        IP       = IPAddress.Parse(r["ServerShareIP"].ToString()),
                        COD3     = r["COD3"].ToString(),
                        Type     = ServerTypes.DATABASE,
                        User     = r["UserShare"].ToString(),
                        Password = r["PasswordShare"].ToString()
                    });
                    if (r["COD3"].ToString() == pCOD3)
                    {
                        Values.COD3 = r["COD3"].ToString();
                        Values.DBServerList.Add(new cServer()
                        {
                            HostName = r["ServerDB"].ToString(), COD3 = "LOC", Type = ServerTypes.DATABASE, User = Values.User, Password = Values.Password
                        });
                        Values.DBServerList.Add(new cServer()
                        {
                            HostName = "DB01.local", COD3 = "OUT", Type = ServerTypes.DATABASE, User = Values.User, Password = Values.Password
                        });
                        Values.DBServerList.Add(new cServer()
                        {
                            HostName = "MASTERDB.local", COD3 = "GLO", Type = ServerTypes.DATABASE, User = Values.User, Password = Values.Password
                        });
                    }
                });

                /*
                 * while (!_RS.EOF)
                 * {
                 *  Values.DBServerList.Add(new cServer() { Resolve=false, HostName = _RS[pCOD3 == "OUT" ? "ServerDBIP" : "ServerDB"].ToString(),IP = IPAddress.Parse(_RS["ServerDBIP"].ToString()), COD3 = _RS["COD3"].ToString(), Type = ServerTypes.DATABASE, User = Values.User, Password = Values.Password });
                 *  Values.ShareServerList.Add(new cServer()
                 *  {
                 *      Resolve=false,
                 *      HostName = _RS[pCOD3 == "OUT"? "ServerShareIP":"ServerShare"].ToString(),
                 *      IP = IPAddress.Parse(_RS["ServerShareIP"].ToString()),
                 *      COD3 = _RS["COD3"].ToString(),
                 *      Type = ServerTypes.DATABASE,
                 *      User = _RS["UserShare"].ToString(),
                 *      Password = _RS["PasswordShare"].ToString()
                 *  });
                 *  if (_RS["COD3"].ToString() == pCOD3)
                 *  {
                 *      Values.COD3 = _RS["COD3"].ToString();
                 *      Values.DBServerList.Add(new cServer() { HostName = _RS["ServerDB"].ToString(), COD3 = "LOC", Type = ServerTypes.DATABASE, User = Values.User, Password = Values.Password });
                 *      Values.DBServerList.Add(new cServer() { HostName = "DB01.local", COD3 = "OUT", Type = ServerTypes.DATABASE, User = Values.User, Password = Values.Password });
                 *  }
                 *  _RS.MoveNext();
                 * }*/
            }
        }
Example #23
0
        // Print HU labels
        public void ZPLPrintLabels(DynamicRS rs, string labelType)
        {
            string _printerAddress = Values.LabelPrinterAddress.ToString();
            int    _printerResolution;
            string _zplTemplate = "", _zplCode = "";

            // Get settings for the printer
            using (var _RS = new StaticRS($"select ValueString,ValueInteger from MiscData where Code='{Values.LabelPrinterAddress}' and cod3='{Values.COD3}'", Values.gDatos))
            {
                _RS.Open();
                if (!_RS.EOF)
                {
                    _printerAddress    = _RS["ValueString"].ToString(); // "\\\\valsrv02\\VALLBLPRN003";
                    _printerResolution = Convert.ToInt32(_RS["ValueInteger"]);
                    if (_printerResolution != 203 && _printerResolution != 300)
                    {
                        MessageBox.Show($"Printer DPI not set in database.", "Print", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                else
                {
                    MessageBox.Show($"Printer {_printerAddress} not found.", "Print", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            // Get the ZPL template code
            using (var _RS = new StaticRS($"select ValueString from MiscData where Code='{labelType}_{_printerResolution}' and cod3='{Values.COD3}'", Values.gDatos))
            {
                _RS.Open();
                if (!_RS.EOF)
                {
                    _zplTemplate = _RS["ValueString"].ToString();
                }
            }
            if (_zplTemplate == "")
            {
                MessageBox.Show("ZLP template not found.", "Print HU", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            using (var _printer = new cRawPrinterHelper(_printerAddress))
            {
                while (!rs.EOF)
                {
                    // Get the Template code
                    _zplCode = _zplTemplate;

                    // Replace values
                    for (int i = 0; i < rs.FieldCount; i++)
                    {
                        _zplCode = _zplCode.Replace("<" + rs.Fields[i] + ">", rs[rs.Fields[i]].ToString());
                    }

                    // Print the label
                    _printer.SendUTF8StringToPrinter(_zplCode, 1);
                    rs.MoveNext();
                }
            }
        }
Example #24
0
            // Definition for the document. It will be called on any new page, so we just define the Header and the query for the Body once. The Footer is cleared and created on each call, as the
            // page number has to change.
            protected override void OnPrintPage(PrintPageEventArgs e)
            {
                Graphics _g = e.Graphics;

                // Page counter
                PageNumber++;

                // Just for the first time
                if (PageNumber == 1)
                {
                    // Define the Header
                    Header();

                    // Define the Body columns
                    NewLine(false, EnumDocumentParts.BODY);
                    Add($"{"LN",2} {"PARTNUMBER",-18} {"DESCRIPTION",-30} {"DESTINATION",-30} {"ORD.",5} {"SENT",5}", new Font("Courier New", 8, FontStyle.Bold));


                    // Change the font and run the query for the Body data
                    this.CurrentFont = new Font("Courier New", 8);
                    using (var _rs = new StaticRS(string.Format("Select Line,Partnumber,Description,Destination=isnull((select top 1 s.planta+' ('+s.Descripcion2+') '+s.Descripcion1 from servicios_destinos s inner join referencias_destinos rd on rd.servicio=s.servicio and rd.ruta=s.ruta where rd.servicio=v.service and rd.partnumber=v.partnumber order by s.planta),''),OrderedQty,SentQty from vSimpleDeliveriesDet v where DeliveryNumber='{0}' and Service='{1}'", DeliveryNumber, Service), Values.gDatos))
                    {
                        _rs.Open();

                        _dontPrintSignature = (_rs.RecordCount > 48);

                        if (_rs.RecordCount != 0)
                        {
                            // Loop through the recordset results
                            while (!_rs.EOF)
                            {
                                //for (int i = 1; i < 25; i++)
                                //{
                                NewLine(true);
                                Add(string.Format("{0,2} {1,-18} {2,-30} {3,-30} {4,5} {5,5}", _rs["Line"], _rs["Partnumber"], _rs["Description"].ToString().Length > 30 ? _rs["Description"].ToString().Substring(0, 30) : _rs["Description"], _rs["Destination"].ToString().Length > 30 ? _rs["Destination"].ToString().Substring(0, 30) : _rs["Destination"], _rs["OrderedQty"], _rs["SentQty"]));
                                //    Add(string.Format("{0,5} {1,-20} {2,-30} {3,7} {4,6}", i, _rs["Partnumber"], _rs["Description"].ToString().Length > 30 ? _rs["Description"].ToString().Substring(0, 30) : _rs["Description"], _rs["OrderedQty"], _rs["SentQty"]));
                                //}
                                _rs.MoveNext();
                            }
                            //NewLine(true);
                            //Add(string.Format("{0,5} {1,-20} {2,-30} {3,7} {4,6}", "xx", "Partnumber", "Description","OrderedQty", "SentQty"));
                        }
                        else
                        {
                            NewLine(true);
                            Add("--- NO DATA FOUND ---");
                        }
                    }
                }
                else
                {
                    _dontPrintSignature = !((BodyList.Lines.Count() - BodyList.LastPrintedLine - 50) < 1);
                }

                // Print the footer (changes on each new page)
                Footer();

                // Draw graphics
                _g.DrawRectangle(new Pen(Color.Black, 0.5F), 25F, 65F, 725F, 75F); // Header box
                _g.DrawImage(Resources.Logo_Espack_transparente, 27F, 67F, 140F, 55F);
                _g.DrawLine(new Pen(Color.Black, 0.5F), 50F, 1010F, 750F, 1010F);  // Footer separator

                // Signature boxes when last page is reached
                if (!_dontPrintSignature) //BodyList.LastPrintedLine+)
                {
                    _g.DrawRectangle(new Pen(Color.Black, 0.5F), 250F, 1020F, 235F, 100F);
                    _g.DrawRectangle(new Pen(Color.Black, 0.5F), 485F, 1020F, 235F, 100F);
                    _g.DrawString("Carrier Signature", new Font("Courier New", 6), new SolidBrush(Color.Black), new PointF(255F, 1022F));
                    _g.DrawString("Forklift Driver Signature", new Font("Courier New", 6), new SolidBrush(Color.Black), new PointF(490F, 1022F));
                }

                // Base object: it has to be the last to be called as it prints the results
                base.OnPrintPage(e);
            }
Example #25
0
        // Main
        public fMain(string[] args)
        {
            //MessageBox.Show("Pollo1", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            if (args.Contains("/ext=1"))
            {
                External = true;
            }
            noXML = args.Contains("/noxml=1");
//#if DEBUG
//            noXML = true;
//#endif
            try
            {
                InitializeComponent();
                txtUser.SetStatus(EnumStatus.EDIT);
                txtPassword.SetStatus(EnumStatus.EDIT);
                txtNewPassword.SetStatus(EnumStatus.EDIT);
                txtNewPasswordConfirm.SetStatus(EnumStatus.EDIT);
                txtNewPIN.SetStatus(EnumStatus.EDIT);
                txtNewPINConfirm.SetStatus(EnumStatus.EDIT);
                ServicePointManager.DnsRefreshTimeout = 0;
                this.Text = string.Format("LogOn Build {0} - ({1:yyyyMMdd})*", Assembly.GetExecutingAssembly().GetName().Version.ToString(), CT.GetBuildDateTime(Assembly.GetExecutingAssembly()));
                // Customize the textbox controls
                txtUser.Multiline               = false;
                txtPassword.Multiline           = false;
                txtNewPassword.Multiline        = false;
                txtNewPasswordConfirm.Multiline = false;
                txtNewPIN.Multiline             = false;
                txtNewPINConfirm.Multiline      = false;
                btnOk.Enabled = false;
                //timer control
                _time  = 0;
                _timer = new System.Timers.Timer()
                {
                    Interval = 1000, Enabled = false
                };
                _timer.Elapsed += _timer_Elapsed;

                // Add the toolbar and set the panels texts
                AddDefaultStatusStrip();

                LogOnChangeStatus(LogOnStatus.INIT);

#if DEBUG
                chkDebug.Checked = true;
                txtUser.Text     = "dvalles";
                txtPassword.Text = "*Kru0DMar*";
#endif
                //MessageBox.Show("Pollo2", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            } catch (Exception ex)
            {
                throw new Exception(string.Format("Error 1 {0}", ex.Message));
            }


            string _dbserver    = "";
            string _shareserver = "";
            string _cod3        = "";
            if (External)
            {
                CTWin.InputBox("", "Enter database server.", ref _dbserver);
            }
            else
            {
                try
                {
                    try
                    {
                        var _dnsDB = Dns.GetHostEntry("appdb.local");
                        _dbserver = _dnsDB.AddressList[0].ToString(); //.HostName;
                        var _dnsShare = Dns.GetHostEntry("appshare.local");
                        _shareserver = _dnsShare.AddressList[0].ToString();
                    }
                    catch
                    {
                        CTWin.InputBox("", "Enter database server.", ref _dbserver);
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(string.Format("Error 2 {0}", ex.Message));
                }
            }
            //MessageBox.Show("Pollo4", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            string[] FilesToUpdate = new string[] { };
            try
            {
                Values.gDatos.DataBase = "SISTEMAS";
                Values.gDatos.Server   = _dbserver;
                Values.gDatos.User     = "******";
                Values.gDatos.Password = "******";
#if DEBUG
                /*_dbserver = "db02.cr2.local";
                 * _shareserver = "net01.cr2.local";
                 * Values.gDatos.Server = _dbserver;
                 * Values.gDatos.User = "******";
                 * Values.gDatos.Password = "******";*/
#endif
                // Connect (or try)
                try
                {
                    //MessageBox.Show("Pollo4.1 "+ Values.gDatos.Server, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Values.gDatos.Connect();
                    Values.gDatos.Close();
                    //MessageBox.Show("Pollo4.2", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (Exception e)
                {
                    //MessageBox.Show("Pollo4.3"+e.Message+e.InnerException, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    throw new Exception("Error connecting database server: " + e.Message);
                }
                // tries to check if we are inside of Espack
                // only updates if in Espack

                _update = IsEspackIP(ref _cod3) && !External;
                if (!_update)
                {
                    MessageBox.Show("This location does not allow application updates.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    _cod3 = "OUT";
                }

                if (_update)
                {
                    FilesToUpdate = new string[] { "logonloader.exe", "logonloader.exe.config" }
                }
                ;

                Values.FillServers(_cod3);

                //this.Load += FMain_Load;
                //if we are out, we add the server we just entered
                if (_cod3 == "OUT")
                {
                    Values.DBServerList.Add(new cServer()
                    {
                        HostName = _dbserver, COD3 = "OUT", Type = ServerTypes.DATABASE, User = Values.User, Password = Values.Password
                    });
                }

                Panel1.Text = "You are connected to " + Values.gDatos.oServer.IP;//HostName.Replace(".local", "") + "!";
                Panel2.Text = "My IP: " + Values.gDatos.IP.ToString();
                Panel3.Text = "DB Server IP: " + Values.gDatos.Server;
                if (_update)
                {
                    Panel4.Text = "Share Server IP: " + Values.ShareServerList[Values.COD3].IP;
                }
                //MessageBox.Show("Pollo5", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                if (_update)
                {
                    FilesToUpdate = FilesToUpdate.Concat(System.IO.Directory.GetFiles("lib").Select(x => x.Replace("\\", "/")).Where(x => Path.GetExtension(x) == ".dll")).ToArray();
                }
                if (!Directory.Exists(Values.LOCAL_PATH + "/lib"))
                {
                    Directory.CreateDirectory(Values.LOCAL_PATH + "/lib");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Error 3 {0}", ex.Message));
            }
            try
            {
                // Check LogOnLoader update
                //#if !DEBUG
                if (_update)
                {
                    FilesToUpdate.ToList().ForEach(x =>
                    {
                        x = x.Replace("\\", "/");
                        if (File.Exists(Values.LOCAL_PATH + x))
                        {
                            if (!File.Exists(Values.LOCAL_PATH + "logon/" + x))
                            {
                                File.Delete(Values.LOCAL_PATH + x);
                            }
                            else if (File.GetLastWriteTime(Values.LOCAL_PATH + x) != File.GetLastWriteTime(Values.LOCAL_PATH + "logon/" + x))
                            {
                                File.Delete(Values.LOCAL_PATH + x);
                                File.Copy(Values.LOCAL_PATH + "logon/" + x, Values.LOCAL_PATH + x);
                            }
                        }
                        else
                        {
                            if (File.Exists(Values.LOCAL_PATH + "logon/" + x))
                            {
                                File.Copy(Values.LOCAL_PATH + "logon/" + x, Values.LOCAL_PATH + x);
                            }
                        }
                    });
                }



                // MessageBox.Show("Pollo6", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                //#endif

                KeyPress   += FMain_KeyPress;
                MouseClick += FMain_MouseClick;;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Pollo7: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw new Exception(string.Format("Error 3 {0}", ex.Message));
            }
            //check Autologon with windows credentials
            var _enviromentUser = Environment.UserName;
#if !DEBUG
            using (var _rs = new StaticRS(string.Format("Select flags,Password from vUsers where UserCode='{0}'", _enviromentUser), Values.gDatos))
            {
                Values.gDatos.context_info = MasterPassword.MasterBytes;
                _rs.Open();
                if (!_rs.EOF)
                {
                    var _flags = _rs["flags"].ToString().Split('|');
                    if (_flags.Contains("AUTOLOGON"))
                    {
                        this.Show();
                        this.txtUser.Text     = _enviromentUser;
                        this.txtPassword.Text = _rs["Password"].ToString();
                        btnOk_Click(null, null);
                    }
                }
            };
#endif
        }