Beispiel #1
0
        private static EcardType[] Fetch(int? id, string name, eType? type, bool? active, eSortColumn sortColumn)
        {
            using (SqlConnection conn = Config.DB.Open())
            {
                SqlDataReader reader = SqlHelper.ExecuteReader(conn, "FetchEcardTypes",
                                                               id,
                                                               name,
                                                               type,
                                                               active,
                                                               sortColumn);

                List<EcardType> lEcardType = new List<EcardType>();

                while (reader.Read())
                {
                    EcardType ecardType = new EcardType();

                    ecardType.id = (int)reader["ID"];
                    ecardType.name = (string) reader["Name"];
                    ecardType.type = (eType) reader["Type"];
                    ecardType.active = (bool) reader["Active"];
                    ecardType.CreditsRequired = reader["CreditsRequired"] as int?;

                    lEcardType.Add(ecardType);
                }

                return lEcardType.ToArray();
            }
        }
Beispiel #2
0
 public static Ecard[] FetchSent(string username, EcardType.eType type)
 {
     return FetchSent(username)
     .Where(x => EcardType.Fetch(x.EcardTypeID).Type == type).ToArray();
 }
Beispiel #3
0
 public static Ecard[] FetchUnread(string username, EcardType.eType type)
 {
     return FetchReceived(username, type).Where(x=> x.IsOpened==false).ToArray();
 }
Beispiel #4
0
 public static Ecard[] FetchSentInLast24Hours(string username, EcardType.eType type)
 {
     return FetchSent(username)
         .Where(x => x.Date > DateTime.Now.AddHours(-24) && 
                     EcardType.Fetch(x.EcardTypeID).Type == type)
         .ToArray();
 }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!HasWriteAccess)
                return;

            if (txtName.Text.Length == 0)
            {
                Messagebox1.Show(Lang.TransA("Please enter name"), Misc.MessageType.Error);
                return;
            }

            byte[] content = new byte[fuContent.PostedFile.InputStream.Length];

            while (true)
            {
                int bytesRead = fuContent.PostedFile.InputStream.Read(content, 0, content.Length);
                if (bytesRead == 0) break;
            }

            string mimeType = String.Empty;
            string extension = System.IO.Path.GetExtension(fuContent.PostedFile.FileName).ToLower();

            if (fuContent.PostedFile.FileName.Length > 0)
            {
                switch (extension)
                {
                    case ".gif":
                        mimeType = "image/gif";
                        break;
                    case ".jpg":
                        mimeType = "image/jpeg";
                        break;
                    case ".jpeg":
                        mimeType = "image/jpeg";
                        break;
                    case ".jpe":
                        mimeType = "image/jpeg";
                        break;
                    case ".png":
                        mimeType = "image/png";
                        break;
                    case ".swf":
                        mimeType = "application/x-shockwave-flash";
                        break;
                    default:
                        Messagebox1.Show(Lang.TransA("Invalid file format!"), Misc.MessageType.Error);
                        return;
                }
            }
            EcardType ecardType = null;
            ecardType = EcardType.Fetch(Convert.ToInt32(ddName.SelectedValue));

            if (ecardType == null)
            {
                ecardType = new EcardType();
            }
            ecardType.Name = txtName.Text.Trim();
            ecardType.Active = cbActive.Checked;
            if (content.Length > 0) ecardType.Content = content;
            else if (!ShowExistedEcardType)
            {
                Messagebox1.Show(Lang.TransA("Invalid file format!"), Misc.MessageType.Error);
                return;
            }
            if (mimeType.Length > 0)
                ecardType.Type = mimeType.Split('/')[0] == "image" ? EcardType.eType.Image : EcardType.eType.Flash;
            ecardType.Save();

            tdImage.Visible = ecardType.Type == EcardType.eType.Image;
            tdFlash.Visible = !tdImage.Visible;

            populateDDName();
            PopulateEcardCategoriesDdl();
            ddName.SelectedValue = ecardType.ID.ToString();
            Messagebox1.Show(Lang.TransA("The e-card has been modified successfully!"), Misc.MessageType.Success);    
        }