Exemple #1
0
        private void ClearFields(bool clearCbType)
        {
            CbType.ReadOnly               = false;
            GrLookProvider.ReadOnly       = false;
            Session["SAP_RECEPTION_TYPE"] = null;
            Session["SAP_RECEPTION_DATA"] = null;
            GridSap.DataSource            = null;
            GridSap.DataBind();
            Session["INGRESO_HEADER"] = "false";
            TxtReference.Text         = "";
            SpinSap.Text    = "";
            GrLookUser.Text = "";
            GrLookSku.Text  = "";
            SpinSku.Number  = 0; GridReception.DataSource = null;
            GridReception.DataBind();
            GrLookSku.Text                     = "";
            SpinSku.Number                     = 0;
            Session["dsReception"]             = null;
            GrLookSku.Visible                  = true;
            SpinSku.Visible                    = true;
            ASPxLabel6.Visible                 = true;
            ASPxLabel8.Visible                 = true;
            SpinSap.ReadOnly                   = false;
            GridReception.Columns["#"].Visible = true;
            LblErpReferences.Text              = string.Empty;
            LblErpReferences.ClientVisible     = false;
            MemoComments.Text                  = string.Empty;
            GrLookProvider.Text                = "";
            GrLookProvider.ReadOnly            = false;

            if (clearCbType)
            {
                CbType.Text = "";
                ASPxPageControl1.TabPages.FindByName("ERP").Enabled = true;
            }
        }
Exemple #2
0
        public void GetSapData(string erpDoc, string tipo)
        {
            if (Session["SAP_RECEPTION_TYPE"] != null && Session["SAP_RECEPTION_TYPE"].ToString().Equals("IT"))
            {
                GridSap.JSProperties.Add("cpError", "Ya fue ingresado un documento.");
                return;
            }

            var pResult = "";
            var ds      = new DataSet();

            switch (tipo)
            {
            case "PO":
                Session["SAP_RECEPTION_TYPE"] = "PO";
                ds = _wscalled.GetSapReception(Session["connectionString"].ToString(), erpDoc, ref pResult);
                break;

            case "IT":
                ds = _wscalled.GetSapIncomeItr(Session["connectionString"].ToString(), erpDoc, ref pResult);
                Session["SAP_RECEPTION_TYPE"] = "IT";
                break;
            }
            var oldDs = (DataSet)Session["SAP_RECEPTION_DATA"];
            var flag  = false;

            if (ds == null)
            {
                return;
            }
            if (pResult == "")
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    if (oldDs != null && oldDs.Tables[0].Rows.Count > 0)
                    {
                        for (var j = 0; j < oldDs.Tables[0].DefaultView.ToTable(true, "ERP_DOC").Rows.Count; j++)
                        {
                            if (
                                oldDs.Tables[0].DefaultView.ToTable(true, "ERP_DOC").Rows[j]["ERP_DOC"].ToString() !=
                                ds.Tables[0].Rows[0]["ERP_DOC"].ToString())
                            {
                                flag = true;
                            }
                            else
                            {
                                flag = false;
                                GridSap.JSProperties.Add("cpError", "Ingresó el mismo documento SAP");
                                break;
                            }
                        }
                        if (flag)
                        {
                            if (oldDs.Tables[0].Rows[0]["PROVIDER_ID"].ToString() ==
                                ds.Tables[0].Rows[0]["PROVIDER_ID"].ToString())
                            {
                                for (var i = 0; i < ds.Tables[0].Rows.Count; i++)
                                {
                                    var row = oldDs.Tables[0].NewRow();

                                    row[0] = ds.Tables[0].Rows[i]["SAP_RECEPTION_ID"];
                                    row[1] = ds.Tables[0].Rows[i]["ERP_DOC"];
                                    row[2] = ds.Tables[0].Rows[i]["PROVIDER_ID"];
                                    row[3] = ds.Tables[0].Rows[i]["PROVIDER_NAME"];
                                    row[4] = ds.Tables[0].Rows[i]["SKU"];
                                    row[5] = ds.Tables[0].Rows[i]["SKU_DESCRIPTION"];
                                    row[6] = ds.Tables[0].Rows[i]["QTY"];
                                    row[8] = ds.Tables[0].Rows[i]["COMMENTS"];

                                    oldDs.Tables[0].Rows.Add(row);
                                }
                                Session["SAP_RECEPTION_DATA"] = oldDs;
                            }
                            else
                            {
                                GridSap.JSProperties.Add("cpError",
                                                         "El proveedor es diferente: " + ds.Tables[0].Rows[0]["PROVIDER_NAME"]);
                            }
                        }
                    }
                    else
                    {
                        Session["SAP_RECEPTION_DATA"] = ds;
                    }

                    GridSap.DataSource = Session["SAP_RECEPTION_DATA"];
                    GridSap.DataBind();
                }
                else
                {
                    GridSap.JSProperties.Add("cpError", "No existe el documento en ERP");
                }
            }
            else
            {
                GridSap.JSProperties.Add("cpError", "Error: " + pResult);
            }
        }
