示例#1
0
    protected void btnGuardar_Click(object sender, EventArgs e)
    {
        string cleanMessage = string.Empty;

        if (txtSolped.Text.Trim() == string.Empty)
        {
            cleanMessage = "Ingresar N° SOLPED";
            ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", "doAlert('" + cleanMessage + "');", true);
        }
        else if (txtSolped.Text.Trim().Length < 10)
        {
            cleanMessage = "Falta completar los 10 digitos requeridos para el N° SOLPED";
            ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", "doAlert('" + cleanMessage + "');", true);
        }
        else
        {
            BL_TBL_RequerimientoSubDetalle obj = new BL_TBL_RequerimientoSubDetalle();
            DataTable dtResultado = new DataTable();


            string Requ_Numero      = string.Empty;
            string Reqd_CodLinea    = string.Empty;
            string Reqs_Correlativo = string.Empty;

            int CantidadPos = 0;
            int registros   = 0;
            foreach (GridViewRow row in GridReq.Rows)
            {
                Requ_Numero      = GridReq.DataKeys[row.RowIndex].Values[0].ToString(); // extrae key
                Reqd_CodLinea    = GridReq.DataKeys[row.RowIndex].Values[1].ToString(); // extrae key
                Reqs_Correlativo = GridReq.DataKeys[row.RowIndex].Values[2].ToString(); // extrae key

                TextBox txtPosAlquiler = ((TextBox)row.FindControl("txtPosAlquiler"));
                TextBox txtPosMov      = ((TextBox)row.FindControl("txtPosMov"));

                DropDownList ddlSubFamilia = ((DropDownList)row.FindControl("ddlSubFamilia"));
                DropDownList ddlMarca      = ((DropDownList)row.FindControl("ddlMarca"));
                DropDownList ddlModelo     = ((DropDownList)row.FindControl("ddlModelo"));
                TextBox      txtCapacidad  = ((TextBox)row.FindControl("txtCapacidad"));

                if (txtPosAlquiler.Text.Trim() == string.Empty)
                {
                    CantidadPos++;
                }


                else
                {
                    obj.UPD_SEL_TBL_REQUERIMIENTO_EQUIPO_MAYOR_SOLPED(
                        Requ_Numero, Reqd_CodLinea,
                        Reqs_Correlativo, txtSolped.Text.Trim(),
                        txtPosAlquiler.Text,
                        txtPosMov.Text,
                        ddlSubFamilia.SelectedValue.ToString(),
                        ddlMarca.SelectedValue.ToString(),
                        ddlModelo.SelectedValue.ToString(),
                        txtCapacidad.Text
                        );

                    if (Requ_Numero != string.Empty)
                    {
                        registros++;
                    }
                }
            }


            if (registros > 0)
            {
                string url     = URLSSK;
                string mensaje = "El Sistema de Equipos Menores SSK informa, se asignó el código Solped " + txtSolped.Text + " a los siguientes requerimientos del proyecto ";
                obj.USP_SEL_TBL_REQUERIMIENTO_CORREO_SOLPED_VARIOS(txtSolped.Text, mensaje, "ALQUILER CARE", url);

                txtSolped.Text = string.Empty;

                cleanMessage = "Registro satisfactorio";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", "doAlert('" + cleanMessage + "');", true);
                BL_TBL_RequerimientoSubDetalle Xobj = new BL_TBL_RequerimientoSubDetalle();
                DataTable dt = new DataTable();
                dt = Xobj.LISTAR_GRUPO_LEGAJOFILE(Requ_Numero, Reqd_CodLinea, Reqs_Correlativo, 1);
                dt.Rows.Count.ToString();

                if (dt.Rows.Count > 0)
                {
                    GridReq.DataSource = dt;
                    GridReq.DataBind();
                }
            }
            if (CantidadPos > 0)
            {
                cleanMessage = "Completar todas las posiciones de alquiler";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", "doAlert('" + cleanMessage + "');", true);
            }
        }
    }