예제 #1
0
 private void btnOk_Click(object sender, EventArgs e)
 {
     try
     {
         if (btnOk.Text.Equals("Guardar"))
         {
             connection.Ejecutar("LOG",
                                 "sp_ListaPrecios",
                                 new string[] { },
                                 new string[] { "@TipoConsulta", "@ItmsGrpCod", "@ItemCode", "@Canal", "@Currency", "@Aplicar", "@valorReferencia", "@Nivel", "@vol", "@CardCode" },
                                 ref valuesOut, 13, cbLinea.SelectedValue, txtArticulo.Text, cbCanal.SelectedValue, cbCurrency.Text, cbEvaluar.SelectedValue, txtValor.Text, cbNivel.Text, cbVolumen.Checked, txtCardCode.Text);
             //DataTable tbl =
             //  connection.GetDataTable("LOG",
             //                          "su_Almacen",
             //                          new string[] { },
             //                          new string[] { "@TipoConsulta", "@ItemCode" },
             //                          ref valuesOut, 22, itemcode);
         }
         else if (btnOk.Text.Equals("Actualizar"))
         {
             connection.Ejecutar("LOG",
                                 "sp_ListaPrecios",
                                 new string[] { },
                                 new string[] { "@TipoConsulta", "@ItmsGrpCod", "@ItemCode", "@Canal", "@Currency", "@Aplicar", "@valorReferencia", "@Nivel", "@vol", "@id", "@Activo", "@CardCode" },
                                 ref valuesOut, 16, cbLinea.SelectedValue, txtArticulo.Text, cbCanal.SelectedValue, cbCurrency.Text, cbEvaluar.SelectedValue, txtValor.Text, cbNivel.Text, cbVolumen.Checked, txtID.Text, txtActivo.Text, txtCardCode.Text);
         }
         this.OnLoad(e);
     }
     catch (Exception ex)
     {
         this.SetMensaje(ex.Message, 5000, Color.Red, Color.White);
     }
 }
예제 #2
0
 private void dgvDatos_ClickCellButton(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
 {
     if (dgvDatos.ActiveRow != null)
     {
         Object[] valuesOut = new Object[] { };
         connection.Ejecutar("LOG",
                             "sp_ListaPrecios",
                             new string[] { },
                             new string[] { "@TipoConsulta", "@ItemCode", "@FactorT", "@FactorM", "@FactorV", "@Volumen" },
                             ref valuesOut, 10, dgvDatos.ActiveRow.Cells["ItemCode"].Value, dgvDatos.ActiveRow.Cells["FFMT"].Value, dgvDatos.ActiveRow.Cells["FFMM"].Value, dgvDatos.ActiveRow.Cells["FFV"].Value, dgvDatos.ActiveRow.Cells["V"].Value);
     }
 }
예제 #3
0
        private void btnAddCliente_Click(object sender, EventArgs e)
        {
            try
            {
                int x = connection.Ejecutar("LOG",
                                            "up_Configuracion",
                                            new string[] { },
                                            new string[] { "@TipoConsulta", "@CardCode", "@WhsCode" },
                                            ref valuesOut, 1, txtCardCode.Text, cbWhsCode.SelectedValue);

                this.GetClientes();
                this.SetMensaje("Listo.", 5000, Color.Green, Color.Black);
            }
            catch (Exception ex)
            {
                this.SetMensaje(ex.Message, 5000, Color.Red, Color.White);
            }
        }
예제 #4
0
 private void dgvDatos_AfterRowUpdate(object sender, Infragistics.Win.UltraWinGrid.RowEventArgs e)
 {
     try
     {
         connection.Ejecutar("LOG",
                             "sp_Reportes",
                             new string[] { },
                             new string[] { "@TipoConsulta", "@Fecha", "@WhsCode", "@DocEntry", "@LineNum", "@tipoDoc" },
                             ref valuesOut, 17, dgvDatos.ActiveRow.Cells["Fecha de arribo"].Value, dgvDatos.ActiveRow.Cells["Lugar de arribo"].Value, dgvDatos.ActiveRow.Cells["DocEntry"].Value, dgvDatos.ActiveRow.Cells["LineNum"].Value, dgvDatos.ActiveRow.Cells["Tipo"].Value);
     }
     catch (Exception ex)
     {
     }
 }
예제 #5
0
        private void btnExaminar_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialof = new OpenFileDialog();

            System.IO.Stream myStream = null;
            if (dialof.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    if ((myStream = dialof.OpenFile()) != null)
                    {
                        using (System.IO.StreamReader cargar = new System.IO.StreamReader(dialof.FileName))
                        {
                            string renglon = string.Empty;
                            int    index   = 0;
                            while (!string.IsNullOrEmpty(renglon = cargar.ReadLine()))
                            {
                                if (index > 0)
                                {
                                    string[] data = renglon.Split('\t');

                                    Datos.Connection conn = new Datos.Connection();

                                    int x = conn.Ejecutar("LOG",
                                                          "su_Almacen",
                                                          new string[] { },
                                                          new string[] { "@TipoConsulta", "@ItemCode", "@AlternativeItem" },
                                                          ref valuesOut, 25, data[0], data[2]);

                                    //System.Threading.Thread.Sleep(60);
                                }
                                index++;
                            }
                        }
                        DataTable tbl = connection.GetDataTable("LOG",
                                                                "su_Almacen",
                                                                new string[] { },
                                                                new string[] { "@TipoConsulta" },
                                                                ref valuesOut, 26);
                        dgvDatos.DataSource = tbl;
                    }
                }
                catch (Exception ex)
                {
                    this.SetMensaje(ex.Message, 5000, Color.Red, Color.White);
                }
            }
        }
