Пример #1
0
 public SDK_Configuracion_Document(decimal _idDocumento, SDK.Documentos.frmDocumentos form)
 {
     tbl_Lines     = new DataTable();
     tbl_Items     = new DataTable();
     IdDocumento   = _idDocumento;
     Form_Document = form;
 }
Пример #2
0
        private void dgvDatos_DoubleClickCell(object sender, Infragistics.Win.UltraWinGrid.DoubleClickCellEventArgs e)
        {
            try
            {
                Int32 docEntry = Convert.ToInt32(dgvDatos.Rows[e.Cell.Row.Index].Cells[(int)Columnas.Docnum].Value);

                SDK.Documentos.frmDocumentos formulario = new SDK.Documentos.frmDocumentos(1);
                formulario.MdiParent     = this.MdiParent;
                formulario.txtFolio.Text = docEntry.ToString();
                var kea = new KeyPressEventArgs(Convert.ToChar(13));
                formulario.txtFolio_KeyPress(sender, kea);
                formulario.Show();
            }
            catch (Exception)
            {
            }
        }
Пример #3
0
        //ok
        public SAPbobsCOM.Documents EliminarLineaOrdenCompra(SDK.Documentos.frmDocumentos form, SDK_SAP.Clases.Document document, int Line)
        {
            SAPbobsCOM.Documents oDocument     = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders);
            SAPbobsCOM.Documents oDocumentCopy = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders);
            oDocument.GetByKey(Convert.ToInt32(document.DocEntry));
            oDocumentCopy = oDocument;

            #region Eliminar Linea
            oDocument.Lines.SetCurrentLine(Line);
            if (oDocument.Lines.LineStatus != SAPbobsCOM.BoStatus.bost_Close)
            {
                oDocument.Lines.Delete();
            }


            if (oDocument.Update() != 0)
            {
                throw new Exception("Error [" + oCompany.GetLastErrorDescription() + "]");
            }
            #endregion

            else
            {
                #region Datos SAP
                form.txtFolio.Text = oCompany.GetNewObjectKey();
                oDocumentCopy.GetByKey(Convert.ToInt32(form.txtFolio.Text));

                form.txtFolio.Text = oDocumentCopy.DocNum.ToString();
                if (SAPbobsCOM.BoStatus.bost_Close == oDocumentCopy.DocumentStatus)
                {
                    form.txtStatus.Text = "Cerrado";
                }
                else if (SAPbobsCOM.BoStatus.bost_Open == oDocumentCopy.DocumentStatus)
                {
                    form.txtStatus.Text = "Abierto";
                }

                //form.btnCrear.Enabled = false;

                #endregion
            }
            this.CloseConnection();

            return(oDocument);
        }
Пример #4
0
        //ok
        public decimal CerrarOrdenCompra(SDK.Documentos.frmDocumentos form, SDK_SAP.Clases.Document document)
        {
            SAPbobsCOM.Documents oDocument = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders);
            oDocument.GetByKey(Convert.ToInt32(document.DocEntry));

            #region Detalle

            for (int i = 0; i < oDocument.Lines.Count; i++)
            {
                oDocument.Lines.SetCurrentLine(i);
                if (oDocument.Lines.LineStatus != SAPbobsCOM.BoStatus.bost_Close)
                {
                    oDocument.Lines.LineStatus = SAPbobsCOM.BoStatus.bost_Close;
                }
            }

            #endregion

            if (oDocument.Update() != 0)
            {
                throw new Exception("Error [" + oCompany.GetLastErrorDescription() + "]");
            }
            else
            {
                #region Datos SAP
                form.txtFolio.Text = oCompany.GetNewObjectKey();
                oDocument.GetByKey(Convert.ToInt32(form.txtFolio.Text));

                form.txtFolio.Text = oDocument.DocNum.ToString();
                if (SAPbobsCOM.BoStatus.bost_Close == oDocument.DocumentStatus)
                {
                    form.txtStatus.Text = "Cerrado";
                }
                else if (SAPbobsCOM.BoStatus.bost_Open == oDocument.DocumentStatus)
                {
                    form.txtStatus.Text = "Abierto";
                }

                #endregion
            }
            this.CloseConnection();

            return(oDocument.DocNum);
        }
Пример #5
0
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            if (this.btnCrear.Text == "Crear")
            {
                SDK.Documentos.frmDocumentos formulario = new SDK.Documentos.frmDocumentos(1);
                formulario.MdiParent = this.MdiParent;
                formulario.Show();
                return;
            }

            txtCardCode.ReadOnly = false;
            txtCardCode.Enabled  = true;

            txtCardName.ReadOnly = false;
            txtCardName.Enabled  = true;
            this.CleanScreen();
            txtFolio.Focus();

            cerrarLíneaToolStripMenuItem.Enabled = true;
        }
