protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            // turn on antilock screen
            PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;

            //Set BackGround
            Random rand = new Random();
            int    n    = rand.Next(1, 48);
            // while (n == 6 || n == 13 || n == 45) { n = rand.Next(1, 51); }
            String      bgpath      = "/Images/Backgrounds/bg" + n + ".jpg/";
            BitmapImage bitmapImage = new BitmapImage(new Uri(bgpath, UriKind.Relative));
            ImageBrush  imageBrush  = new ImageBrush();

            imageBrush.ImageSource = bitmapImage;
            imageBrush.Stretch     = Stretch.UniformToFill;
            imageBrush.AlignmentX  = 0;
            imageBrush.AlignmentY  = 0;
            bghandler.Background   = imageBrush;
            //Query Database
            mRace = NavigationContext.QueryString["race"];
            Debug.WriteLine("Race is " + mRace);
            DB_Helper.connect();
            built_in.ItemsSource = DB_Helper.get_Index_Built_In(mRace);
            custom.ItemsSource   = DB_Helper.get_Index_By_Author("Custom", mRace);
        }
Exemplo n.º 2
0
    public void BuyCreditsDB(double amount_money, int credits, int id_user)
    {
        DB_Helper db = new DB_Helper();
        db.Execute("exec BUY_CREDITS " + id_user + "," + amount_money + "," + credits);

        MyUtils.RefreshUserRow();
    }
Exemplo n.º 3
0
Arquivo: Olymps.cs Projeto: SahsaB/pk
        public Olymps(DB_Connector connection, ApplicationEdit parent)
        {
            InitializeComponent();

            _DB_Connection = connection;
            _DB_Helper     = new DB_Helper(_DB_Connection);
            _Parent        = parent;

            cbDiplomaType.Items.AddRange(_DB_Helper.GetDictionaryItems(FIS_Dictionary.DIPLOMA_TYPE).Values.ToArray());
            cbClass.SelectedItem = "10";
            cbDiscipline.Items.AddRange(_DB_Helper.GetDictionaryItems(FIS_Dictionary.SUBJECTS).Values.ToArray());
            cbCountry.Items.AddRange(_DB_Helper.GetDictionaryItems(FIS_Dictionary.COUNTRY).Values.ToArray());

            Forms.ApplicationEdit.ODoc loadedDocument = _Parent.OlympicDoc;

            if ((loadedDocument.olympType != null) && (loadedDocument.olympType != ""))
            {
                cbOlympType.SelectedItem = loadedDocument.olympType;
                tbDocNumber.Text         = loadedDocument.olympDocNumber.ToString();

                if ((loadedDocument.diplomaType != null) && (loadedDocument.diplomaType != ""))
                {
                    cbDiplomaType.SelectedItem = loadedDocument.diplomaType;
                }

                if (loadedDocument.olympID != 0)
                {
                    tbOlympID.Text            = loadedDocument.olympID.ToString();
                    cbOlympName.SelectedIndex = cbOlympName.FindString(_DB_Connection.Select(DB_Table.DICTIONARY_19_ITEMS, new string[] { "olympic_name" }, new System.Collections.Generic.List <Tuple <string, Relation, object> >
                    {
                        new Tuple <string, Relation, object>("olympic_id", Relation.EQUAL, loadedDocument.olympID)
                    })[0][0].ToString());
                    cbOlympProfile.SelectedIndex = cbOlympProfile.FindString(loadedDocument.olympProfile);
                }
                else
                {
                    if (loadedDocument.olympName != null)
                    {
                        cbOlympName.Text = loadedDocument.olympName;
                    }
                    cbOlympProfile.SelectedItem = loadedDocument.olympProfile;
                }

                if (loadedDocument.olympClass != 0)
                {
                    cbClass.SelectedItem = loadedDocument.olympClass.ToString();
                }

                if ((loadedDocument.olympDist != null) && (loadedDocument.olympDist != ""))
                {
                    cbDiscipline.SelectedItem = loadedDocument.olympDist;
                }

                if ((loadedDocument.country != null) && (loadedDocument.country != ""))
                {
                    cbCountry.SelectedItem = loadedDocument.country;
                }
            }
        }
Exemplo n.º 4
0
    public void BuyCreditsDB(double amount_money, int credits, int id_user)
    {
        DB_Helper db = new DB_Helper();

        db.Execute("exec BUY_CREDITS " + id_user + "," + amount_money + "," + credits);

        MyUtils.RefreshUserRow();
    }
Exemplo n.º 5
0
 public static string GetUsersPage(int pageIndex, string filter)
 {
     filter = HttpUtility.UrlDecode(filter);
     DB_Helper db = new DB_Helper();
     string sql;
     DataSet d = GetUsers(pageIndex, filter,out sql);
     return d.GetXml();
 }
Exemplo n.º 6
0
    public static string GetUsersPage(int pageIndex, string filter)
    {
        filter = HttpUtility.UrlDecode(filter);
        DB_Helper db = new DB_Helper();
        string    sql;
        DataSet   d = GetUsers(pageIndex, filter, out sql);

        return(d.GetXml());
    }
Exemplo n.º 7
0
        public Campaigns(DB_Connector connection)
        {
            InitializeComponent();

            _DB_Connection = connection;
            _DB_Helper     = new DB_Helper(_DB_Connection);

            UpdateTableAndCombobox();
        }
