コード例 #1
0
ファイル: FormSignIn.cs プロジェクト: skanerOH/ISTP_EF_lab
 private void buttonSignIn_Click(object sender, EventArgs e)
 {
     if (!String.IsNullOrWhiteSpace(textBoxLogin.Text) && !String.IsNullOrWhiteSpace(textBoxPassword.Text))
     {
         var user = (from u in ctx.RegisteredUsers where (u.login == textBoxLogin.Text) select u).Any();
         if (!user)
         {
             MessageBox.Show("User with this name is not exist");
         }
         else
         {
             user = (from u in ctx.RegisteredUsers where (u.login == textBoxLogin.Text && u.password == textBoxPassword.Text) select u).Any();
             if (!user)
             {
                 MessageBox.Show("Login or password is incorrect");
             }
             else
             {
                 ClassLib.RegisteredUsers logedInUser = (from u in ctx.RegisteredUsers where (u.login == textBoxLogin.Text && u.password == textBoxPassword.Text) select u).First();
                 FormMain formMain = new FormMain(logedInUser);
                 this.Hide();
                 formMain.ShowDialog();
                 formMain.Dispose();
                 this.Show();
             }
         }
     }
     else
     {
         MessageBox.Show("You need to fill login and password fields");
     }
 }
コード例 #2
0
        public FormOffersOfBank(int b_idtempo, ClassLib.RegisteredUsers tempo)
        {
            user = tempo;
            InitializeComponent();
            ctx  = new BanksDBV2Entities();
            b_id = b_idtempo;

            if (user.access_lvl > 0)
            {
            }
            else
            {
                SetSettingsForUser();
            }

            comboBoxOfferType.SelectedIndex = 2;

            var query = (from offer in ctx.Offers
                         join con in ctx.Conditions on offer.o_c_ID equals con.c_ID
                         where (offer.o_b_ID == b_id &&
                                con.c_credit_count_max >= (int)numericUpDownCredCount.Value &&
                                con.c_deposit_count_min <= (int)numericUpDownDepCount.Value &&
                                con.c_sum_max >= (int)numericUpDownSum.Value && con.c_sum_min <= (int)numericUpDownSum.Value)
                         select offer);

            query = query.Where(c => c.o_b_ID == b_id);
            if (!String.IsNullOrWhiteSpace(textBoxName.Text))
            {
                query = query.Where(c => c.o_name.Contains(textBoxName.Text));
            }
            if (comboBoxOfferType.SelectedIndex != 2)
            {
                query = query.Where(c => c.o_ot_ID == (comboBoxOfferType.SelectedIndex + 1));
            }

            if ((int)numericUpDownPercentage.Value != 0)
            {
                query = query.Where(c => c.o_percentage == (int)numericUpDownPercentage.Value);
            }

            query.Load();
            offersBindingSource.DataSource = ctx.Offers.Local.ToBindingList();

            ctx.Conditions.Load();
            conditionsBindingSource.DataSource = ctx.Conditions.Local.ToBindingList();

            ctx.OfferType.Load();
            offerTypeBindingSource.DataSource = ctx.OfferType.Local.ToBindingList();
        }
コード例 #3
0
        public FormContractsOfClient(int cl_idtemp, ClassLib.RegisteredUsers tempo)
        {
            user = tempo;
            InitializeComponent();
            cl_id = cl_idtemp;

            if (user.access_lvl > 0)
            {
            }
            else
            {
                SetSettingsForUser();
            }

            comboBoxContractType.SelectedIndex = 0;
            LoadContracts();
        }
コード例 #4
0
        public FormMain(ClassLib.RegisteredUsers temp)
        {
            logedInUser = temp;
            InitializeComponent();

            if (logedInUser.access_lvl > 0)
            {
            }
            else
            {
                SetSettingForUser();
            }
            ctx = new BanksDBV2Entities();

            ctx.Banks.Load();
            this.banksBindingSource.DataSource = ctx.Banks.Local.ToBindingList();

            ctx.Clients.Load();
            this.clientsBindingSource.DataSource = ctx.Clients.Local.ToBindingList();

            ctx.ClientType.Load();
            this.clientTypeBindingSource.DataSource = ctx.ClientType.Local.ToBindingList();
        }
コード例 #5
0
ファイル: FormSignUp.cs プロジェクト: skanerOH/ISTP_EF_lab
        private void buttonSignUp_Click(object sender, EventArgs e)
        {
            if (IsPasswordValid() && IsLoginValid() && IsAdminCodeValid())
            {
                ClassLib.RegisteredUsers newuser = new ClassLib.RegisteredUsers();
                System.Nullable <int>    ID      = (int)(from u in ctx.RegisteredUsers select u.ID).Max() + 1;
                newuser.ID       = (int)ID;
                newuser.login    = textBoxLogin.Text;
                newuser.password = textBoxPassword.Text;
                if (textBoxAdminCode.Text == "I am ADMIN")
                {
                    newuser.access_lvl = 2;
                }
                else
                {
                    newuser.access_lvl = 0;
                }

                ctx.RegisteredUsers.Add(newuser);
                ctx.SaveChanges();

                this.Dispose();
            }
        }