コード例 #1
0
 public static void Initialize()
 {
     if (Categories == null)
     {
         Categories = new Dictionary<int, string>();
         Database db = new Database();
         var cat = db.getAllCategories();
         foreach (var c in cat)
         {
             Categories.Add(c.ID, c.Name);
         }
     }
     isInitialized = true;
 }
コード例 #2
0
        protected override void OnLoad(EventArgs e)
        {
            //Get from login
            if (Session["user_id"] == null)
            {
                Response.Redirect("Login.aspx");
            }

            db = new Database();
            DateTime from = DateTime.Now.Subtract(new TimeSpan(1, 0, 0, 0, 0));
            DateTime to = DateTime.Now;
            if (Request.QueryString.HasKeys())
            {
                from = Convert.ToDateTime(Request.QueryString["start"]);
                to = Convert.ToDateTime(Request.QueryString["end"]);
            }
            ShowData(from, to);
        }
コード例 #3
0
 public static string AJAX_DailyStats(string type)
 {
     Database db = new Database();
     List<Transaction> transactions = null;
     switch (type)
     {
         case "1":
             break;
         case "2":
             break;
         case "3":
             break;
     }
     transactions = db.getFromToTransactions(int.Parse(HttpContext.Current.Session["user_id"].ToString()), DateTime.Now.Subtract(new TimeSpan(7, 0, 0, 0, 0)), DateTime.Now, int.Parse(type));
     //return chart data
     return HelperTools.FormatToChartData(transactions);
 }
コード例 #4
0
        private static Transaction ValidateAndAdd(TransactionType type, string name, int amount, int category_id, string comment)
        {
            Database db = new Database();
            var user = int.Parse(HttpContext.Current.Session["user_id"].ToString());
            int comment_id = -1;
            if (!string.IsNullOrWhiteSpace(comment))
            {
                comment_id = (int)db.addComment(comment);
                db.addTransaction(category_id, user, (int)comment_id, amount, DateTime.Now, name, type == TransactionType.Wishlist);
            }
            else
            {
                db.addTransactionBezKomentar(category_id, user, amount, DateTime.Now, name, type == TransactionType.Wishlist);
            }

            return new Transaction()
            {
                Category = new Category(category_id, HelperTools.Categories[category_id]),
                Date = DateTime.Now,
                Type = (int)type,
                Amount = amount,
                Comment_ID = comment_id,
                ID = -1,
                Name = name
            };
        }
コード例 #5
0
        public static string AJAX_TransactionData(string from, string to, string type)
        {
            DateTime dateFrom = Convert.ToDateTime(from);
            DateTime dateTo = Convert.ToDateTime(to);

            Database db = new Database();
            var transactions = db.getFromToTransactions(int.Parse(HttpContext.Current.Session["user_id"].ToString()), dateFrom, dateTo, int.Parse(type));
            //return chart data
            return HelperTools.FormatTransactions(transactions);
        }
コード例 #6
0
 public static string AJAX_GetCurrentFunds()
 {
     Database db = new Database();
     int user_id = (int)HttpContext.Current.Session["user_id"];
     int saved_funds = db.getSavedFunds(user_id);
     int curr_funds = db.currentFunds(user_id);
     StringBuilder sb = new StringBuilder();
     sb.Append("{");
     sb.Append("\"funds\": ");
     sb.Append(curr_funds);
     sb.Append(", ");
     sb.Append("\"saved_funds\": ");
     sb.Append(saved_funds);
     sb.Append("}");
     return sb.ToString();
 }
コード例 #7
0
 //brisenje na daden element od transakcii
 void removeTransaction(int transaction_id)
 {
     Database db = new Database();
     db.removeTransaction(transaction_id);
 }
コード例 #8
0
 public static string AJAX_removeTransaction(int transaction_id)
 {
     Database db = new Database();
     return db.removeTransaction(transaction_id).ToString();
 }
コード例 #9
0
 public static string AJAX_RemoveWishlist(string id)
 {
     int _id = int.Parse(id);
     Database db = new Database();
     return db.removeTransaction(_id).ToString();
 }
コード例 #10
0
 public static string AJAX_BuyWishlist(string id)
 {
     int _id = int.Parse(id);
     Database db = new Database();
     return db.buyItemFromWishlist(_id);
 }
コード例 #11
0
ファイル: Database.cs プロジェクト: kachulach/BankrotManager
        internal static User authenticateUser(string username, string password)
        {
            //da se naprave funkcija za avtentikacija na korisnikot i da vrakja User so site parametri so gi ima za user
            Database db = new Database();
            MySqlConnection konekcija = db.getConnection();

            string sqlString = "SELECT * FROM user WHERE username=@username " +
                "AND password=AES_ENCRYPT(@password, SHA1(@username))";// AND is_active = 1";
            // neznam so e is_active zatoa e iskomentirano :D nema takvo nesto vo bazata zacuvano :)

            MySqlCommand komanda = new MySqlCommand(sqlString, konekcija);
            komanda.Parameters.AddWithValue("@username", username);
            komanda.Parameters.AddWithValue("@password", password);

            try
            {
                konekcija.Open();
                MySqlDataReader citac = komanda.ExecuteReader();
                if (citac.Read())
                {
                    // mozi da se zemi i datumot koga e kreiran userot...
                    // dokolku se dodade pole vo User klasata za datum
                    // u.datum = citac["datum"]
                    User u = new User();
                    u.username = citac["username"] as string;
                    u.name = citac["name"] as string;
                    u.user_id = int.Parse(citac["user_id"].ToString());
                    ;
                    u.funds = int.Parse(citac["funds"].ToString());
                    ;
                    u.email = citac["e_mail"] as string;

                    // u.user_id = int.Parse(citac["user_id"].ToString());
                    // u.name = citac["first_name"].ToString();
                    // u.last_name = citac["last_name"].ToString();
                    // u.organization_id = int.Parse(citac["organization_id"].ToString());

                    return u;
                }
                else
                    return null;
            }
            catch (Exception err)
            {
                Console.Write(err.ToString());
            }
            finally
            {
                konekcija.Close();
            }

            return null;
        }