示例#1
0
        private void btnCopiarDe_Click(object sender, EventArgs e)
        {
            if (DocumentMode.Equals("Registrar"))
            {
                SDK.Documentos.frmListadoDocumentos formulario =
                    new frmListadoDocumentos(-2, txtCardCode.Text,
                                             string.Empty, dtpDocDate.Value, string.Empty);

                if (formulario.ShowDialog() == System.Windows.Forms.DialogResult.Yes)
                {
                    DocumentMode = "Registrar";
                    this.Formulario_Modo();
                    foreach (var item in formulario.DocKey)
                    {
                        using (SqlConnection cnnection = new SqlConnection(Datos.Clases.Constantes.conectionLog))
                        {
                            SqlCommand cmd = new SqlCommand("sp_SDKDataSource", cnnection);
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Add(new SqlParameter("@TipoConsulta", 11));
                            cmd.Parameters.Add(new SqlParameter("@Key", item));

                            DataTable      line_tbl = new DataTable();
                            SqlDataAdapter da       = new SqlDataAdapter();
                            da.SelectCommand = cmd;
                            da.Fill(line_tbl);

                            config.FillDetails(line_tbl);
                        }
                    }
                }
                else
                {
                    return;
                }
            }
            else
            {
                this.SetMensaje("Proveedor no existe!!!", 5000, Color.Red, Color.White);
            }
        }
示例#2
0
        public void txtFolio_KeyPress(object sender, KeyPressEventArgs e)
        {
            try
            {
                switch (DocumentMode)
                {
                    #region Nuevo
                case "Nuevo":
                {
                    if ((int)e.KeyChar == (int)Keys.Enter)
                    {
                        if (string.IsNullOrEmpty(txtFolio.Text))
                        {
                            SDK.Documentos.frmListadoDocumentos formulario =
                                new frmListadoDocumentos(-1, txtCardCode.Text.Replace('*', '%'),
                                                         txtCardName.Text.Replace('*', '%'), dtpDocDate.Value, txtTC.Text.Replace('*', '%'));

                            if (formulario.ShowDialog() == System.Windows.Forms.DialogResult.Yes)
                            {
                                txtCardCode.Text = formulario.Row["CardCode"].ToString();
                                txtCardCode_Leave(sender, e);
                                cbMoneda_SelectionChangeCommitted(sender, e);
                            }
                            else
                            {
                                return;
                            }
                        }
                    }
                } break;
                    #endregion
                    #region Documento Encontrado

                    /*(dgvDatos.DataSource as DataTable).Rows.Clear();
                     *
                     * Document = new SDKDatos.SDK_OPOR();
                     * Document = Document.Fill(Convert.ToDecimal(txtFolio.Text));
                     *
                     *
                     *
                     #region LLenar Form
                     * this.CleanScreen();
                     * txtFolio.Text = Document.DocNum.ToString();
                     * txtCardCode.Text = Document.CardCode;
                     * txtCardName.Text = Document.CardName;
                     * txtMoneda.Text = Document.DocCur;
                     * cbMoneda.SelectedValue = Document.DocCur;
                     * txtNumAtCard.Text = Document.NumAtCard;
                     *
                     * cbMoneda.Enabled = false;
                     * if (Document.DocStatus == "C")
                     * {
                     *  txtStatus.Text = "Cerrado";
                     *  btnCrear.Enabled = false;
                     *  cerrarStripButton.Enabled = false;
                     *
                     *  cerrarLíneaToolStripMenuItem.Enabled = false;
                     *  agregarFilaToolStripMenuItem1.Enabled = false;
                     *  tooStripDuplicar.Enabled = false;
                     * }
                     * else if (Document.DocStatus == "O")
                     * {
                     *  txtStatus.Text = "Abierto";
                     *  btnCrear.Enabled = true;
                     *  cerrarStripButton.Enabled = true;
                     *  cerrarLíneaToolStripMenuItem.Enabled = true;
                     *  agregarFilaToolStripMenuItem1.Enabled = true;
                     *  tooStripDuplicar.Enabled = true;
                     * }
                     *
                     * dtpDocDate.Value = Document.DocDate;
                     * dtpDocDueDate.Value = Document.DocDueDate;
                     * txtComments.Text = Document.Comments;
                     * txtSubtotal.Text = (Document.DocTotal - Document.VatSum).ToString("N2");
                     * txtIVA.Text = Document.VatSum.ToString("N2");
                     * txtTotal.Text = Document.DocTotal.ToString("N2");
                     *
                     #region Detalle
                     * foreach (SDKDatos.SDK_POR1 item in Document.Lines)
                     * {
                     *  DataRow row = (dgvDatos.DataSource as DataTable).NewRow();
                     *  row["ItemCode"] = item.ItemCode;
                     *  row["ItemName"] = item.Dscription;
                     *  row["Quantity"] = item.Quantity;
                     *  row["OpenQty"] = item.OpenQty;
                     *  row["Price"] = item.Price;
                     *  row["Currency"] = item.Currency;
                     *  row["WhsCode"] = item.Whscode;
                     *  row["WhsName"] = item.Whscode + " | " + item.WhsName;
                     *  row["LineNum"] = item.LineNum;
                     *  row["Rate"] = item.Rate;
                     *  row["ShipDate"] = item.ShipDate;
                     *  row["LineTotal"] = item.LineTotal;
                     *  row["LineStatus"] = item.LineStatus;
                     *  row["U_Vendedor"] = item.U_Vendedor;
                     *  row["SlpCode"] = item.U_Vendedor;
                     *  row["U_Comentario"] = item.U_Comentario;
                     *  row["VolumenU"] = item.VolumenU;
                     *  row["PesoU"] = item.PesoU;
                     *
                     *  (dgvDatos.DataSource as DataTable).Rows.Add(row);
                     *
                     *  (dgvDatos.DataSource as DataTable).AcceptChanges();
                     * }
                     #endregion
                     #endregion*/
                    #endregion
                }
            }
            catch (Exception ex)
            {
                this.SetMensaje("Error al cargar OC: " + ex.Message, 5000, Color.Red, Color.White);
            }
        }
