Esempio n. 1
0
        protected void rlvPeriodos_ItemCommand(object sender, RadListViewCommandEventArgs e)
        {
            if (e.CommandName == "Select")
            {
                RadListViewDataItem item = e.ListViewItem as RadListViewDataItem;
                rlvPeriodos.SelectedItems.Clear();
                item.Selected = true;

                int vIdPeriodoLista = 0;
                if (int.TryParse(item.GetDataKeyValue("ID_PERIODO").ToString(), out vIdPeriodoLista))
                {
                    vIdPeriodo = vIdPeriodoLista;
                }

                //DESACTIVAR BOTONES
                if (e.CommandName == RadListView.SelectCommandName)
                {
                    //no borrar esta parte de codigo, revisar como poder aplicar estas validaíón a los botones
                    //(item.FindControl("btnModificar") as RadButton).Enabled = ContextoUsuario.oUsuario.TienePermiso("J.A.A.B");
                    //(item.FindControl("btnEliminar") as RadButton).Enabled = ContextoUsuario.oUsuario.TienePermiso("J.A.A.C");

                    string vClEstado = (item.GetDataKeyValue("CL_ESTADO_PERIODO").ToString());
                    EstatusBotonesPeriodos((vClEstado.ToUpper() == "CERRADO") ? false : true);
                }
            }
        }
 protected void rlv_ItemCommand(object sender, RadListViewCommandEventArgs e)
 {
     if (e.CommandName == "Select")
     {
         string[] index  = e.CommandArgument.ToString().Split(new char[] { ',' });
         var      button = sender as Button;
         for (int i = 0; i < 12; i++)
         {
             if (int.Parse(index[0].ToString()) == i)
             {
                 DataTable dt4 = FRB.GetInfoPeoByFilterPDF(int.Parse(Request.QueryString["ID"].ToString()), int.Parse(index[0].ToString()));
                 Response.ContentType = "pdf";
                 Response.Clear();
                 Response.AddHeader("content-disposition", "attachment; filename=" + dt4.Rows[0]["name"].ToString() + " " + dt4.Rows[0]["family"].ToString() + " " + "." + dt4.Rows[0]["ext"].ToString());
                 Response.BinaryWrite((byte[])dt4.Rows[0]["scan_document"]);
                 Response.Flush();
                 Response.End();
             }
         }
     }
     if (e.CommandName == "ShowPic")
     {
         string[] index  = e.CommandArgument.ToString().Split(new char[] { ',' });
         var      button = sender as Button;
         for (int i = 0; i < 16; i++)
         {
             if (int.Parse(index[0].ToString()) == i)
             {
                 Response.Redirect("../ShowPicture.aspx?" + "ID" + "=" + int.Parse(Request.QueryString["ID"].ToString()) + "&" + "TypePic" + "=" + int.Parse(index[0].ToString()));
             }
         }
     }
 }