Exemplo n.º 8
0
        public DirectionsProfiles(DB_Connector connection)
        {
            InitializeComponent();

            _DB_Connection = connection;
            _DB_Helper     = new DB_Helper(_DB_Connection);
            UpdateTable();
            cbDirections.ValueMember = "Value";
        }
Exemplo n.º 9
0
 public Constants(DB_Connector connection, uint campaignID)
 {
     InitializeComponent();
     _DB_Connection         = connection;
     _DB_Helper             = new DB_Helper(_DB_Connection);
     _CurrCampaignID        = campaignID;
     lbCurrentCampaign.Text = _DB_Connection.Select(DB_Table.CAMPAIGNS, new string[] { "name" }, new List <Tuple <string, Relation, object> >
     {
         new Tuple <string, Relation, object>("id", Relation.EQUAL, _CurrCampaignID)
     })[0][0].ToString();
     UpdateTable();
 }
Exemplo n.º 10
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            // turn on antilock screen
            PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;

            //Set BackGround
            Random rand = new Random();
            int    n    = rand.Next(1, 48);
            // while (n == 6 || n == 13 || n == 45) { n = rand.Next(1, 51); }
            String      bgpath      = "/Images/Backgrounds/bg" + n + ".jpg/";
            BitmapImage bitmapImage = new BitmapImage(new Uri(bgpath, UriKind.Relative));
            ImageBrush  imageBrush  = new ImageBrush();

            imageBrush.ImageSource = bitmapImage;
            LayoutRoot.Background  = imageBrush;
            //Current Build Panel
            bgpath                        = "/Images/Backgrounds/bg_translucent.png/";
            bitmapImage                   = new BitmapImage(new Uri(bgpath, UriKind.Relative));
            imageBrush                    = new ImageBrush();
            imageBrush.ImageSource        = bitmapImage;
            currentbuild_panel.Background = imageBrush;
            //Query Database
            mRace          = NavigationContext.QueryString["race"];
            buildname      = NavigationContext.QueryString["buildname"];
            index_id       = Int16.Parse(NavigationContext.QueryString["index_id"]);
            PageTitle.Text = buildname;
            DB_Helper.connect();
            builds = DB_Helper.get_Build_Order_By_Index_Id(index_id);
            for (int i = 0; i < builds.Count; i++)
            {
                current_build_order.Add(DB_Helper.get_Object_SC_by_Obj_Id(builds.ElementAt <Build_Order>(i).Obj_Id).ElementAt <Object_SC>(0));
            }
            build.ItemsSource = current_build_order;
            if (build.Items.Any())
            {
                selectedIndex       = 0;
                build.SelectedIndex = selectedIndex;
                Object_SC item = (Object_SC)build.SelectedItem;
                //items.Background = new SolidColorBrush(Colors.Orange);
                Debug.WriteLine("Initial selected index is " + build.SelectedIndex);
                Debug.WriteLine("selected name is " + item.Name);

                Uri         uri       = new Uri(item.Imagesource, UriKind.Relative);
                ImageSource imgSource = new BitmapImage(uri);
                current_icon.Source  = imgSource;
                current_name.Text    = item.Name;
                current_mineral.Text = item.Mineral + "";
                current_gas.Text     = item.Gas + "";
                current_food.Text    = item.Food + "";
                current_time.Text    = item.Time + "";
            }
        }
Exemplo n.º 11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.Form.Attributes["data-form"] = "message";

        note.Visible = MyUtils.IsMale;

        ID_USER          = (int)MyUtils.GetUserField("ID_USER"); //will redirect to login page if not logged in
        ID_USER_CHATWITH = Convert.ToInt32(Request.QueryString["id"]);

        DB_Helper db = new DB_Helper();

        int id_offer = db.ExecuteScalarInt("exec CAN_MESSAGE_WITH " + ID_USER + "," + ID_USER_CHATWITH, 0);

        if (id_offer == 0)
        {
            id_offer = db.ExecuteScalarInt("select id_offer from offers where id_offer_state=404 and (id_user_from=" + ID_USER_CHATWITH + " and id_user_to=" + MyUtils.ID_USER + ") or (id_user_from=" + MyUtils.ID_USER + " and id_user_to=" + ID_USER_CHATWITH + ")", 0);

            if (id_offer > 0)
            {
                Response.Redirect("/Account/Messages#" + id_offer, true);
                return;
            }

            Response.Clear();
            Response.Write("You don't have permission to send messages to this user.");
            Response.End();
        }

        R = db.GetRow("exec GET_USER_PROFILE " + ID_USER + "," + ID_USER_CHATWITH);
        if (R == null)
        {
            Response.Clear();
            Response.Write("This user doesn't exist.");
            Response.End();
        }

        Offer = db.GetRow("select amount from offers where (id_user_to=" + ID_USER + " and id_user_from=" + ID_USER_CHATWITH + ") or (id_user_to=" + ID_USER_CHATWITH + " and id_user_from=" + ID_USER + ")");



        //do some magic here with  ID_USER and ID_USER_CHATWITH

        //.......................................................


        //Example on how to insert message to DB
        //SaveMessage2DB(10002, 10003, "testing.... ", "1,2,3,4");

        //Example on how to get messages for user pair
        //DataTable T = GetMessagesForUser(10002, 10003);
    }