示例#3
0
        public void txtFolio_KeyPress(object sender, KeyPressEventArgs e)
        {
            try
            {
                if ((int)e.KeyChar == (int)Keys.Enter)
                {
                    if (string.IsNullOrEmpty(txtFolio.Text))
                    {
                        SDK.Documentos.frmListadoDocumentos formulario =
                            new frmListadoDocumentos(IdDocument, txtCardCode.Text.Replace('*', '%'),
                                                     txtCardName.Text.Replace('*', '%'), dtpDocDate.Value, txtNumAtCard.Text.Replace('*', '%'));

                        if (formulario.ShowDialog() == System.Windows.Forms.DialogResult.Yes)
                        {
                            txtFolio.Text = formulario.DocEntry.ToString();
                            typeDocument  = formulario.Tipo;
                        }
                        else
                        {
                            //this.CleanScreen();
                            return;
                        }
                    }

                    #region Documento Encontrado
                    (dgvDatos.DataSource as DataTable).Rows.Clear();

                    DocumentSAP = new SDK_SAP.Clases.Document();
                    DocumentSAP = DocumentSAP.Fill_OPOR(Convert.ToDecimal(txtFolio.Text), ObjType, typeDocument);

                    #region LLenar Form
                    this.CleanScreen();
                    txtFolio.Text          = DocumentSAP.DocNum.ToString();
                    txtCardCode.Text       = DocumentSAP.CardCode;
                    txtCardName.Text       = DocumentSAP.CardName;
                    txtMoneda.Text         = DocumentSAP.DocCurrency;
                    cbMoneda.SelectedValue = DocumentSAP.DocCurrency;
                    txtNumAtCard.Text      = DocumentSAP.NumAtCard;

                    cbMoneda.Enabled = false;
                    if (DocumentSAP.DocStatus == "C")
                    {
                        txtStatus.Text            = "Cerrado";
                        btnCrear.Enabled          = false;
                        cerrarStripButton.Enabled = false;

                        cerrarLíneaToolStripMenuItem.Enabled  = false;
                        agregarFilaToolStripMenuItem1.Enabled = false;
                        tooStripDuplicar.Enabled = false;
                    }
                    else if (DocumentSAP.DocStatus == "O")
                    {
                        txtStatus.Text                        = "Abierto";
                        btnCrear.Enabled                      = true;
                        cerrarStripButton.Enabled             = true;
                        cerrarLíneaToolStripMenuItem.Enabled  = true;
                        agregarFilaToolStripMenuItem1.Enabled = true;
                        tooStripDuplicar.Enabled              = true;
                    }
                    else if (DocumentSAP.DocStatus == "P")
                    {
                        txtStatus.Text                        = "Pendiente";
                        btnCrear.Text                         = "Autorizar";
                        btnCrear.Enabled                      = true;
                        cerrarStripButton.Enabled             = true;
                        cerrarLíneaToolStripMenuItem.Enabled  = true;
                        agregarFilaToolStripMenuItem1.Enabled = true;
                        tooStripDuplicar.Enabled              = true;
                    }
                    else if (DocumentSAP.DocStatus == "A")
                    {
                        txtStatus.Text                        = "Autorizado";
                        btnCrear.Text                         = "Crear";
                        btnCrear.Enabled                      = true;
                        cerrarStripButton.Enabled             = false;
                        cerrarLíneaToolStripMenuItem.Enabled  = false;
                        agregarFilaToolStripMenuItem1.Enabled = false;
                        tooStripDuplicar.Enabled              = false;
                    }
                    else if (DocumentSAP.DocStatus == "R")
                    {
                        txtStatus.Text                        = "Rechazado";
                        btnCrear.Text                         = "Crear";
                        btnCrear.Enabled                      = false;
                        cerrarStripButton.Enabled             = false;
                        cerrarLíneaToolStripMenuItem.Enabled  = false;
                        agregarFilaToolStripMenuItem1.Enabled = false;
                        tooStripDuplicar.Enabled              = false;
                    }


                    dtpDocDate.Value    = DocumentSAP.DocDate;
                    dtpDocDueDate.Value = DocumentSAP.DocDueDate;
                    txtComments.Text    = DocumentSAP.Comments;
                    txtSubtotal.Text    = (DocumentSAP.DocTotal - DocumentSAP.VatSum).ToString("N2");
                    txtIVA.Text         = DocumentSAP.VatSum.ToString("N2");
                    txtTotal.Text       = DocumentSAP.DocTotal.ToString("N2");

                    #region Detalle
                    foreach (var item in DocumentSAP.Lines)
                    {
                        DataRow row = (dgvDatos.DataSource as DataTable).NewRow();
                        row["ItemCode"]     = item.ItemCode;
                        row["ItemName"]     = item.ItemDescription;
                        row["Quantity"]     = item.Quantity;
                        row["OpenQty"]      = item.OpenQty;
                        row["Price"]        = item.Price;
                        row["Currency"]     = item.Currency;
                        row["WhsCode"]      = item.WarehouseCode;
                        row["WhsName"]      = item.WarehouseCode + " | " + item.WarehouseName;
                        row["LineNum"]      = item.LineNum;
                        row["Rate"]         = item.Rate;
                        row["ShipDate"]     = item.ShipDate;
                        row["LineTotal"]    = item.LineTotal;
                        row["LineStatus"]   = item.LineStatus;
                        row["U_Vendedor"]   = item.U_Vendedor;
                        row["SlpCode"]      = item.U_Vendedor;
                        row["U_Comentario"] = item.U_Comentario;
                        row["VolumenU"]     = item.VolumenU;
                        row["PesoU"]        = item.PesoU;

                        row["OnHand"] = item.OnHand;
                        row["Ideal"]  = item.Ideal;

                        row["ABC"] = item.ABC;

                        (dgvDatos.DataSource as DataTable).Rows.Add(row);

                        (dgvDatos.DataSource as DataTable).AcceptChanges();
                    }
                    #endregion
                    #endregion

                    #endregion

                    #region Eliminar

                    /*
                     #region Documento Encontrado
                     * (dgvDatos.DataSource as DataTable).Rows.Clear();
                     *
                     * Document = new SDKDatos.SDK_OPOR();
                     * Document = Document.Fill(Convert.ToDecimal(txtFolio.Text));
                     *
                     #region LLenar Form
                     * this.CleanScreen();
                     * txtFolio.Text = Document.DocNum.ToString();
                     * txtCardCode.Text = Document.CardCode;
                     * txtCardName.Text = Document.CardName;
                     * txtMoneda.Text = Document.DocCur;
                     * cbMoneda.SelectedValue = Document.DocCur;
                     * txtNumAtCard.Text = Document.NumAtCard;
                     *
                     * cbMoneda.Enabled = false;
                     * if (Document.DocStatus == "C")
                     * {
                     *  txtStatus.Text = "Cerrado";
                     *  btnCrear.Enabled = false;
                     *  cerrarStripButton.Enabled = false;
                     *
                     *  cerrarLíneaToolStripMenuItem.Enabled = false;
                     *  agregarFilaToolStripMenuItem1.Enabled = false;
                     *  tooStripDuplicar.Enabled = false;
                     * }
                     * else if (Document.DocStatus == "O")
                     * {
                     *  txtStatus.Text = "Abierto";
                     *  btnCrear.Enabled = true;
                     *  cerrarStripButton.Enabled = true;
                     *  cerrarLíneaToolStripMenuItem.Enabled = true;
                     *  agregarFilaToolStripMenuItem1.Enabled = true;
                     *  tooStripDuplicar.Enabled = true;
                     * }
                     *
                     * dtpDocDate.Value = Document.DocDate;
                     * dtpDocDueDate.Value = Document.DocDueDate;
                     * txtComments.Text = Document.Comments;
                     * txtSubtotal.Text = (Document.DocTotal - Document.VatSum).ToString("N2");
                     * txtIVA.Text = Document.VatSum.ToString("N2");
                     * txtTotal.Text = Document.DocTotal.ToString("N2");
                     *
                     #region Detalle
                     * foreach (SDKDatos.SDK_POR1 item in Document.Lines)
                     * {
                     *  DataRow row = (dgvDatos.DataSource as DataTable).NewRow();
                     *  row["ItemCode"] = item.ItemCode;
                     *  row["ItemName"] = item.Dscription;
                     *  row["Quantity"] = item.Quantity;
                     *  row["OpenQty"] = item.OpenQty;
                     *  row["Price"] = item.Price;
                     *  row["Currency"] = item.Currency;
                     *  row["WhsCode"] = item.Whscode;
                     *  row["WhsName"] = item.Whscode + " | " + item.WhsName;
                     *  row["LineNum"] = item.LineNum;
                     *  row["Rate"] = item.Rate;
                     *  row["ShipDate"] = item.ShipDate;
                     *  row["LineTotal"] = item.LineTotal;
                     *  row["LineStatus"] = item.LineStatus;
                     *  row["U_Vendedor"] = item.U_Vendedor;
                     *  row["SlpCode"] = item.U_Vendedor;
                     *  row["U_Comentario"] = item.U_Comentario;
                     *  row["VolumenU"] = item.VolumenU;
                     *  row["PesoU"] = item.PesoU;
                     *
                     *  (dgvDatos.DataSource as DataTable).Rows.Add(row);
                     *
                     *  (dgvDatos.DataSource as DataTable).AcceptChanges();
                     * }
                     #endregion
                     #endregion
                     *
                     #endregion
                     */
                    #endregion

                    txtCardName.ReadOnly = true;
                    txtCardName.ReadOnly = true;
                }

                #region solo lectura;
                if (ReadOnly)
                {
                    btnCrear.Enabled    = false;
                    btnCancelar.Enabled = false;
                    contextMenu.Enabled = false;

                    foreach (var item in dgvDatos.DisplayLayout.Bands[0].Columns)
                    {
                        item.CellActivation = Activation.NoEdit;
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                this.SetMensaje("Error al cargar OC: " + ex.Message, 5000, Color.Red, Color.White);
            }
        }