Пример #6
0
        private void CrearOC(string Zona)
        {
            DataTable tbl = new DataTable();

            tbl.Columns.Add("CardCode", typeof(string));
            tbl.Columns.Add("Autorizado", typeof(decimal));
            tbl.Columns.Add("Artículo", typeof(string));
            tbl.Columns.Add("Descripción", typeof(string));
            tbl.Columns.Add("WhsCode", typeof(string));
            tbl.Columns.Add("Almacén", typeof(string));
            tbl.Columns.Add("Price", typeof(decimal));
            tbl.Columns.Add("Currency", typeof(string));
            tbl.Columns.Add("Rate", typeof(decimal));
            tbl.Columns.Add("Volumen", typeof(decimal));
            tbl.Columns.Add("BWeight1", typeof(decimal));

            foreach (DataRow item in Tbl_Volumen.Rows)
            {
                if (item.Field <string>("Zona").Equals(Zona))
                {
                    DataRow r = tbl.NewRow();
                    r["CardCode"]    = item["CardCode"];
                    r["Autorizado"]  = item["ComprarM"];
                    r["Artículo"]    = item["ItemCode"];
                    r["Descripción"] = item["ItemName"];
                    r["WhsCode"]     = item["WhsCode"];
                    r["Almacén"]     = item["WhsName"];
                    r["Price"]       = item["Price"];
                    r["Currency"]    = item["Currency"];
                    r["Rate"]        = item["Rate"];
                    r["Volumen"]     = item["Volumen"];
                    r["BWeight1"]    = item["BWeight1"];
                    tbl.Rows.Add(r);
                }
            }

            SDK.Documentos.frmDocumentos formulario = new SDK.Documentos.frmDocumentos(tbl, 1, cbProveedor.SelectedValue.ToString());
            formulario.MdiParent = this.MdiParent;
            formulario.Show();
        }
Пример #7
0
        private void dgvStock_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (ClasesSGUV.Login.Rol == (int)ClasesSGUV.Propiedades.RolesHalcoNET.Administrador
                    | ClasesSGUV.Login.Rol == (int)ClasesSGUV.Propiedades.RolesHalcoNET.GerenteCompras
                    | ClasesSGUV.Login.Rol == (int)ClasesSGUV.Propiedades.RolesHalcoNET.Zulma)
                {
                    Int32 docEntry = Convert.ToInt32(dgvStock.Rows[e.RowIndex].Cells[0].Value);

                    SDK.Documentos.frmDocumentos formulario = new SDK.Documentos.frmDocumentos(1);
                    formulario.typeDocument  = "OC";
                    formulario.MdiParent     = this.MdiParent;
                    formulario.txtFolio.Text = docEntry.ToString();
                    var kea = new KeyPressEventArgs(Convert.ToChar(13));
                    formulario.txtFolio_KeyPress(sender, kea);
                    formulario.Show();
                }
            }
            catch (Exception)
            {
            }
        }
