Ejemplo n.º 1
0
        protected void btnSaveRefresh_Click(object sender, EventArgs e)
        {
            OperationResult objOperationResult1 = new OperationResult();

            if (Mode == "New")
            {
                var roleNodeComponentProfile = new rolenodecomponentprofileDto();

                roleNodeComponentProfile.i_NodeId      = NodeId;
                roleNodeComponentProfile.i_RoleId      = RoleId;
                roleNodeComponentProfile.v_ComponentId = ddlComponent.SelectedValue;
                roleNodeComponentProfile.i_Read        = Convert.ToInt32(chkRead.Checked);
                roleNodeComponentProfile.i_Write       = Convert.ToInt32(chkWrite.Checked);
                roleNodeComponentProfile.i_Dx          = !chkDx.Enabled ? -1 : Convert.ToInt32(chkDx.Checked);
                roleNodeComponentProfile.i_Approved    = !chkApproved.Enabled ? -1 : Convert.ToInt32(chkApproved.Checked);

                _nodeBL.AddRoleNodeComponentProfile(ref objOperationResult1,
                                                    roleNodeComponentProfile,
                                                    ((ClientSession)Session["objClientSession"]).GetAsList());


                if (objOperationResult1.ErrorMessage != null)
                {
                    Alert.ShowInTop(string.Format("<font color='red'> {0} </font> ya se encuentra registrado. Por favor elija otro.", ddlComponent.SelectedText));
                    return;
                }

                if (objOperationResult1.Success != 1)
                {
                    Alert.ShowInTop("Error en operación:" + System.Environment.NewLine + objOperationResult1.ExceptionMessage);
                    return;
                }
            }
            else if (Mode == "Edit")
            {
                var roleNodeComponentProfile = Session["sroleNodeComponentProfile"] as rolenodecomponentprofileDto;

                roleNodeComponentProfile.v_RoleNodeComponentId = RoleNodeComponentId;
                roleNodeComponentProfile.i_Read     = Convert.ToInt32(chkRead.Checked);
                roleNodeComponentProfile.i_Write    = Convert.ToInt32(chkWrite.Checked);
                roleNodeComponentProfile.i_Dx       = !chkDx.Enabled ? -1 : Convert.ToInt32(chkDx.Checked);
                roleNodeComponentProfile.i_Approved = !chkApproved.Enabled ? -1 : Convert.ToInt32(chkApproved.Checked);

                _nodeBL.UpdateRoleNodeComponentProfile(ref objOperationResult1,
                                                       roleNodeComponentProfile,
                                                       ((ClientSession)Session["objClientSession"]).GetAsList());

                if (objOperationResult1.Success != 1)
                {
                    Alert.ShowInTop("Error en operación:" + System.Environment.NewLine + objOperationResult1.ExceptionMessage);
                    return;
                }
            }

            // Cerrar página actual y hacer postback en el padre para actualizar
            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
        }