Exemplo n.º 12
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        if (MyUtils.authenticate(LoginUser.UserName, LoginUser.Password, out membership) && !Utils.IsUserBan())
        {
            bool CreatePersistentCookie = this.LoginUser.RememberMeSet; //even if you close browser the account will stay logged in
            if (!MyUtils.IsUserAdmin())
            {
                DB_Helper db = new DB_Helper();
                db.Execute(string.Format("update Users set [lastlogin_time] = getdate(), ip_address={1} where id_user = {0}", MyUtils.ID_USER,MyUtils.safe(MyUtils.GetIP())));
            }

            FormsAuthentication.RedirectFromLoginPage(LoginUser.UserName, CreatePersistentCookie);
        }
    }
        /// <summary>
        /// Creates and adds a few ItemViewModel objects into the Items collection.
        /// </summary>
        public void LoadData(String mRace)
        {
            // Sample data; replace with real data
            //this.Items.Add(new ItemViewModel() { Name = "runtime one", Mineral = 50, Vespene = 0, Supply = 2, BuildTime = 30 });
            //this.Items.Add(new ItemViewModel() { Name = "runtime one", Mineral = 50, Vespene = 0, Supply = 2, BuildTime = 30 });
            //this.Items.Add(new ItemViewModel() { Name = "runtime one", Mineral = 50, Vespene = 0, Supply = 2, BuildTime = 30 });
            //this.Items.Add(new ItemViewModel() { Name = "runtime one", Mineral = 50, Vespene = 0, Supply = 2, BuildTime = 30 });
            //this.Items.Add(new ItemViewModel() { Name = "runtime one", Mineral = 50, Vespene = 0, Supply = 2, BuildTime = 30 });
            //this.Items.Add(new ItemViewModel() { Name = "runtime one", Mineral = 50, Vespene = 0, Supply = 2, BuildTime = 30 });

            //Object_SC_Table = DB_Helper.get_Object_SC_by_Type(DB_Helper.UNIT);
            //// List<Pushpin> pushpin = new List<Pushpin>();
            //for (int i = 0; i < Object_SC_Table.Count; i++)
            //{
            //    this.Items.Add(new ItemViewModel() { Name = Object_SC_Table[i].Name, Mineral = Object_SC_Table[i].Mineral, Vespene = Object_SC_Table[i].Gas, Supply = Object_SC_Table[i].Food, BuildTime = Object_SC_Table[i].Time });

            //}

            DB_Helper.connect();
            //Load Units
            Object_SC_Table = DB_Helper.get_Object_SC_by_Type_and_Race(mRace, DB_Helper.UNIT);
            foreach (Object_SC obj in Object_SC_Table)
            {
                this.Units.Add(new ItemViewModel()
                {
                    ObjId = obj.Obj_Id, Name = obj.Name, Mineral = obj.Mineral, Vespene = obj.Gas, Supply = obj.Food, BuildTime = obj.Time
                });
            }
            //Load Buildings
            Object_SC_Table.Clear();
            Object_SC_Table = DB_Helper.get_Object_SC_by_Type_and_Race(mRace, DB_Helper.BUILDING);
            foreach (Object_SC obj in Object_SC_Table)
            {
                this.Buildings.Add(new ItemViewModel()
                {
                    ObjId = obj.Obj_Id, Name = obj.Name, Mineral = obj.Mineral, Vespene = obj.Gas, Supply = obj.Food, BuildTime = obj.Time
                });
            }
            //Load Upgardes
            Object_SC_Table.Clear();
            Object_SC_Table = DB_Helper.get_Object_SC_by_Type_and_Race(mRace, DB_Helper.UPGRADE);
            foreach (Object_SC obj in Object_SC_Table)
            {
                this.Upgrades.Add(new ItemViewModel()
                {
                    ObjId = obj.Obj_Id, Name = obj.Name, Mineral = obj.Mineral, Vespene = obj.Gas, Supply = obj.Food, BuildTime = obj.Time
                });
            }
            this.IsDataLoaded = true;
        }
Exemplo n.º 14
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        if (MyUtils.authenticate(LoginUser.UserName, LoginUser.Password, out membership) && !Utils.IsUserBan())
        {
            bool CreatePersistentCookie = this.LoginUser.RememberMeSet; //even if you close browser the account will stay logged in
            if (!MyUtils.IsUserAdmin())
            {
                DB_Helper db = new DB_Helper();
                db.Execute(string.Format("update Users set [lastlogin_time] = getdate(), ip_address={1} where id_user = {0}", MyUtils.ID_USER, MyUtils.safe(MyUtils.GetIP())));
            }

            FormsAuthentication.RedirectFromLoginPage(LoginUser.UserName, CreatePersistentCookie);
        }
    }
Exemplo n.º 15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        DB_Helper db = new DB_Helper();

        int v  = db.ExecuteScalarInt("select email_verified from users where id_user="******"/Account/");
            return;
        }

        if (!IsPostBack) txtEmail.Text = MyUtils.GetUserField("email").ToString();
    }
 public void LoadData(String mRace)
 {
     Units.Clear();
     DB_Helper.connect();
     //Load Units
     Object_SC_Table = DB_Helper.get_Object_SC_by_Type_and_Race(mRace, DB_Helper.UNIT);
     foreach (Object_SC obj in Object_SC_Table)
     {
         Units.Add(new ItemViewModel()
         {
             ObjId = obj.Obj_Id, Name = obj.Name, Path = obj.Imagesource, Strong1 = obj.Strong1, Strong2 = obj.Strong2, Strong3 = obj.Strong3, Weak1 = obj.Weak1, Weak2 = obj.Weak2, Weak3 = obj.Weak3
         });
     }
 }
