示例#1
0
        private void CargarDatosWS()
        {
            string str = "";

            try
            {
                this.cnn.Open();
                new SqlCeCommand("delete from CatMaterial", this.cnn).ExecuteNonQuery();
                ServicePointManager.Expect100Continue = false;
                WSPedidos wsPedidos  = new WSPedidos();
                DataTable dataTable1 = new DataTable();
                DataTable dataTable2;
                try
                {
                    dataTable2 = wsPedidos.GetParameter(this.cmbFiltro.Text, idhand).Tables[0];
                }
                catch (Exception)
                {
                    int num = (int)MessageBox.Show("No se puede conectar al servidor, favor de verificar su conexion");
                    return;
                }
                int MinValue = 0;
                int MaxValue = (int)dataTable2.Rows[0][1];
                str = string.Concat(new object[4]
                {
                    (object)str,
                    (object)"tengo parametros ",
                    (object)MaxValue,
                    (object)"\n"
                });
                this.BULK(wsPedidos.GetValues(MinValue, MaxValue).Tables[0]);
                int num1 = (int)MessageBox.Show("Termine con la carga");
            }
            catch (WebException ex)
            {
                int num = (int)MessageBox.Show(ex.Message);
            }
            catch (Exception ex)
            {
                int num = (int)MessageBox.Show(str + ex.Message);
            }
            finally
            {
                this.cnn.Close();
            }
        }
示例#2
0
        private void CargarDatosWS()
        {
            string str = "";

            try
            {
                if (this.cnn.State == ConnectionState.Closed)
                {
                    this.cnn.Open();
                }
                new SqlCeCommand("delete from CatMaterial where IdCon =" + this.idConexion.ToString(), this.cnn).ExecuteNonQuery();
                ServicePointManager.Expect100Continue = false;
                var       wsPedidos  = new WSPedidos();
                var       dataTable1 = new DataTable();
                DataTable dataTable2;
                try
                {
                    //dataTable2 = wsPedidos.GetParameter(this.cmbFiltro.Text, this.idConexion, this.IdHandHeld).Tables[0];
                    dataTable2 = wsPedidos.GetParameterNew(this.idConexion, this.IdHandHeld).Tables[0];
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Func: CargarDatosWS Proc: GetParameter \n Err:" + ex.Message);
                    //int num = (int)MessageBox.Show("No se puede conectar al servidor, favor de verificar su conexion");
                    return;
                }

                int MinValue = (int)dataTable2.Rows[0][0];
                int MaxValue = (int)dataTable2.Rows[0][1];
                MessageBox.Show(string.Format("El total de registros son: {0}", (MaxValue - MinValue)));
                if (MinValue == 0 | MaxValue == 0)
                {
                    if (this.cmbFiltro.Visible)
                    {
                        MessageBox.Show("No existen lotes con estos parametros: \n {0}", this.cmbFiltro.Text);
                    }
                    else
                    {
                        MessageBox.Show("No existen lotes en el servidor , favor de revisar con el Administrador de sistemas");
                    }

                    return;
                }
                var datos = new DataTable();
                str = string.Concat(str, "tengo parametros ", MaxValue - MinValue, "\n");
                try
                {
                    var Start = MinValue;
                    while (Start < MaxValue)
                    {
                        if (MaxValue - Start >= 3000)
                        {
                            datos = wsPedidos.GetValues(Start, Start + 3000, this.idConexion, this.IdHandHeld).Tables[0];
                        }
                        else
                        {
                            datos = wsPedidos.GetValues(Start, MaxValue, this.idConexion, this.IdHandHeld).Tables[0];
                        }

                        this.BULK(datos);
                        Start = Start + 3000;
                    }
                }
                catch (Exception ex)
                {
                    int num = (int)MessageBox.Show("Func: CargarDatosWS Proc:wsPedidos Web  \n Err:" + ex.Message);
                }
                int num1 = (int)MessageBox.Show("Termine con la carga");
            }
            catch (WebException ex)
            {
                int num = (int)MessageBox.Show("Func: CargarDatosWS Proc:BULK Web  \n Err:" + ex.Message);
            }
            catch (Exception ex)
            {
                int num = (int)MessageBox.Show("Func: CargarDatosWS Proc:BULK \n Err:" + str + ex.Message);
            }
            finally
            {
                this.cnn.Close();
            }
        }