示例#1
0
        private void btnActualizar_Click(object sender, EventArgs e)
        {
            foreach (var line in Document.Lines)
            {
                line.LotesList.Clear();

                foreach (DataRow lote in tbl_lotes.Rows)
                {
                    if ((line.ItemCode +
                         line.WarehouseCode +
                         (line.BaseEntry == null ? 0 : line.BaseEntry) +
                         (line.BaseLine == null ? 0 : line.BaseLine)).Equals(lote.Field <string>("ID")))
                    {
                        SDK_SAP.Clases.Lotes oLote = new SDK_SAP.Clases.Lotes();
                        oLote.Lote          = lote.Field <string>("Lote");
                        oLote.Cantidad      = lote.Field <double>("Cantidad");
                        oLote.Pedimento     = lote.Field <string>("Pedimento");
                        oLote.Aduana        = lote.Field <string>("Aduana");
                        oLote.FechaAdmision = lote.Field <DateTime>("Fecha de admisión");

                        line.LotesList.Add(oLote);

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

            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }
示例#2
0
        private void btnEntrega_Click(object sender, EventArgs e)
        {
            try
            {
                btnConsultar.Focus();

                SDK_SAP.Clases.Document doc = new SDK_SAP.Clases.Document();

                DataTable tbl_Datos = new DataTable();
                tbl_Datos       = dgvDatos.DataSource as DataTable;
                doc.DocType     = "dDocument_Items";
                doc.DocDate     = DateTime.Now;
                doc.CardCode    = Convert.ToString(tbl_Datos.Rows[0]["CardCode"]);
                doc.DocCurrency = Convert.ToString(tbl_Datos.Rows[0]["DocCur"]);

                doc.U_Cuenta  = Convert.ToString(tbl_Datos.Rows[0]["U_Cuenta"]);
                doc.U_MPAGO2  = Convert.ToString(tbl_Datos.Rows[0]["U_MPAGO2"]);
                doc.U_TipoOV  = Convert.ToString(tbl_Datos.Rows[0]["U_TipoOV"]);
                doc.U_Titular = Convert.ToString(tbl_Datos.Rows[0]["U_Titular"]);
                doc.U_TPedido = Convert.ToString(tbl_Datos.Rows[0]["U_TPedido"]);
                doc.U_OC      = Convert.ToString(tbl_Datos.Rows[0]["U_OC"]);

                doc.Series = Convert.ToInt32(tbl_Datos.Rows[0]["Series"]);

                /*
                 * doc.U_LugarExp = Convert.ToString(tbl_Heder.Rows[0]["LugarExp"]);
                 * doc.FE_Calle = Convert.ToString(tbl_Heder.Rows[0]["Calle"]);
                 * doc.FE_NoExt = Convert.ToString(tbl_Heder.Rows[0]["NoExt"]);
                 * doc.FE_NoInt = Convert.ToString(tbl_Heder.Rows[0]["NoInt"]);
                 * doc.FE_Colonia = Convert.ToString(tbl_Heder.Rows[0]["Colonia"]);
                 * doc.FE_Municipio = Convert.ToString(tbl_Heder.Rows[0]["Municipio"]);
                 * doc.FE_Estado = Convert.ToString(tbl_Heder.Rows[0]["Estado"]);
                 * doc.FE_Pais = "México";
                 * doc.FE_CP = Convert.ToString(tbl_Heder.Rows[0]["CP"]);
                 */

                foreach (DataRow item in tbl_Datos.Rows)
                {
                    if (Convert.ToBoolean(item["Seleccionar"]))
                    {
                        SDK_SAP.Clases.DocumentLines lineDoc = new SDK_SAP.Clases.DocumentLines();
                        lineDoc.ItemCode      = Convert.ToString(item["ItemCode"]);
                        lineDoc.Quantity      = Convert.ToDouble(item["Surtido"]);
                        lineDoc.Currency      = Convert.ToString(item["Currency"]);
                        lineDoc.WarehouseCode = Convert.ToString(item["WhsCode"]);
                        lineDoc.Price         = Convert.ToDouble(item["Price"]);
                        lineDoc.MeasureUnit   = Convert.ToString(item["SalUnitMsr"]);
                        if (item["U_PReal"] != DBNull.Value)
                        {
                            lineDoc.U_PReal = Convert.ToDouble(item["U_PReal"]);
                        }
                        if (item["U_Comentario"] != DBNull.Value)
                        {
                            lineDoc.U_Comentario = Convert.ToString(item["U_Comentario"]);
                        }
                        lineDoc.ManBtchNum = Convert.ToString(item["ManBtchNum"]);

                        SDK_SAP.Clases.Lotes lote = new SDK_SAP.Clases.Lotes();
                        if (lineDoc.ManBtchNum.Equals("Y"))
                        {
                            DataTable tbl_Lot = lote.getLotes(lineDoc.ItemCode, lineDoc.WarehouseCode, lineDoc.Quantity);
                            foreach (DataRow itemLote in tbl_Lot.Rows)
                            {
                                SDK_SAP.Clases.Lotes oLot = new SDK_SAP.Clases.Lotes();
                                oLot.Lote     = itemLote.Field <string>("BatchNum");
                                oLot.Cantidad = (double)itemLote.Field <decimal>("Quantity");
                                lineDoc.LotesList.Add(oLot);
                            }
                        }

                        lineDoc.BaseEntry = Convert.ToInt32(item["DocEntry"]);
                        lineDoc.BaseLine  = Convert.ToInt32(item["LineNum"]);
                        lineDoc.BaseType  = Convert.ToInt32(tbl_Datos.Rows[0]["ObjType"]);

                        doc.Lines.Add(lineDoc);
                    }
                }

                SDK_SAP.DI.Documents diAPI_Document = new SDK_SAP.DI.Documents(20011);

                decimal FolioSap = diAPI_Document.AddDocument("ODLN", doc);

                this.SetMensaje("Listo! Folio: " + FolioSap, 5000, Color.Green, Color.Black);

                this.OnLoad(e);
            }
            catch (Exception ex)
            {
                this.SetMensaje(ex.Message, 5000, Color.Red, Color.White);
            }
        }