Exemplo n.º 17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        DB_Helper db = new DB_Helper();
        int id = Convert.ToInt32(Request.QueryString["id"]);

        DataSet ds= db.GetDataSet("select dbo.CalculateCredits2Unlock(amount) as credits from offers  where (id_user_from=" + id + " and id_user_to=" + MyUtils.ID_USER + ") or (id_user_from=" + MyUtils.ID_USER + " and id_user_to=" + id + ");select username from users where id_user=" + id);
        cr = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
        user = Convert.ToString(ds.Tables[1].Rows[0][0]);

        bool not_enough_credits = cr > MyUtils.Credits;

        nocredits.Visible = not_enough_credits;
        confirm.Visible = !nocredits.Visible;
    }
Exemplo n.º 18
0
    public void BuyCreditsDB(double amount_money, int credits, int id_user)
    {
        DB_Helper db = new DB_Helper();
        db.Execute("exec BUY_CREDITS " + id_user + "," + amount_money + "," + credits);
        List<string> p = new List<string>();
        p.Add("emailtitle:Credits were added");
        p.Add("line:We added " + credits + " credits to your account.");
        p.Add("credits:" + credits);
        p.Add("cost:" + amount_money.ToString("c2"));
        p.Add("date:" + DateTime.Now.ToString("MM/dd/yyyy"));
        p.Add("package:" + credits + " credit package");
        RWorker.AddToEmailQueue("EMAIL_PAYMENT", MyUtils.ID_USER, null, false, p);

        MyUtils.RefreshUserRow();
    }
Exemplo n.º 19
0
    static DataTable GetMessagesForUser(int id_user, int id_user_with, int start_with_id = 0)
    {
        //IsFromMe gives 1 if the message was sent my me.
        DB_Helper db = new DB_Helper();

        string sql = "select " +
                     "(SELECT top 1 [username] FROM [dbo].[Users] where [id_user] = m.id_user_from) FromUser," +
                     "(SELECT top 1 [username] FROM[dbo].[Users] where[id_user] = m.id_user_to) ToUser, " +
                     "case when id_user_from=" + id_user +
                     " then 1 else 0 end as IsFromMe, * from messages m where ((id_user_from=" +
                     id_user + " and id_user_to=" + id_user_with + ") or (id_user_to=" + id_user + " and id_user_from=" + id_user_with + ")) and m.[id_message] >= " + start_with_id + " order by [time] desc";

        sql += "; update messages set is_new = 0 where id_user_to =" + id_user + " and id_user_from = " + id_user_with + " and is_new = 1 and [id_message] >= " + start_with_id;
        return(db.GetDataSet(sql).Tables[0]);
    }
Exemplo n.º 20
0
    protected void Page_Load(object sender, EventArgs e)
    {
        DB_Helper db = new DB_Helper();
        int       id = Convert.ToInt32(Request.QueryString["id"]);

        DataSet ds = db.GetDataSet("select dbo.CalculateCredits2Unlock(amount) as credits from offers  where (id_user_from=" + id + " and id_user_to=" + MyUtils.ID_USER + ") or (id_user_from=" + MyUtils.ID_USER + " and id_user_to=" + id + ");select username from users where id_user=" + id);

        cr   = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
        user = Convert.ToString(ds.Tables[1].Rows[0][0]);

        bool not_enough_credits = cr > MyUtils.Credits;

        nocredits.Visible = not_enough_credits;
        confirm.Visible   = !nocredits.Visible;
    }
Exemplo n.º 21
0
        public InstitutionAchievementsEdit(DB_Connector connection)
        {
            InitializeComponent();

            _DB_Connection = connection;
            _DB_Helper     = new DB_Helper(_DB_Connection);

            foreach (var campaign in _DB_Connection.Select(DB_Table.CAMPAIGNS, "name"))
            {
                cbCampaign.Items.Add(campaign[0]);
            }

            cbAchievementType.DataSource    = new BindingSource(_DB_Helper.GetDictionaryItems(FIS_Dictionary.IND_ACH_CATEGORIES), null);
            cbAchievementType.DisplayMember = "Value";
            cbAchievementType.ValueMember   = "Value";
        }
Exemplo n.º 22
0
        public Examinations(DB_Connector connection)
        {
            #region Components
            InitializeComponent();

            // Для отображения без компонента времени:
            dataGridView_Date.ValueType         = typeof(DateTime);
            dataGridView_RegStartDate.ValueType = typeof(DateTime);
            dataGridView_RegEndDate.ValueType   = typeof(DateTime);
            #endregion

            _DB_Connection = connection;
            _DB_Helper     = new DB_Helper(_DB_Connection);

            UpdateTable();
        }
