public FormReports(res.Employee _curEmpl)
 {
     InitializeComponent();
     database = new res.Model1Container(RegistryInteractor.GetFromReg("Connection String"));
     curEmpl = _curEmpl;
     InitTypes();
 }
        public FormEditOrder(ref res.Employee curEmpl)
        {
            InitializeComponent();
            mode = (short)OrderMode.mode_new;
            curEmployee = curEmpl;
            lbl_num.Text = "Новый";
            #region database context & entities filling
            database = new res.Model1Container(RegistryInteractor.GetFromReg("Connection String"));
            curPositions = new List<PositionForOrder>();
            curOrder = res.Order.CreateOrder(-1, DateTime.Now, "Обработка", -1, -1);
            Items = from it in database.ItemSet select it;
            Categories = from cat in database.ItemCategorySet select cat;
            #endregion
            #region data sources
            cb_itemType.DataSource = Categories.ToArray();
            cb_itemType.DisplayMember = "name";
            cb_itemType.ValueMember = "id";

            DGV.DataSource = DGV_contentsT;
            #endregion
            #region event_bindings
            cb_itemType.SelectedValueChanged += new EventHandler(btn_addPos_check);
            cb_itemType.SelectedValueChanged += new EventHandler(this.cb_itemType_SelectedIndexChanged);

            cb_itemDesignation.SelectedIndexChanged += new EventHandler(this.cb_itemDesignation_SelectedIndexChanged);
            cb_itemDesignation.SelectedValueChanged += new EventHandler(this.num_itemCount_check);
            cb_itemDesignation.SelectedValueChanged += new EventHandler(btn_addPos_check);
            cb_itemDesignation.SelectedValueChanged += new EventHandler(num_itemCount_anull);

            num_itemCount.ValueChanged += new EventHandler(btn_addPos_check);
            num_itemCount.ValueChanged += new EventHandler(num_itemCount_ValueChanged);

            btn_addItem.Click += new EventHandler(btn_addItem_Click);
            btn_addItem.Click += new EventHandler(btn_rmItem_check);
            btn_addItem.Click += new EventHandler(DGV_contentsT_Refill);
            btn_addItem.Click += new EventHandler(this.btn_accept_check);

            btn_rmItem.Click += new EventHandler(btn_rmItem_Click);
            btn_rmItem.Click += new EventHandler(btn_rmItem_check);
            btn_rmItem.Click += new EventHandler(DGV_contentsT_Refill);
            btn_rmItem.Click += new EventHandler(this.btn_accept_check);

            btn_accept.Click += new EventHandler(btn_accept_Click);

            tb_Name.TextChanged += new EventHandler(this.btn_accept_check);
            tb_phone.TextChanged += new EventHandler(this.btn_accept_check);

            DGV.SelectionChanged += new EventHandler(btn_rmItem_check);
            DGV.CellValueChanged += new DataGridViewCellEventHandler(DGV_CellValueChanged);
            DGV.CellValueChanged += new DataGridViewCellEventHandler(DGV_contentsT_Refill);
            DGV.DataError += new DataGridViewDataErrorEventHandler(DGV_DataError);
            #endregion
        }
 private void btn_ok_Click(object sender, EventArgs e)
 {
     int sel_apt_id = -1;
     string str_acc = "";
     if (rb_ord.Checked)
     {
         sel_apt_id = (from app in database.AppointmentSet where app.name == "Заказы" select app).Single().id;
         str_acc = "к заказам";
     }
     else if (rb_store.Checked)
     {
         sel_apt_id = (from app in database.AppointmentSet where app.name == "Склад" select app).Single().id;
         str_acc = "к складу";
     }
     else
     {
         sel_apt_id = (from app in database.AppointmentSet where app.name == "Полный" select app).Single().id;
         str_acc = "ко всему";
     }
     resEmpl = res.Employee.CreateEmployee(-1, tb_name.Text, tb_login.Text, tb_login.Text, sel_apt_id);
     #region confirmation
     DialogResult cnd = MessageBox.Show(string.Format("Добавить пользователя с никнеймом {0} \n ФИО {1} \n и доступом {2} \n в базу данных?", resEmpl.login, resEmpl.name, str_acc), "Внимание", MessageBoxButtons.YesNo);
     if (cnd == DialogResult.No) return;
     #endregion
     #region check_if_exist
     if (Employees.Any(emp => emp.login == resEmpl.login))
     {
         MessageBox.Show("Такой логин уже занят");
         return;
     }
     #endregion
     #region addition
     lbl_try_add_user:
     try
     {
         database.AddObject("EmployeeSet", resEmpl);
         database.SaveChanges();
     }
     catch (Exception exc)
     {
         DialogResult dlgres = MessageBox.Show("Не удалось добавить пользователя в базу данных:" + exc.Message, "Системная ошибка", MessageBoxButtons.RetryCancel);
         switch (dlgres)
         {
             case DialogResult.Cancel:
                 return;
             case DialogResult.Retry:
                 goto lbl_try_add_user;
         }
     }
     #endregion
 }
        public FormEditEmplOne(ref res.Employee empl)
        {
            InitializeComponent();
            database = new res.Model1Container(RegistryInteractor.GetFromReg("Connection String"));
            Employees = from emp in database.EmployeeSet select emp;
            this.Empl = empl;
            lbl_username.Text = Empl.login;
            btn_loginChange.Enabled = false;

            #region event_bindings
            Empl.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(this.user_prop_changed);
            database.SavingChanges += new System.EventHandler(this.database_changing);
            #endregion
        }
        private void btn_enter_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(tb_login.Text) && !String.IsNullOrEmpty(tb_passwd.Text))
            {
                try
                {
                    #region compare entered login data with data in DB

                    if ((from emp in database.EmployeeSet where emp.login == tb_login.Text select emp).Count() == 0)
                    {
                        MessageBox.Show("Нет такого пользователя в базе данных, проверьте правильность ввода логина");
                        return;
                    }
                    else
                    {
                        if ((from emp in database.EmployeeSet where emp.login == tb_login.Text select emp).Single().password != tb_passwd.Text)
                        {
                            MessageBox.Show("Неверный пароль");
                            return;
                        }
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + "\n Будет осуществлен выход, обратитесь к системному администратору", "Ошибка базы данных", MessageBoxButtons.OK);
                    this.Close();
                    return;
                }

                #region get empl from DB
                usr = (from emp in database.EmployeeSet where emp.login == tb_login.Text select emp).Single();

                #endregion
                if (cb_remember.Checked)
                {
                    #region Saving current user to registry
                    RegistryInteractor.WriteToReg("Last User", tb_login.Text);
                    #endregion
                }
                DialogResult = DialogResult.OK;
                return;
            }
            else
            {
                MessageBox.Show("Логин и пароль не должны быть пустыми");
                return;
            }
        }
 private void btn_search_Click(object sender, EventArgs e)
 {
     if (Employees.Any(emp => emp.login == (string)tb_search.Text))
     {
         selEmpl = Employees.Single(emp => emp.login == (string)tb_search.Text);
         if (selEmpl == null)
         {
             MessageBox.Show("Поиск не дал результатов");
             return;
         }
         selEmpl_Changed();
     }
     else
     {
         selEmpl = null;
         lbl_id.Text = "";
         lbl_name.Text = "";
         MessageBox.Show("Поиск не дал результатов");
     }
 }
 public FormEditEmplSet(res.Employee _preselEmpl, res.Employee _curEmpl)
     : this(_curEmpl)
 {
     selEmpl = _preselEmpl;
     selEmpl_Changed();
 }
Exemple #8
0
 private void Logout()
 {
     this.curEmpl = null;
     this.Enabled = false;
     this.Hide();
 }
Exemple #9
0
        //################# IDENTIFICATION ############################
        private void Login()
        {
            FormLogin flogin = new FormLogin();
            DialogResult res = flogin.ShowDialog();
            switch (res)
            {
                case DialogResult.OK:
                    this.Enabled = true;
                    this.curEmpl = flogin.usr;
                    curEmpl.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(this.user_prop_changed);
                    this.Text = Settings.AppTitle + " - " + curEmpl.login;

                    database = new res.Model1Container(RegistryInteractor.GetFromReg("Connection String"));
                    search_Panel_Initialization();
                    cb_table_Init_And_Fill();

                    this.Enabled = true;
                    this.Show();

                    break;
                default:
                    MessageBox.Show("Окно авторизации было закрыто", "Ошибка авторизации");
                    this.Show();
                    break;
            }
        }