Esempio n. 3
0
        protected void rlvProgramas_ItemCommand(object sender, RadListViewCommandEventArgs e)
        {
            RadListViewDataItem item = e.ListViewItem as RadListViewDataItem;
            int vIdPeriodoLista      = 0;

            if (int.TryParse(item.GetDataKeyValue("ID_PROGRAMA").ToString(), out vIdPeriodoLista))
            {
                CargarDatosDetalle(vIdPeriodoLista);

                //ProgramaNegocio nPrograma = new ProgramaNegocio();
                //SPE_OBTIENE_C_PROGRAMA_Result vPrograma = nPrograma.ObtieneProgramasCapacitacion(pIdPrograma: vIdPeriodoLista).FirstOrDefault();

                //txtClPeriodo.Text = vPrograma.CL_PROGRAMA;
                //txtDsPeriodo.Text = vPrograma.NB_PROGRAMA;
                //txtClEstatus.Text = vPrograma.CL_ESTADO;
                //txtTipo.Text = vPrograma.CL_TIPO_PROGRAMA;
                //txtUsuarioMod.Text = vPrograma.CL_USUARIO_APP_MODIFICA;
                //txtFechaMod.Text = String.Format("{0:dd/MM/yyyy}", vPrograma.FE_MODIFICA);

                //if (vPrograma.DS_NOTAS != null)
                //{
                //    XElement vNotas = XElement.Parse(vPrograma.DS_NOTAS);

                //    if (vNotas != null)
                //    {
                //        string vNotasTexto = validarDsNotas(vNotas.ToString());
                //        txtNotas.InnerHtml = vNotasTexto;
                //    }
                //}
            }
        }
        protected void lstDownload_ItemCommand(object sender, RadListViewCommandEventArgs e)
        {
            if (e.CommandName == "dnlbtnFlv")
            {
                Label  lblterm      = (Label)e.ListViewItem.FindControl("lbl_Term");
                Label  lblClassCode = (Label)e.ListViewItem.FindControl("lbl_ClassCode");
                Label  lblFileDate  = (Label)e.ListViewItem.FindControl("lbl_Date");
                string fd           = lblFileDate.Text.Replace('/', '-');

                SendFileToUser(Server.MapPath("../content/" + lblterm.Text + "/" + lblClassCode.Text + "/" + fd + "/" + "flv.zip"));
                cmnb.InsertIntoStudentLog(Session[sessionNames.userID_StudentOstad].ToString(), DateTime.Now.ToShortTimeString(), int.Parse(Session[sessionNames.appID_StudentOstad].ToString()), 5, lblClassCode.Text + "-" + lblFileDate.Text);
            }
            if (e.CommandName == "dnlbtnavi")
            {
                Label  lblterm      = (Label)e.ListViewItem.FindControl("lbl_Term");
                Label  lblClassCode = (Label)e.ListViewItem.FindControl("lbl_ClassCode");
                Label  lblFileDate  = (Label)e.ListViewItem.FindControl("lbl_Date");
                string fd           = lblFileDate.Text.Replace('/', '-');
                SendFileToUser(Server.MapPath("../content/" + lblterm.Text + "/" + lblClassCode.Text + "/" + fd + "/" + "avi.zip"));
                cmnb.InsertIntoStudentLog(Session[sessionNames.userID_StudentOstad].ToString(), DateTime.Now.ToShortTimeString(), int.Parse(Session[sessionNames.appID_StudentOstad].ToString()), 6, lblClassCode.Text + "-" + lblFileDate.Text);
            }
            if (e.CommandName == "dnlbtnMp3")
            {
                Label  lblterm      = (Label)e.ListViewItem.FindControl("lbl_Term");
                Label  lblClassCode = (Label)e.ListViewItem.FindControl("lbl_ClassCode");
                Label  lblFileDate  = (Label)e.ListViewItem.FindControl("lbl_Date");
                string fd           = lblFileDate.Text.Replace('/', '-');

                SendFileToUser(Server.MapPath("../content/" + lblterm.Text + "/" + lblClassCode.Text + "/" + fd + "/" + "mp3.zip"));
                cmnb.InsertIntoStudentLog(Session[sessionNames.userID_StudentOstad].ToString(), DateTime.Now.ToShortTimeString(), int.Parse(Session[sessionNames.appID_StudentOstad].ToString()), 4, lblClassCode.Text + "-" + lblFileDate.Text);
            }
        }
    protected void RadListView1_ItemCommand(object sender, RadListViewCommandEventArgs e)
    {
        try
        {
            var RadListView1  = (RadListView)sender;
            var Parent        = RadListView1.NamingContainer;
            var OdsPhotoAlbum = (ObjectDataSource)Parent.FindControl("OdsPhotoAlbum");

            if (e.CommandName == "Update")
            {
                var item          = e.ListViewItem;
                var dsUpdateParam = OdsPhotoAlbum.UpdateParameters;

                var strOldImageName = ((HiddenField)e.ListViewItem.FindControl("hdnImageName")).Value;
                var strIsAvailable  = ((CheckBox)item.FindControl("chkAddIsAvailable")).Checked.ToString();

                dsUpdateParam["ImageName"].DefaultValue   = strOldImageName;
                dsUpdateParam["IsAvailable"].DefaultValue = strIsAvailable;
            }
            else if (e.CommandName == "Delete")
            {
                var strOldImageName = ((HiddenField)e.ListViewItem.FindControl("hdnImageName")).Value;
                DeletePhotoAlbum(strOldImageName);
            }
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }
        protected void RadListViewBaseItems_ItemCommand(object sender, RadListViewCommandEventArgs e)
        {
            try
            {
                if (e.CommandName.ToUpper() == "UPDATE")
                {
                    TextBox      Title            = e.ListViewItem.FindControl("txtBoxItemTitle") as TextBox;
                    DropDownList CategoryName     = e.ListViewItem.FindControl("ddlCategory") as DropDownList;
                    TextBox      BaseitemCode     = e.ListViewItem.FindControl("txtBaseItemCode") as TextBox;
                    TextBox      TitleDescription = e.ListViewItem.FindControl("txtBoxTitleDesc") as TextBox;
                    TextBox      Description      = e.ListViewItem.FindControl("txtBoxDesc") as TextBox;
                    TextBox      SubDescription   = e.ListViewItem.FindControl("txtBoxSubDesc") as TextBox;
                    TextBox      ItemAttributes   = e.ListViewItem.FindControl("txtBoxAttributes") as TextBox;

                    BaseItem baseItem = new BaseItem()
                    {
                        BaseItemId               = Convert.ToInt64(e.CommandArgument),
                        BaseItemCode             = BaseitemCode.Text,
                        CategoryId               = Convert.ToInt64(CategoryName.SelectedItem.Value),
                        CategoryName             = CategoryName.SelectedItem.Text,
                        BaseItemTitle            = Title.Text,
                        BaseItemTitleDescription = TitleDescription.Text,
                        BaseItemDescription      = Description.Text,
                        BaseItemSubDescription   = SubDescription.Text,
                        BaseItemAttributes       = ItemAttributes.Text
                    };

                    bool IsSaved = _baseItemManagement.UpdateBaseItem(baseItem);
                    RadListViewBaseItems.DataSource = GetBaseItemsDataSource();
                    RadListViewBaseItems.DataBind();
                }
                else if (e.CommandName.ToUpper().Equals("DELETE"))
                {
                    string baseItemId = Convert.ToString(e.CommandArgument);
                    Session["DELBASEITEM"] = baseItemId;
                    radWindowManager.RadConfirm("Are you sure you want to delete this base item, please confirm?", "confirmCallBackUserFn", 300, 150, null, "Delete Confirmation", baseItemId);
                }
                else if (e.CommandName.ToUpper().Equals("REFRESH"))
                {
                    RadListViewBaseItems.DataSource = null;
                    RadListViewBaseItems.DataSource = GetBaseItemsDataSource();
                    RadListViewBaseItems.DataBind();
                }
                else if (e.CommandName.ToUpper().Equals("INSERT"))
                {
                    string classId    = ddlClass.SelectedItem.Value;
                    string menuTypeId = ddlClass.SelectedItem.Value;
                    string languageId = ddlLanguage.SelectedItem.Value;

                    ScriptManager.RegisterStartupScript(this, this.GetType(), "KEY", "ShowInsertForm(" + classId + "," + menuTypeId + "," + languageId + ");", true);
                }
            }
            catch (Exception ex)
            {
                //write to Elma
                ErrorSignal.FromCurrentContext().Raise(ex);
            }
        }
Esempio n. 7
0
        protected void rlvPeriodos_ItemCommand(object sender, RadListViewCommandEventArgs e)
        {
            if (e.CommandName == "Select")
            {
                RadListViewDataItem item = e.ListViewItem as RadListViewDataItem;
                //rlvPeriodos.SelectedItems.Clear();
                //item.Selected = true;

                int vIdPeriodoLista = 0;
                if (int.TryParse(item.GetDataKeyValue("ID_PERIODO").ToString(), out vIdPeriodoLista))
                {
                    vIdPeriodo = vIdPeriodoLista;
                }

                CargarDatosDetalle(vIdPeriodo);

                PeriodoNegocio nPeriodo = new PeriodoNegocio();

                vCuestionarios = nPeriodo.ObtieneEvaluadosCuestionarios((int)vIdPeriodo, ContextoUsuario.oUsuario.ID_EMPRESA, null).Count;
                //PeriodoNegocio nPeriodo = new PeriodoNegocio();
                //SPE_OBTIENE_FYD_PERIODOS_EVALUACION_Result vPeriodo = nPeriodo.ObtienePeriodosEvaluacion(pIdPeriodo: vIdPeriodo).FirstOrDefault();

                //txtClPeriodo.Text = vPeriodo.CL_PERIODO;
                //txtDsPeriodo.Text = vPeriodo.DS_PERIODO;
                //txtClEstatus.Text = vPeriodo.CL_ESTADO_PERIODO;
                //txtTipoEval.Text = ObtieneTiposEvaluacion(vPeriodo);
                //txtUsuarioMod.Text = vPeriodo.CL_USUARIO_APP_MODIFICA;
                //txtFechaMod.Text = String.Format("{0:dd/MM/yyyy}", vPeriodo.FE_MODIFICA);

                //if (vPeriodo.DS_NOTAS != null)
                //{
                //    XElement vNotas = XElement.Parse(vPeriodo.DS_NOTAS);

                //    if (vNotas != null)
                //    {
                //        string vNotasTexto = validarDsNotas(vNotas.ToString());
                //        txtNotas.InnerHtml = vNotasTexto;
                //    }
                //}

                //rlvPeriodos.SelectedItemTemplate = null;

                //DESACTIVAR BOTONES
                //if (e.CommandName == RadListView.SelectCommandName)
                //{
                //no borrar esta parte de codigo, revisar como poder aplicar estas validaíón a los botones
                //(item.FindControl("btnModificar") as RadButton).Enabled = ContextoUsuario.oUsuario.TienePermiso("J.A.A.B");
                //(item.FindControl("btnEliminar") as RadButton).Enabled = ContextoUsuario.oUsuario.TienePermiso("J.A.A.C");

                string vClEstado = (item.GetDataKeyValue("CL_ESTADO_PERIODO").ToString());
                EstatusBotonesPeriodos((vClEstado.ToUpper() == "CERRADO") ? false : true, vCuestionarios > 0? true:false);
                //}
            }
        }
Esempio n. 8
0
    void ImagesListView_ItemDeleting(object sender, RadListViewCommandEventArgs e)
    {
        RadListViewDataItem deletedItem = e.ListViewItem as RadListViewDataItem;
        int imageId = Convert.ToInt32(deletedItem.GetDataKeyValue("ID").ToString());
        DataContext.Image image = (from i in context.Images
                                   where i.ID == imageId
                                   select i).First();

        context.Images.DeleteOnSubmit(image);
        context.SubmitChanges();
    }
Esempio n. 9
0
    void ImagesListView_ItemCommand(object sender, RadListViewCommandEventArgs e)
    {
        if (e.CommandName == "DownloadAllAsZip")
        {
            RadListViewDataItem item = ListViewAlbums.SelectedItems[0];
            int    parentID          = Convert.ToInt32(item.GetDataKeyValue("ID").ToString());
            string albumName         = item.GetDataKeyValue("Name").ToString();
            List <DataContext.Image> allImagesFromAlbum = (from a in context.Images
                                                           where a.AlbumID == parentID
                                                           select a).ToList();

            MemoryStream memStream = new MemoryStream();

            Package = ZipPackage.Create(memStream);

            foreach (var image in allImagesFromAlbum)
            {
                Stream stream = new MemoryStream(image.Data);
                Package.AddStream(stream, image.FileName);
            }

            Package.Close(false);

            memStream.Position = 0;

            if (memStream != null && memStream.Length > 0)
            {
                Response.Clear();
                Response.AddHeader("content-disposition", "attachment; filename=" + albumName + ".zip");
                Response.ContentType = "application/zip";
                Response.BinaryWrite(memStream.ToArray());
                Response.End();
            }
        }
        if (e.CommandName == "DownloadImage")
        {
            RadListViewDataItem item = e.ListViewItem as RadListViewDataItem;
            int imageID             = Convert.ToInt32(item.GetDataKeyValue("ID").ToString());
            DataContext.Image image = (from i in context.Images
                                       where i.ID == imageID
                                       select i).First();
            byte[] data = image.Data;
            string name = image.FileName;

            if (data != null && data.Length > 0)
            {
                Response.Clear();
                Response.ContentType = "application/octet-stream";
                Response.AddHeader("content-disposition", "attachment; filename=" + name);
                Response.BinaryWrite(data);
                Response.End();
            }
        }
    }
Esempio n. 10
0
    void ImagesListView_ItemDeleting(object sender, RadListViewCommandEventArgs e)
    {
        RadListViewDataItem deletedItem = e.ListViewItem as RadListViewDataItem;
        int imageId = Convert.ToInt32(deletedItem.GetDataKeyValue("ID").ToString());

        DataContext.Image image = (from i in context.Images
                                   where i.ID == imageId
                                   select i).First();

        context.Images.DeleteOnSubmit(image);
        context.SubmitChanges();
    }
Esempio n. 11
0
        protected void RadListView1_ItemCommand(object sender, RadListViewCommandEventArgs e)
        {
            int id = Convert.ToInt32(e.CommandArgument.ToString());

            if (e.CommandName.ToString() == "Delete")
            {
                ImgModel img = new ImgModel();
                img = ImgList.Where(x => x.ID == id).SingleOrDefault();
                ImgList.Remove(img);
                RadListView1.Rebind();
            }
        }
Esempio n. 12
0
    void ListViewAlbums_ItemUpdating(object sender, RadListViewCommandEventArgs e)
    {
        var   dataItem = e.ListViewItem as RadListViewDataItem;
        int   albumID  = Convert.ToInt32(dataItem.GetDataKeyValue("ID").ToString());
        Album album    = (from a in context.Albums
                          where a.ID == albumID
                          select a).First();

        UpdateAlbum(e, album);

        context.SubmitChanges();
    }
Esempio n. 13
0
 /// <summary>
 /// This Command is actívate when one ítems is selected or deselected
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void abc_ItemCommand(object sender, RadListViewCommandEventArgs e)
 {
     if (e.CommandName.Equals("Deselect"))
     {
         var item         = e.ListViewItem;
         var selectbutton = (LinkButton)item.FindControl("SelectButton");
     }
     else if (e.CommandName.Equals("Select"))
     {
         var item         = e.ListViewItem;
         var selectbutton = (LinkButton)item.FindControl("SelectButton");
     }
 }
Esempio n. 14
0
        protected void rlvPeriodos_ItemCommand(object sender, RadListViewCommandEventArgs e)
        {
            if (e.CommandName == "Select")
            {
                RadListViewDataItem item = e.ListViewItem as RadListViewDataItem;
                rlvPeriodos.SelectedItems.Clear();
                item.Selected = true;

                int vIdPeriodoLista = 0;
                if (int.TryParse(item.GetDataKeyValue("ID_PERIODO").ToString(), out vIdPeriodoLista))
                {
                    vIdPeriodo = vIdPeriodoLista;
                }

                CargarDatosDetalle(vIdPeriodo);

                PeriodoDesempenoNegocio nPeriodo = new PeriodoDesempenoNegocio();
                var vFgConfigurado = nPeriodo.VerificaConfiguracion(vIdPeriodo).FirstOrDefault();

                //PeriodoDesempenoNegocio nPeriodo = new PeriodoDesempenoNegocio();
                //SPE_OBTIENE_EO_PERIODOS_DESEMPENO_Result  vPeriodo = nPeriodo.ObtienePeriodosDesempeno(pIdPeriodo: vIdPeriodo).FirstOrDefault();

                //txtClPeriodo.Text = vPeriodo.CL_PERIODO;
                //txtDsPeriodo.Text = vPeriodo.DS_PERIODO;
                //txtClEstatus.Text = vPeriodo.CL_ESTADO_PERIODO;
                //txtTipo.Text = vPeriodo.CL_ORIGEN_CUESTIONARIO;
                //txtUsuarioMod.Text = vPeriodo.CL_USUARIO_APP_MODIFICA;
                //txtFechaMod.Text = String.Format("{0:dd/MM/yyyy}", vPeriodo.FE_MODIFICA);


                //if (vPeriodo.DS_NOTAS != null)
                //{
                //    XElement vNotas = XElement.Parse(vPeriodo.DS_NOTAS);

                //    if (vNotas != null)
                //    {
                //       string vNotasTexto = validarDsNotas(vNotas.ToString());
                //       txtNotas.InnerHtml = vNotasTexto;
                //    }
                //}

                //if (e.CommandName == "Select")
                //{
                vIdPeriodo = int.Parse(item.GetDataKeyValue("ID_PERIODO").ToString());
                string vClEstado = (item.GetDataKeyValue("CL_ESTADO_PERIODO").ToString());
                EstatusBotonesPeriodos((vClEstado.ToUpper() == "CERRADO") ? false : true, vFgConfigurado.FG_ESTATUS);

                //}
            }
        }
Esempio n. 15
0
    private static void UpdateAlbum(RadListViewCommandEventArgs e, Album album)
    {
        album.Name        = (e.ListViewItem.FindControl("TextBox1") as TextBox).Text;
        album.Description = (e.ListViewItem.FindControl("TextBox2") as TextBox).Text;
        RadAsyncUpload uploadThumbnail = (e.ListViewItem.FindControl("RadAsyncUpload1") as RadAsyncUpload);

        if (uploadThumbnail.UploadedFiles.Count > 0)
        {
            UploadedFile file          = uploadThumbnail.UploadedFiles[0];
            byte[]       thumbnailData = new byte[file.InputStream.Length];
            file.InputStream.Read(thumbnailData, 0, (int)file.InputStream.Length);

            album.Thumbnail = thumbnailData;
        }
    }
Esempio n. 16
0
        //hide button if qty of redeem item is 0
        protected void GoClaimsBut_Command(object sender, RadListViewCommandEventArgs e)
        {
            RadListViewDataItem item = e.ListViewItem as RadListViewDataItem;
            int rewardid             = (int)item.GetDataKeyValue("rewardid");
            int promotionid          = (int)item.GetDataKeyValue("promotionid");

            if ((Request.QueryString["userid"] != null) && (Request.QueryString["clientid"] != null))
            {
                // int rewardid = int.Parse(e.CommandArgument.ToString());
                var reward    = ClientManager.getReward(rewardid);
                var promotion = ClientManager.getPromotion(promotionid);

                //Check logged in first
                if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    //logged in

                    if (promotion.type == (int)PromotionType.BY_POINT)
                    {
                        //go to members screen points
                        Response.Redirect("MemberRedeemByPoints.aspx?rewardid=" + rewardid + "&promotionid=" + promotionid + "&userid=" + Request.QueryString["userid"] + "&clientid=" + Request.QueryString["clientid"]);
                    }
                    if (promotion.type == (int)PromotionType.BY_PRODUCT)
                    {
                        //go to upload receipt to complete the redemption
                        Response.Redirect("MemberRedeemByProduct.aspx?rewardid=" + rewardid + "&promotionid=" + promotionid + "&userid=" + Request.QueryString["userid"] + "&clientid=" + Request.QueryString["clientid"]);
                    }
                }
                else
                {
                    //if (promotion.type == (int)PromotionType.BY_POINT)
                    //{
                    //    //go to members screen points
                    //    //ask user to login or sign up
                    //    Response.Redirect(Config.RootRelativePath + "/login.aspx?rewardid=" + rewardid + "&promotionid=" + promotionid);

                    //}
                    //if (promotion.type == (int)PromotionType.BY_PRODUCT)
                    //{
                    //    //go to upload receipt to complete the redemption
                    //    Response.Redirect(Config.RootRelativePath + "/login.aspx?rewardid=" + rewardid + "&promotionid=" + promotionid);
                    //}
                }

                //Response.Redirect("/rewards.aspx?promotionid=" + promotionid.ToString());
            }
        }
