Esempio n. 1
0
        protected void GridAR_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            Idioma = (DataTable)ViewState["TablaIdioma"];
            foreach (GridViewRow Row in GrdDatos.Rows)
            {
                if ((int)ViewState["VblEliMS"] == 0)
                {
                    ImageButton imgD = Row.FindControl("IbtDelete") as ImageButton;
                    if (imgD != null)
                    {
                        Row.Cells[3].Controls.Remove(imgD);
                    }
                }
            }
            foreach (GridViewRow Row in GrdAR.Rows)
            {
                if ((int)ViewState["VblEliMS"] == 0)
                {
                    ImageButton imgD = Row.FindControl("IbtDelete") as ImageButton;
                    if (imgD != null)
                    {
                        Row.Cells[8].Controls.Remove(imgD);
                    }
                }
            }
            if (e.CommandName.Equals("AddNew"))
            {
                string VbMayor, VbSubC, VBQuery;
                VbMayor = (GrdAR.FooterRow.FindControl("DdlMotorPP") as DropDownList).SelectedValue.Trim();
                VbSubC  = (GrdAR.FooterRow.FindControl("DdlSubCPP") as DropDownList).SelectedValue.Trim();
                CultureInfo Culture = new CultureInfo("en-US");
                string      VbTxtCFA, VbTxtCFE, VbTxtCFF, VbTxtLLH, VbTxtLLC;
                double      VbCFA, VbCFE, VbCFF, VbLLH, VbLLC;
                VbTxtCFA = (GrdAR.FooterRow.FindControl("TxtCFAbbrPP") as TextBox).Text.Trim().Equals("") ? "0" : (GrdAR.FooterRow.FindControl("TxtCFAbbrPP") as TextBox).Text.Trim();
                VbCFA    = VbTxtCFA.Length == 0 ? 0 : Convert.ToDouble(VbTxtCFA, Culture);

                VbTxtCFE = (GrdAR.FooterRow.FindControl("TxtCFExtPP") as TextBox).Text.Trim().Equals("") ? "0" : (GrdAR.FooterRow.FindControl("TxtCFExtPP") as TextBox).Text.Trim();
                VbCFE    = VbTxtCFE.Length == 0 ? 0 : Convert.ToDouble(VbTxtCFE, Culture);

                VbTxtCFF = (GrdAR.FooterRow.FindControl("TxtFCFactorPP") as TextBox).Text.Trim().Equals("") ? "0" : (GrdAR.FooterRow.FindControl("TxtFCFactorPP") as TextBox).Text.Trim();
                VbCFF    = VbTxtCFF.Length == 0 ? 0 : Convert.ToDouble(VbTxtCFF, Culture);

                VbTxtLLH = (GrdAR.FooterRow.FindControl("TxtLLHoursPP") as TextBox).Text.Trim().Equals("") ? "0" : (GrdAR.FooterRow.FindControl("TxtLLHoursPP") as TextBox).Text.Trim();
                VbLLH    = VbTxtLLH.Length == 0 ? 0 : Convert.ToDouble(VbTxtLLH, Culture);

                VbTxtLLC = (GrdAR.FooterRow.FindControl("TxtLLCyclesPP") as TextBox).Text.Trim().Equals("") ? "0" : (GrdAR.FooterRow.FindControl("TxtLLCyclesPP") as TextBox).Text.Trim();
                VbLLC    = VbTxtLLC.Length == 0 ? 0 : Convert.ToDouble(VbTxtLLC, Culture);

                if (VbMayor == String.Empty || VbSubC == String.Empty)
                {
                    DataRow[] Result = Idioma.Select("Objeto= 'Mensj01CicDisk'");
                    foreach (DataRow row in Result)
                    {
                        ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('" + row["Texto"].ToString() + "');", true);
                    }                                                                                                                                       //El mayor y el subcomponentes son obligatorios')", true);
                    return;
                }
                Cnx.SelecBD();

                using (SqlConnection sqlCon = new SqlConnection(Cnx.GetConex()))
                {
                    sqlCon.Open();
                    using (SqlTransaction Transac = sqlCon.BeginTransaction())
                    {
                        VBQuery = "EXEC SP_TablasPlantillaM 14, @Myr, @SubC, @Desc,@Usu,'','','','H','INSERT', @ICC, @CFA, @CFE, @CFF, @LLH, @LLC,'01-01-1','02-01-1','03-01-1'";
                        using (SqlCommand sqlCmd = new SqlCommand(VBQuery, sqlCon, Transac))
                        {
                            try
                            {
                                sqlCmd.Parameters.AddWithValue("@Myr", VbMayor);
                                sqlCmd.Parameters.AddWithValue("@SubC", VbSubC);
                                sqlCmd.Parameters.AddWithValue("@Desc", (GrdAR.FooterRow.FindControl("TxtDescPP") as TextBox).Text.Trim());
                                sqlCmd.Parameters.AddWithValue("@ICC", Session["!dC!@"]);
                                sqlCmd.Parameters.AddWithValue("@CFA", VbCFA);
                                sqlCmd.Parameters.AddWithValue("@CFE", VbCFE);
                                sqlCmd.Parameters.AddWithValue("@CFF", VbCFF);
                                sqlCmd.Parameters.AddWithValue("@LLH", VbLLH);
                                sqlCmd.Parameters.AddWithValue("@LLC", VbLLC);
                                sqlCmd.Parameters.AddWithValue("@Usu", Session["C77U"]);
                                var Mensj = sqlCmd.ExecuteScalar();
                                if (!Mensj.ToString().Trim().Equals(""))
                                {
                                    DataRow[] Result = Idioma.Select("Objeto= '" + Mensj.ToString().Trim() + "'");
                                    foreach (DataRow row in Result)
                                    {
                                        Mensj = row["Texto"].ToString().Trim();
                                    }
                                    ScriptManager.RegisterClientScriptBlock(this.UpPnlAF, UpPnlAF.GetType(), "alert", "alert('" + Mensj + "');", true);
                                    Transac.Rollback();
                                    return;
                                }
                                Transac.Commit();
                                BindDataAlaR("");
                            }
                            catch (Exception Ex)
                            {
                                Transac.Rollback();
                                DataRow[] Result = Idioma.Select("Objeto= 'MensErrIng'");
                                foreach (DataRow row in Result)
                                {
                                    ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('" + row["Texto"].ToString() + "');", true);
                                }                                                                                                                                       //Error en el ingreso')", true);
                                string VbcatUs = Session["C77U"].ToString(), VbcatNArc = ViewState["PFileName"].ToString(), VbcatVer = Session["77Version"].ToString(), VbcatAct = Session["77Act"].ToString();
                                Cnx.UpdateErrorV2(VbcatUs, VbcatNArc, "INSERT ALA ROTATORIA", Ex.StackTrace.Substring(Ex.StackTrace.Length - 300, 300), Ex.Message, VbcatVer, VbcatAct);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        protected void GrdDatos_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            Idioma = (DataTable)ViewState["TablaIdioma"];
            foreach (GridViewRow Row in GrdDatos.Rows)
            {
                if ((int)ViewState["VblEliMS"] == 0)
                {
                    ImageButton imgD = Row.FindControl("IbtDelete") as ImageButton;
                    if (imgD != null)
                    {
                        Row.Cells[3].Controls.Remove(imgD);
                    }
                }
            }
            foreach (GridViewRow Row in GrdAR.Rows)
            {
                if ((int)ViewState["VblEliMS"] == 0)
                {
                    ImageButton imgD = Row.FindControl("IbtDelete") as ImageButton;
                    if (imgD != null)
                    {
                        Row.Cells[8].Controls.Remove(imgD);
                    }
                }
            }
            if (e.CommandName.Equals("AddNew"))
            {
                string VbMayor, VbSubC, VBQuery;
                VbMayor = (GrdDatos.FooterRow.FindControl("DdlMotorPP") as DropDownList).SelectedValue.Trim();
                VbSubC  = (GrdDatos.FooterRow.FindControl("DdlSubCPP") as DropDownList).SelectedValue.Trim();
                CultureInfo Culture = new CultureInfo("en-US");
                string      VbTxtVlr;
                double      VbVlr;
                VbTxtVlr = (GrdDatos.FooterRow.FindControl("TxtCiclosPP") as TextBox).Text.Trim().Equals("") ? "0" : (GrdDatos.FooterRow.FindControl("TxtCiclosPP") as TextBox).Text.Trim();
                VbVlr    = VbTxtVlr.Length == 0 ? 0 : Convert.ToDouble(VbTxtVlr, Culture);

                if (VbMayor == String.Empty || VbSubC == String.Empty)
                {
                    DataRow[] Result = Idioma.Select("Objeto= 'Mensj01CicDisk'");
                    foreach (DataRow row in Result)
                    {
                        ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('" + row["Texto"].ToString() + "');", true);
                    }                                                                                                                                       //El mayor y el subcomponentes son obligatorios
                    return;
                }
                Cnx.SelecBD();
                using (SqlConnection sqlCon = new SqlConnection(Cnx.GetConex()))
                {
                    sqlCon.Open();
                    using (SqlTransaction Transac = sqlCon.BeginTransaction())
                    {
                        VBQuery = "EXEC SP_TablasPlantillaM 14, @My, @SbC,'', @Us,'','','','A','INSERT', @Valor,0,0,0,0,@ICC,'01-01-1','02-01-1','03-01-1'";
                        using (SqlCommand SC = new SqlCommand(VBQuery, sqlCon, Transac))
                        {
                            try
                            {
                                SC.Parameters.AddWithValue("@My", VbMayor);
                                SC.Parameters.AddWithValue("@SbC", VbSubC);
                                SC.Parameters.AddWithValue("@Us", Session["C77U"]);
                                SC.Parameters.AddWithValue("@Valor", VbVlr);
                                SC.Parameters.AddWithValue("@ICC", Session["!dC!@"]);
                                var Mensj = SC.ExecuteScalar();
                                if (!Mensj.ToString().Trim().Equals(""))
                                {
                                    DataRow[] Result = Idioma.Select("Objeto= '" + Mensj.ToString().Trim() + "'");
                                    foreach (DataRow row in Result)
                                    {
                                        Mensj = row["Texto"].ToString().Trim();
                                    }

                                    ScriptManager.RegisterClientScriptBlock(this.UpPnlAF, UpPnlAF.GetType(), "alert", "alert('" + Mensj + "');", true);
                                    Transac.Rollback();
                                    return;
                                }
                                Transac.Commit();
                                BindDataAlaF("");
                            }
                            catch (Exception Ex)
                            {
                                Transac.Rollback();
                                DataRow[] Result = Idioma.Select("Objeto= 'MensErrIng'");
                                foreach (DataRow row in Result)
                                {
                                    ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('" + row["Texto"].ToString() + "');", true);
                                }                                                                                                                                       //Error en el ingreso')", true);
                                string VbcatUs = Session["C77U"].ToString(), VbcatNArc = ViewState["PFileName"].ToString(), VbcatVer = Session["77Version"].ToString(), VbcatAct = Session["77Act"].ToString();
                                Cnx.UpdateErrorV2(VbcatUs, VbcatNArc, "INSERT AlA FIJA", Ex.StackTrace.Substring(Ex.StackTrace.Length > 300 ? Ex.StackTrace.Length - 300 : 0, 300), Ex.Message, VbcatVer, VbcatAct);
                            }
                        }
                    }/**/
                }
            }
        }

        protected void GrdDatos_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            Idioma = (DataTable)ViewState["TablaIdioma"];
            string VBQuery;

            Cnx.SelecBD();
            using (SqlConnection sqlCon = new SqlConnection(Cnx.GetConex()))
            {
                sqlCon.Open();
                using (SqlTransaction Transac = sqlCon.BeginTransaction())
                {
                    VBQuery = string.Format("EXEC SP_TablasPlantillaM 14,'','','','{0}','','','{1}','A','DELETE',0,0,0,0,0,@ICC,'01-01-1','02-01-1','03-01-1'",
                                            Session["C77U"], GrdDatos.DataKeys[e.RowIndex].Value.ToString());
                    using (SqlCommand SC = new SqlCommand(VBQuery, sqlCon, Transac))
                    {
                        try
                        {
                            SC.Parameters.AddWithValue("@ICC", Session["!dC!@"]);
                            SC.ExecuteNonQuery();
                            Transac.Commit();
                            BindDataAlaF("");
                        }
                        catch (Exception Ex)
                        {
                            Transac.Rollback();
                            DataRow[] Result = Idioma.Select("Objeto= 'MensErrEli'");
                            foreach (DataRow row in Result)
                            {
                                ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('" + row["Texto"].ToString() + "');", true);
                            }                                                                                                                                       //Error en la eliminación')", true);
                            string VbcatUs = Session["C77U"].ToString(), VbcatNArc = ViewState["PFileName"].ToString(), VbcatVer = Session["77Version"].ToString(), VbcatAct = Session["77Act"].ToString();
                            Cnx.UpdateErrorV2(VbcatUs, VbcatNArc, "DELETE AlA FIJA", Ex.StackTrace.Substring(Ex.StackTrace.Length - 300, 300), Ex.Message, VbcatVer, VbcatAct);
                        }
                    }
                }
            }
        }

        protected void GrdDatos_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            Idioma = (DataTable)ViewState["TablaIdioma"];
            DSTDdl = (DataSet)ViewState["DSTDdl"];
            if (e.Row.RowType == DataControlRowType.Footer)
            {
                DropDownList DdlMotorPP = (e.Row.FindControl("DdlMotorPP") as DropDownList);
                DdlMotorPP.DataSource     = DSTDdl.Tables[0];
                DdlMotorPP.DataTextField  = "PN";
                DdlMotorPP.DataValueField = "CodPN";
                DdlMotorPP.DataBind();

                DropDownList DdlSubCPP = (e.Row.FindControl("DdlSubCPP") as DropDownList);
                DdlSubCPP.DataSource     = DSTDdl.Tables[1];
                DdlSubCPP.DataTextField  = "PN";
                DdlSubCPP.DataValueField = "PN";
                DdlSubCPP.DataBind();

                ImageButton IbtAddNew = (e.Row.FindControl("IbtAddNew") as ImageButton);
                DataRow[]   Result    = Idioma.Select("Objeto= 'IbtAddNew'");
                foreach (DataRow row in Result)
                {
                    IbtAddNew.ToolTip = row["Texto"].ToString().Trim();
                }
            }
            if ((e.Row.RowState & DataControlRowState.Edit) > 0)
            {
                DropDownList DdlMotor = (DropDownList)e.Row.FindControl("DdlMotor");
                DdlMotor.DataTextField  = "PN";
                DdlMotor.DataValueField = "CodPN";
                DdlMotor.DataSource     = DSTDdl.Tables[0];
                DdlMotor.DataBind();
                DataRowView dr = e.Row.DataItem as DataRowView;
                DdlMotor.SelectedValue = dr["Engine"].ToString();

                DropDownList DdlSubC = (DropDownList)e.Row.FindControl("DdlSubC");
                DdlSubC.DataTextField  = "PN";
                DdlSubC.DataValueField = "PN";
                DdlSubC.DataSource     = DSTDdl.Tables[1];
                DdlSubC.DataBind();
                DataRowView drSc = e.Row.DataItem as DataRowView;
                DdlSubC.SelectedValue = drSc["PN"].ToString();
            }
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink(GrdDatos, "Select$" + e.Row.RowIndex);
                ImageButton imgD = e.Row.FindControl("IbtDelete") as ImageButton;
                if (imgD != null)
                {
                    DataRow[] Result = Idioma.Select("Objeto='IbtDelete'");
                    foreach (DataRow RowIdioma in Result)
                    {
                        imgD.ToolTip = RowIdioma["Texto"].ToString().Trim();
                    }
                    Result = Idioma.Select("Objeto= 'IbtDeleteOnClick'");
                    foreach (DataRow row in Result)
                    {
                        imgD.OnClientClick = string.Format("return confirm('" + row["Texto"].ToString().Trim() + "');");
                    }
                }
            }/* */
            if ((int)ViewState["VblEliMS"] == 0)
            {
                ImageButton imgD = e.Row.FindControl("IbtDelete") as ImageButton;
                if (imgD != null)
                {
                    e.Row.Cells[3].Controls.Remove(imgD);
                }
            }
        }