Beispiel #1
0
 protected void btnSaveChanges_Click(object sender, EventArgs e)
 {
     try
     {
         Int64 albumID = BAYMYO.UI.Converts.NullToInt64(Request.QueryString["raid"]);
         if (ddlIslemler.SelectedIndex > 0 & albumID > 0)
         {
             if (ddlIslemler.SelectedIndex == 1)
             {
                 foreach (GridViewRow item in dataGrid1.Rows)
                 {
                     if (((CheckBox)item.Cells[0].FindControl("chkSelected")).Checked)
                     {
                         GaleriMethods.Update(albumID);
                         Core.Update("galeri", "kapak", BAYMYO.UI.Converts.NullToGuidString(dataGrid1.DataKeys[item.RowIndex][0]), true);
                         break;
                     }
                 }
             }
             else if (ddlIslemler.SelectedIndex == 2)
             {
                 foreach (GridViewRow item in dataGrid1.Rows)
                 {
                     if (((CheckBox)item.Cells[0].FindControl("chkSelected")).Checked)
                     {
                         if (BAYMYO.UI.FileIO.Remove(Server.MapPath(Settings.ImagesPath + "album/" + albumID + "/" + dataGrid1.DataKeys[item.RowIndex][1].ToString())))
                         {
                             GaleriMethods.Delete(BAYMYO.UI.Converts.NullToGuidString(dataGrid1.DataKeys[item.RowIndex][0]));
                         }
                     }
                 }
             }
             Core.CreateContents("galeri");
             GetDataPaging(albumID);
         }
     }
     catch (Exception ex)
     {
         CustomizeControl1.MessageText = MessageBox.Show(DialogResult.Error, ex.Message);
     }
 }
Beispiel #2
0
        void CustomizeControl1_SubmitClick(SortedDictionary <string, Control> controls)
        {
            try
            {
                bool IsInsert = false;
                if (!string.IsNullOrEmpty(((TextBox)controls["Adi"]).Text)
                    & ((DropDownList)controls["Kategori"]).SelectedIndex > 0)
                {
                    using (Album m = AlbumMethods.GetAlbum(BAYMYO.UI.Converts.NullToInt64(Request.QueryString["raid"])))
                    {
                        m.Adi              = ((TextBox)controls["Adi"]).Text.Trim();
                        m.Etiket           = ((TextBox)controls["Etiket"]).Text;
                        m.KategoriID       = BAYMYO.UI.Converts.NullToString(((DropDownList)controls["Kategori"]).SelectedValue);
                        m.GuncellemeTarihi = DateTime.Now;
                        m.GosterimSayi     = ((CheckBoxList)controls["chkList"]).Items[0].Selected;
                        m.Uye              = ((CheckBoxList)controls["chkList"]).Items[1].Selected;
                        m.Yorum            = ((CheckBoxList)controls["chkList"]).Items[2].Selected;
                        if (Core.IsUserAdmin)
                        {
                            m.YoneticiOnay = ((CheckBoxList)controls["chkList"]).Items[3].Selected;
                            m.Aktif        = ((CheckBoxList)controls["chkList"]).Items[4].Selected;
                        }
                        else
                        {
                            m.YoneticiOnay = false;
                            m.Aktif        = false;
                        }
                        if (m.ID > 0)
                        {
                            if (AlbumMethods.Update(m) > 0)
                            {
                                CustomizeControl1.MessageText = MessageBox.Show(ProccesType.Update, DialogResult.Succes);
                            }
                        }
                        else
                        {
                            m.HesapID     = Core.CurrentUser.ID;
                            m.KayitTarihi = m.GuncellemeTarihi;
                            m.ID          = AlbumMethods.Insert(m);
                            if (m.ID > 0)
                            {
                                IsInsert = true;
                                CustomizeControl1.MessageText = MessageBox.Show(ProccesType.Insert, DialogResult.Succes);
                            }
                        }

                        if (m.ID > 0)
                        {
                            foreach (ListItem item in ((RadioButtonList)controls["Kapak"]).Items)
                            {
                                if (item.Selected)
                                {
                                    GaleriMethods.Update(m.ID);
                                    break;
                                }
                            }
                            const int pixel = 728;
                            string    path  = Server.MapPath(Settings.ImagesPath + "album/" + m.ID + "/");
                            if ((controls["Resim1"] as FileUpload).HasFile)
                            {
                                using (Galeri r = new Galeri())
                                {
                                    r.AlbumID     = m.ID;
                                    r.ResimUrl    = BAYMYO.UI.FileIO.UploadImage(controls["Resim1"] as FileUpload, m.Adi, path, pixel, true);
                                    r.Aciklama    = BAYMYO.UI.Converts.NullToString(((TextBox)controls["Aciklama1"]).Text).Trim();
                                    r.Kapak       = ((RadioButtonList)controls["Kapak"]).Items[0].Selected;
                                    r.KayitTarihi = DateTime.Now;
                                    GaleriMethods.Insert(r);
                                }
                            }

                            if ((controls["Resim2"] as FileUpload).HasFile)
                            {
                                using (Galeri r = new Galeri())
                                {
                                    r.AlbumID     = m.ID;
                                    r.ResimUrl    = BAYMYO.UI.FileIO.UploadImage(controls["Resim2"] as FileUpload, m.Adi, path, pixel, true);
                                    r.Aciklama    = BAYMYO.UI.Converts.NullToString(((TextBox)controls["Aciklama2"]).Text).Trim();
                                    r.Kapak       = ((RadioButtonList)controls["Kapak"]).Items[1].Selected;
                                    r.KayitTarihi = DateTime.Now;
                                    GaleriMethods.Insert(r);
                                }
                            }

                            if ((controls["Resim3"] as FileUpload).HasFile)
                            {
                                using (Galeri r = new Galeri())
                                {
                                    r.AlbumID     = m.ID;
                                    r.ResimUrl    = BAYMYO.UI.FileIO.UploadImage(controls["Resim3"] as FileUpload, m.Adi, path, pixel, true);
                                    r.Aciklama    = BAYMYO.UI.Converts.NullToString(((TextBox)controls["Aciklama3"]).Text).Trim();
                                    r.Kapak       = ((RadioButtonList)controls["Kapak"]).Items[2].Selected;
                                    r.KayitTarihi = DateTime.Now;
                                    GaleriMethods.Insert(r);
                                }
                            }

                            foreach (ListItem item in ((RadioButtonList)controls["Kapak"]).Items)
                            {
                                item.Selected = false;
                            }

                            if (IsInsert)
                            {
                                Core.CreateContents("galeri");
                                jSonData.CreateData("galeriler");
                                Response.Redirect(Settings.PanelPath + "?go=galeri&raid=" + m.ID, false);
                            }
                            else
                            {
                                GetDataPaging(m.ID);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CustomizeControl1.MessageText = MessageBox.Show(DialogResult.Error, ex.Message);
            }
        }