Exemplo n.º 23
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            // turn on antilock screen
            PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;

            //Set BackGround
            Random rand = new Random();
            int    n    = rand.Next(1, 48);
            // while (n == 6 || n == 13 || n == 45) { n = rand.Next(1, 51); }
            String      bgpath      = "/Images/Backgrounds/bg" + n + ".jpg/";
            BitmapImage bitmapImage = new BitmapImage(new Uri(bgpath, UriKind.Relative));
            ImageBrush  imageBrush  = new ImageBrush();

            imageBrush.ImageSource = bitmapImage;
            bghandler.Background   = imageBrush;
            //Current Build Panel
            bgpath                 = "/Images/Backgrounds/bg_translucent_darker.png/";
            bitmapImage            = new BitmapImage(new Uri(bgpath, UriKind.Relative));
            imageBrush             = new ImageBrush();
            imageBrush.ImageSource = bitmapImage;
            LayoutRoot.Background  = imageBrush;
            //Query Database
            mRace          = NavigationContext.QueryString["race"];
            buildname      = NavigationContext.QueryString["buildname"];
            index_id       = Int16.Parse(NavigationContext.QueryString["index_id"]);
            PageTitle.Text = buildname;
            DB_Helper.connect();
            builds = DB_Helper.get_Build_Order_By_Index_Id(index_id);
            for (int i = 0; i < builds.Count; i++)
            {
                Build_Order current_step = builds.ElementAt <Build_Order>(i);
                Object_SC   unit         = DB_Helper.get_Object_SC_by_Obj_Id(current_step.Obj_Id).ElementAt <Object_SC>(0);

                current_build_order.Add(new unitforBuildOrder(unit.Name, unit.Food, unit.Mineral, unit.Gas, unit.Time, unit.Imagesource, "@" + current_step.When, current_step.Note));
            }
            build.ItemsSource = current_build_order;
            Before.Text       = NavigationContext.QueryString["note"];
            if (Before.Text == "")
            {
                Before_Button.Visibility = Visibility.Collapsed;
            }
            After.Text = NavigationContext.QueryString["notefooter"];
            if (After.Text == "")
            {
                After_Button.Visibility = Visibility.Collapsed;
            }
        }
Exemplo n.º 24
0
    private static void EnsureFilterIsSaved(Filter f)
    {
        string user_filter    = MyUtils.GetUserField("filter") as string;
        string current_filter = f.ToString();

        if (user_filter != current_filter)
        {
            DB_Helper db      = new DB_Helper();
            int       id_user = MyUtils.ID_USER; //currently logged in user
            if (f.IsDefault())
            {
                current_filter = "DEFAULT";
            }
            db.Execute("update users set filter=" + MyUtils.safe(current_filter) + " where id_user=" + id_user);
            MyUtils.RefreshUserRow();
        }
    }
Exemplo n.º 25
0
    static DataTable SaveMessage2DBAndSelect(int id_user_from, int id_user_to, string message, string gift_list, int id_offer)
    {
        DB_Helper db = new DB_Helper();
        string    s  = "";

        if (MyUtils.IsFemale)
        {
            s = "select female_sent_msg from offers where id_offer=" + id_offer;
            int female_sent_msg = db.ExecuteScalarIntCache(s, 0, 5);
            if (female_sent_msg == 0)
            {
                db.Execute("update offers set female_sent_msg=1 where isnull(female_sent_msg,0)=0 and id_offer=" + id_offer + "; ");
                DB_Helper.InvalidateCache("SQL_" + s);
            }
        }
        return(db.GetDataSet("insert into messages (id_user_from,id_user_to,text,gift_list,id_offer) OUTPUT inserted.* values (" + id_user_from + "," + id_user_to + "," + MyUtils.safe(message) + "," + MyUtils.safe(gift_list) + "," + id_offer + ");").Tables[0]);
    }
Exemplo n.º 26
0
    public void BuyCreditsDB(double amount_money, int credits, int id_user)
    {
        DB_Helper db = new DB_Helper();

        db.Execute("exec BUY_CREDITS " + id_user + "," + amount_money + "," + credits);
        List <string> p = new List <string>();

        p.Add("emailtitle:Credits were added");
        p.Add("line:We added " + credits + " credits to your account.");
        p.Add("credits:" + credits);
        p.Add("cost:" + amount_money.ToString("c2"));
        p.Add("date:" + DateTime.Now.ToString("MM/dd/yyyy"));
        p.Add("package:" + credits + " credit package");
        RWorker.AddToEmailQueue("EMAIL_PAYMENT", MyUtils.ID_USER, null, false, p);

        MyUtils.RefreshUserRow();
    }
Exemplo n.º 27
0
    protected void Page_Load(object sender, EventArgs e)
    {
        DB_Helper db = new DB_Helper();

        int v = db.ExecuteScalarInt("select email_verified from users where id_user="******"/Account/");
            return;
        }

        if (!IsPostBack)
        {
            txtEmail.Text = MyUtils.GetUserField("email").ToString();
        }
    }
Exemplo n.º 28
0
        public DirectionSelect(DB_Connector connection, List <string> filters)
        {
            InitializeComponent();

            _DB_Connection = connection;
            _DB_Helper     = new DB_Helper(_DB_Connection);

            foreach (object[] item in _DB_Connection.Select(DB_Table.DIRECTIONS, "direction_id", "faculty_short_name"))
            {
                Tuple <string, string> dirData = _DB_Helper.GetDirectionNameAndCode((uint)item[0]);
                foreach (string v in filters)
                {
                    if (dirData.Item2.Split('.')[1] == v)
                    {
                        dgvDirectionSelection.Rows.Add(item[0], dirData.Item2, dirData.Item1, item[1]);
                    }
                }
            }
        }