Esempio n. 17
0
 protected void radListViewUsers_ItemCommand(object sender, RadListViewCommandEventArgs e)
 {
     if (e.CommandName.ToUpper().Equals("DELETE"))
     {
         string userId = Convert.ToString(e.CommandArgument);
         Session["DELUSERID"] = userId;
         radWindowManager.RadConfirm("Are you sure you want to delete this user, please confirm?", "confirmCallBackUserFn", 300, 150, null, "Delete Confirmation", userId);
     }
     else if (e.CommandName.ToUpper().Equals("REFRESH"))
     {
         radListViewUsers.DataSource = null;
         BindUserList();
     }
     else if (e.CommandName.ToUpper().Equals("INSERT"))
     {
         ScriptManager.RegisterStartupScript(this, this.GetType(), "KEY", "ShowInsertForm();", true);
     }
 }
Esempio n. 18
0
        protected void rlvConsultas_ItemCommand(object sender, RadListViewCommandEventArgs e)
        {
            if (e.CommandName == "Select")
            {
                RadListViewDataItem item = e.ListViewItem as RadListViewDataItem;

                rlvConsultas.SelectedItems.Clear();
                item.Selected = true;

                int vIdConsultaLista = 0;
                if (int.TryParse(item.GetDataKeyValue("ID_TABULADOR").ToString(), out vIdConsultaLista))
                {
                    vIdConsulta = vIdConsultaLista;
                }

                CargarDatosDetalle(vIdConsulta);
                //SPE_OBTIENE_TABULADORES_Result vPeriodo =  nTabulador.ObtenerTabuladores(ID_TABULADOR: vIdConsulta).FirstOrDefault();

                //txtClPeriodo.Text = vPeriodo.CL_TABULADOR;
                //txtDsPeriodo.Text = vPeriodo.NB_TABULADOR;
                //txtClEstatus.Text = vPeriodo.CL_ESTADO;
                //txtTipo.Text = vPeriodo.CL_TIPO_PUESTO;
                //txtUsuarioMod.Text = vPeriodo.CL_USUARIO_APP_MODIFICA;
                //txtFechaMod.Text = String.Format("{0:dd/MM/yyyy}", vPeriodo.FE_ULTIMA_MODIFICACION);
                //txtNotas.Text = vPeriodo.DS_TABULADOR;
                var vVerificaConfiguracion = nTabulador.VerificarTabulador(vIdConsulta).FirstOrDefault();
                if (vVerificaConfiguracion != null)
                {
                    vFgTabuladorConfigurado = (bool)vVerificaConfiguracion.FG_CONFIGURACION;
                }


                //DESACTIVAR BOTONES
                if (e.CommandName == RadListView.SelectCommandName)
                {
                    //    (item.FindControl("btnModificar") as RadButton).Enabled = ContextoUsuario.oUsuario.TienePermiso("K.A.A.B");
                    //    (item.FindControl("btnEliminar") as RadButton).Enabled = ContextoUsuario.oUsuario.TienePermiso("K.A.A.C");

                    string vClEstado = (item.GetDataKeyValue("CL_ESTADO").ToString());
                    EstatusBotonesPeriodos((vClEstado.ToUpper() == "CERRADO") ? false : true, vFgTabuladorConfigurado);
                }
            }
        }
Esempio n. 19
0
    void ImagesListView_ItemUpdating(object sender, RadListViewCommandEventArgs e)
    {
        var dataItem = e.ListViewItem as RadListViewDataItem;
        int imageId = Convert.ToInt32(dataItem.GetDataKeyValue("ID").ToString());
        DataContext.Image image = (from a in context.Images
                                   where a.ID == imageId
                                   select a).First();

        RadAsyncUpload radUpload = (e.ListViewItem.FindControl("RadAsyncUpload1") as RadAsyncUpload);
        if (radUpload.UploadedFiles.Count > 0)
        {
            UploadedFile file = radUpload.UploadedFiles[0];
            byte[] data = new byte[file.InputStream.Length];
            file.InputStream.Read(data, 0, (int)file.InputStream.Length);

            image.Data = data;

            context.SubmitChanges();
        }
    }
Esempio n. 20
0
    void ListViewAlbums_ItemDeleting(object sender, RadListViewCommandEventArgs e)
    {
        RadListViewDataItem deletedItem = e.ListViewItem as RadListViewDataItem;
        int albumID = Convert.ToInt32(deletedItem.GetDataKeyValue("ID").ToString());
        Album album = (from a in context.Albums
                       where a.ID == albumID
                       select a).First();
        context.Images.DeleteAllOnSubmit(album.Images.ToList());
        context.Albums.DeleteOnSubmit(album);
        context.SubmitChanges();

        RadListViewDataItem selectedItem = ListViewAlbums.SelectedItems[0] as RadListViewDataItem;
        if (deletedItem == selectedItem)
        {
            ListViewAlbums.SelectedIndexes.Clear();
            ListViewAlbums.SelectedIndexes.Add(0);

            ImagesListView.Rebind();
        }
    }
