/// <summary>
        /// Page Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!ValidarConexionYUsuarioLogueado(sender))
            {
                return;
            }
            if (Session["UiVistaTransaccionesConsignacion"] != null)
            {
                UiVistaTransaccionesConsignacion.DataSource = Session["UiVistaTransaccionesConsignacion"];
                UiVistaTransaccionesConsignacion.DataBind();
            }
            if (Session["UiVistaDetalle"] != null)
            {
                UiVistaDetalle.DataSource = Session["UiVistaDetalle"];
                UiVistaDetalle.DataBind();
            }
            if (Session["UiVistaConsignacion"] != null)
            {
                UiVistaConsignacion.DataSource = Session["UiVistaConsignacion"];
                UiVistaConsignacion.DataBind();
                GenerarReporteVistaGeneral();
            }

            if (Session["ConsignacionesHistoricas"] != null)
            {
                GenerarReporteHistoricoDeConsignacion();
            }
        }
        protected void BtnSi_Click(object sender, EventArgs e)
        {
            //string Result = string.Empty;
            try
            {
                var objInterfaz = new InterfazWs.SboInterfaceService
                {
                    Timeout = 1800000,
                    Url     = Session["URL_WS_INTERFACE"].ToString()
                };

                var pikcingId = Session["IDPICKING"].ToString();

                if (int.Parse(UiComboTipo.Value.ToString()) == 3)
                {
                    var result = "";
                    if (_objPicking.SondaInventoryTransfer(int.Parse(pikcingId), ref result,
                                                           Session["connectionString"].ToString()))
                    {
                        if (!result.Equals("OK"))
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "ErrorText", "CallError('Error: " + result + "');", true);
                        }
                    }
                }

                _objPicking.UpdatePicking(UiMemoObservaciones.Text, Convert.ToInt32(Session["IDPICKING"]),
                                          Session["connectionString"].ToString());
                UiSpinNumero.Number  = 0;
                UiComboOperador.Text = "";
                UiComboCliente.Text  = "";
                UiComboTipo.Text     = "";
                UiTxtReferencia.Text = "";
                UiTxtDocSap.Text     = "";
                //ASPxMemo1.Text = "";
                UiVistaDetalle.DataSource = null;
                UiVistaDetalle.DataBind();

                var op = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize <Operacion>(objInterfaz.ProcesesarPicking(pikcingId));
                //var op = new JavaScriptSerializer().Deserialize<Operacion>(objInterfaz.ProcessDispatch("201742"));
                if (op.Resultado == ResultadoOperacionTipo.Error || op.Resultado == ResultadoOperacionTipo.Parcial)
                {
                    objInterfaz.Dispose();
                    ScriptManager.RegisterStartupScript(this, GetType(), "ErrorText",
                                                        "CallError('Resultado envío a SAP: " + op.Mensaje + "'); window.location = 'PanleListingPicking.aspx';", true);
                }
                else
                {
                    objInterfaz.Dispose();
                    Response.Redirect("PanleListingPicking.aspx");
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "ErrorText",
                                                    "CallError('Error: " + ex.Message + "');", true);
            }
            ASPxPopupControl1.ShowOnPageLoad = false;
        }
        public void LoadGridView(int codeIncome)
        {
            try
            {
                var pResult = "";
                _ds = _objPicking.GePickingInPanelReception(codeIncome, Session["connectionString"].ToString(), ref pResult);
                MobilityScm.Modelo.Entidades.PickingEncabezado pickingEncabezado = new MobilityScm.Modelo.Entidades.PickingEncabezado();

                pickingEncabezado.PICKING_HEADER = codeIncome;
                if (pResult == "")
                {
                    Session["dsReporte"] = _ds;
                    if (!Convert.IsDBNull(_ds))
                    {
                        if (_ds.Tables[0].Rows.Count > 0)
                        {
                            if (!Convert.IsDBNull(_ds.Tables[0].Rows[0]["TASK_ID"]))
                            {
                                Session["TASK_ID_PANEL_PICKING"] = Convert.ToString(_ds.Tables[0].Rows[0]["TASK_ID"]);

                                pickingEncabezado.TASK_ID = int.Parse(Convert.ToString(_ds.Tables[0].Rows[0]["TASK_ID"]));
                            }
                            if (!Convert.IsDBNull(_ds.Tables[0].Rows[0]["NAME_CLASSIFICATION"]))
                            {
                                pickingEncabezado.CLASSIFICATION_PICKING = Convert.ToString(_ds.Tables[0].Rows[0]["NAME_CLASSIFICATION"]);
                            }
                            if ((!Convert.IsDBNull(_ds.Tables[0].Rows[0]["NAME_CUSTOMER"])))
                            {
                                pickingEncabezado.CODE_CLIENT = Convert.ToString(_ds.Tables[0].Rows[0]["NAME_CUSTOMER"]);
                            }
                            if ((!Convert.IsDBNull(_ds.Tables[0].Rows[0]["LOGIN"])))
                            {
                                pickingEncabezado.LOGIN = Convert.ToString(_ds.Tables[0].Rows[0]["LOGIN"]);
                            }
                            if ((!Convert.IsDBNull(_ds.Tables[0].Rows[0]["REFERENCE"])))
                            {
                                pickingEncabezado.REFERENCE = Convert.ToString(_ds.Tables[0].Rows[0]["REFERENCE"]);
                            }
                            if ((!Convert.IsDBNull(_ds.Tables[0].Rows[0]["DOC_SAP_RECEPTION"])))
                            {
                                pickingEncabezado.DOC_SAP_RECEPTION = Convert.ToString(_ds.Tables[0].Rows[0]["DOC_SAP_RECEPTION"]);
                            }
                            if ((!Convert.IsDBNull(_ds.Tables[0].Rows[0]["COMMENTS"])))
                            {
                                pickingEncabezado.COMMENTS = Convert.ToString(_ds.Tables[0].Rows[0]["COMMENTS"]);
                            }
                            if ((!Convert.IsDBNull(_ds.Tables[0].Rows[0]["ALLOW_STORAGE_ON_DIFF"])))
                            {
                                pickingEncabezado.CODE_WAREHOUSE_SOURCE = _ds.Tables[0].Rows[0]["ALLOW_STORAGE_ON_DIFF"].ToString();
                            }
                            if ((!Convert.IsDBNull(_ds.Tables[0].Rows[0]["SCANNING_STATUS"])))
                            {
                                pickingEncabezado.STATUS = _ds.Tables[0].Rows[0]["SCANNING_STATUS"].ToString();
                            }
                        }
                        if (_ds.Tables[1].Rows.Count > 0)
                        {
                            UiVistaDetalle.DataSource = _ds.Tables[1];
                            var regionCombo = (UiVistaDetalle.Columns["CODE_SKU"] as GridViewDataComboBoxColumn);
                            if (regionCombo != null)
                            {
                                regionCombo.PropertiesComboBox.DataSource = _ds.Tables[1].DefaultView.ToTable(true,
                                                                                                              "CODE_SKU");
                                regionCombo.PropertiesComboBox.ValueField = "CODE_SKU";
                                regionCombo.PropertiesComboBox.TextField  = "CODE_SKU";
                            }

                            UiVistaDetalle.DataBind();
                            Session["DATOS"] = _ds;

                            //ASPxComboBox4.Text = Convert.ToString(ds.Tables[1].Rows[0]["CODE_SKU"]);
                            //ASPxTextBox3.Text = Convert.ToString(ds.Tables[1].Rows[0]["DESCRIPTION_SKU"]);
                            //ASPxSpinEdit1.Number = Convert.ToInt32(ds.Tables[1].Rows[0]["EXPECTED"]);
                        }


                        ASPxGridView1.JSProperties.Add("cpTerminoDeCargarDetalle", pickingEncabezado.PICKING_HEADER + "|" +
                                                       pickingEncabezado.TASK_ID + "|" +
                                                       pickingEncabezado.CLASSIFICATION_PICKING + "|" +
                                                       pickingEncabezado.CODE_CLIENT + "|" +
                                                       pickingEncabezado.LOGIN + "|" +
                                                       pickingEncabezado.REFERENCE + "|" +
                                                       pickingEncabezado.DOC_SAP_RECEPTION + "|" +
                                                       pickingEncabezado.COMMENTS + "|" +
                                                       pickingEncabezado.CODE_WAREHOUSE_SOURCE + "|" +
                                                       pickingEncabezado.STATUS);
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "ErrorText", "CallError('" + pResult + "');", true);
                    ASPxGridView1.JSProperties.Add("cpError", pResult);
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "ErrorText", "CallError('Error: " + ex.Message + "');", true);
                ASPxGridView1.JSProperties.Add("cpError", ex.Message);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!ValidarConexionYUsuarioLogueado(sender))
            {
                return;
            }
            if (Session["DSDISEÑO_PICKING"] != null)
            {
                var reporte = new Report.ReportListPicking {
                    DataSource = Session["DSDISEÑO_PICKING"]
                };
                ASPxDocumentViewer1.Report = reporte;
                ASPxDocumentViewer1.DataBind();
            }

            if (Session["DSDISEÑO_PICKING_AUDIT"] != null)
            {
                var reporte = new Report.ReportPickingAudit {
                    DataSource = Session["DSDISEÑO_PICKING_AUDIT"]
                };
                UiReporteDetalle.Report = reporte;
                UiReporteDetalle.DataBind();
            }

            UiMenuDetalle.Items.FindByName("btnBill").ClientVisible = GeneraFactura();

            if (!Page.IsPostBack)
            {
                Session["DATOS"]        = null;
                Session["datosPicking"] = null;
                ASPxDateEdit1.Date      = DateTime.Today;
                ASPxDateEdit2.Date      = DateTime.Today;
                try
                {
                    var pResult = "";
                    var ds      = _objPicking.GetAllPicking(Session["connectionString"].ToString(), Convert.ToDateTime(ASPxDateEdit1.Date), Convert.ToDateTime(ASPxDateEdit2.Date), ref pResult);
                    if (pResult == "")
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            ASPxGridView1.DataSource = ds;
                            ASPxGridView1.DataBind();
                            Session["datosPicking"] = ds;
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "ErrorText", "CallError('" + pResult + "');", true);
                    }
                }
                catch (Exception ex)
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "ErrorText", "CallError('Error: " + ex.Message + "');", true);
                }
            }
            if (Session["datosPicking"] != null)
            {
                ASPxGridView1.DataSource = Session["datosPicking"];
                ASPxGridView1.DataBind();
            }
            if (Session["DATOS"] != null)
            {
                DataSet dstmp = (DataSet)Session["DATOS"];

                switch (dstmp.Tables[0].Rows[0]["SCANNING_STATUS"].ToString())
                {
                case "PENDING":
                    ASPxLabel11.Text      = "Pendiente";
                    ASPxLabel11.ForeColor = System.Drawing.Color.Red;
                    break;

                case "IN_PROGRESS":
                    ASPxLabel11.Text      = "En progreso...";
                    ASPxLabel11.ForeColor = System.Drawing.Color.Yellow;
                    break;

                case "COMPLETED":
                    ASPxLabel11.Text      = "Completado";
                    ASPxLabel11.ForeColor = System.Drawing.Color.Green;
                    break;
                }

                UiVistaDetalle.DataSource = dstmp.Tables[1];
                var regionCombo = (UiVistaDetalle.Columns["CODE_SKU"] as GridViewDataComboBoxColumn);
                if (regionCombo != null)
                {
                    regionCombo.PropertiesComboBox.DataSource = dstmp.Tables[1].DefaultView.ToTable(true,
                                                                                                    "CODE_SKU");
                    regionCombo.PropertiesComboBox.ValueField = "CODE_SKU";
                    regionCombo.PropertiesComboBox.TextField  = "CODE_SKU";
                }
                UiVistaDetalle.DataBind();
            }
        }