Пример #8
0
        //ok
        public decimal ActualizarDocumento(SDK.Documentos.frmDocumentos form, SDK_SAP.Clases.Document documentConCambios)
        {
            //SAPbobsCOM.Documents oDocumentCopy = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders);
            SAPbobsCOM.Documents oDocumento = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders);
            oDocumento.GetByKey(Convert.ToInt32(documentConCambios.DocEntry));
            //oDocumentCopy = oDocumento;
            oDocumento.DocDueDate = form.dtpDocDueDate.Value;

            #region Encabezado
            if (!string.IsNullOrEmpty(form.txtNumAtCard.Text))
            {
                oDocumento.NumAtCard = form.txtNumAtCard.Text;
            }
            if (!string.IsNullOrEmpty(form.txtComments.Text))
            {
                oDocumento.Comments = form.txtComments.Text;
            }
            #endregion

            #region Detalle
            foreach (UltraGridRow row in form.dgvDatos.Rows)
            {
                if (!row.IsAddRow)
                {
                    //si la linea ya existe la linea solo actiaizar
                    if (Convert.ToInt32(row.Cells["LineNum"].Value == DBNull.Value ? -1 : row.Cells["LineNum"].Value) > -1)
                    {
                        oDocumento.Lines.SetCurrentLine(Convert.ToInt32(row.Index));

                        oDocumento.Lines.Quantity = Convert.ToDouble(row.Cells["Quantity"].Value);
                        if (row.Cells["ShipDate"].Value != DBNull.Value)
                        {
                            oDocumento.Lines.ShipDate = Convert.ToDateTime(row.Cells["ShipDate"].Value);
                        }

                        if (row.Cells["U_Comentario"].Value != DBNull.Value)
                        {
                            oDocumento.Lines.UserFields.Fields.Item("U_Comentario").Value = row.Cells["U_Comentario"].Value;
                        }
                        else
                        {
                            oDocumento.Lines.UserFields.Fields.Item("U_Comentario").Value = String.Empty;
                        }

                        if (row.Cells["U_Vendedor"].Value != DBNull.Value)
                        {
                            oDocumento.Lines.UserFields.Fields.Item("U_Vendedor").Value = row.Cells["U_Vendedor"].Value;
                        }
                        else
                        {
                            oDocumento.Lines.UserFields.Fields.Item("U_Vendedor").Value = String.Empty;
                        }

                        if (row.Cells["WhsCode"].Value != DBNull.Value)
                        {
                            oDocumento.Lines.UserFields.Fields.Item("U_Warehouse").Value = Convert.ToString(row.Cells["WhsCode"].Value);
                        }
                        if (row.Cells["ShipDate"].Value != DBNull.Value)
                        {
                            oDocumento.Lines.UserFields.Fields.Item("U_ShipDate").Value = Convert.ToDateTime(row.Cells["ShipDate"].Value);
                        }
                        else
                        {
                            oDocumento.Lines.UserFields.Fields.Item("U_ShipDate").Value = oDocumento.DocDueDate;
                        }
                    }
                    else
                    {
                        oDocumento.Lines.Add();
                        oDocumento.Lines.ItemCode      = Convert.ToString(row.Cells["ItemCode"].Value);
                        oDocumento.Lines.Quantity      = Convert.ToDouble(row.Cells["Quantity"].Value);
                        oDocumento.Lines.Currency      = Convert.ToString(row.Cells["Currency"].Value);
                        oDocumento.Lines.UnitPrice     = Convert.ToDouble(row.Cells["Price"].Value);
                        oDocumento.Lines.WarehouseCode = Convert.ToString(row.Cells["WhsCode"].Value);

                        if (row.Cells["ShipDate"].Value != DBNull.Value)
                        {
                            oDocumento.Lines.ShipDate = Convert.ToDateTime(row.Cells["ShipDate"].Value);
                        }

                        if (row.Cells["U_Comentario"].Value != DBNull.Value)
                        {
                            oDocumento.Lines.UserFields.Fields.Item("U_Comentario").Value = row.Cells["U_Comentario"].Value;
                        }
                        else
                        {
                            oDocumento.Lines.UserFields.Fields.Item("U_Comentario").Value = String.Empty;
                        }

                        if (row.Cells["U_Vendedor"].Value != DBNull.Value)
                        {
                            oDocumento.Lines.UserFields.Fields.Item("U_Vendedor").Value = row.Cells["U_Vendedor"].Value;
                        }
                        else
                        {
                            oDocumento.Lines.UserFields.Fields.Item("U_Vendedor").Value = String.Empty;
                        }

                        if (row.Cells["WhsCode"].Value != DBNull.Value)
                        {
                            oDocumento.Lines.UserFields.Fields.Item("U_Warehouse").Value = Convert.ToString(row.Cells["WhsCode"].Value);
                        }
                        if (row.Cells["ShipDate"].Value != DBNull.Value)
                        {
                            oDocumento.Lines.UserFields.Fields.Item("U_ShipDate").Value = Convert.ToDateTime(row.Cells["ShipDate"].Value);
                        }
                        else
                        {
                            oDocumento.Lines.UserFields.Fields.Item("U_ShipDate").Value = oDocumento.DocDueDate;
                        }
                    }
                }
            }
            #endregion

            if (oDocumento.Update() != 0)
            {
                throw new Exception("Error [" + oCompany.GetLastErrorDescription() + "]");
            }
            else
            {
                #region Datos SAP
                form.txtFolio.Text = oCompany.GetNewObjectKey();
                oDocumento.GetByKey(Convert.ToInt32(form.txtFolio.Text));

                form.txtFolio.Text = oDocumento.DocNum.ToString();
                if (SAPbobsCOM.BoStatus.bost_Close == oDocumento.DocumentStatus)
                {
                    form.txtStatus.Text = "Cerrado";
                }
                else if (SAPbobsCOM.BoStatus.bost_Open == oDocumento.DocumentStatus)
                {
                    form.txtStatus.Text = "Abierto";
                }

                //form.btnCrear.Enabled = false;

                #endregion
            }
            this.CloseConnection();

            return(oDocumento.DocNum);
        }