예제 #6
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         foreach (var item in dgvItem.DisplayLayout.Rows)
         {
             int x = connection.Ejecutar("SGUV",
                                         "PJ_IdealLinea",
                                         new string[] { },
                                         new string[] { "@TipoConsulta", "@Accion", "@Articulo", "@Comentario" },
                                         ref valuesOut, 6, item.Cells["Accion"].Value, item.Cells[(int)Columnas_Articulo.Articulo].Value, item.Cells["Comentarios"].Value);
         }
     }
     catch (Exception)
     {
     }
 }
예제 #7
0
 private void dataGridView1_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
 {
     try
     {
         if (e.Row.Index > -1)
         {
             if (MessageBox.Show("¿Esta seguro de elimiar este registro?", "HalcoNET", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
             {
                 connection.Ejecutar("LOG",
                                     "su_Almacen",
                                     new string[] { },
                                     new string[] { "@TipoConsulta", "@DocEntry" },
                                     ref valuesOut, 30, e.Row.Cells["Id"].Value);
             }
         }
     }
     catch (Exception)
     {
     }
 }
예제 #8
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                foreach (var item in dgvDatos.DisplayLayout.Rows)
                {
                    // if (item.Cells["Artículo"].Value.ToString().Equals("006"))
                    {
                        int x = connection.Ejecutar("SGUV",
                                                    "PJ_IdealLinea",
                                                    new string[] { },
                                                    new string[] { "@TipoConsulta", "@Accion", "@Articulo", "@Comentario" },
                                                    ref valuesOut, 6, item.Cells["Accion"].Value, item.Cells["Artículo"].Value, item.Cells["Comentarios"].Value);
                    }
                }

                this.SetMensaje("Listo", 5000, Color.Green, Color.Black);
            }
            catch (Exception)
            {
            }
        }