Esempio n. 21
0
    protected void RadListView2_ItemCommand(object sender, RadListViewCommandEventArgs e)
    {
        try
        {
            var RadListView2 = (RadListView)sender;
            if (e.CommandName == "Delete")
            {
                var Parent          = RadListView2.NamingContainer;
                var strOldImageName = ((HiddenField)e.ListViewItem.FindControl("hdnImageName")).Value;
                DeletePhotoAlbum(strOldImageName);

                TempImage.Rows.Cast <DataRow>().Where(c => c["ImageName"].ToString() == strOldImageName).Single().Delete();
                RadListView2.DataSource = TempImage;
                RadListView2.DataBind();
            }
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }
Esempio n. 22
0
    void ImagesListView_ItemUpdating(object sender, RadListViewCommandEventArgs e)
    {
        var dataItem = e.ListViewItem as RadListViewDataItem;
        int imageId  = Convert.ToInt32(dataItem.GetDataKeyValue("ID").ToString());

        DataContext.Image image = (from a in context.Images
                                   where a.ID == imageId
                                   select a).First();

        RadAsyncUpload radUpload = (e.ListViewItem.FindControl("RadAsyncUpload1") as RadAsyncUpload);

        if (radUpload.UploadedFiles.Count > 0)
        {
            UploadedFile file = radUpload.UploadedFiles[0];
            byte[]       data = new byte[file.InputStream.Length];
            file.InputStream.Read(data, 0, (int)file.InputStream.Length);

            image.Data = data;

            context.SubmitChanges();
        }
    }
Esempio n. 23
0
    void ListViewAlbums_ItemDeleting(object sender, RadListViewCommandEventArgs e)
    {
        RadListViewDataItem deletedItem = e.ListViewItem as RadListViewDataItem;
        int   albumID = Convert.ToInt32(deletedItem.GetDataKeyValue("ID").ToString());
        Album album   = (from a in context.Albums
                         where a.ID == albumID
                         select a).First();

        context.Images.DeleteAllOnSubmit(album.Images.ToList());
        context.Albums.DeleteOnSubmit(album);
        context.SubmitChanges();

        RadListViewDataItem selectedItem = ListViewAlbums.SelectedItems[0] as RadListViewDataItem;

        if (deletedItem == selectedItem)
        {
            ListViewAlbums.SelectedIndexes.Clear();
            ListViewAlbums.SelectedIndexes.Add(0);

            ImagesListView.Rebind();
        }
    }
Esempio n. 24
0
        protected void rlvPeriodos_ItemCommand(object sender, RadListViewCommandEventArgs e)
        {
            if (e.CommandName == "Select")
            {
                RadListViewDataItem item = e.ListViewItem as RadListViewDataItem;
                rlvPeriodos.SelectedItems.Clear();

                int vIdPeriodoLista = 0;
                if (int.TryParse(item.GetDataKeyValue("ID_PERIODO").ToString(), out vIdPeriodoLista))
                {
                    vIdPeriodo = vIdPeriodoLista;
                }

                TableroControlNegocio nTableroControl = new TableroControlNegocio();
                SPE_OBTIENE_PERIODO_TABLERO_CONTROL_Result vPeriodo = nTableroControl.ObtenerPeriodoTableroControl(pIdPeriodo: vIdPeriodo).FirstOrDefault();

                txtClPeriodo.Text = vPeriodo.CL_PERIODO;
                txtDsPeriodo.Text = vPeriodo.DS_PERIODO;
                txtClEstatus.Text = vPeriodo.CL_ESTADO_PERIODO;
                //txtTipo.Text = vPeriodo.CL_TIPO_PUESTO;
                txtUsuarioMod.Text = vPeriodo.CL_USUARIO_APP_MODIFICA;
                txtFechaMod.Text   = String.Format("{0:dd/MM/yyyy}", vPeriodo.FE_MODIFICA);
            }
        }
Esempio n. 25
0
    protected void RadListView1_ItemCommand(object sender, RadListViewCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "PerformInsert" || e.CommandName == "Update")
            {
                var item = e.ListViewItem;
                var FileImagePath = (RadUpload)item.FindControl("FileImagePath");
                var FileVideoPath = (RadUpload)item.FindControl("FileVideoPath");

                string strProjectVideoID;
                var strProjectID = Request.QueryString["PI"];
                var strProjectTitle = ((Label)FormView1.FindControl("lblProjectTitle")).Text.Trim();
                var strConvertedProjectTitle = Common.ConvertTitle(strProjectTitle);
                var strImagePath = FileImagePath.UploadedFiles.Count > 0 ? FileImagePath.UploadedFiles[0].GetName() : "";
                var strVideoPath = FileVideoPath.UploadedFiles.Count > 0 ? FileVideoPath.UploadedFiles[0].GetName() : "";
                var strTitle = ((TextBox)item.FindControl("txtTitle")).Text.Trim();
                var strDescription = ((TextBox)item.FindControl("txtDescription")).Text.Trim();
                var strTitleEn = ((TextBox)item.FindControl("txtTitleEn")).Text.Trim();
                var strDescriptionEn = ((TextBox)item.FindControl("txtDescriptionEn")).Text.Trim();
                var strIsAvailable = ((CheckBox)item.FindControl("chkIsAvailable")).Checked.ToString();
                var strPriority = ((RadNumericTextBox)item.FindControl("txtPriority")).Text.Trim();
                var oProjectVideo = new ProjectVideo();

                if (e.CommandName == "PerformInsert")
                {
                    strProjectVideoID = oProjectVideo.ProjectVideoInsert(
                            strTitle,
                            strDescription,
                            strTitleEn,
                            strDescriptionEn,
                            strConvertedProjectTitle,
                            strImagePath,
                            strVideoPath,
                            strProjectID,
                            strIsAvailable,
                            strPriority).ToString();
                    RadListView1.InsertItemPosition = RadListViewInsertItemPosition.None;
                }
                else
                {
                    strProjectVideoID = ((HiddenField)item.FindControl("hdnProjectVideoID")).Value;
                    var strOldImagePath = ((HiddenField)item.FindControl("hdnImagePath")).Value;
                    var strOldVideoPath = ((HiddenField)item.FindControl("hdnProjectVideoPath")).Value;
                    var dsUpdateParam = ObjectDataSource1.UpdateParameters;

                    if (!string.IsNullOrEmpty(strVideoPath))
                    {
                        strOldVideoPath = Server.MapPath("~/res/project/video/" + strOldVideoPath);
                        if (File.Exists(strOldVideoPath))
                            File.Delete(strOldVideoPath);
                    }
                    if (!string.IsNullOrEmpty(strImagePath))
                    {
                        strOldImagePath = Server.MapPath("~/res/project/video/thumbs/" + strOldImagePath);
                        if (File.Exists(strOldImagePath))
                            File.Delete(strOldImagePath);
                    }

                    dsUpdateParam["ImagePath"].DefaultValue = strImagePath;
                    dsUpdateParam["ProjectVideoPath"].DefaultValue = strVideoPath;
                    dsUpdateParam["ConvertedTitle"].DefaultValue = strConvertedProjectTitle;
                }


                string strFullVideoPath = "~/res/project/video/" + (string.IsNullOrEmpty(strConvertedProjectTitle) ? "" : strConvertedProjectTitle + "-") + strProjectVideoID + Path.GetExtension(strVideoPath);
                string strFullImagePath = "~/res/project/video/thumbs/" + (string.IsNullOrEmpty(strConvertedProjectTitle) ? "" : strConvertedProjectTitle + "-") + strProjectVideoID + Path.GetExtension(strImagePath);

                if (!string.IsNullOrEmpty(strVideoPath))
                {
                    FileVideoPath.UploadedFiles[0].SaveAs(Server.MapPath(strFullVideoPath));
                }
                if (!string.IsNullOrEmpty(strImagePath))
                {
                    FileImagePath.UploadedFiles[0].SaveAs(Server.MapPath(strFullImagePath));
                    ResizeCropImage.ResizeByCondition(strFullImagePath, 600, 600);
                }
            }
            else if (e.CommandName == "Delete")
            {
                var strOldImagePath = ((HiddenField)e.ListViewItem.FindControl("hdnImagePath")).Value;
                DeleteImage(strOldImagePath);
            }
            else if (e.CommandName == "QuickUpdate")
            {
                string ProjectVideoID, Priority, IsAvailable;
                var oProjectVideo = new ProjectVideo();

                foreach (RadListViewDataItem item in RadListView1.Items)
                {
                    ProjectVideoID = item.GetDataKeyValue("ProjectVideoID").ToString();
                    Priority = ((RadNumericTextBox)item.FindControl("txtPriority")).Text.Trim();
                    IsAvailable = ((CheckBox)item.FindControl("chkIsAvailable")).Checked.ToString();

                    oProjectVideo.ProjectVideoQuickUpdate(
                        ProjectVideoID,
                        IsAvailable,
                        Priority
                    );
                }
            }
            else if (e.CommandName == "DeleteSelected")
            {
                var oProjectVideo = new ProjectVideo();
                string ProjectVideoID, OldImagePath, OldVideoPath;

                foreach (RadListViewDataItem item in RadListView1.Items)
                {
                    var chkSelect = (CheckBox)item.FindControl("chkSelect");

                    if (chkSelect.Checked)
                    {
                        ProjectVideoID = item.GetDataKeyValue("ProjectVideoID").ToString();
                        OldImagePath = ((HiddenField)item.FindControl("hdnImagePath")).Value;
                        OldVideoPath = ((HiddenField)item.FindControl("hdnVideoPath")).Value;

                        DeleteImage(OldImagePath);
                        DeleteVideo(OldVideoPath);
                        oProjectVideo.ProjectVideoDelete(ProjectVideoID);
                    }
                }
            }
            RadListView1.Rebind();
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }
    protected void RadListView2_ItemCommand(object sender, RadListViewCommandEventArgs e)
    {
        try
        {
            var RadListView2 = (RadListView)sender;
            if (e.CommandName == "Delete")
            {
                var Parent = RadListView2.NamingContainer;
                var strOldImageName = ((HiddenField)e.ListViewItem.FindControl("hdnImageName")).Value;
                DeletePhotoAlbum(strOldImageName);

                TempImage.Rows.Cast<DataRow>().Where(c => c["ImageName"].ToString() == strOldImageName).Single().Delete();
                RadListView2.DataSource = TempImage;
                RadListView2.DataBind();
            }
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }
    protected void RadListView1_ItemCommand(object sender, RadListViewCommandEventArgs e)
    {
        try
        {
            var RadListView1 = (RadListView)sender;
            var Parent = RadListView1.NamingContainer;
            var OdsProductPhotoAlbum = (ObjectDataSource)Parent.FindControl("OdsProductPhotoAlbum");

            if (e.CommandName == "Update")
            {
                var item = e.ListViewItem;
                var dsUpdateParam = OdsProductPhotoAlbum.UpdateParameters;

                var strOldImageName = ((HiddenField)e.ListViewItem.FindControl("hdnImageName")).Value;
                var strIsAvailable = ((CheckBox)item.FindControl("chkAddIsAvailable")).Checked.ToString();

                dsUpdateParam["ImageName"].DefaultValue = strOldImageName;
                dsUpdateParam["IsAvailable"].DefaultValue = strIsAvailable;
            }
            else if (e.CommandName == "Delete")
            {
                var strOldImageName = ((HiddenField)e.ListViewItem.FindControl("hdnImageName")).Value;
                DeletePhotoAlbum(strOldImageName);
            }

            //var RadListView1 = (RadListView)sender;
            //var Parent = RadListView1.NamingContainer;
            //var OdsProductPhotoAlbum = (ObjectDataSource)Parent.FindControl("OdsProductPhotoAlbum");

            //if (e.CommandName == "Update")
            //{
            //    var item = e.ListViewItem;
            //    var FileImageName = (RadUpload)item.FindControl("FileImageName");
            //    var dsUpdateParam = OdsProductPhotoAlbum.UpdateParameters;

            //    var strOldImageName = ((HiddenField)e.ListViewItem.FindControl("hdnImageName")).Value;
            //    var strIsAvailable = ((CheckBox)item.FindControl("chkAddIsAvailable")).Checked.ToString();
            //    string strImageName = FileImageName.UploadedFiles.Count > 0 ? Guid.NewGuid().GetHashCode().ToString("X") + "." + FileImageName.UploadedFiles[0].GetExtension() : strOldImageName;

            //    dsUpdateParam["ImageName"].DefaultValue = strImageName;
            //    dsUpdateParam["IsAvailable"].DefaultValue = strIsAvailable;

            //    if (!string.IsNullOrEmpty(strImageName))
            //    {
            //        var strOldImagePath = Server.MapPath("~/res/product/album/" + strOldImageName);
            //        var strOldThumbImagePath = Server.MapPath("~/res/product/album/thumbs/" + strOldImageName);

            //        if (File.Exists(strOldImagePath))
            //            File.Delete(strOldImagePath);
            //        if (File.Exists(strOldThumbImagePath))
            //            File.Delete(strOldThumbImagePath);

            //        string strFullPath = "~/res/product/album/" + strImageName;

            //        FileImageName.UploadedFiles[0].SaveAs(Server.MapPath(strFullPath));
            //        ResizeCropImage.ResizeByCondition(strFullPath, 800, 800);
            //        ResizeCropImage.CreateThumbNailByCondition("~/res/product/album/", "~/res/product/album/thumbs/", strImageName, 120, 120);
            //    }
            //}
            //else if (e.CommandName == "Delete")
            //{
            //    var strOldImageName = ((HiddenField)e.ListViewItem.FindControl("hdnImageName")).Value;
            //    DeletePhotoAlbum(strOldImageName);
            //}


        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }
Esempio n. 28
0
 protected void EvaluationTemplateItemCommand(object o, RadListViewCommandEventArgs e)
 {
 }
Esempio n. 29
0
        protected void GoEventsBut_Command(object sender, RadListViewCommandEventArgs e)
        {
            string url = e.CommandArgument.ToString();

            Response.Redirect(url);
        }
Esempio n. 30
0
        protected void rdFriendUser_ItemCommand(object sender, RadListViewCommandEventArgs e)
        {
            if (e.ListViewItem is RadListViewDataItem)
            {
                RadListViewDataItem dataItem = (RadListViewDataItem)e.ListViewItem;
                if (e.CommandName == "GOPROFILE")
                {
                    string    cPath  = Server.MapPath(".");
                    DataTable oNodos = oWeb.DeserializarTbl(cPath, "Nodos.bin");
                    if (oNodos != null)
                    {
                        if (oNodos.Rows.Count > 0)
                        {
                            DataRow[] oRow = oNodos.Select(" pf_nodo = 'V' ");
                            if (oRow != null)
                            {
                                if (oRow.Count() > 0)
                                {
                                    Session["CodNodo"]          = oRow[0]["cod_nodo"].ToString();
                                    Session["CodUsuarioPerfil"] = dataItem.GetDataKeyValue("cod_usuario_rel").ToString();
                                }
                            }
                            oRow = null;
                        }
                    }
                    oNodos = null;
                }
                if (e.CommandName == "GODELFRIEND")
                {
                    SysRelacionUsuarios oRelacionUsuarios;
                    StringBuilder       oFolder = new StringBuilder();
                    oFolder.Append(Server.MapPath(".")).Append(@"\binary\");

                    StringBuilder sFile  = new StringBuilder();
                    StringBuilder sError = new StringBuilder();
                    DBConn        oConn  = new DBConn();
                    try
                    {
                        if (oConn.Open())
                        {
                            oConn.BeginTransaction();
                            oRelacionUsuarios               = new SysRelacionUsuarios(ref oConn);
                            oRelacionUsuarios.CodUsuario    = oIsUsuario.CodUsuario;
                            oRelacionUsuarios.CodUsuarioRel = dataItem.GetDataKeyValue("cod_usuario_rel").ToString();
                            oRelacionUsuarios.Accion        = "ELIMINAR";
                            oRelacionUsuarios.Put();
                            sError.Append(oRelacionUsuarios.Error);
                            if (sError.Length == 0)
                            {
                                sFile.Append("RelacionUsuario_").Append(oIsUsuario.CodUsuario).Append(".bin");
                                oRelacionUsuarios.SerializaTblRelacionUsuarios(ref oConn, oFolder.ToString(), sFile.ToString());

                                oRelacionUsuarios.CodUsuarioRel = dataItem.GetDataKeyValue("cod_usuario_rel").ToString();
                                oRelacionUsuarios.CodUsuario    = oIsUsuario.CodUsuario;
                                oRelacionUsuarios.Accion        = "ELIMINAR";
                                oRelacionUsuarios.Put();
                                sError.Append(oRelacionUsuarios.Error);
                                if (sError.Length == 0)
                                {
                                    sFile.Append("RelacionUsuario_").Append(dataItem.GetDataKeyValue("cod_usuario_rel").ToString()).Append(".bin");
                                    oRelacionUsuarios.SerializaTblRelacionUsuarios(ref oConn, oFolder.ToString(), sFile.ToString());
                                }
                            }
                            if (sError.Length == 0)
                            {
                                oConn.Commit();
                            }
                            else
                            {
                                oConn.Rollback();
                            }
                            oConn.Close();
                        }
                    }
                    catch {
                        if (oConn.bIsOpen)
                        {
                            oConn.Rollback();
                            oConn.Close();
                        }
                    }
                }
            }
            Page.Response.Redirect(".");
        }
Esempio n. 31
0
    protected void RadListView1_ItemCommand(object sender, RadListViewCommandEventArgs e)
    {
        try
        {
            var RadListView1         = (RadListView)sender;
            var Parent               = RadListView1.NamingContainer;
            var OdsProductPhotoAlbum = (ObjectDataSource)Parent.FindControl("OdsProductPhotoAlbum");

            if (e.CommandName == "Update")
            {
                var item          = e.ListViewItem;
                var dsUpdateParam = OdsProductPhotoAlbum.UpdateParameters;

                var strOldImageName = ((HiddenField)e.ListViewItem.FindControl("hdnImageName")).Value;
                var strIsAvailable  = ((CheckBox)item.FindControl("chkAddIsAvailable")).Checked.ToString();

                dsUpdateParam["ImageName"].DefaultValue   = strOldImageName;
                dsUpdateParam["IsAvailable"].DefaultValue = strIsAvailable;
            }
            else if (e.CommandName == "Delete")
            {
                var strOldImageName = ((HiddenField)e.ListViewItem.FindControl("hdnImageName")).Value;
                DeletePhotoAlbum(strOldImageName);
            }

            //var RadListView1 = (RadListView)sender;
            //var Parent = RadListView1.NamingContainer;
            //var OdsProductPhotoAlbum = (ObjectDataSource)Parent.FindControl("OdsProductPhotoAlbum");

            //if (e.CommandName == "Update")
            //{
            //    var item = e.ListViewItem;
            //    var FileImageName = (RadUpload)item.FindControl("FileImageName");
            //    var dsUpdateParam = OdsProductPhotoAlbum.UpdateParameters;

            //    var strOldImageName = ((HiddenField)e.ListViewItem.FindControl("hdnImageName")).Value;
            //    var strIsAvailable = ((CheckBox)item.FindControl("chkAddIsAvailable")).Checked.ToString();
            //    string strImageName = FileImageName.UploadedFiles.Count > 0 ? Guid.NewGuid().GetHashCode().ToString("X") + "." + FileImageName.UploadedFiles[0].GetExtension() : strOldImageName;

            //    dsUpdateParam["ImageName"].DefaultValue = strImageName;
            //    dsUpdateParam["IsAvailable"].DefaultValue = strIsAvailable;

            //    if (!string.IsNullOrEmpty(strImageName))
            //    {
            //        var strOldImagePath = Server.MapPath("~/res/product/album/" + strOldImageName);
            //        var strOldThumbImagePath = Server.MapPath("~/res/product/album/thumbs/" + strOldImageName);

            //        if (File.Exists(strOldImagePath))
            //            File.Delete(strOldImagePath);
            //        if (File.Exists(strOldThumbImagePath))
            //            File.Delete(strOldThumbImagePath);

            //        string strFullPath = "~/res/product/album/" + strImageName;

            //        FileImageName.UploadedFiles[0].SaveAs(Server.MapPath(strFullPath));
            //        ResizeCropImage.ResizeByCondition(strFullPath, 800, 800);
            //        ResizeCropImage.CreateThumbNailByCondition("~/res/product/album/", "~/res/product/album/thumbs/", strImageName, 120, 120);
            //    }
            //}
            //else if (e.CommandName == "Delete")
            //{
            //    var strOldImageName = ((HiddenField)e.ListViewItem.FindControl("hdnImageName")).Value;
            //    DeletePhotoAlbum(strOldImageName);
            //}
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }
Esempio n. 32
0
        protected void rlvPeriodos_ItemCommand(object sender, RadListViewCommandEventArgs e)
        {
            if (e.CommandName == "Select")
            {
                RadListViewDataItem item = e.ListViewItem as RadListViewDataItem;
                vIdPeriodo = int.Parse(item.GetDataKeyValue("ID_PERIODO").ToString());

                vFgCuestionariosCreados = bool.Parse(item.GetDataKeyValue("FG_CUESTIONARIOS_CREADOS").ToString());

                CargarDatosDetalle(vIdPeriodo);

                //ClimaLaboralNegocio nPeriodo = new ClimaLaboralNegocio();
                //SPE_OBTIENE_EO_PERIODOS_CLIMA_Result vPeriodo = nPeriodo.ObtienePeriodosClima(pIdPerido: vIdPeriodo).FirstOrDefault();


                //txtClPeriodo.Text = vPeriodo.CL_PERIODO;
                //txtDsPeriodo.Text = vPeriodo.DS_PERIODO;
                //txtClEstatus.Text = vPeriodo.CL_ESTADO_PERIODO;
                //txtTipo.Text = vPeriodo.CL_ORIGEN_CUESTIONARIO;
                //txtUsuarioMod.Text = vPeriodo.CL_USUARIO_APP_MODIFICA;
                //txtFechaMod.Text = String.Format("{0:dd/MM/yyyy}", vPeriodo.FE_MODIFICA);

                //if (vPeriodo.DS_NOTAS != null)
                //{
                //    if (vPeriodo.DS_NOTAS.Contains("DS_NOTA"))
                //    {
                //        txtNotas.InnerHtml = Utileria.MostrarNotas(vPeriodo.DS_NOTAS);
                //    }
                //    else
                //    {
                //        XElement vRequerimientos = XElement.Parse(vPeriodo.DS_NOTAS);
                //        if (vRequerimientos != null)
                //        {
                //            vRequerimientos.Name = vNbFirstRadEditorTagName;
                //            txtNotas.InnerHtml = vRequerimientos.ToString();
                //        }
                //    }
                //}

                //var vPeriodo = vListaPeriodo.Where(w => w.ID_PERIODO == vIdPeriodo).FirstOrDefault();

                //txtDsDescripcion.Text = vPeriodo.DS_PERIODO;
                //txtDsEstado.Text = vPeriodo.CL_ESTADO_PERIODO;
                //// txtDsNotas.Content = vPeriodo.DS_NOTAS;
                //if (vPeriodo.DS_NOTAS != null)
                //{
                //    if (vPeriodo.DS_NOTAS.Contains("DS_NOTA"))
                //    {
                //        txtDsNotas.Content = Utileria.MostrarNotas(vPeriodo.DS_NOTAS);
                //    }
                //    else
                //    {
                //        XElement vRequerimientos = XElement.Parse(vPeriodo.DS_NOTAS);
                //        if (vRequerimientos != null)
                //        {
                //            vRequerimientos.Name = vNbFirstRadEditorTagName;
                //            txtDsNotas.Content = vRequerimientos.ToString();
                //        }
                //    }
                //}

                //DESACTIVAR BOTONES
                string vClEstado = (item.GetDataKeyValue("CL_ESTADO_PERIODO").ToString());
                EstatusBotonesPeriodos((vClEstado.ToUpper() == "CERRADO") ? false : true, vFgCuestionariosCreados);
            }
        }
Esempio n. 33
0
    protected void RadListView1_ItemCommand(object sender, RadListViewCommandEventArgs e)
    {
        try
        {
            var RadListView1 = (RadListView)sender;
            //var Parent = RadListView1.NamingContainer;
            //var OdsProductPhotoAlbum = (ObjectDataSource)Parent.FindControl("OdsProductPhotoAlbum");

            if (e.CommandName == "Update")
            {
                var item          = e.ListViewItem;
                var dsUpdateParam = OdsProductPhotoAlbum.UpdateParameters;

                var strOldImageName = ((HiddenField)item.FindControl("hdnImageName")).Value;
                //var strOldImagePath = Server.MapPath("~/res/productoption/" + strOldImageName);
                //var strOldThumbImagePath = Server.MapPath("~/res/productoption/thumbs/" + strOldImageName);

                //var FileImageName = (RadUpload)item.FindControl("FileImageName");
                //var strImageName = FileImageName.UploadedFiles.Count > 0 ? FileImageName.UploadedFiles[0].GetName() : "";
                //var strImageName = FileImageName.UploadedFiles.Count > 0 ? Guid.NewGuid().GetHashCode().ToString("X") + FileImageName.UploadedFiles[0].GetExtension() : strOldImageName;

                //var strProductOptionTitle = ((RadTextBox)item.FindControl("txtProductOptionTitle")).Text.Trim();
                //var strConvertedProductOptionTitle = Common.ConvertTitle(strProductOptionTitle);
                var strIsAvailable             = ((CheckBox)item.FindControl("chkAddIsAvailable")).Checked.ToString();
                var strProductOptionCategoryID = string.IsNullOrEmpty(Request.QueryString["poi"])
                                                     ? ""
                                                     : Request.QueryString["poi"];

                dsUpdateParam["ImageName"].DefaultValue               = strOldImageName;
                dsUpdateParam["IsAvailable"].DefaultValue             = strIsAvailable;
                dsUpdateParam["ProductOptionCategoryID"].DefaultValue = strProductOptionCategoryID;

                //if (!string.IsNullOrEmpty(strImageName))
                //{
                //    if (File.Exists(strOldImagePath))
                //        File.Delete(strOldImagePath);
                //    if (File.Exists(strOldThumbImagePath))
                //        File.Delete(strOldThumbImagePath);

                //    //strImageName = (string.IsNullOrEmpty(strConvertedProductOptionTitle) ? "" : strConvertedProductOptionTitle + "-") + strProductOptionID + strImageName.Substring(strImageName.LastIndexOf('.'));
                //    //strImageName = Guid.NewGuid().GetHashCode().ToString("X") + FileImageName.UploadedFiles[0].GetExtension();
                //    string strFullPath = "~/res/productoption/" + strImageName;

                //    FileImageName.UploadedFiles[0].SaveAs(Server.MapPath(strFullPath));
                //    string bgColor = "#ffffff";
                //    ResizeCropImage.CreateThumbNailWithBackGroundColor("~/res/productoption/", "~/res/productoption/thumbs/", strImageName, 70, 82, bgColor);
                //    ResizeCropImage.ResizeWithBackGroundColor(strFullPath, 1000, 1182, bgColor);
                //}
                RadListView1.DataBind();
            }
            else if (e.CommandName == "Delete")
            {
                var strOldImageName = ((HiddenField)e.ListViewItem.FindControl("hdnImageName")).Value;
                DeletePhotoAlbum(strOldImageName);
            }
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }
Esempio n. 34
0
    void ImagesListView_ItemCommand(object sender, RadListViewCommandEventArgs e)
    {
        if (e.CommandName == "DownloadAllAsZip")
        {
            RadListViewDataItem item = ListViewAlbums.SelectedItems[0];
            int parentID = Convert.ToInt32(item.GetDataKeyValue("ID").ToString());
            string albumName = item.GetDataKeyValue("Name").ToString();
            List<DataContext.Image> allImagesFromAlbum = (from a in context.Images
                                                          where a.AlbumID == parentID
                                                          select a).ToList();

            MemoryStream memStream = new MemoryStream();

            Package = ZipPackage.Create(memStream);

            foreach (var image in allImagesFromAlbum)
            {
                Stream stream = new MemoryStream(image.Data);
                Package.AddStream(stream, image.FileName);
            }

            Package.Close(false);

            memStream.Position = 0;

            if (memStream != null && memStream.Length > 0)
            {
                Response.Clear();
                Response.AddHeader("content-disposition", "attachment; filename=" + albumName + ".zip");
                Response.ContentType = "application/zip";
                Response.BinaryWrite(memStream.ToArray());
                Response.End();
            }
        }
        if (e.CommandName == "DownloadImage")
        {
            RadListViewDataItem item = e.ListViewItem as RadListViewDataItem;
            int imageID = Convert.ToInt32(item.GetDataKeyValue("ID").ToString());
            DataContext.Image image = (from i in context.Images
                                       where i.ID == imageID
                                       select i).First();
            byte[] data = image.Data;
            string name = image.FileName;

            if (data != null && data.Length > 0)
            {
                Response.Clear();
                Response.ContentType = "application/octet-stream";
                Response.AddHeader("content-disposition", "attachment; filename=" + name);
                Response.BinaryWrite(data);
                Response.End();
            }
        }
    }
Esempio n. 35
0
    private static void UpdateAlbum(RadListViewCommandEventArgs e, Album album)
    {
        album.Name = (e.ListViewItem.FindControl("TextBox1") as TextBox).Text;
        album.Description = (e.ListViewItem.FindControl("TextBox2") as TextBox).Text;
        RadAsyncUpload uploadThumbnail = (e.ListViewItem.FindControl("RadAsyncUpload1") as RadAsyncUpload);

        if (uploadThumbnail.UploadedFiles.Count > 0)
        {
            UploadedFile file = uploadThumbnail.UploadedFiles[0];
            byte[] thumbnailData = new byte[file.InputStream.Length];
            file.InputStream.Read(thumbnailData, 0, (int)file.InputStream.Length);

            album.Thumbnail = thumbnailData;
        }
    }
Esempio n. 36
0
    void ListViewAlbums_ItemUpdating(object sender, RadListViewCommandEventArgs e)
    {
        var dataItem = e.ListViewItem as RadListViewDataItem;
        int albumID = Convert.ToInt32(dataItem.GetDataKeyValue("ID").ToString());
        Album album = (from a in context.Albums
                       where a.ID == albumID
                       select a).First();

        UpdateAlbum(e, album);

        context.SubmitChanges();
    }
Esempio n. 37
0
        protected void RadListView1_ItemCommand(object source, RadListViewCommandEventArgs e)
        {
            if (e.CommandName == "Validate")
            {
                DataTable dttemp = Peerfx_DB.SPs.ViewVerificationMethods().GetDataSet().Tables[0];
                RadListViewDataItem lvdi = (RadListViewDataItem)e.ListViewItem;
                int userkey = Convert.ToInt32(hduserkey.Value);
                int verificationmethod = Convert.ToInt32(dttemp.Rows[lvdi.DataItemIndex]["verification_method_key"]);
                Peerfx_DB.SPs.UpdateVerification(userkey, verificationmethod, true, sitetemp.get_ipaddress(), null).Execute();
                LoadUserProfile(Convert.ToInt32(hduserkey.Value));
                if ((verificationmethod == 2) || (verificationmethod == 3))
                {
                    External_APIs.SendGrid sg = new External_APIs.SendGrid();
                    sg.Send_Email_Verification_Approved(userkey, verificationmethod);

                    if (verificationmethod == 2)
                    {
                        mx.TrackEvent("Verification - Passport ID Confirmed", userkey, null);
                    }
                    else
                    {
                        mx.TrackEvent("Verification - Address Confirmed", userkey, null);
                    }
                }
            }
            else if (e.CommandName == "Reject")
            {
                DataTable dttemp = Peerfx_DB.SPs.ViewVerificationMethods().GetDataSet().Tables[0];
                RadListViewDataItem lvdi = (RadListViewDataItem)e.ListViewItem;
                Peerfx_DB.SPs.UpdateVerification(Convert.ToInt32(hduserkey.Value), Convert.ToInt32(dttemp.Rows[lvdi.DataItemIndex]["verification_method_key"]), false, sitetemp.get_ipaddress(), null).Execute();
                LoadUserProfile(Convert.ToInt32(hduserkey.Value));
            }
        }
Esempio n. 38
0
    protected void RadListView1_ItemCommand(object sender, RadListViewCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "PerformInsert")
            {
                var item          = e.ListViewItem;
                var FileImageName = (RadUpload)item.FindControl("FileImageName");

                var strProductName          = ((Label)FormView1.FindControl("lblProductName")).Text.Trim();
                var strConvertedProductName = Common.ConvertTitle(strProductName);
                var strImageName            = FileImageName.UploadedFiles.Count > 0 ? Guid.NewGuid().GetHashCode().ToString("X") + FileImageName.UploadedFiles[0].GetExtension() : "";
                var strTitle         = ((TextBox)item.FindControl("txtTitle")).Text.Trim();
                var strDescription   = ((TextBox)item.FindControl("txtDescription")).Text.Trim();
                var strTitleEn       = ((TextBox)item.FindControl("txtTitleEn")).Text.Trim();
                var strDescriptionEn = ((TextBox)item.FindControl("txtDescriptionEn")).Text.Trim();
                var IsAvailable      = ((CheckBox)item.FindControl("chkAddIsAvailable")).Checked.ToString();
                var Priority         = ((RadNumericTextBox)item.FindControl("txtPriority")).Text.Trim();
                var oProductImage    = new ProductImage();

                oProductImage.ProductImageInsert(
                    strImageName,
                    strConvertedProductName,
                    strTitle,
                    strDescription,
                    strTitleEn,
                    strDescriptionEn,
                    Request.QueryString["PI"],
                    IsAvailable,
                    Priority);

                string strFullPath = "~/res/product/album/" + strImageName;

                if (!string.IsNullOrEmpty(strImageName))
                {
                    FileImageName.UploadedFiles[0].SaveAs(Server.MapPath(strFullPath));
                    ResizeCropImage.ResizeByCondition(strFullPath, 700, 445);
                    ResizeCropImage.CreateThumbNailByCondition("~/res/product/album/", "~/res/product/album/thumbs/", strImageName, 120, 120);
                }
                RadListView1.InsertItemPosition = RadListViewInsertItemPosition.None;
            }
            else if (e.CommandName == "Update")
            {
                var item          = e.ListViewItem;
                var FileImageName = (RadUpload)item.FindControl("FileImageName");
                var dsUpdateParam = ObjectDataSource1.UpdateParameters;

                var strProductImageID       = ((HiddenField)e.ListViewItem.FindControl("hdnProductImageID")).Value;
                var strProductName          = ((Label)FormView1.FindControl("lblProductName")).Text.Trim();
                var strConvertedProductName = Common.ConvertTitle(strProductName);
                var strOldImageName         = ((HiddenField)e.ListViewItem.FindControl("hdnImageName")).Value;
                var strIsAvailable          = ((CheckBox)item.FindControl("chkAddIsAvailable")).Checked.ToString();
                var strImageName            = FileImageName.UploadedFiles.Count > 0 ? Guid.NewGuid().GetHashCode().ToString("X") + FileImageName.UploadedFiles[0].GetExtension() : "";

                dsUpdateParam["ImageName"].DefaultValue            = !string.IsNullOrEmpty(strImageName) ? strImageName : strOldImageName;
                dsUpdateParam["ConvertedProductName"].DefaultValue = strConvertedProductName;
                dsUpdateParam["IsAvailable"].DefaultValue          = strIsAvailable;

                if (!string.IsNullOrEmpty(strImageName))
                {
                    var strOldImagePath      = Server.MapPath("~/res/product/album/" + strOldImageName);
                    var strOldThumbImagePath = Server.MapPath("~/res/product/album/thumbs/" + strOldImageName);

                    if (File.Exists(strOldImagePath))
                    {
                        File.Delete(strOldImagePath);
                    }
                    if (File.Exists(strOldThumbImagePath))
                    {
                        File.Delete(strOldThumbImagePath);
                    }

                    strImageName = (string.IsNullOrEmpty(strConvertedProductName) ? "" : strConvertedProductName + "-") + strProductImageID + strImageName.Substring(strImageName.LastIndexOf('.'));
                    string strFullPath = "~/res/product/album/" + strImageName;

                    FileImageName.UploadedFiles[0].SaveAs(Server.MapPath(strFullPath));
                    ResizeCropImage.ResizeByCondition(strFullPath, 700, 445);
                    ResizeCropImage.CreateThumbNailByCondition("~/res/product/album/", "~/res/product/album/thumbs/", strImageName, 120, 120);
                }
            }
            else if (e.CommandName == "Delete")
            {
                var strOldImageName = ((HiddenField)e.ListViewItem.FindControl("hdnImageName")).Value;
                DeleteImage(strOldImageName);
            }
            else if (e.CommandName == "QuickUpdate")
            {
                string ProductImageID, Priority, IsAvailable;
                var    oProductImage = new ProductImage();

                foreach (RadListViewDataItem item in RadListView1.Items)
                {
                    ProductImageID = item.GetDataKeyValue("ProductImageID").ToString();
                    Priority       = ((RadNumericTextBox)item.FindControl("txtPriority")).Text.Trim();
                    IsAvailable    = ((CheckBox)item.FindControl("chkIsAvailable")).Checked.ToString();

                    oProductImage.ProductImageQuickUpdate(
                        ProductImageID,
                        IsAvailable,
                        Priority
                        );
                }
            }
            else if (e.CommandName == "DeleteSelected")
            {
                var    oProductImage = new ProductImage();
                string ProductImageID, OldImageName;

                foreach (RadListViewDataItem item in RadListView1.Items)
                {
                    var chkSelect = (CheckBox)item.FindControl("chkSelect");

                    if (chkSelect.Checked)
                    {
                        ProductImageID = item.GetDataKeyValue("ProductImageID").ToString();
                        OldImageName   = ((HiddenField)item.FindControl("hdnImageName")).Value;

                        DeleteImage(OldImageName);
                        oProductImage.ProductImageDelete(ProductImageID);
                    }
                }
            }
            RadListView1.Rebind();
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }
    protected void RadListView1_ItemCommand(object sender, RadListViewCommandEventArgs e)
    {
        try
        {
            var RadListView1 = (RadListView)sender;
            var Parent = RadListView1.NamingContainer;
            var OdsPhotoAlbum = (ObjectDataSource)Parent.FindControl("OdsPhotoAlbum");

            if (e.CommandName == "Update")
            {
                var item = e.ListViewItem;
                var dsUpdateParam = OdsPhotoAlbum.UpdateParameters;

                var strOldImageName = ((HiddenField)e.ListViewItem.FindControl("hdnImageName")).Value;
                var strIsAvailable = ((CheckBox)item.FindControl("chkAddIsAvailable")).Checked.ToString();

                dsUpdateParam["ImageName"].DefaultValue = strOldImageName;
                dsUpdateParam["IsAvailable"].DefaultValue = strIsAvailable;
            }
            else if (e.CommandName == "Delete")
            {
                var strOldImageName = ((HiddenField)e.ListViewItem.FindControl("hdnImageName")).Value;
                DeletePhotoAlbum(strOldImageName);
            }
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }
    protected void RadListView1_ItemCommand(object sender, RadListViewCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "PerformInsert")
            {
                var item = e.ListViewItem;
                var FileImageName = (RadUpload)item.FindControl("FileImageName");

                var strProductName = ((Label)FormView1.FindControl("lblProductName")).Text.Trim();
                var strConvertedProductName = Common.ConvertTitle(strProductName);
                var strImageName = FileImageName.UploadedFiles.Count > 0 ? Guid.NewGuid().GetHashCode().ToString("X") + FileImageName.UploadedFiles[0].GetExtension() : "";
                var strTitle = ((TextBox)item.FindControl("txtTitle")).Text.Trim();
                var strDescription = ((TextBox)item.FindControl("txtDescription")).Text.Trim();
                var strTitleEn = ((TextBox)item.FindControl("txtTitleEn")).Text.Trim();
                var strDescriptionEn = ((TextBox)item.FindControl("txtDescriptionEn")).Text.Trim();
                var IsAvailable = ((CheckBox)item.FindControl("chkAddIsAvailable")).Checked.ToString();
                var Priority = ((RadNumericTextBox)item.FindControl("txtPriority")).Text.Trim();
                var oProductImage = new ProductImage();

                oProductImage.ProductImageInsert(
                    strImageName,
                    strConvertedProductName,
                    strTitle,
                    strDescription,
                    strTitleEn,
                    strDescriptionEn,
                    Request.QueryString["PI"],
                    IsAvailable,
                    Priority);

                string strFullPath = "~/res/product/album/" + strImageName;

                if (!string.IsNullOrEmpty(strImageName))
                {
                    FileImageName.UploadedFiles[0].SaveAs(Server.MapPath(strFullPath));
                    //ResizeCropImage.ResizeByCondition(strFullPath, 600, 600);
                    //ResizeCropImage.CreateThumbNailByCondition("~/res/product/album/", "~/res/product/album/thumbs/", strImageName, 120, 120);
                }
                RadListView1.InsertItemPosition = RadListViewInsertItemPosition.None;
            }
            else if (e.CommandName == "Update")
            {
                var item = e.ListViewItem;
                var FileImageName = (RadUpload)item.FindControl("FileImageName");
                var dsUpdateParam = ObjectDataSource1.UpdateParameters;

                var strProductImageID = ((HiddenField)e.ListViewItem.FindControl("hdnProductImageID")).Value;
                var strProductName = ((Label)FormView1.FindControl("lblProductName")).Text.Trim();
                var strConvertedProductName = Common.ConvertTitle(strProductName);
                var strOldImageName = ((HiddenField)e.ListViewItem.FindControl("hdnImageName")).Value;
                var strIsAvailable = ((CheckBox)item.FindControl("chkAddIsAvailable")).Checked.ToString();
                var strImageName = FileImageName.UploadedFiles.Count > 0 ? Guid.NewGuid().GetHashCode().ToString("X") + FileImageName.UploadedFiles[0].GetExtension() : "";

                dsUpdateParam["ImageName"].DefaultValue = !string.IsNullOrEmpty(strImageName) ? strImageName : strOldImageName;
                dsUpdateParam["ConvertedProductName"].DefaultValue = strConvertedProductName;
                dsUpdateParam["IsAvailable"].DefaultValue = strIsAvailable;
                
                if (!string.IsNullOrEmpty(strImageName))
                {
                    var strOldImagePath = Server.MapPath("~/res/product/album/" + strOldImageName);
                    var strOldThumbImagePath = Server.MapPath("~/res/product/album/thumbs/" + strOldImageName);

                    if (File.Exists(strOldImagePath))
                        File.Delete(strOldImagePath);
                    if (File.Exists(strOldThumbImagePath))
                        File.Delete(strOldThumbImagePath);

                    strImageName = (string.IsNullOrEmpty(strConvertedProductName) ? "" : strConvertedProductName + "-") + strProductImageID + strImageName.Substring(strImageName.LastIndexOf('.'));
                    string strFullPath = "~/res/product/album/" + strImageName;

                    FileImageName.UploadedFiles[0].SaveAs(Server.MapPath(strFullPath));
                    //ResizeCropImage.ResizeByCondition(strFullPath, 600, 600);
                    //ResizeCropImage.CreateThumbNailByCondition("~/res/product/album/", "~/res/product/album/thumbs/", strImageName, 120, 120);
                }
            }
            else if (e.CommandName == "Delete")
            {
                var strOldImageName = ((HiddenField)e.ListViewItem.FindControl("hdnImageName")).Value;
                DeleteImage(strOldImageName);
            }
            else if (e.CommandName == "QuickUpdate")
            {
                string ProductImageID, Priority, IsAvailable;
                var oProductImage = new ProductImage();

                foreach (RadListViewDataItem item in RadListView1.Items)
                {
                    ProductImageID = item.GetDataKeyValue("ProductImageID").ToString();
                    Priority = ((RadNumericTextBox)item.FindControl("txtPriority")).Text.Trim();
                    IsAvailable = ((CheckBox)item.FindControl("chkIsAvailable")).Checked.ToString();

                    oProductImage.ProductImageQuickUpdate(
                        ProductImageID,
                        IsAvailable,
                        Priority
                    );
                }
            }
            else if (e.CommandName == "DeleteSelected")
            {
                var oProductImage = new ProductImage();
                string ProductImageID, OldImageName;

                foreach (RadListViewDataItem item in RadListView1.Items)
                {
                    var chkSelect = (CheckBox)item.FindControl("chkSelect");

                    if (chkSelect.Checked)
                    {
                        ProductImageID = item.GetDataKeyValue("ProductImageID").ToString();
                        OldImageName = ((HiddenField)item.FindControl("hdnImageName")).Value;

                        DeleteImage(OldImageName);
                        oProductImage.ProductImageDelete(ProductImageID);
                    }
                }
            }
            RadListView1.Rebind();
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }
Esempio n. 41
0
        protected void rdUserImage_ItemCommand(object sender, RadListViewCommandEventArgs e)
        {
            try
            {
                if (e.ListViewItem is RadListViewDataItem)
                {
                    StringBuilder sNameFile = new StringBuilder();
                    sNameFile.Append(DateTime.Now.Year.ToString());
                    sNameFile.Append(DateTime.Now.Month.ToString());
                    sNameFile.Append(DateTime.Now.Day.ToString());
                    sNameFile.Append(DateTime.Now.Hour.ToString());
                    sNameFile.Append(DateTime.Now.Minute.ToString());
                    sNameFile.Append(DateTime.Now.Millisecond.ToString());
                    sNameFile.Append(".jpg");

                    RadListViewDataItem dataItem = (RadListViewDataItem)e.ListViewItem;
                    SysArchivosUsuarios oArchivosUsuarios;

                    if (e.CommandName == "IMGPERFIL")
                    {
                        DBConn oConn = new DBConn();
                        if (oConn.Open())
                        {
                            StringBuilder sFile;
                            string        sNomArchivo = string.Empty;

                            oArchivosUsuarios            = new SysArchivosUsuarios(ref oConn);
                            oArchivosUsuarios.CodUsuario = oIsUsuario.CodUsuario;
                            oArchivosUsuarios.TipArchivo = "P";
                            DataTable dFotoPerfil = oArchivosUsuarios.Get();
                            if (dFotoPerfil != null)
                            {
                                if (dFotoPerfil.Rows.Count > 0)
                                {
                                    if (!string.IsNullOrEmpty(dFotoPerfil.Rows[0]["img_profile_archivo"].ToString()))
                                    {
                                        sNomArchivo = dFotoPerfil.Rows[0]["img_profile_archivo"].ToString();
                                        sFile       = new StringBuilder();
                                        sFile.Append(HttpContext.Current.Server.MapPath("."));
                                        sFile.Append(@"\rps_onlineservice\escorts\escort_").Append(oIsUsuario.CodUsuario).Append(@"\");
                                        sFile.Append(sNomArchivo);
                                        if (File.Exists(sFile.ToString()))
                                        {
                                            File.Delete(sFile.ToString());
                                        }
                                    }
                                }
                            }
                            dFotoPerfil = null;

                            oArchivosUsuarios.ImgProfileArchivo = string.Empty;
                            oArchivosUsuarios.Accion            = "EDITAR";
                            oArchivosUsuarios.TipArchivo        = string.Empty;
                            oArchivosUsuarios.Put();

                            oArchivosUsuarios.CodArchivo = dataItem.GetDataKeyValue("cod_archivo").ToString();
                            dFotoPerfil = oArchivosUsuarios.Get();
                            if (dFotoPerfil != null)
                            {
                                if (dFotoPerfil.Rows.Count > 0)
                                {
                                    sNomArchivo = dFotoPerfil.Rows[0]["nom_archivo"].ToString();
                                    sFile       = new StringBuilder();
                                    sFile.Append(HttpContext.Current.Server.MapPath("."));
                                    sFile.Append(@"\rps_onlineservice\escorts\escort_").Append(oIsUsuario.CodUsuario).Append(@"\");
                                    sFile.Append(sNomArchivo);
                                    FileStream fileStream = new FileStream(sFile.ToString(), FileMode.Open);
                                    byte[]     imageData  = GetImageBytes(fileStream);
                                    fileStream.Close();
                                    sFile = new StringBuilder();
                                    sFile.Append(HttpContext.Current.Server.MapPath("."));
                                    sFile.Append(@"\rps_onlineservice\escorts\escort_").Append(oIsUsuario.CodUsuario).Append(@"\");
                                    sFile.Append(sNameFile.ToString());
                                    File.WriteAllBytes(sFile.ToString(), imageData);
                                    oArchivosUsuarios.ImgProfileArchivo = sNameFile.ToString();
                                    oArchivosUsuarios.TipArchivo        = "P";
                                    oArchivosUsuarios.Put();
                                }
                            }
                            dFotoPerfil = null;

                            if (string.IsNullOrEmpty(oArchivosUsuarios.Error))
                            {
                                string cPath           = HttpContext.Current.Server.MapPath(".") + @"\binary\";
                                string sFileUsrArchivo = "UserArchivo_" + oIsUsuario.CodUsuario + ".bin";
                                oArchivosUsuarios.SerializaTblUserArchivo(ref oConn, cPath, sFileUsrArchivo);
                            }

                            oConn.Close();
                        }
                    }

                    if (e.CommandName == "IMGDELETE")
                    {
                        DBConn oConn = new DBConn();
                        if (oConn.Open())
                        {
                            string        sArchivo = string.Empty;
                            StringBuilder sPath    = new StringBuilder();
                            sPath.Append(HttpContext.Current.Server.MapPath("."));
                            sPath.Append(@"\rps_onlineservice\");
                            sPath.Append(@"\escorts\");
                            sPath.Append(@"\escort_");
                            sPath.Append(oIsUsuario.CodUsuario);
                            sPath.Append(@"\");

                            oArchivosUsuarios            = new SysArchivosUsuarios(ref oConn);
                            oArchivosUsuarios.CodUsuario = oIsUsuario.CodUsuario;
                            oArchivosUsuarios.CodArchivo = dataItem.GetDataKeyValue("cod_archivo").ToString();
                            DataTable dArchivosUsuarios = oArchivosUsuarios.Get();
                            if (dArchivosUsuarios != null)
                            {
                                if (dArchivosUsuarios.Rows.Count > 0)
                                {
                                    sArchivo = dArchivosUsuarios.Rows[0]["nom_archivo"].ToString();
                                }
                            }
                            dArchivosUsuarios        = null;
                            oArchivosUsuarios.Accion = "ELIMINAR";
                            oArchivosUsuarios.Put();

                            if (string.IsNullOrEmpty(oArchivosUsuarios.Error))
                            {
                                sPath.Append(sArchivo);
                                File.Delete(sPath.ToString());

                                string cPath           = HttpContext.Current.Server.MapPath(".") + @"\binary\";
                                string sFileUsrArchivo = "UserArchivo_" + oIsUsuario.CodUsuario + ".bin";
                                oArchivosUsuarios.SerializaTblUserArchivo(ref oConn, cPath, sFileUsrArchivo);
                            }

                            oConn.Close();
                        }
                    }
                }
                Response.Redirect(".");
            }
            catch
            {
                //Error:
            }
            rdUserImage.Rebind();
        }
Esempio n. 42
0
        protected void GoRewardsBut_Command(object sender, RadListViewCommandEventArgs e)
        {
            string promotionid = e.CommandArgument.ToString();

            Response.Redirect(Config.RootRelativePath + "/rewards.aspx?promotionid=" + promotionid.ToString());
        }
    protected void RadListView1_ItemCommand(object sender, RadListViewCommandEventArgs e)
    {
        try
        {
            var RadListView1 = (RadListView)sender;
            //var Parent = RadListView1.NamingContainer;
            //var OdsProductPhotoAlbum = (ObjectDataSource)Parent.FindControl("OdsProductPhotoAlbum");

            if (e.CommandName == "Update")
            {
                var item = e.ListViewItem;
                var dsUpdateParam = OdsProductPhotoAlbum.UpdateParameters;

                var strOldImageName = ((HiddenField)item.FindControl("hdnImageName")).Value;
                //var strOldImagePath = Server.MapPath("~/res/productoption/" + strOldImageName);
                //var strOldThumbImagePath = Server.MapPath("~/res/productoption/thumbs/" + strOldImageName);

                //var FileImageName = (RadUpload)item.FindControl("FileImageName");
                //var strImageName = FileImageName.UploadedFiles.Count > 0 ? FileImageName.UploadedFiles[0].GetName() : "";
                //var strImageName = FileImageName.UploadedFiles.Count > 0 ? Guid.NewGuid().GetHashCode().ToString("X") + FileImageName.UploadedFiles[0].GetExtension() : strOldImageName;

                //var strProductOptionTitle = ((RadTextBox)item.FindControl("txtProductOptionTitle")).Text.Trim();
                //var strConvertedProductOptionTitle = Common.ConvertTitle(strProductOptionTitle);
                var strIsAvailable = ((CheckBox)item.FindControl("chkAddIsAvailable")).Checked.ToString();
                var strProductOptionCategoryID = string.IsNullOrEmpty(Request.QueryString["poi"])
                                                     ? ""
                                                     : Request.QueryString["poi"];

                dsUpdateParam["ImageName"].DefaultValue = strOldImageName;
                dsUpdateParam["IsAvailable"].DefaultValue = strIsAvailable;
                dsUpdateParam["ProductOptionCategoryID"].DefaultValue = strProductOptionCategoryID;

                //if (!string.IsNullOrEmpty(strImageName))
                //{
                //    if (File.Exists(strOldImagePath))
                //        File.Delete(strOldImagePath);
                //    if (File.Exists(strOldThumbImagePath))
                //        File.Delete(strOldThumbImagePath);

                //    //strImageName = (string.IsNullOrEmpty(strConvertedProductOptionTitle) ? "" : strConvertedProductOptionTitle + "-") + strProductOptionID + strImageName.Substring(strImageName.LastIndexOf('.'));
                //    //strImageName = Guid.NewGuid().GetHashCode().ToString("X") + FileImageName.UploadedFiles[0].GetExtension();
                //    string strFullPath = "~/res/productoption/" + strImageName;

                //    FileImageName.UploadedFiles[0].SaveAs(Server.MapPath(strFullPath));
                //    string bgColor = "#ffffff";
                //    ResizeCropImage.CreateThumbNailWithBackGroundColor("~/res/productoption/", "~/res/productoption/thumbs/", strImageName, 70, 82, bgColor);
                //    ResizeCropImage.ResizeWithBackGroundColor(strFullPath, 1000, 1182, bgColor);
                //}
                RadListView1.DataBind();
            }
            else if (e.CommandName == "Delete")
            {
                var strOldImageName = ((HiddenField)e.ListViewItem.FindControl("hdnImageName")).Value;
                DeletePhotoAlbum(strOldImageName);
            }
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }