示例#1
0
        public void setValues()
        {
            this.Visible = true;
            this.Show();
            this.BringToFront();
            _arts        = (List <Articulo>)FormArticulos.ListArt.GetArticulos();
            labProd.Text = _arts[FormArticulos.Index].producto;
            string tipo = _arts[FormArticulos.Index].tipo;

            JToken     json;
            bool       err    = false;
            clientREST client = new clientREST();

            comboProv.Items.Clear();

            client.endPoint = "http://system.maxpower-ar.com/prov/rub/" + tipo;

            client.httpMethod = httpVerb.GET;

            string resp = string.Empty;

            resp = client.makeRequest();
            if (resp == "0")
            {
                MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                err = true;
            }
            else if (resp == "15")
            {
                err = true;
                MessageBox.Show("No existen proveedores de dicho rubro, por favor ingrese un proveedor (Cod. 15)", "Maxpower System dice: ");
            }
            json = JToken.Parse(resp);

            if (json.Type != JTokenType.Array)
            {
                err = true;
            }
            else if (!err)
            {
                List <string> prods = new List <string>();
                foreach (var p in json)
                {
                    prods.Add((String)p["emp"]);
                }
                prods.Add("");
                object[] list = prods.ToArray <object>();
                comboProv.Items.AddRange(list);
            }
        }
示例#2
0
        private void ValLogin(object sender, EventArgs e)
        {
            bool   err = false;
            string usr = usrBox.Text;
            string pwd = pwdBox.Text;

            if ((!string.IsNullOrEmpty(usr) && !string.IsNullOrEmpty(pwd)) || usr == "Usuario" || pwdBox.PasswordChar != '\0')
            {
                clientREST client = new clientREST();
                client.endPoint   = "http://system.maxpower-ar.com/login?usr="******"&&pwd=" + pwd;
                client.httpMethod = httpVerb.GET;
                string resp = string.Empty;
                JToken json = "";
                resp = client.makeRequest();
                json = JToken.Parse(resp);
                if (resp == "0")
                {
                    err = true;
                    MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                }
                else if (resp == "false")
                {
                    err = true;
                    MessageBox.Show("Usuario o contraseña incorrecta", "Maxpower System dice: ");
                }
                else if (!(json.Count() == 1))
                {
                    err = true;
                }


                if (!err)
                {
                    Form1 f1 = new Form1();
                    this.Hide();
                    f1.IdUser   = (int)json[0]["id_empleado"];
                    f1.Admin    = (bool)json[0]["admin"];
                    f1.UserName = (String)json[0]["usuario"];
                    f1.ShowDialog();
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("Los campos deben estar completos para iniciar sesion", "Maxpower System dice: ");
            }
        }
示例#3
0
        public void ConfirmOrder(object sender, EventArgs e, string order, int db, string index)
        {
            if (MessageBox.Show("¿Desea confirmar la orden " + order + "?", "Maxpower System dice: ", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                int idx = int.Parse(index);

                clientREST client = new clientREST();

                client.endPoint = "http://system.maxpower-ar.com/confirm";

                client.httpMethod = httpVerb.POST;

                JObject sjson = new JObject();
                sjson["orden"] = order;
                sjson["db"]    = db;
                sjson["fecha"] = DateTime.Now.ToString("dd/MM/yyyy");

                client.postJSON = sjson.ToString();

                string resp = string.Empty;

                resp = client.makeRequest();

                if (resp == "0")
                {
                    MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                }
                else if (resp == "13")
                {
                    MessageBox.Show("Error al confirmar la orden (Cod. 13)", "Maxpower System dice: ");
                }
                else if (resp == "1")
                {
                    json.RemoveAt(idx - 1);
                    this.changeVal();
                }
            }
        }
        private void CompArticulosUC_Load(object sender, EventArgs e)
        {
            json = "";
            bool       err    = false;
            clientREST client = new clientREST();

            client.endPoint = "http://system.maxpower-ar.com/s/last/";

            client.httpMethod = httpVerb.GET;
            string resp = string.Empty;

            resp = client.makeRequest();
            if (resp == "0")
            {
                MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                err = true;
            }
            json = JToken.Parse(resp);



            if (!err)
            {
                cmbOrd.Items.Clear();

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

                foreach (var ord in json)
                {
                    orders.Add((String)ord["orden"]);
                }
                orders.Add("");
                object[] list = orders.ToArray <object>();
                cmbOrd.Items.AddRange(list);
                cmbOrd.SelectedIndex = cmbOrd.Items.Count - 1;
            }
        }
        private void CmbOrd_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r' || e.KeyChar == '\n')
            {
                string     ord = cmbOrd.Text;
                JToken     response;
                bool       err    = false;
                clientREST client = new clientREST();
                client.endPoint = "http://system.maxpower-ar.com/sol/" + ord;

                client.httpMethod = httpVerb.GET;

                string resp = string.Empty;

                resp = client.makeRequest();
                if (resp == "0")
                {
                    MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                    err = true;
                }
                else if (resp == "6")
                {
                    err = true;
                    MessageBox.Show("No existen los registros buscados (Cod. 6)", "Maxpower System dice: ");
                }
                else if (resp == "7")
                {
                    MessageBox.Show("No existen registros (Cod. 7)", "Maxpower System dice: ");
                    err = true;
                }
                if (!err)
                {
                    response = JToken.Parse(resp);
                    if ((String)response[0]["tipo"] != "Cot. Venta de productos")
                    {
                        MessageBox.Show("La orden buscada no corresponde (Cod. 15)", "Maxpower System dice:");
                        labEnt.Visible    = false;
                        resEnt.Visible    = false;
                        labDesc.Visible   = false;
                        resDesc.Visible   = false;
                        butAccept.Visible = false;
                    }
                    else
                    {
                        labEnt.Visible    = true;
                        resEnt.Visible    = true;
                        labDesc.Visible   = true;
                        resDesc.Visible   = true;
                        butAccept.Visible = true;
                        resEnt.Text       = (String)response[0]["cliente"];
                        resDesc.Text      = (String)response[0]["descr"];
                    }
                }
                else
                {
                    labEnt.Visible    = false;
                    resEnt.Visible    = false;
                    labDesc.Visible   = false;
                    resDesc.Visible   = false;
                    butAccept.Visible = false;
                }
            }
        }
示例#6
0
        public void init()
        {
            bool       err    = false;
            JToken     json   = "";
            clientREST client = new clientREST();

            client.endPoint = "http://system.maxpower-ar.com/notif";

            client.httpMethod = httpVerb.GET;

            string resp = string.Empty;

            resp = client.makeRequest();


            json = JToken.Parse(resp);
            if (json.Type == JTokenType.Array)
            {
                Controls.Remove(panel);
                panel.Location    = new System.Drawing.Point(100, 60);
                panel.Size        = new Size(800, 400);
                panel.MaximumSize = new Size(800, 400);
                panel.AutoScroll  = true;

                panel.ColumnCount = 4;
                panel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 10F));
                panel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 40F));
                panel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 30F));
                panel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F));

                panel.RowCount = json.Count() + 1;
                panel.RowStyles.Add(new RowStyle(SizeType.AutoSize));

                panel.Controls.Clear();

                Label cod = new Label();
                cod.Text      = "Código";
                cod.AutoSize  = true;
                cod.Font      = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                cod.TextAlign = ContentAlignment.TopCenter;

                Label descr = new Label();
                descr.Text      = "Descripción";
                descr.AutoSize  = true;
                descr.Font      = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                descr.TextAlign = ContentAlignment.TopCenter;

                Label tipo = new Label();
                tipo.Text      = "Tipo";
                tipo.AutoSize  = true;
                tipo.Font      = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                tipo.TextAlign = ContentAlignment.TopCenter;

                Label orden = new Label();
                orden.Text      = "Orden";
                orden.AutoSize  = true;
                orden.Font      = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                orden.TextAlign = ContentAlignment.TopCenter;

                panel.Controls.Add(cod, 0, 0);
                panel.Controls.Add(descr, 1, 0);
                panel.Controls.Add(tipo, 2, 0);
                panel.Controls.Add(orden, 3, 0);

                for (int i = 1; i < panel.RowCount; i++)
                {
                    int ncod = (int)json[i - 1]["cod"];

                    Label codText = new Label();
                    codText.Text     = ncod.ToString();
                    codText.AutoSize = false;
                    //codText.TextAlign = ContentAlignment.MiddleCenter;
                    panel.Controls.Add(codText, 0, i);


                    Label  descText = new Label();
                    string d        = string.Empty;
                    if (ncod == 0)
                    {
                        d = "Entrega tarde.";
                    }
                    else if (ncod == 1)
                    {
                        d = "Día de entrega.";
                    }
                    else if (ncod == 2)
                    {
                        d = "Día anterior a la entrega.";
                    }
                    else if (ncod == 3)
                    {
                        d = "El plazo máximo de entrega fue excedido pero la orden no fue confirmada.";
                    }
                    else if (ncod == 4)
                    {
                        d = "Falta una semana para la entrega.";
                    }
                    else if (ncod == 5)
                    {
                        d = "Faltan 5 días para la entrega.";
                    }

                    descText.Text      = d;
                    descText.AutoSize  = true;
                    descText.TextAlign = ContentAlignment.MiddleCenter;
                    panel.Controls.Add(descText, 1, i);

                    Label  tipoText = new Label();
                    string db       = string.Empty;
                    string idb      = (String)json[i - 1]["db"];
                    if (idb == "venta_prod")
                    {
                        db = "Cot. Venta de productos";
                    }
                    else if (idb == "rep_lab")
                    {
                        db = "Cot. Reparación de laboratorio";
                    }
                    else if (idb == "asis_tec")
                    {
                        db = "Cot. Asistencia técnica";
                    }
                    else if (idb == "ord_nac")
                    {
                        db = "Orden de compra nacional";
                    }
                    else if (idb == "ord_ext")
                    {
                        db = "Orden de compra exterior";
                    }

                    tipoText.Text     = db;
                    tipoText.AutoSize = true;
                    // tipoText.TextAlign = ContentAlignment.MiddleCenter;
                    panel.Controls.Add(tipoText, 2, i);


                    Label ordText = new Label();
                    ordText.Text     = (String)json[i - 1]["orden"];
                    ordText.AutoSize = true;
                    //ordText.TextAlign = ContentAlignment.MiddleCenter;
                    panel.Controls.Add(ordText, 3, i);
                }



                Controls.Add(panel);
            }
        }
