コード例 #1
0
        void oBtnDejaTuComengtario_Click(object sender, EventArgs e)
        {
            DBConn oConn = new DBConn();

            try
            {
                if (oConn.Open())
                {
                    oConn.BeginTransaction();
                    StringBuilder oFolder = new StringBuilder();
                    oFolder.Append(Server.MapPath(".")).Append(@"\binary\");

                    ObjectModel          oObjectModel       = new ObjectModel(ref oConn);
                    SysComentarioUsuario oComentarioUsuario = new SysComentarioUsuario(ref oConn);
                    oComentarioUsuario.CodComentario = oObjectModel.getCodeKey("SYS_COMENTARIO_USUARIO");
                    oComentarioUsuario.CodUsuario    = Session["CodUsuarioPerfil"].ToString();
                    oComentarioUsuario.CodUsuarioRel = oIsUsuario.CodUsuario;
                    oComentarioUsuario.IpUsuario     = oWeb.GetIpUsuario();
                    oComentarioUsuario.FecUsuario    = DateTime.Now.ToString();
                    oComentarioUsuario.Comentario    = (Page.FindControl((sender as Button).Attributes["TxtControlID"].Replace("_", "$").ToString()) as TextBox).Text;
                    oComentarioUsuario.Accion        = "CREAR";
                    oComentarioUsuario.Put();
                    oObjectModel = null;
                    if (string.IsNullOrEmpty(oComentarioUsuario.Error))
                    {
                        oConn.Commit();

                        StringBuilder sFile = new StringBuilder();
                        sFile.Append("ComentarioUsuario_").Append(Session["CodUsuarioPerfil"].ToString()).Append(".bin");
                        oComentarioUsuario.CodUsuario = Session["CodUsuarioPerfil"].ToString();
                        oComentarioUsuario.SerializaTblComentarioUsuario(ref oConn, oFolder.ToString(), sFile.ToString());
                        oComentarioUsuario = null;

                        oLog.CodEvtLog = "001";
                        oLog.IdUsuario = oLog.IdUsuario = (!string.IsNullOrEmpty(oIsUsuario.CodUsuario) ? oIsUsuario.CodUsuario : "-1");
                        oLog.ObsLog    = "<COMENTARIOA>" + Session["CodUsuarioPerfil"].ToString();
                        //oLog.putLog();
                    }
                    else
                    {
                        oConn.Rollback();
                    }
                    oConn.Close();
                }
            }
            catch
            {
                if (oConn.bIsOpen)
                {
                    oConn.Rollback();
                    oConn.Close();
                }
            }
            Response.Redirect(".");
        }
コード例 #2
0
ファイル: Usuarios.aspx.cs プロジェクト: netxuz/InternetOEM
        protected void rdUsuarios_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {
            switch (e.CommandName)
            {
            case "cmdEdit":
                string[] cParam = new string[2];
                cParam[0] = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["cod_user"].ToString();
                Response.Redirect(String.Format("Usuario.aspx?CodUsuario={0}", cParam));
                break;

            case "cmdDelete":
                string pCodUsuario = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["cod_user"].ToString();
                DBConn oConn       = new DBConn();
                if (oConn.Open())
                {
                    string sPath = string.Empty;
                    sPath = Server.MapPath(".") + @"\binary\ComentarioUsuario_" + pCodUsuario + ".bin";
                    File.Delete(sPath);
                    SysComentarioUsuario oComentarioUsuario = new SysComentarioUsuario(ref oConn);
                    oComentarioUsuario.CodUsuario = pCodUsuario;
                    oComentarioUsuario.Accion     = "ELIMINAR";
                    oComentarioUsuario.Put();

                    sPath = string.Empty;
                    sPath = Server.MapPath(".") + @"\binary\InfoUsuario_" + pCodUsuario + ".bin";
                    File.Delete(sPath);
                    SyrInfoUsuarios oInfoUsuarios = new SyrInfoUsuarios(ref oConn);
                    oInfoUsuarios.CodUsuario = pCodUsuario;
                    oInfoUsuarios.Accion     = "ELIMINAR";
                    oInfoUsuarios.Put();

                    SyrPerfilesUsuarios oPerfilesUsuarios = new SyrPerfilesUsuarios(ref oConn);
                    oPerfilesUsuarios.CodUsuario = pCodUsuario;
                    oPerfilesUsuarios.Accion     = "ELIMINAR";
                    oPerfilesUsuarios.Put();

                    sPath = string.Empty;
                    sPath = Server.MapPath(".") + @"\binary\RelacionUsuario_" + pCodUsuario + ".bin";
                    File.Delete(sPath);
                    SysRelacionUsuarios oRelacionUsuarios = new SysRelacionUsuarios(ref oConn);
                    oRelacionUsuarios.CodUsuario = pCodUsuario;
                    oRelacionUsuarios.Accion     = "ELIMINAR";
                    oRelacionUsuarios.Put();

                    /* Eliminar referencia de los usuarios con el usuario eliminado */

                    sPath = string.Empty;
                    sPath = Server.MapPath(".") + @"\binary\UserArchivo_" + pCodUsuario + ".bin";
                    File.Delete(sPath);
                    SysArchivosUsuarios oArchivosUsuarios = new SysArchivosUsuarios(ref oConn);
                    oArchivosUsuarios.CodUsuario = pCodUsuario;
                    DataTable dUserFile = oArchivosUsuarios.Get();
                    if (dUserFile != null)
                    {
                        if (dUserFile.Rows.Count > 0)
                        {
                            sPath = string.Empty;
                            sPath = Server.MapPath(".") + @"\rps_onlineservice\usuarios\usuario_" + pCodUsuario + @"\";
                            foreach (DataRow oRow in dUserFile.Rows)
                            {
                                sPath = sPath + oRow["nom_archivo"].ToString();
                                File.Delete(sPath);
                            }
                        }
                    }
                    dUserFile = null;
                    oArchivosUsuarios.Accion = "ELIMINAR";
                    oArchivosUsuarios.Put();

                    sPath = string.Empty;
                    sPath = Server.MapPath(".") + @"\binary\Usuario_" + pCodUsuario + ".bin";
                    File.Delete(sPath);
                    SysUsuario oUsuario = new SysUsuario(ref oConn);
                    oUsuario.CodUsuario = pCodUsuario;
                    oUsuario.EstUsuario = "E";
                    oUsuario.Accion     = "EDITAR";
                    oUsuario.Put();

                    sPath = string.Empty;
                    sPath = Server.MapPath(".") + @"\binary\";
                    string sFile = "Usuarios.bin";
                    oUsuario.SerializaTblUsuario(ref oConn, sPath, sFile);

                    oConn.Close();
                }
                rdUsuarios.Rebind();
                break;
            }
        }