Exemple #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!ValidarConexionYUsuarioLogueado(sender))
            {
                return;
            }
            try
            {
                if (Session["SAP_RECEPTION_DATA"] != null)
                {
                    GridSap.DataSource = Session["SAP_RECEPTION_DATA"];
                    GridSap.DataBind();
                }

                //Validacion de insercion de datos HEADER en tabla temporal
                if (Request["__EVENTARGUMENT"] == "KeyPress")
                {
                    _cs = Session["connectionString"].ToString();
                    _wscalled.InsertIncomeTemp(Convert.ToString(CbType.Value), Convert.ToString(GrLookProvider.Value), Convert.ToString(GrLookUser.Text), TxtReference.Text, SpinSap.Text, Session["USER"].ToString(), Session["connectionString"].ToString(), DateAssignedDate.Date, Convert.ToInt32(CbPriority.Value));
                    Session["INGRESO_HEADER"] = "TRUE";
                }

                //Validacion de insercion de datos en Detail en tabla Temporal
                if (Request["__EVENTARGUMENT"] == "KeyPressSpE")
                {
                    if ((string)Session["UPDATE_TEMP"] == "true")
                    {
                        _wscalled.UpdateDetail((int)Session["RECEPTION_DETAIL_TEMP"], Convert.ToString(GrLookSku.Value), Convert.ToString(GrLookSku.Text), Convert.ToInt32(SpinSku.Number), Session["connectionString"].ToString());
                        Session["UPDATE_TEMP"] = "false";

                        Session["EXPECTED"] = Convert.ToInt32(SpinSku.Number);
                        var pResult  = "";
                        var dsDetail = _wscalled.GetIncomeDetailForIncomeHeader((int)Session["Header"], Session["connectionString"].ToString(), ref pResult);
                        if (pResult == "")
                        {
                            GridReception.DataSource = dsDetail;
                            GridReception.DataBind();
                            Session["dsReception"] = dsDetail;
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "ErrorText", "CallError('" + pResult + "');", true);
                        }
                    }

                    else if ((string)Session["INGRESO_HEADER"] == "TRUE")
                    {
                        var dsNumber = _wscalled.GetNumberHeader(Session["connectionString"].ToString());
                        Session["Header"] = Convert.ToInt32(dsNumber.Tables[0].Rows[0]["RECEPTION_HEADER"]);
                        _wscalled.InsertIncomeDetail(Convert.ToInt32(dsNumber.Tables[0].Rows[0]["RECEPTION_HEADER"]), Convert.ToString(GrLookSku.Value), Convert.ToDecimal(SpinSku.Number), Session["connectionString"].ToString(), GrLookSku.Text);
                        var pResult  = "";
                        var dsDetail = _wscalled.GetIncomeDetailForIncomeHeader((int)Session["Header"], Session["connectionString"].ToString(), ref pResult);
                        if (pResult == "")
                        {
                            GridReception.DataSource = dsDetail;
                            GridReception.DataBind();
                            SpinSku.Number         = 0;
                            Session["dsReception"] = dsDetail;
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "ErrorText", "CallError('" + pResult + "');", true);
                        }
                    }
                    else
                    {
                        //?Actualizar o insertar en base a la variable de sesion que lo indica
                        if ((string)Session["UPDATE_TEMP"] == "true")
                        {
                            _wscalled.UpdateDetail((int)Session["RECEPTION_DETAIL_TEMP"], Convert.ToString(GrLookSku.Value), Convert.ToString(GrLookSku.Text), Convert.ToInt32(SpinSku.Number), Session["connectionString"].ToString());
                            Session["UPDATE_TEMP"] = "false";

                            Session["EXPECTED"] = Convert.ToInt32(SpinSku.Number);
                            var pResult  = "";
                            var dsDetail = _wscalled.GetIncomeDetailForIncomeHeader((int)Session["Header"], Session["connectionString"].ToString(), ref pResult);
                            if (pResult == "")
                            {
                                GridReception.DataSource = dsDetail;
                                GridReception.DataBind();
                                Session["dsReception"] = dsDetail;
                            }
                            else
                            {
                                ScriptManager.RegisterStartupScript(this, GetType(), "ErrorText", "CallError('" + pResult + "');", true);
                            }
                        }
                        else
                        {
                            _wscalled.InsertIncomeTemp(Convert.ToString(CbType.Value), Convert.ToString(GrLookProvider.Value), Convert.ToString(GrLookUser.Text), TxtReference.Text, SpinSap.Text, Session["USER"].ToString(), Session["connectionString"].ToString(), DateAssignedDate.Date, Convert.ToInt32(CbPriority.Value));
                            Session["INGRESO_HEADER"] = "TRUE";

                            var dsNumber = _wscalled.GetNumberHeader(Session["connectionString"].ToString());
                            Session["Header"] = Convert.ToInt32(dsNumber.Tables[0].Rows[0]["RECEPTION_HEADER"]);
                            _wscalled.InsertIncomeDetail(Convert.ToInt32(dsNumber.Tables[0].Rows[0]["RECEPTION_HEADER"]), Convert.ToString(GrLookSku.Value), Convert.ToDecimal(SpinSku.Number), Session["connectionString"].ToString(), GrLookSku.Text);
                            var pResult  = "";
                            var dsDetail = _wscalled.GetIncomeDetailForIncomeHeader((int)Session["Header"], Session["connectionString"].ToString(), ref pResult);
                            if (pResult == "")
                            {
                                GridReception.DataSource = dsDetail;
                                GridReception.DataBind();
                                SpinSku.Number         = 0;
                                Session["dsReception"] = dsDetail;
                            }
                            else
                            {
                                ScriptManager.RegisterStartupScript(this, GetType(), "ErrorText", "CallError('" + pResult + "');", true);
                            }
                        }
                    }
                }
                _cs = (string)Session["connectionString"];
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "ErrorText", "CallError('Error: " + ex.Message + "');", true);
            }
            if (!Page.IsPostBack)
            {
                try
                {
                    Session["SAP_RECEPTION_TYPE"]   = null;
                    Session["LIST_DOC_ERP_PICKING"] = null;
                    Session["SAP_RECEPTION_DATA"]   = null;
                    GridSap.DataSource = null;
                    GridSap.DataBind();
                    DateAssignedDate.Date     = DateTime.Today;
                    Session["INGRESO_HEADER"] = "false";
                    Session["SaveReception"]  = "false";
                    Session["dsReception"]    = null;
                    //
                    LlenarListaDocErp();
                    //Carga de Tipos de clasificacion Recepcion
                    GetClassificationReception();
                    //Carga de Proveedores
                    GetProvider("");
                    //Carga de Operadores
                    GetOperator();
                    //Carga de SKU
                    if (Session["SKU"] != null)
                    {
                        var ds = (DataSet)Session["SKU"];
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            GrLookSku.DataSource = ds;
                            GrLookSku.DataBind();
                            Session["SKU"] = ds;
                        }
                    }
                    else
                    {
                        GetSku();
                    }
                }
                catch (Exception ex)
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "ErrorText", "CallError('Error: " + ex.Message + "');", true);
                }
            }
            try
            {
                if (Session["LIST_DOC_ERP_PICKING"] != null)
                {
                    UiListaPedidosErp.DataSource = Session["LIST_DOC_ERP_PICKING"];
                    UiListaPedidosErp.DataBind();
                }

                GetSkuIngrid();
                GrLookUser.DataSource = Session["OPERATOR"];
                GrLookUser.DataBind();
                GrLookProvider.DataSource = Session["PROVIDER"];
                GrLookProvider.DataBind();
                GrLookSku.DataSource = Session["SKU"];
                GrLookSku.DataBind();
                GridReception.DataSource = Session["dsReception"];
                GridReception.DataBind();
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "ErrorText", "CallError('Error: " + ex.Message + "');", true);
            }

            ReportView();
        }