예제 #9
0
        private void btnCrear_Click(object sender, EventArgs e)
        {
            if (btnCrear.Text == "Crear")
            {
                #region Orden de compra

                if (string.IsNullOrEmpty(txtMoneda.Text))
                {
                    this.SetMensaje("Campo MONEDA obligatorio", 5000, Color.Red, Color.White);
                    return;
                }

                #region Crear
                try
                {
                    #region Encabezado
                    DocumentSAP          = new SDK_SAP.Clases.Document();
                    Cursor.Current       = Cursors.WaitCursor;
                    DocumentSAP.CardCode = txtCardCode.Text;
                    DocumentSAP.Series   = 15;
                    if (!String.IsNullOrWhiteSpace(txtFolio.Text))
                    {
                        DocumentSAP.DocNum = Convert.ToInt32(txtFolio.Text);
                    }
                    else
                    {
                        DocumentSAP.DocNum = 0;
                    }
                    DocumentSAP.DocRate     = (double)Rate;
                    DocumentSAP.DocDate     = dtpDocDate.Value;
                    DocumentSAP.DocDueDate  = dtpDocDueDate.Value;
                    DocumentSAP.DocType     = "dDocument_Items";
                    DocumentSAP.DocCurrency = txtMoneda.Text;

                    if (!string.IsNullOrEmpty(txtNumAtCard.Text))
                    {
                        DocumentSAP.NumAtCard = txtNumAtCard.Text;
                    }
                    if (!string.IsNullOrEmpty(txtComments.Text))
                    {
                        DocumentSAP.Comments = txtComments.Text;
                    }

                    DocumentSAP.DocTotal = Convert.ToDouble(txtTotal.Text);
                    DocumentSAP.VatSum   = Convert.ToDouble(txtIVA.Text);

                    #endregion
                    foreach (var item in dgvDatos.Rows)
                    {
                        #region Detalles
                        SDK_SAP.Clases.DocumentLines line = new SDK_SAP.Clases.DocumentLines();

                        line.ItemCode        = Convert.ToString(item.Cells["ItemCode"].Value);
                        line.ItemDescription = Convert.ToString(item.Cells["ItemName"].Value);
                        line.Quantity        = Convert.ToDouble(item.Cells["Quantity"].Value);
                        line.Currency        = Convert.ToString(item.Cells["Currency"].Value);
                        line.WarehouseCode   = Convert.ToString(item.Cells["WhsCode"].Value);

                        if (item.Cells["ShipDate"].Value != DBNull.Value)
                        {
                            line.ShipDate = Convert.ToDateTime(item.Cells["ShipDate"].Value);
                        }

                        line.U_Comentario = Convert.ToString(item.Cells["U_Comentario"].Value);
                        line.U_Vendedor   = Convert.ToString(item.Cells["U_Vendedor"].Value);

                        line.Price     = Convert.ToDouble(item.Cells["Price"].Value);
                        line.Rate      = Convert.ToDouble(item.Cells["Rate"].Value);
                        line.LineTotal = Convert.ToDouble(item.Cells["LineTotal"].Value);

                        if (item.Cells["OnHand"].Value != DBNull.Value)
                        {
                            line.OnHand = Convert.ToDouble(item.Cells["OnHand"].Value);
                        }
                        if (item.Cells["Ideal"].Value != DBNull.Value)
                        {
                            line.Ideal = Convert.ToDouble(item.Cells["Ideal"].Value);
                        }
                        if (item.Cells["VI"].Value != DBNull.Value)
                        {
                            line.VI = Convert.ToDouble(item.Cells["VI"].Value);
                        }
                        if (item.Cells["ABC"].Value != DBNull.Value)
                        {
                            line.ABC = Convert.ToString(item.Cells["ABC"].Value);
                        }

                        DocumentSAP.Lines.Add(line);
                        #endregion
                    }

                    if (!txtStatus.Text.Equals("Autorizado"))
                    {
                        #region Borrador
                        DocumentSAP.DocType = ObjType.ToString();
                        txtFolio.Text       = DocumentSAP.SaveDraft(DocumentSAP).ToString();

                        DocumentSAP   = DocumentSAP.Fill_OPOR(DocumentSAP.DocNum, ObjType, "Borrador");
                        txtFolio.Text = DocumentSAP.DocNum.ToString();

                        if (DocumentSAP.DocStatus.Equals("P"))
                        {
                            txtStatus.Text = "Pendiente";
                        }
                        else if (DocumentSAP.DocStatus.Equals("R"))
                        {
                            txtStatus.Text = "Rechazado";
                        }
                        else if (DocumentSAP.DocStatus.Equals("A"))
                        {
                            txtStatus.Text = "Autorizado";
                        }

                        typeDocument = "Borrador";

                        var kea = new KeyPressEventArgs(Convert.ToChar(13));
                        this.txtFolio_KeyPress(sender, kea);

                        this.SetMensaje("Listo", 5000, Color.Green, Color.Black);

                        #endregion
                    }

                    if (txtStatus.Text.Equals("Autorizado"))
                    {
                        SDK.SDKDatos.SDK_DI sdk = new SDKDatos.SDK_DI(1);//--Orden de compra  1
                        sdk.CrearOrdenCompra(this).ToString();
                        this.SetMensaje("Listo", 5000, Color.Green, Color.Black);

                        Object[]         valuesOut  = new Object[] { };
                        Datos.Connection connection = new Datos.Connection();

                        connection.Ejecutar("LOG",
                                            "sp_SDKDocumentosPrevios_test",
                                            new string[] { },
                                            new string[] { "@TipoConsulta", "@ObjType", "@DocNum", "@DocNumSAP" },
                                            ref valuesOut, 17, ObjType, DocumentSAP.DocNum, txtFolio.Text);

                        /*
                         #region SAP
                         * SDK_SAP.DI.Connection.InitializeConnection(9);
                         * SDK_SAP.DI.Connection.StartConnection();
                         * SDK_SAP.DI.Documents doc = new SDK_SAP.DI.Documents(9);
                         *
                         * txtFolio.Text = doc.AddDocument("ORDN", Document).ToString();
                         *
                         * var kea = new KeyPressEventArgs(Convert.ToChar(13));
                         * this.txtFolio_KeyPress(sender, kea);
                         *
                         * SDK_SAP.DI.Connection.CloseConnection();
                         * this.SetMensaje("Listo", 5000, Color.Green, Color.Black);
                         * DocumentMode = "Creado";
                         *
                         * Object[] valuesOut = new Object[] { };
                         * Datos.Connection connection = new Datos.Connection();
                         *
                         * connection.Ejecutar("LOG",
                         *                          "sp_SDKDocumentosPrevios",
                         *                          new string[] { },
                         *                          new string[] { "@TipoConsulta", "@ObjType", "@DocNum", "@DocNumSAP" },
                         *                          ref valuesOut, 17, ObjType, Document.DocNum, txtFolio.Text);
                         #endregion
                         */
                    }
                }
                catch (Exception ex)
                {
                    this.SetMensaje(ex.Message, 5000, Color.Red, Color.White);
                }
                finally
                {
                    Cursor.Current = Cursors.Arrow;
                }

                #endregion
                #endregion
            }
            if (btnCrear.Text == "Actualizar")
            {
                #region Modificar
                try
                {
                    Cursor.Current = Cursors.WaitCursor;

                    if (IdDocument == (int)SDK.Configuracion.SDK_Configuracion_Document.DocumentType.OrdenCompra)
                    {
                        SDK.SDKDatos.SDK_DI sdk = new SDKDatos.SDK_DI(1);//Orden de compra

                        sdk.ActualizarDocumento(this, DocumentSAP).ToString();
                        this.SetMensaje("OC Actualizada correctamente", 5000, Color.Green, Color.Black);
                    }
                }
                catch (Exception ex)
                {
                    this.SetMensaje(ex.Message, 5000, Color.Red, Color.White);
                }
                finally
                {
                    Cursor.Current = Cursors.Arrow;
                }
                #endregion
            }

            if (btnCrear.Text == "Autorizar")
            {
                #region Autorizar
                using (SqlConnection connection1 = new SqlConnection(Datos.Clases.Constantes.conectionLog))
                {
                    connection1.Open();
                    SqlCommand command = new SqlCommand();

                    command.CommandText = "sp_SDKDocumentosPrevios";
                    command.Connection  = connection1;
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@TipoConsulta", 16);
                    command.Parameters.AddWithValue("@DocNum", DocKey);
                    command.Parameters.AddWithValue("@Comments", txtComments.Text);
                    command.Parameters.AddWithValue("@WddCode", WddCode);
                    command.Parameters.AddWithValue("@userID", ClasesSGUV.Login.Id_Usuario);
                    try
                    {
                        command.ExecuteNonQuery();
                        connection1.Close();
                        MessageBox.Show("Listo", "HalcoNET", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        this.SetMensaje("Listo", 5000, Color.Green, Color.Black);

                        DocumentSAP   = DocumentSAP.Fill_OPOR(Convert.ToDecimal(txtFolio.Text), 22, "Borrador");
                        txtFolio.Text = DocumentSAP.DocNum.ToString();

                        if (DocumentSAP.DocStatus.Equals("P"))
                        {
                            txtStatus.Text = "Pendiente";
                        }
                        else if (DocumentSAP.DocStatus.Equals("R"))
                        {
                            txtStatus.Text = "Rechazado";
                        }
                        else if (DocumentSAP.DocStatus.Equals("A"))
                        {
                            txtStatus.Text = "Autorizado";
                        }

                        this.SetMensaje("Listo", 5000, Color.Green, Color.Black);

                        btnCrear.Enabled = false;
                    }
                    catch (Exception ex)
                    {
                        this.SetMensaje(ex.Message, 5000, Color.Red, Color.White);
                    }
                }
                #endregion
            }
        }
예제 #10
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                if (MessageBox.Show("Esta operacion puede tardar varios minutos, ¿Desea Continuar?", "HalcoNET", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)
                {
                    return;
                }

                //activar
                connection.Ejecutar("LOG",
                                    "su_Almacen",
                                    new string[] { },
                                    new string[] { "@TipoConsulta", "@frozenFor" },
                                    ref valuesOut, 27, "N");

                DataTable tbl_Datos = dgvDatos.DataSource as DataTable;

                var lista_Items = (from item in tbl_Datos.AsEnumerable()
                                   select item.Field <string>("ItemCode")).Distinct();

                SDK_SAP.DI.Connection.InitializeConnection(6);

                int Cont = 0;
                foreach (var item in lista_Items)
                {
                    Cont++;

                    this.SetMensaje("Procesando: " + Cont + " de " + lista_Items.Count() + " | " + item, 3000);

                    SDK_SAP.DI.AlternativeItems oItem = new SDK_SAP.DI.AlternativeItems();
                    try
                    {
                        oItem.DeleteAlternativeItems(item);
                    }
                    catch (Exception)
                    {
                    }

                    var qryAlt = (from row in tbl_Datos.AsEnumerable()
                                  where row.Field <string>("ItemCode").Equals(item)
                                  select new
                    {
                        AlternativeItem = row.Field <string>("AlternativeItem")
                    });

                    DataTable tblAlt = ClasesSGUV.ListConverter.ToDataTable(qryAlt);

                    oItem.AddAlternativeItems(item, tblAlt);
                }

                System.Threading.Thread.Sleep(3000);

                MessageBox.Show("Listo", "HalcoNET", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                this.SetMensaje(ex.Message, 5000, Color.Red, Color.White);

                DataTable tbl = connection.GetDataTable("LOG",
                                                        "su_Almacen",
                                                        new string[] { },
                                                        new string[] { "@TipoConsulta" },
                                                        ref valuesOut, 26);
                dgvDatos.DataSource = tbl;
            }
            finally
            {
                connection.Ejecutar("LOG",
                                    "su_Almacen",
                                    new string[] { },
                                    new string[] { "@TipoConsulta", "@frozenFor" },
                                    ref valuesOut, 28, "Y");

                //btnActualizar_Click(sender, e);
            }
        }