Exemplo n.º 29
0
    private static DataSet GetUsers(int index, string filter, out string sql)
    {
        //index = 1;
        DB_Helper db = new DB_Helper();

        int id_user = (int)MyUtils.GetUserField("id_user");  //currently logged in user

        if (string.IsNullOrEmpty(filter))
        {
            filter = db.ExecuteScalarString("select isnull(filter,'DEFAULT') from users where id_user="******"mainphoto_");
        d.Tables[0].Columns.Add("online");
        d.Tables[0].Columns.Add("button_switch");
        foreach (DataRow r in d.Tables[0].Rows)
        {
            r["button_switch"] = GetButtonSwitch(r);
            r["mainphoto_"]    = MyUtils.GetImageUrl(r, MyUtils.ImageSize.MEDIUM);
            r["online"]        = MyUtils.IsOnline((int)r["id_user"]) ? "1" : "0";// ..GetImageUrl(r, MyUtils.ImageSize.MEDIUM);
        }
        d.Tables[0].Columns.Remove("mainphoto");
        d.Tables[0].Columns["mainphoto_"].ColumnName = "MainPhoto";

        d.Tables[0].TableName = "U";
        DataTable t = new DataTable();

        t.TableName = "filter";
        t.Columns.Add("json");
        t.Rows.Add(t.NewRow());
        t.Rows[0]["json"] = f.ToString();
        d.Tables.Add(t);
        return(d);
    }
Exemplo n.º 30
0
    protected void btnSendCode_Click(object sender, EventArgs e)
    {
        if (regexEmailValid.IsValid && RequiredFieldValidator1.IsValid)
        {
            DB_Helper db = new DB_Helper();
            string    em = txtEmail.Text;

            if (em.StartsWith("ACTIVATE"))
            {
                db.Execute(string.Format("update Users set email_verified=1 where id_user = {0}", MyUtils.ID_USER));
                MyUtils.RefreshUserRow();
            }
            else
            {
                int id_user = db.ExecuteScalarInt("select id_user from users where email=" + MyUtils.safe(em), 0);
                if (id_user > 0 && id_user != MyUtils.ID_USER)
                {
                    Session["message"] = "ERROR: This email is already used by a different user.";
                    return;
                }
                db.Execute("update users set email=" + MyUtils.safe(em) + " where id_user="******"EMAIL_ACTIVATE", MyUtils.ID_USER);
                Session["message"] = "OK: Activation email was sent. Please check your inbox.";
            }
        }
        else
        {
            Session["message"] = "ERROR: Invalid email.";
        }

        bool needtoverify = Convert.ToUInt32(MyUtils.GetUserField("email_verified")) == 0;

        if (!needtoverify)
        {
            Response.Redirect("/Account/");
            Session["message"] = "Account is active.";
        }
    }
Exemplo n.º 31
0
        public MainForm()
        {
            InitializeComponent();

            //_DB_Connection = new DB_Connector("server = localhost; port = 3306; database = pk_db;"/*Properties.Settings.Default.pk_db_CS*/, "administrator", "adm1234");
            _DB_Connection = new DB_Connector("server = serv-priem; port = 3306; database = pk_db;" /*Properties.Settings.Default.pk_db_CS*/, "administrator", "adm1234");

            _DB_Helper = new DB_Helper(_DB_Connection);
            Dictionary <uint, string> campaigns = new Dictionary <uint, string>();

            foreach (object[] campaign in _DB_Connection.Select(DB_Table.CAMPAIGNS, new string[] { "id", "name" }))
            {
                if (_DB_Helper.GetCampaignType((uint)campaign[0]) == DB_Helper.CampaignType.BACHELOR_SPECIALIST)
                {
                    campaigns.Add((uint)campaign[0], campaign[1].ToString());
                }
            }

            cbCampaigns.DataSource    = campaigns.ToList();
            cbCampaigns.ValueMember   = "Key";
            cbCampaigns.DisplayMember = "Value";
            cbAdress.SelectedIndex    = 0;
            cbAdress.Enabled          = cbPost.Checked;
            cbUnits.SelectedIndex     = 1;
            for (int i = 1; i <= 60; i++)
            {
                cbInterval.Items.Add(i);
            }
            cbInterval.SelectedItem = 15;

            _SubjectsCodes = new Dictionary <uint, string>
            {
                { _DB_Helper.GetDictionaryItemID(FIS_Dictionary.SUBJECTS, DB_Helper.SubjectMath), "Math" },
                { _DB_Helper.GetDictionaryItemID(FIS_Dictionary.SUBJECTS, DB_Helper.SubjectPhis), "Phis" },
                { _DB_Helper.GetDictionaryItemID(FIS_Dictionary.SUBJECTS, DB_Helper.SubjectRus), "Rus" },
                { _DB_Helper.GetDictionaryItemID(FIS_Dictionary.SUBJECTS, DB_Helper.SubjectObsh), "Obsh" },
                { _DB_Helper.GetDictionaryItemID(FIS_Dictionary.SUBJECTS, DB_Helper.SubjectForen), "Foren" }
            };
        }
        private void gotoPage()
        {
            if (mTo != "Surprise")
            {
                String path = "/" + mTo + ".xaml?race=" + mRace;
                NavigationService.Navigate(new Uri(path, UriKind.RelativeOrAbsolute));
            }
            else
            {
                DB_Helper.connect();
                ObservableCollection <Index> Built_in = new ObservableCollection <Index>();
                ObservableCollection <Index> Custom   = new ObservableCollection <Index>();
                ObservableCollection <Index> All      = new ObservableCollection <Index>();
                Random mRand = new Random();

                Built_in = DB_Helper.get_Index_Built_In(mRace);
                Custom   = DB_Helper.get_Index_By_Author("Custom", mRace);
                All      = Built_in;
                foreach (Index build in Custom)
                {
                    All.Add(build);
                }
                if (All.Count == 0)
                {
                    MessageBox.Show("There is no build order for this race");
                    RaceDialog.Visibility = Visibility.Collapsed;
                    PageTitle.Visibility  = Visibility.Visible;
                    onRaceChoser          = false;
                }
                else
                {
                    int    chosen      = mRand.Next(All.Count);
                    Index  chosenBuild = All[chosen];
                    String path        = "/BuiltInOrder.xaml?index_id=" + chosenBuild.Id + "&race=" + mRace + "&buildname=" + chosenBuild.Name + "&note=" + chosenBuild.Note + "&notefooter=" + chosenBuild.Note_Footer;
                    NavigationService.Navigate(new Uri(path, UriKind.RelativeOrAbsolute));
                }
            }
        }
Exemplo n.º 33
0
Arquivo: Main.cs Projeto: SahsaB/pk
        public Main(string userRole, string usersLogin)
        {
            InitializeComponent();

            _DB_Connection = new DB_Connector(Properties.Settings.Default.pk_db_CS, userRole,
                                              new DB_Connector(Properties.Settings.Default.pk_db_CS, "initial", "1234").Select(
                                                  DB_Table.ROLES_PASSWORDS,
                                                  new string[] { "password" },
                                                  new List <Tuple <string, Relation, object> > {
                new Tuple <string, Relation, object>("role", Relation.EQUAL, userRole)
            }
                                                  )[0][0].ToString());

            _DB_UpdateConnection = new DB_Connector(Properties.Settings.Default.pk_db_CS, userRole,
                                                    new DB_Connector(Properties.Settings.Default.pk_db_CS, "initial", "1234").Select(
                                                        DB_Table.ROLES_PASSWORDS,
                                                        new string[] { "password" },
                                                        new List <Tuple <string, Relation, object> > {
                new Tuple <string, Relation, object>("role", Relation.EQUAL, userRole)
            }
                                                        )[0][0].ToString());

            _DB_Helper = new DB_Helper(_DB_Connection);
            _UserLogin = usersLogin;
            _UserRole  = userRole;
            SetUserRole();

            dgvApplications.Sort(dgvApplications_LastName, System.ComponentModel.ListSortDirection.Ascending);
            System.IO.Directory.CreateDirectory(Classes.Settings.TempPath);
            dtpRegDate.Value = dtpRegDate.MinDate;
            SetCurrentCampaign();
            rbNew.Checked = true;

            lFilter.BackColor    = toolStrip.BackColor;
            rbAdm.BackColor      = toolStrip.BackColor;
            rbNew.BackColor      = toolStrip.BackColor;
            rbWithdraw.BackColor = toolStrip.BackColor;
        }
Exemplo n.º 34
0
        public DictionaryUpdater(DB_Connector dbConnection, string address, string fisLogin, string fisPassword)
        {
            #region Contracts
            if (dbConnection == null)
            {
                throw new System.ArgumentNullException(nameof(dbConnection));
            }
            if (string.IsNullOrWhiteSpace(fisLogin))
            {
                throw new System.ArgumentException("Некорректный логин.", nameof(fisLogin));
            }
            if (string.IsNullOrWhiteSpace(fisPassword))
            {
                throw new System.ArgumentException("Некорректный пароль.", nameof(fisPassword));
            }
            #endregion

            _DB_Connection = dbConnection;
            _FIS_Address   = address;
            _FIS_Login     = fisLogin;
            _FIS_Password  = fisPassword;
            _DB_Helper     = new DB_Helper(_DB_Connection);
        }
Exemplo n.º 35
0
    protected void btnSendCode_Click(object sender, EventArgs e)
    {
        if (regexEmailValid.IsValid && RequiredFieldValidator1.IsValid)
        {
            DB_Helper db = new DB_Helper();
            string em =txtEmail.Text;

            if (em.StartsWith("ACTIVATE"))
            {
                db.Execute(string.Format("update Users set email_verified=1 where id_user = {0}", MyUtils.ID_USER));
                MyUtils.RefreshUserRow();
            }
            else
            {

                int id_user = db.ExecuteScalarInt("select id_user from users where email=" + MyUtils.safe(em), 0);
                if (id_user > 0 && id_user != MyUtils.ID_USER)
                {
                    Session["message"] = "ERROR: This email is already used by a different user.";
                    return;
                }
                db.Execute("update users set email=" + MyUtils.safe(em) + " where id_user="******"EMAIL_ACTIVATE", MyUtils.ID_USER);
                Session["message"] = "OK: Activation email was sent. Please check your inbox.";
            }
        }
        else Session["message"] = "ERROR: Invalid email.";

        bool needtoverify = Convert.ToUInt32(MyUtils.GetUserField("email_verified")) == 0;
        if (!needtoverify)
        {
            Response.Redirect("/Account/");
            Session["message"] = "Account is active.";
        }
    }
        void input_name_Completed(object sender, PopUpEventArgs <string, PopUpResult> e)
        {
            name = e.Result;
            DB_Helper.connect();
            ObservableCollection <Index> test = DB_Helper.get_Index_By_Name(name);

            if (test.Count == 0)
            {
                mAuthor = "Custom";
                DB_Helper.createIndex(name, desc, mRace, mAuthor, "", "");
                ObservableCollection <Index> result = DB_Helper.get_Index_By_Name(name);
                int index_id = result[0].Id;

                for (int i = 0; i < BuildOrder.Count; i++)
                {
                    DB_Helper.insertBuild(index_id, i, BuildOrder[i].ObjId, "", "");
                }
                NavigationService.Navigate(new Uri("/MainMenu.xaml", UriKind.RelativeOrAbsolute));
            }
            else
            {
                MessageBox.Show("Name is used. Please choose other name.");
            }
        }
Exemplo n.º 37
0
        public QuotDocs(DB_Connector connection, Forms.ApplicationEdit.QDoc loadedDocument)
        {
            InitializeComponent();

            _DB_Connection = connection;
            DB_Helper dbHelper = new DB_Helper(_DB_Connection);


            cbCause.SelectedIndex    = 0;
            cbMedCause.SelectedIndex = 0;

            cbOrphanhoodDocType.DataSource    = dbHelper.GetDictionaryItems(FIS_Dictionary.ORPHAN_DOC_TYPE).Values.ToArray();
            cbOrphanhoodDocType.SelectedIndex = 0;

            cbDisabilityGroup.DataSource    = dbHelper.GetDictionaryItems(FIS_Dictionary.DISABILITY_GROUP).Values.ToArray();
            cbDisabilityGroup.SelectedIndex = 0;

            _Document = loadedDocument;
            if (loadedDocument.cause == "Медицинские показатели")
            {
                cbCause.SelectedItem           = loadedDocument.cause;
                cbMedCause.SelectedItem        = loadedDocument.medCause;
                tbMedDocSeries.Text            = loadedDocument.medDocSerie;
                tbMedDocNumber.Text            = loadedDocument.medDocNumber;
                cbDisabilityGroup.SelectedItem = loadedDocument.disabilityGroup;
                tbConclusionNumber.Text        = loadedDocument.conclusionNumber;
                dtpConclusionDate.Value        = loadedDocument.conclusionDate;
            }
            else if (loadedDocument.cause == "Сиротство")
            {
                cbOrphanhoodDocType.SelectedItem = loadedDocument.orphanhoodDocType;
                tbOrphanhoodDocName.Text         = loadedDocument.orphanhoodDocName;
                dtpOrphanhoodDocDate.Value       = loadedDocument.orphanhoodDocDate;
                tbOrphanhoodDocOrg.Text          = loadedDocument.orphanhoodDocOrg;
            }
        }
Exemplo n.º 38
0
 private static void EnsureFilterIsSaved(Filter f)
 {
     string user_filter = MyUtils.GetUserField("filter") as string;
     string current_filter = f.ToString();
     if (user_filter != current_filter)
     {
         DB_Helper db = new DB_Helper();
         int id_user = MyUtils.ID_USER; //currently logged in user
         if (f.IsDefault()) current_filter = "DEFAULT";
         db.Execute("update users set filter=" + MyUtils.safe(current_filter) + " where id_user=" + id_user);
         MyUtils.RefreshUserRow();
     }
 }
Exemplo n.º 39
0
    private static DataSet GetUsers(int index, string filter, out string sql)
    {
        //index = 1;
        DB_Helper db = new DB_Helper();

        int id_user = (int) MyUtils.GetUserField("id_user"); //currently logged in user

        if (string.IsNullOrEmpty(filter)) filter = db.ExecuteScalarString("select isnull(filter,'DEFAULT') from users where id_user="******"mainphoto_");
        d.Tables[0].Columns.Add("online");
        d.Tables[0].Columns.Add("button_switch");
        foreach (DataRow r in d.Tables[0].Rows)
        {
            r["button_switch"] = GetButtonSwitch(r);
            r["mainphoto_"] = MyUtils.GetImageUrl(r, MyUtils.ImageSize.MEDIUM);
            r["online"] = MyUtils.IsOnline((int)r["id_user"]) ? "1" : "0";// ..GetImageUrl(r, MyUtils.ImageSize.MEDIUM);
        }
        d.Tables[0].Columns.Remove("mainphoto");
        d.Tables[0].Columns["mainphoto_"].ColumnName = "MainPhoto";

        d.Tables[0].TableName = "U";
        DataTable t = new DataTable();
        t.TableName = "filter";
        t.Columns.Add("json");
        t.Rows.Add(t.NewRow());
        t.Rows[0]["json"] = f.ToString();
        d.Tables.Add(t);
        return d;
    }