示例#7
0
        private void ComboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            bool   err  = false;
            string ord  = ordBox.Text;
            string view = cmbDb2.Text;

            if (view == "Ordenes confirmadas")
            {
                dbOrdConf1.Hide();
                JToken json = "";
                if (!string.IsNullOrEmpty(ord))
                {
                    client.endPoint = "http://system.maxpower-ar.com/confirm/" + ord;

                    client.httpMethod = httpVerb.GET;

                    string resp = string.Empty;

                    resp = client.makeRequest();
                    if (resp == "0")
                    {
                        MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                        err = true;
                    }
                    else if (resp == "7")
                    {
                        err = true;
                        MessageBox.Show("No existen los registros buscados (Cod. 7)", "Maxpower System dice: ");
                    }

                    json = JToken.Parse(resp);
                    if (json.Type != JTokenType.Array)
                    {
                        err = true;
                    }
                }
                else
                {
                    client.endPoint = "http://system.maxpower-ar.com/confirm";

                    client.httpMethod = httpVerb.GET;

                    string resp = string.Empty;

                    resp = client.makeRequest();
                    if (resp == "0")
                    {
                        MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                        err = true;
                    }
                    else if (resp == "12")
                    {
                        err = true;
                        MessageBox.Show("No existen ordenes confirmadas (Cod. 12)", "Maxpower System dice: ");
                    }

                    json = JToken.Parse(resp);
                    if (json.Type != JTokenType.Array)
                    {
                        err = true;
                    }
                }

                if (!err)
                {
                    ordBox.Text     = string.Empty;
                    dbOrdConf1.db   = false;
                    dbOrdConf1.json = (JArray)json;
                    dbOrdConf1.changeVal();
                    dbOrdConf1.Show();
                    dbOrdConf1.BringToFront();
                }
            }
            else if (view == "Ordenes sin confirmar")
            {
                dbOrdConf1.Hide();
                JToken json = "";
                if (!string.IsNullOrEmpty(ord))
                {
                    client.endPoint = "http://system.maxpower-ar.com/nconfirm/" + ord;

                    client.httpMethod = httpVerb.GET;

                    string resp = string.Empty;

                    resp = client.makeRequest();
                    if (resp == "0")
                    {
                        MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                        err = true;
                    }
                    else if (resp == "7")
                    {
                        err = true;
                        MessageBox.Show("No existen los registros buscados (Cod. 7)", "Maxpower System dice: ");
                    }

                    json = JToken.Parse(resp);
                    if (json.Type != JTokenType.Array)
                    {
                        err = true;
                    }
                }
                else
                {
                    client.endPoint   = "http://system.maxpower-ar.com/nconfirm";
                    client.httpMethod = httpVerb.GET;

                    string resp = string.Empty;

                    resp = client.makeRequest();
                    if (resp == "0")
                    {
                        MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                        err = true;
                    }
                    else if (resp == "12")
                    {
                        err = true;
                        MessageBox.Show("Todas las ordenes están confirmadas (Cod. 11)", "Maxpower System dice: ");
                    }

                    json = JToken.Parse(resp);
                    if (json.Type != JTokenType.Array)
                    {
                        err = true;
                    }
                }

                if (!err)
                {
                    dbOrdConf1.db        = true;
                    ordBox.Text          = string.Empty;
                    cmbDb2.SelectedIndex = cmbDb2.Items.Count - 1;
                    dbOrdConf1.json      = (JArray)json;
                    dbOrdConf1.changeVal();
                    dbOrdConf1.Show();
                    dbOrdConf1.BringToFront();
                }
            }
            else
            {
                dbOrdConf1.Hide();
            }
            newSearch.Visible = false;

            cmbDb2.SelectedIndex = cmbDb2.Items.Count - 1;
        }
        private void Button1_MouseClick(object sender, MouseEventArgs e)
        {
            string prec        = boxPrec.Text;
            string cli         = boxCli.Text;
            string desc        = boxDesc.Text;
            string t_solicitud = tSolicitud.Text;

            if (string.IsNullOrEmpty(prec) || string.IsNullOrEmpty(cli) || string.IsNullOrEmpty(desc) || string.IsNullOrEmpty(t_solicitud))
            {
                MessageBox.Show("Debe completar todos los campos para poder guardar la solicitud.", "Maxpower System dice: ");
            }
            else
            {
                JToken     json   = "";
                bool       err    = false;
                clientREST client = new clientREST();

                client.endPoint = "http://system.maxpower-ar.com/emp/" + cli;

                client.httpMethod = httpVerb.GET;
                string resp = string.Empty;

                resp = client.makeRequest();
                if (resp == "0")
                {
                    MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                    err = true;
                }
                else if (resp == "9")
                {
                    MessageBox.Show("No existen los registros buscados (Cod. 9)", "Maxpower System dice: ");
                    err = true;
                }
                json = JToken.Parse(resp);

                if (!(json.Count() == 1))
                {
                    err = true;
                }


                if (!err)
                {
                    client.endPoint = "http://system.maxpower-ar.com/last";

                    client.httpMethod = httpVerb.GET;
                    resp = string.Empty;

                    resp = client.makeRequest();
                    if (resp == "0")
                    {
                        MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                        err = true;
                    }
                    json = JToken.Parse(resp);
                    if (json.Type != JTokenType.Array)
                    {
                        err = true;
                        MessageBox.Show("No se pudo conectar con el servidor (Cod. 3)", "Maxpower System dice: ");
                    }
                    if (!(json.Count() == 1))
                    {
                        err = true;
                    }
                }


                if (!err)
                {
                    JObject postJ = new JObject();
                    int     nof   = (int)json[0]["num"] + 1;
                    postJ["orden"]   = "MAX-" + nof + "-AR19-1";
                    postJ["proc"]    = prec;
                    postJ["cliente"] = cli;
                    postJ["descr"]   = desc;
                    postJ["t_sol"]   = t_solicitud;
                    postJ["fecha"]   = DateTime.Now.ToString("dd/MM/yyyy");

                    client.endPoint   = "http://system.maxpower-ar.com/sol";
                    client.httpMethod = httpVerb.POST;
                    client.postJSON   = postJ.ToString();
                    resp = string.Empty;
                    resp = client.makeRequest();

                    if (resp == "0")
                    {
                        MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                    }
                    else if (resp == "14")
                    {
                        MessageBox.Show("No se pudo ingresar la solicitud (Cod. 14)", "Maxpower System dice: ");
                    }
                    else if (resp == "1")
                    {
                        MessageBox.Show("La solicitud ha sido ingresada con éxito.", "Maxpower System dice: ");
                        boxDesc.Text = string.Empty;
                        boxCli.Text  = string.Empty;
                        boxPrec.Text = string.Empty;
                    }
                }
            }
        }