Пример #9
0
        //ok
        public decimal CrearOrdenCompra(SDK.Documentos.frmDocumentos form)
        {
            SAPbobsCOM.Documents oDocument = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders);

            #region Encabezado
            oDocument.CardCode    = form.txtCardCode.Text;
            oDocument.Series      = 15;
            oDocument.DocDate     = form.dtpDocDate.Value;
            oDocument.DocDueDate  = form.dtpDocDueDate.Value;
            oDocument.DocType     = SAPbobsCOM.BoDocumentTypes.dDocument_Items;
            oDocument.DocCurrency = form.txtMoneda.Text;

            if (!string.IsNullOrEmpty(form.txtNumAtCard.Text))
            {
                oDocument.NumAtCard = form.txtNumAtCard.Text;
            }
            if (!string.IsNullOrEmpty(form.txtComments.Text))
            {
                oDocument.Comments = form.txtComments.Text;
            }
            #endregion

            #region Detalle
            foreach (UltraGridRow row in form.dgvDatos.Rows)
            {
                if (!row.IsAddRow)
                {
                    oDocument.Lines.ItemCode = Convert.ToString(row.Cells["ItemCode"].Value);
                    oDocument.Lines.Quantity = Convert.ToDouble(row.Cells["Quantity"].Value);
                    oDocument.Lines.Currency = Convert.ToString(row.Cells["Currency"].Value);
                    //oDocument.Lines.UnitPrice = Convert.ToDouble(row.Cells["Price"].Value);
                    //No se envia precio porque se toma directamente de la lista de precios 17, esto para evitar
                    //problemas con los articulos con multiplo de compra
                    oDocument.Lines.WarehouseCode = Convert.ToString(row.Cells["WhsCode"].Value);
                    if (row.Cells["ShipDate"].Value != DBNull.Value)
                    {
                        oDocument.Lines.ShipDate = Convert.ToDateTime(row.Cells["ShipDate"].Value);
                    }

                    oDocument.Lines.UserFields.Fields.Item("U_Comentario").Value = Convert.ToString(row.Cells["U_Comentario"].Value);
                    oDocument.Lines.UserFields.Fields.Item("U_Vendedor").Value   = Convert.ToString(row.Cells["U_Vendedor"].Value);

                    oDocument.Lines.UserFields.Fields.Item("U_Warehouse").Value = Convert.ToString(row.Cells["WhsCode"].Value);
                    if (row.Cells["ShipDate"].Value != DBNull.Value)
                    {
                        oDocument.Lines.UserFields.Fields.Item("U_ShipDate").Value = Convert.ToDateTime(row.Cells["ShipDate"].Value);
                    }
                    else
                    {
                        oDocument.Lines.UserFields.Fields.Item("U_ShipDate").Value = oDocument.DocDueDate;
                    }

                    oDocument.Lines.Add();
                }
            }
            #endregion
            if (string.IsNullOrEmpty(form.txtStatus.Text))
            {
                //oDocument.DocType = 22;
                //SDK_SAP.DI.Documents doc = new SDK_SAP.DI.Documents(10006);
                //form.txtFolio.Text = oDocument.SaveDraft(oDocument).ToString();

                //Document = Document.Fill(Document.DocNum, 16, "Borrador");
                //txtFolio.Text = Document.DocNum.ToString();

                //if (Document.DocStatus.Equals("P"))
                //    txtStatus.Text = "Pendiente";
                //else if (Document.DocStatus.Equals("R"))
                //    txtStatus.Text = "Rechazado";
                //else if (Document.DocStatus.Equals("A"))
                //    txtStatus.Text = "Autorizado";

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

                //btnCrear_Click(sender, e);

                //this.SetMensaje("Listo", 5000, Color.Green, Color.Black);
                //DocumentMode = "Creado";
            }

            // if (oDocument.DocumentStatus.Equals("A"))
            if (oDocument.Add() != 0)
            {
                throw new Exception("Error [" + oCompany.GetLastErrorDescription() + "]");
            }
            else
            {
                #region Datos SAP
                form.txtFolio.Text = oCompany.GetNewObjectKey();
                oDocument.GetByKey(Convert.ToInt32(form.txtFolio.Text));

                form.txtFolio.Text = oDocument.DocNum.ToString();
                if (SAPbobsCOM.BoStatus.bost_Close == oDocument.DocumentStatus)
                {
                    form.txtStatus.Text = "Cerrado";
                }
                else if (SAPbobsCOM.BoStatus.bost_Open == oDocument.DocumentStatus)
                {
                    form.txtStatus.Text = "Abierto";
                }

                form.btnCrear.Enabled = false;

                #endregion
            }

            this.CloseConnection();
            return(oDocument.DocNum);
        }