示例#9
0
        private void ComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            bool   err   = false;
            string query = string.Empty;
            string ord   = ordBox.Text;
            string ent   = entBox.Text;
            string cuit  = cuitBox.Text;

            string view = cmbDb.Text;

            if (!string.IsNullOrEmpty(cuit) && view != "Empresas")
            {
                MessageBox.Show("No se puede buscar por cuit en " + view, "Maxpower System dice: ");
                return;
            }
            else if (!string.IsNullOrEmpty(ord) && view == "Empresas")
            {
                MessageBox.Show("No se puede buscar por orden en " + view, "Maxpower System dice: ");
                return;
            }



            if (view == "Orden de compra exterior")
            {
                JToken json = "";
                if (string.IsNullOrEmpty(ord) && string.IsNullOrEmpty(ent))
                {
                    client.endPoint = "http://system.maxpower-ar.com/ord_ext";

                    client.httpMethod = httpVerb.GET;

                    string resp = string.Empty;

                    resp = client.makeRequest();
                    if (resp == "0")
                    {
                        MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                        err = true;
                    }
                    else if (resp == "6")
                    {
                        err = true;
                        MessageBox.Show("No existen los registros buscados (Cod. 6)", "Maxpower System dice: ");
                    }
                    else if (resp == "9")
                    {
                        err = true;
                        MessageBox.Show("No existen registros (Cod. 9)", "Maxpower System dice: ");
                    }
                    json = JToken.Parse(resp);
                    if (json.Type != JTokenType.Array)
                    {
                        err = true;
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(ord))
                    {
                        client.endPoint = "http://system.maxpower-ar.com/ord_ext/" + ord;

                        client.httpMethod = httpVerb.GET;

                        string resp = string.Empty;

                        resp = client.makeRequest();
                        if (resp == "0")
                        {
                            MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                            err = true;
                        }
                        else if (resp == "6")
                        {
                            err = true;
                            MessageBox.Show("No existen los registros buscados (Cod. 6)", "Maxpower System dice: ");
                        }
                        else if (resp == "7")
                        {
                            MessageBox.Show("No existen registros (Cod. 7)", "Maxpower System dice: ");
                            err = true;
                        }

                        json = JToken.Parse(resp);
                        if (json.Type != JTokenType.Array)
                        {
                            err = true;
                        }
                    }
                    else if (!string.IsNullOrEmpty(ent))
                    {
                        client.endPoint = "http://system.maxpower-ar.com/ord_ext/emp/" + ent;

                        client.httpMethod = httpVerb.GET;

                        string resp = string.Empty;

                        resp = client.makeRequest();
                        if (resp == "0")
                        {
                            MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                            err = true;
                        }
                        else if (resp == "6")
                        {
                            MessageBox.Show("No existen los registros buscados (Cod. 6)", "Maxpower System dice: ");
                            err = true;
                        }
                        else if (resp == "8")
                        {
                            MessageBox.Show("No existen registros (Cod. 8)", "Maxpower System dice: ");
                            err = true;
                        }

                        json = JToken.Parse(resp);
                        if (json.Type != JTokenType.Array)
                        {
                            err = true;
                        }
                    }

                    entBox.Text = string.Empty;
                    ordBox.Text = string.Empty;
                }

                dbVentProd1.Hide();
                dbTecAsist1.Hide();
                dbEnterprise1.Hide();
                dbOrdExt1.Hide();
                dbSolicitudesUC1.Hide();

                if (!err)
                {
                    dbOrdExt1.json = json;

                    if (json.Count() == 1)
                    {
                        leftBut.Visible  = false;
                        leftLab.Visible  = false;
                        rightBut.Visible = false;
                        rightLab.Visible = false;
                        dbOrdExt1.Index  = 0;
                        dbOrdExt1.changeVal(view);
                    }
                    else
                    {
                        dbOrdExt1.Index  = 0;
                        leftBut.Visible  = true;
                        leftLab.Text     = (dbOrdExt1.Index + 1).ToString();
                        leftLab.Visible  = true;
                        rightBut.Visible = true;
                        rightLab.Text    = json.Count().ToString();
                        rightLab.Visible = true;
                        dbOrdExt1.changeVal(view);
                    }
                    dbOrdExt1.chInco("Incoterm:");
                    dbOrdExt1.Show();
                    dbOrdExt1.BringToFront();
                }
            }
            else if (view == "Orden de compra nacional")
            {
                JToken json = "";

                if (string.IsNullOrEmpty(ord) && string.IsNullOrEmpty(ent))
                {
                    client.endPoint = "http://system.maxpower-ar.com/ord_nac";

                    client.httpMethod = httpVerb.GET;

                    string resp = string.Empty;

                    resp = client.makeRequest();
                    if (resp == "0")
                    {
                        MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                        err = true;
                    }
                    else if (resp == "6")
                    {
                        err = true;
                        MessageBox.Show("No existen los registros buscados (Cod. 6)", "Maxpower System dice: ");
                    }
                    else if (resp == "9")
                    {
                        err = true;
                        MessageBox.Show("No existen registros (Cod. 9)", "Maxpower System dice: ");
                    }
                    json = JToken.Parse(resp);
                    if (json.Type != JTokenType.Array)
                    {
                        err = true;
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(ord))
                    {
                        client.endPoint = "http://system.maxpower-ar.com/ord_nac/" + ord;

                        client.httpMethod = httpVerb.GET;

                        string resp = string.Empty;

                        resp = client.makeRequest();
                        if (resp == "0")
                        {
                            MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                            err = true;
                        }
                        else if (resp == "6")
                        {
                            err = true;
                            MessageBox.Show("No existen los registros buscados (Cod. 6)", "Maxpower System dice: ");
                        }
                        else if (resp == "7")
                        {
                            MessageBox.Show("No existen registros (Cod. 7)", "Maxpower System dice: ");
                            err = true;
                        }

                        json = JToken.Parse(resp);
                        if (json.Type != JTokenType.Array)
                        {
                            err = true;
                        }
                    }
                    else if (!string.IsNullOrEmpty(ent))
                    {
                        client.endPoint = "http://system.maxpower-ar.com/ord_nac/emp/" + ent;

                        client.httpMethod = httpVerb.GET;

                        string resp = string.Empty;

                        resp = client.makeRequest();
                        if (resp == "0")
                        {
                            MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                            err = true;
                        }
                        else if (resp == "6")
                        {
                            MessageBox.Show("No existen los registros buscados (Cod. 6)", "Maxpower System dice: ");
                            err = true;
                        }
                        else if (resp == "8")
                        {
                            MessageBox.Show("No existen registros (Cod. 8)", "Maxpower System dice: ");
                            err = true;
                        }

                        json = JToken.Parse(resp);
                        if (json.Type != JTokenType.Array)
                        {
                            err = true;
                        }
                    }

                    entBox.Text = string.Empty;
                    ordBox.Text = string.Empty;
                }
                dbVentProd1.Hide();
                dbTecAsist1.Hide();
                dbEnterprise1.Hide();
                dbOrdExt1.Hide();
                dbSolicitudesUC1.Hide();

                if (!err)
                {
                    dbOrdExt1.json = json;

                    if (json.Count() == 1)
                    {
                        leftBut.Visible  = false;
                        leftLab.Visible  = false;
                        rightBut.Visible = false;
                        rightLab.Visible = false;
                        dbOrdExt1.Index  = 0;
                        dbOrdExt1.changeVal(view);
                    }
                    else
                    {
                        dbOrdExt1.Index  = 0;
                        leftBut.Visible  = true;
                        leftLab.Text     = (dbOrdExt1.Index + 1).ToString();
                        leftLab.Visible  = true;
                        rightBut.Visible = true;
                        rightLab.Text    = json.Count().ToString();
                        rightLab.Visible = true;
                        dbOrdExt1.changeVal(view);
                    }
                    dbOrdExt1.chInco("Forma de pago:");
                    dbOrdExt1.Show();
                    dbOrdExt1.BringToFront();
                }
            }
            else if (view == "Cot. Reparación de laboratorio")
            {
                JToken json = "";

                if (string.IsNullOrEmpty(ord) && string.IsNullOrEmpty(ent))
                {
                    client.endPoint = "http://system.maxpower-ar.com/rep_lab";

                    client.httpMethod = httpVerb.GET;

                    string resp = string.Empty;

                    resp = client.makeRequest();
                    if (resp == "0")
                    {
                        MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                        err = true;
                    }
                    else if (resp == "6")
                    {
                        err = true;
                        MessageBox.Show("No existen los registros buscados (Cod. 6)", "Maxpower System dice: ");
                    }
                    else if (resp == "9")
                    {
                        err = true;
                        MessageBox.Show("No existen registros (Cod. 9)", "Maxpower System dice: ");
                    }
                    json = JToken.Parse(resp);
                    if (json.Type != JTokenType.Array)
                    {
                        err = true;
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(ord))
                    {
                        client.endPoint = "http://system.maxpower-ar.com/rep_lab/" + ord;

                        client.httpMethod = httpVerb.GET;

                        string resp = string.Empty;

                        resp = client.makeRequest();
                        if (resp == "0")
                        {
                            MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                            err = true;
                        }
                        else if (resp == "6")
                        {
                            err = true;
                            MessageBox.Show("No existen los registros buscados (Cod. 6)", "Maxpower System dice: ");
                        }
                        else if (resp == "7")
                        {
                            MessageBox.Show("No existen registros (Cod. 7)", "Maxpower System dice: ");
                            err = true;
                        }

                        json = JToken.Parse(resp);
                        if (json.Type != JTokenType.Array)
                        {
                            err = true;
                        }
                    }
                    else if (!string.IsNullOrEmpty(ent))
                    {
                        client.endPoint = "http://system.maxpower-ar.com/rep_lab/emp/" + ent;

                        client.httpMethod = httpVerb.GET;

                        string resp = string.Empty;

                        resp = client.makeRequest();
                        if (resp == "0")
                        {
                            MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                            err = true;
                        }
                        else if (resp == "6")
                        {
                            MessageBox.Show("No existen los registros buscados (Cod. 6)", "Maxpower System dice: ");
                            err = true;
                        }
                        else if (resp == "8")
                        {
                            MessageBox.Show("No existen registros (Cod. 8)", "Maxpower System dice: ");
                            err = true;
                        }

                        json = JToken.Parse(resp);
                        if (json.Type != JTokenType.Array)
                        {
                            err = true;
                        }
                    }

                    entBox.Text = string.Empty;
                    ordBox.Text = string.Empty;
                }


                dbOrdExt1.Hide();
                dbTecAsist1.Hide();
                dbEnterprise1.Hide();
                dbVentProd1.Hide();
                dbSolicitudesUC1.Hide();

                if (!err)
                {
                    dbVentProd1.json  = json;
                    dbVentProd1.Index = 0;

                    if (json.Count() == 1)
                    {
                        leftBut.Visible  = false;
                        leftLab.Visible  = false;
                        rightBut.Visible = false;
                        rightLab.Visible = false;
                    }
                    else
                    {
                        leftBut.Visible  = true;
                        leftLab.Visible  = true;
                        rightBut.Visible = true;
                        rightLab.Visible = true;
                        rightLab.Text    = json.Count().ToString();
                        leftLab.Text     = 1.ToString();
                    }
                }

                dbVentProd1.changeVal(view);
                dbVentProd1.Show();
                dbVentProd1.BringToFront();
            }
            else if (view == "Cot. Venta de productos")
            {
                JToken json = "";

                if (string.IsNullOrEmpty(ord) && string.IsNullOrEmpty(ent))
                {
                    client.endPoint = "http://system.maxpower-ar.com/venta_prod";

                    client.httpMethod = httpVerb.GET;

                    string resp = string.Empty;

                    resp = client.makeRequest();
                    if (resp == "0")
                    {
                        MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                        err = true;
                    }
                    else if (resp == "6")
                    {
                        err = true;
                        MessageBox.Show("No existen los registros buscados (Cod. 6)", "Maxpower System dice: ");
                    }
                    else if (resp == "9")
                    {
                        err = true;
                        MessageBox.Show("No existen registros (Cod. 9)", "Maxpower System dice: ");
                    }
                    json = JToken.Parse(resp);
                    if (json.Type != JTokenType.Array)
                    {
                        err = true;
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(ord))
                    {
                        client.endPoint = "http://system.maxpower-ar.com/venta_prod/" + ord;

                        client.httpMethod = httpVerb.GET;

                        string resp = string.Empty;

                        resp = client.makeRequest();
                        if (resp == "0")
                        {
                            MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                            err = true;
                        }
                        else if (resp == "6")
                        {
                            err = true;
                            MessageBox.Show("No existen los registros buscados (Cod. 6)", "Maxpower System dice: ");
                        }
                        else if (resp == "7")
                        {
                            MessageBox.Show("No existen registros (Cod. 7)", "Maxpower System dice: ");
                            err = true;
                        }

                        json = JToken.Parse(resp);
                        if (json.Type != JTokenType.Array)
                        {
                            err = true;
                        }
                    }
                    else if (!string.IsNullOrEmpty(ent))
                    {
                        client.endPoint = "http://system.maxpower-ar.com/venta_prod/emp/" + ent;

                        client.httpMethod = httpVerb.GET;

                        string resp = string.Empty;

                        resp = client.makeRequest();
                        if (resp == "0")
                        {
                            MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                            err = true;
                        }
                        else if (resp == "6")
                        {
                            MessageBox.Show("No existen los registros buscados (Cod. 6)", "Maxpower System dice: ");
                            err = true;
                        }
                        else if (resp == "8")
                        {
                            MessageBox.Show("No existen registros (Cod. 8)", "Maxpower System dice: ");
                            err = true;
                        }

                        json = JToken.Parse(resp);
                        if (json.Type != JTokenType.Array)
                        {
                            err = true;
                        }
                    }

                    entBox.Text = string.Empty;
                    ordBox.Text = string.Empty;
                }
                dbOrdExt1.Hide();
                dbTecAsist1.Hide();
                dbEnterprise1.Hide();
                dbVentProd1.Hide();
                dbSolicitudesUC1.Hide();

                if (!err)
                {
                    dbVentProd1.json  = json;
                    dbVentProd1.Index = 0;

                    if (json.Count() == 1)
                    {
                        leftBut.Visible  = false;
                        leftLab.Visible  = false;
                        rightBut.Visible = false;
                        rightLab.Visible = false;
                    }
                    else
                    {
                        leftBut.Visible  = true;
                        leftLab.Visible  = true;
                        rightBut.Visible = true;
                        rightLab.Visible = true;
                        rightLab.Text    = json.Count().ToString();
                        leftLab.Text     = 1.ToString();
                    }

                    dbVentProd1.changeVal(view);
                    dbVentProd1.Show();
                    dbVentProd1.BringToFront();
                }
            }
            else if (view == "Cot. Asistencia técnica")
            {
                JToken json = "";
                if (string.IsNullOrEmpty(ord) && string.IsNullOrEmpty(ent))
                {
                    client.endPoint = "http://system.maxpower-ar.com/asis_tec";

                    client.httpMethod = httpVerb.GET;

                    string resp = string.Empty;

                    resp = client.makeRequest();
                    if (resp == "0")
                    {
                        MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                        err = true;
                    }
                    else if (resp == "6")
                    {
                        err = true;
                        MessageBox.Show("No existen los registros buscados (Cod. 6)", "Maxpower System dice: ");
                    }
                    else if (resp == "9")
                    {
                        err = true;
                        MessageBox.Show("No existen registros (Cod. 9)", "Maxpower System dice: ");
                    }
                    json = JToken.Parse(resp);
                    if (json.Type != JTokenType.Array)
                    {
                        err = true;
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(ord))
                    {
                        client.endPoint = "http://system.maxpower-ar.com/asis_tec/" + ord;

                        client.httpMethod = httpVerb.GET;

                        string resp = string.Empty;

                        resp = client.makeRequest();
                        if (resp == "0")
                        {
                            MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                            err = true;
                        }
                        else if (resp == "6")
                        {
                            err = true;
                            MessageBox.Show("No existen los registros buscados (Cod. 6)", "Maxpower System dice: ");
                        }
                        else if (resp == "7")
                        {
                            MessageBox.Show("No existen registros (Cod. 7)", "Maxpower System dice: ");
                            err = true;
                        }

                        json = JToken.Parse(resp);
                        if (json.Type != JTokenType.Array)
                        {
                            err = true;
                        }
                    }
                    else if (!string.IsNullOrEmpty(ent))
                    {
                        client.endPoint = "http://system.maxpower-ar.com/asis_tec/emp/" + ent;

                        client.httpMethod = httpVerb.GET;

                        string resp = string.Empty;

                        resp = client.makeRequest();
                        if (resp == "0")
                        {
                            MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                            err = true;
                        }
                        else if (resp == "6")
                        {
                            MessageBox.Show("No existen los registros buscados (Cod. 6)", "Maxpower System dice: ");
                            err = true;
                        }
                        else if (resp == "8")
                        {
                            MessageBox.Show("No existen registros (Cod. 8)", "Maxpower System dice: ");
                            err = true;
                        }

                        json = JToken.Parse(resp);
                        if (json.Type != JTokenType.Array)
                        {
                            err = true;
                        }
                    }

                    entBox.Text = string.Empty;
                    ordBox.Text = string.Empty;
                }
                dbOrdExt1.Hide();
                dbSolicitudesUC1.Hide();
                dbVentProd1.Hide();
                dbEnterprise1.Hide();
                dbTecAsist1.Hide();
                if (!err)
                {
                    if (json.Count() == 1)
                    {
                        leftBut.Visible  = false;
                        leftLab.Visible  = false;
                        rightBut.Visible = false;
                        rightLab.Visible = false;
                    }
                    else
                    {
                        leftBut.Visible  = true;
                        leftLab.Text     = (dbTecAsist1.Index + 1).ToString();
                        leftLab.Visible  = true;
                        rightBut.Visible = true;
                        rightLab.Text    = json.Count().ToString();
                        rightLab.Visible = true;
                    }

                    dbTecAsist1.json  = json;
                    dbTecAsist1.Index = 0;
                    dbTecAsist1.changeVal();
                    dbTecAsist1.Show();
                    dbTecAsist1.BringToFront();
                }
            }
            else if (view == "Empresas")
            {
                JToken json = "";

                if (string.IsNullOrEmpty(ent) && string.IsNullOrEmpty(cuit))
                {
                    entBox.Text = string.Empty;

                    client.endPoint = "http://system.maxpower-ar.com/emp";

                    client.httpMethod = httpVerb.GET;

                    string resp = string.Empty;

                    resp = client.makeRequest();
                    if (resp == "0")
                    {
                        err = true;
                        MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                    }
                    else if (resp == "6")
                    {
                        MessageBox.Show("No existen los registros buscados (Cod. 6)", "Maxpower System dice: ");
                        err = true;
                    }
                    else if (resp == "9")
                    {
                        MessageBox.Show("No existen registros (Cod. 9)", "Maxpower System dice: ");
                        err = true;
                    }

                    json = JToken.Parse(resp);
                    if (json.Type != JTokenType.Array)
                    {
                        err = true;
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(cuit))
                    {
                        client.endPoint = "http://system.maxpower-ar.com/emp/" + cuit;

                        client.httpMethod = httpVerb.GET;

                        string resp = string.Empty;

                        resp = client.makeRequest();
                        if (resp == "0")
                        {
                            MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                            err = true;
                        }
                        else if (resp == "6")
                        {
                            MessageBox.Show("No existen los registros buscados (Cod. 6)", "Maxpower System dice: ");
                            err = true;
                        }
                        else if (resp == "9")
                        {
                            MessageBox.Show("No existen registros (Cod. 9)", "Maxpower System dice: ");
                            err = true;
                        }
                        json = JToken.Parse(resp);
                        if (json.Type != JTokenType.Array)
                        {
                            err = true;
                        }
                    }
                    else if (!string.IsNullOrEmpty(ent))
                    {
                        client.endPoint = "http://system.maxpower-ar.com/emp/" + ent;

                        client.httpMethod = httpVerb.GET;

                        string resp = string.Empty;

                        resp = client.makeRequest();
                        if (resp == "0")
                        {
                            MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                            err = true;
                        }
                        else if (resp == "6")
                        {
                            MessageBox.Show("No existen los registros buscados (Cod. 6)", "Maxpower System dice: ");
                            err = true;
                        }
                        else if (resp == "9")
                        {
                            err = true;
                            MessageBox.Show("No existen los registros buscados (Cod. 9)", "Maxpower System dice: ");
                        }
                        json = JToken.Parse(resp);
                        if (json.Type != JTokenType.Array)
                        {
                            err = true;
                        }
                    }
                    cuitBox.Text = string.Empty;
                    entBox.Text  = string.Empty;
                }

                dbOrdExt1.Hide();
                dbTecAsist1.Hide();
                dbEnterprise1.Hide();
                dbVentProd1.Hide();
                dbSolicitudesUC1.Hide();

                if (!err)
                {
                    dbEnterprise1.json  = json;
                    dbEnterprise1.Index = 0;

                    if (json.Count() == 1)
                    {
                        leftBut.Visible  = false;
                        leftLab.Visible  = false;
                        rightBut.Visible = false;
                        rightLab.Visible = false;
                    }
                    else
                    {
                        leftBut.Visible  = true;
                        leftLab.Visible  = true;
                        rightBut.Visible = true;
                        rightLab.Visible = true;
                        rightLab.Text    = json.Count().ToString();
                        leftLab.Text     = 1.ToString();
                    }
                    dbEnterprise1.changeVal();
                    dbEnterprise1.Show();
                    dbEnterprise1.BringToFront();
                }
            }
            else if (view == "Solicitudes")
            {
                JToken json = "";
                if (string.IsNullOrEmpty(ord) && string.IsNullOrEmpty(ent))
                {
                    client.endPoint = "http://system.maxpower-ar.com/sol";

                    client.httpMethod = httpVerb.GET;

                    string resp = string.Empty;

                    resp = client.makeRequest();
                    if (resp == "0")
                    {
                        MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                        err = true;
                    }
                    else if (resp == "6")
                    {
                        err = true;
                        MessageBox.Show("No existen los registros buscados (Cod. 6)", "Maxpower System dice: ");
                    }
                    else if (resp == "9")
                    {
                        err = true;
                        MessageBox.Show("No existen registros (Cod. 9)", "Maxpower System dice: ");
                    }
                    json = JToken.Parse(resp);
                    if (json.Type != JTokenType.Array)
                    {
                        err = true;
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(ord))
                    {
                        client.endPoint = "http://system.maxpower-ar.com/sol/" + ord;

                        client.httpMethod = httpVerb.GET;

                        string resp = string.Empty;

                        resp = client.makeRequest();
                        if (resp == "0")
                        {
                            MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                            err = true;
                        }
                        else if (resp == "6")
                        {
                            err = true;
                            MessageBox.Show("No existen los registros buscados (Cod. 6)", "Maxpower System dice: ");
                        }
                        else if (resp == "7")
                        {
                            MessageBox.Show("No existen registros (Cod. 7)", "Maxpower System dice: ");
                            err = true;
                        }

                        json = JToken.Parse(resp);
                        if (json.Type != JTokenType.Array)
                        {
                            err = true;
                        }
                    }
                    else if (!string.IsNullOrEmpty(ent))
                    {
                        client.endPoint = "http://system.maxpower-ar.com/sol/emp/" + ent;
                        Console.WriteLine("aa");
                        client.httpMethod = httpVerb.GET;

                        string resp = string.Empty;

                        resp = client.makeRequest();
                        if (resp == "0")
                        {
                            MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                            err = true;
                        }
                        else if (resp == "6")
                        {
                            MessageBox.Show("No existen los registros buscados (Cod. 6)", "Maxpower System dice: ");
                            err = true;
                        }
                        else if (resp == "8")
                        {
                            MessageBox.Show("No existen registros (Cod. 8)", "Maxpower System dice: ");
                            err = true;
                        }

                        json = JToken.Parse(resp);
                        if (json.Type != JTokenType.Array)
                        {
                            err = true;
                        }
                    }

                    entBox.Text = string.Empty;
                    ordBox.Text = string.Empty;
                }
                dbOrdExt1.Hide();
                dbSolicitudesUC1.Hide();
                dbVentProd1.Hide();
                dbEnterprise1.Hide();
                dbTecAsist1.Hide();

                if (!err)
                {
                    if (json.Count() == 1)
                    {
                        leftBut.Visible  = false;
                        leftLab.Visible  = false;
                        rightBut.Visible = false;
                        rightLab.Visible = false;
                    }
                    else
                    {
                        leftBut.Visible  = true;
                        leftLab.Text     = (dbSolicitudesUC1.Index + 1).ToString();
                        leftLab.Visible  = true;
                        rightBut.Visible = true;
                        rightLab.Text    = json.Count().ToString();
                        rightLab.Visible = true;
                    }

                    dbSolicitudesUC1.json  = json;
                    dbSolicitudesUC1.Index = 0;
                    dbSolicitudesUC1.changeVal();
                    dbSolicitudesUC1.Show();
                    dbSolicitudesUC1.BringToFront();
                }
            }
            else
            {
                dbEnterprise1.Hide();
                dbOrdExt1.Hide();
                dbVentProd1.Hide();
                dbTecAsist1.Hide();
            }
            newSearch.Visible  = true;
            countPanel.Visible = true;
        }
        private void insertData(object sender, EventArgs e)
        {
            if (titulo == "Clientes")
            {
                //tit
                string emp    = boxEmp.Text;
                string cuit   = boxCuit.Text;
                string dir    = boxDir.Text;
                string loc    = boxLoc.Text;
                string rub    = boxRub.Text;
                string esp    = boxEsp.Text;
                string web    = boxWeb.Text;
                string cont   = boxCont.Text;
                string tel    = boxTel.Text;
                string mail   = boxMail.Text;
                string contb  = boxContB.Text;
                string telb   = boxTelB.Text;
                string mailb  = boxMailB.Text;
                string telCom = boxTelCom.Text;

                if (string.IsNullOrEmpty(emp) || string.IsNullOrEmpty(cuit) || string.IsNullOrEmpty(dir) ||
                    string.IsNullOrEmpty(loc) || string.IsNullOrEmpty(rub) || string.IsNullOrEmpty(esp) ||
                    string.IsNullOrEmpty(web) || string.IsNullOrEmpty(cont) || string.IsNullOrEmpty(tel) ||
                    string.IsNullOrEmpty(mail) || string.IsNullOrEmpty(contb) || string.IsNullOrEmpty(telb) ||
                    string.IsNullOrEmpty(mailb) || string.IsNullOrEmpty(telCom))
                {
                    MessageBox.Show("Todos los campos deben estar completos");
                }
                else
                {
                    clientREST client = new clientREST();

                    JObject json = new JObject();

                    json["emp"]    = emp;
                    json["cuit"]   = cuit;
                    json["dir"]    = dir;
                    json["loc"]    = loc;
                    json["rub"]    = rub;
                    json["esp"]    = esp;
                    json["web"]    = web;
                    json["cont"]   = cont;
                    json["tel"]    = tel;
                    json["mail"]   = mail;
                    json["contb"]  = contb;
                    json["telb"]   = telb;
                    json["mailb"]  = mailb;
                    json["telcom"] = telCom;

                    client.endPoint = "http://system.maxpower-ar.com/emp";

                    client.httpMethod = httpVerb.POST;

                    client.postJSON = json.ToString();

                    string resp = string.Empty;

                    try
                    {
                        resp = client.makeRequest();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("No se pudo conectar con el servidor (Cod. 3)");
                    }


                    if (resp == "0")
                    {
                        MessageBox.Show("SQL ERROR (Cod. 0)");
                    }
                    else if (resp == "1")
                    {
                        MessageBox.Show("Operación finalizada con éxito");
                        boxEmp.Text    = string.Empty;
                        boxCuit.Text   = string.Empty;
                        boxDir.Text    = string.Empty;
                        boxLoc.Text    = string.Empty;
                        boxWeb.Text    = string.Empty;
                        boxTelCom.Text = string.Empty;
                        boxRub.Text    = string.Empty;
                        boxEsp.Text    = string.Empty;
                        boxCont.Text   = string.Empty;
                        boxContB.Text  = string.Empty;
                        boxTel.Text    = string.Empty;
                        boxTelB.Text   = string.Empty;
                        boxMail.Text   = string.Empty;
                        boxMailB.Text  = string.Empty;
                    }
                    else if (resp == "2")
                    {
                        MessageBox.Show("Ya existen registros de la empresa ingresada (Cod. 2)");
                    }
                }
            }
            else if (titulo == "Proveedores")
            {
                //prov
                string emp    = boxEmp.Text;
                string cuit   = boxCuit.Text;
                string dir    = boxDir.Text;
                string loc    = boxLoc.Text;
                string rub    = comboRub.Text;
                string web    = boxWeb.Text;
                string cont   = boxCont.Text;
                string tel    = boxTel.Text;
                string mail   = boxMail.Text;
                string contb  = boxContB.Text;
                string telb   = boxTelB.Text;
                string mailb  = boxMailB.Text;
                string telCom = boxTelCom.Text;

                if (string.IsNullOrEmpty(emp) || string.IsNullOrEmpty(cuit) || string.IsNullOrEmpty(dir) ||
                    string.IsNullOrEmpty(loc) || string.IsNullOrEmpty(rub) || string.IsNullOrEmpty(web) ||
                    string.IsNullOrEmpty(cont) || string.IsNullOrEmpty(tel) || string.IsNullOrEmpty(mail) ||
                    string.IsNullOrEmpty(contb) || string.IsNullOrEmpty(telb) || string.IsNullOrEmpty(mailb) ||
                    string.IsNullOrEmpty(telCom))
                {
                    MessageBox.Show("Todos los campos deben estar completos");
                }
                else
                {
                    clientREST client = new clientREST();

                    JObject json = new JObject();

                    json["emp"]    = emp;
                    json["cuit"]   = cuit;
                    json["dir"]    = dir;
                    json["loc"]    = loc;
                    json["rub"]    = rub;
                    json["web"]    = web;
                    json["cont"]   = cont;
                    json["tel"]    = tel;
                    json["mail"]   = mail;
                    json["contb"]  = contb;
                    json["telb"]   = telb;
                    json["mailb"]  = mailb;
                    json["telcom"] = telCom;

                    client.endPoint = "http://system.maxpower-ar.com/prov";

                    client.httpMethod = httpVerb.POST;

                    client.postJSON = json.ToString();

                    string resp = string.Empty;

                    try
                    {
                        resp = client.makeRequest();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("No se pudo conectar con el servidor (Cod. 3)");
                    }


                    if (resp == "0")
                    {
                        MessageBox.Show("SQL ERROR (Cod. 0)");
                    }
                    else if (resp == "1")
                    {
                        MessageBox.Show("Operación finalizada con éxito");
                        boxEmp.Text    = string.Empty;
                        boxCuit.Text   = string.Empty;
                        boxDir.Text    = string.Empty;
                        boxLoc.Text    = string.Empty;
                        boxWeb.Text    = string.Empty;
                        boxTelCom.Text = string.Empty;
                        boxRub.Text    = string.Empty;
                        boxEsp.Text    = string.Empty;
                        boxCont.Text   = string.Empty;
                        boxContB.Text  = string.Empty;
                        boxTel.Text    = string.Empty;
                        boxTelB.Text   = string.Empty;
                        boxMail.Text   = string.Empty;
                        boxMailB.Text  = string.Empty;
                    }
                    else if (resp == "2")
                    {
                        MessageBox.Show("Ya existen registros de la empresa ingresada (Cod. 2)");
                    }
                }
            }
        }
示例#11
0
        private void ButtonWordFile_Click(object sender, EventArgs e)
        {
            string detail = labPor.Text + " " + boxDays.Text + " " + labDay.Text + " " + boxHours.Text + " " + labAsist.Text + " " + labTec.Text + " " + labForAsist.Text + " " + boxDetalle.Text;
            Form1  F1     = new Form1();

            if (!string.IsNullOrEmpty(boxEnterprise.Text) &&
                !string.IsNullOrEmpty(boxAsist.Text) &&
                !string.IsNullOrEmpty(boxPrice.Text) &&
                !string.IsNullOrEmpty(boxForm.Text) &&
                !string.IsNullOrEmpty(boxDays.Text) &&
                !string.IsNullOrEmpty(boxHours.Text) &&
                !string.IsNullOrEmpty(boxDetalle.Text) &&
                !string.IsNullOrEmpty(combMon.Text))
            {
                JToken     json   = "";
                bool       err    = false;
                clientREST client = new clientREST();

                client.endPoint = "http://system.maxpower-ar.com/emp/" + boxEnterprise.Text;

                client.httpMethod = httpVerb.GET;


                string resp = string.Empty;

                try
                {
                    resp = client.makeRequest();
                    if (resp == "0")
                    {
                        err = true;
                        MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                    }
                    else if (resp == "6")
                    {
                        err = true;
                        MessageBox.Show("No existen los registros buscados (Cod. 6)", "Maxpower System dice: ");
                    }
                    json = JToken.Parse(resp);
                    if (json.Type != JTokenType.Array)
                    {
                        err = true;
                        MessageBox.Show("No se pudo conectar con el servidor (Cod. 3)", "Maxpower System dice: ");
                    }

                    if (!(json.Count() == 1))
                    {
                        err = true;
                    }
                }
                catch (WebException)
                {
                    err = true;
                    MessageBox.Show("No se pudo conectar con el servidor (Cod. 3)", "Maxpower System dice: ");
                }

                if (!err)
                {
                    List <Files> data = new List <Files>();
                    string       msg  = $"Contacto 1: {json[0]["cont"]}\n\nContacto 2: {json[0]["contb"]}\n\n\nPresione \"Si\" para el contacto 1, \"No\" para el contacto 2";
                    if (MessageBox.Show(msg, "Maxpower System dice: ", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        data.Add(new Files((string)json[0]["cont"], "<para>"));
                        data.Add(new Files((string)json[0]["mail"], "<email>"));
                    }
                    else
                    {
                        data.Add(new Files((string)json[0]["contb"], "<para>"));
                        data.Add(new Files((string)json[0]["mailb"], "<email>"));
                    }

                    data.Add(new Files(DateTime.Now.ToString("dd/MM/yyyy"), "<fecha>"));
                    data.Add(new Files((string)json[0]["telcom"], "<tel>"));
                    data.Add(new Files(boxEnterprise.Text, "<empresa>"));
                    data.Add(new Files(BoxRef.Text, "<ref>"));
                    data.Add(new Files(boxAsist.Text, "<asistencia>"));
                    data.Add(new Files(detail, "<detalle>"));
                    data.Add(new Files(boxPrice.Text, "<precio>"));
                    data.Add(new Files(boxForm.Text, "<formadepago>"));

                    client.endPoint = "http://system.maxpower-ar.com/last";

                    try
                    {
                        resp = client.makeRequest();

                        if (resp == "0")
                        {
                            MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                        }
                        else if (resp == "6")
                        {
                            MessageBox.Show("No existen los registros buscados (Cod. 6)", "Maxpower System dice: ");
                        }

                        json = JToken.Parse(resp);
                        if (json.Type != JTokenType.Array)
                        {
                            err = true;
                            MessageBox.Show("No se pudo conectar con el servidor (Cod. 3)", "Maxpower System dice: ");
                            Console.WriteLine(json["errorMessages"]);
                        }
                    }
                    catch (WebException)
                    {
                        MessageBox.Show("No se pudo conectar con el servidor (Cod. 3)", "Maxpower System dice: ");
                    }

                    if (!err)
                    {
                        int nof = (int)json[0]["num"] + 1;
                        data.Add(new Files("MAX-" + nof + "-AR19-1", "<noferta>"));
                        string filepath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\MaxPowerSystem\MaxPowerSystem\Asistencia Técnica\asist_tec.docx";
                        bool   done     = false;

                        try
                        {
                            done = F1.CreateWordDocument(@"C:\Program Files\Maxpower\Maxpower System\static\temp_asist_tec.docx", filepath, data);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Error al generar el archivo (Cod. 4)", "Maxpower System dice: ");
                        }


                        if (done)
                        {
                            boxEnterprise.Text = "";
                            boxAsist.Text      = "";
                            boxPrice.Text      = "";
                            boxForm.Text       = "";
                            boxDays.Text       = "";
                            boxHours.Text      = "";
                            boxDetalle.Text    = "";
                            boxDays.Text       = "";
                            boxHours.Text      = "";
                            combMon.Text       = "";
                            BoxRef.Text        = "";

                            JToken temp;
                            client.postJSON = string.Empty;
                            client.postJSON = "{";
                            char[] tr  = { '{', '}' };
                            string aux = string.Empty;
                            foreach (Files d in data)
                            {
                                aux += d.toSTR();
                            }
                            aux = aux.Remove(aux.Length - 1);

                            client.postJSON    += aux;
                            client.postJSON    += "}";
                            temp                = JToken.Parse(client.postJSON);
                            temp["mon"]         = combMon.Text;
                            temp["id_empleado"] = this.IdUser;
                            client.postJSON     = temp.ToString();

                            client.endPoint = "http://system.maxpower-ar.com/asis_tec";

                            client.httpMethod = httpVerb.POST;


                            resp = string.Empty;

                            try
                            {
                                resp = client.makeRequest();
                                if (resp == "0")
                                {
                                    MessageBox.Show("SQL ERROR (Cod. 0)", "Maxpower System dice: ");
                                }
                                else if (resp == "1")
                                {
                                    MessageBox.Show("Operación finalizada con éxito", "Maxpower System dice: ");
                                }
                                else if (resp == "2")
                                {
                                    MessageBox.Show("Ya existen registros de la empresa ingresada (Cod. 2)", "Maxpower System dice: ");
                                }
                                else
                                {
                                    MessageBox.Show("Error al enviar al servidor (Cod. 5)", "Maxpower System dice: ");
                                }
                            }
                            catch (WebException)
                            {
                                MessageBox.Show("No se pudo conectar con el servidor (Cod. 3)", "Maxpower System dice: ");
                            }
                            string f = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\MaxPowerSystem\MaxPowerSystem\Asistencia Técnica\MAX-" + nof + "-AR19-1.docx";
                            System.IO.File.Delete(f);
                            System.IO.File.Move(filepath, f);
                            data.Clear();
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Todo los campos deben estar completos", "Maxpower System dice: ");
            }
        }