Example #1
0
 public FormReports(res.Employee _curEmpl)
 {
     InitializeComponent();
     database = new res.Model1Container(RegistryInteractor.GetFromReg("Connection String"));
     curEmpl = _curEmpl;
     InitTypes();
 }
        public FormEditEmplSet(res.Employee _curEmpl)
        {
            InitializeComponent();

            database = new res.Model1Container(RegistryInteractor.GetFromReg("Connection String"));
            Employees = from emp in database.EmployeeSet select emp;
            Appointments = from app in database.AppointmentSet select app;

            this.curEmpl = _curEmpl;

            cb_app_fill();
        }
        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
        }
Example #4
0
        public FormIntake(res.Item _preselectedItem)
        {
            InitializeComponent();
            database = new res.Model1Container(RegistryInteractor.GetFromReg("Connection String"));

            FillCategories();

            cb_type.SelectedValue = _preselectedItem.catID;
            RefillItems();
            cb_designation.SelectedValue = _preselectedItem.id;
            checks(this, null);
        }
Example #5
0
        public FormNewEmpl()
        {
            InitializeComponent();
            database = new res.Model1Container(RegistryInteractor.GetFromReg("Connection String"));
            Employees = from emp in database.EmployeeSet select emp;

            #region event_bindings
            tb_login.TextChanged += new EventHandler(Idata_Changed);
            tb_name.TextChanged += new EventHandler(Idata_Changed);
            rb_ord.CheckedChanged += new EventHandler(Idata_Changed);
            rb_store.CheckedChanged += new EventHandler(Idata_Changed);
            #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
        }
Example #7
0
        public FormIntake()
        {
            InitializeComponent();
            database = new res.Model1Container(RegistryInteractor.GetFromReg("Connection String"));
            database.Connection.Open();
            cb_type.IsAccessible = false;
            cb_designation.IsAccessible = false;
            btn_accept.Enabled = false;

            #region events
            this.cb_type.SelectedIndexChanged += new EventHandler(checks);
            this.cb_designation.SelectedIndexChanged += new EventHandler(checks);
            #endregion

            FillCategories();
        }
        public FormEditCategories()
        {
            InitializeComponent();
            #region Event Bindings
            this.tb_catName.TextChanged += new System.EventHandler(this.btn_checks);
            this.tb_newParamName.TextChanged += new System.EventHandler(this.btn_checks);
            this.tb_newItemDesignation.TextChanged += new System.EventHandler(this.btn_checks);

            this.rb_binary.CheckedChanged += new EventHandler(this.btn_checks);
            this.rb_numeric.CheckedChanged +=new EventHandler(this.btn_checks);
            this.rb_text.CheckedChanged += new EventHandler(this.btn_checks);

            this.cb_cat.SelectedIndexChanged += new System.EventHandler(this.RefillAssociations);
            this.cb_cat.SelectedIndexChanged += new System.EventHandler(this.RefillItems);
            this.cb_cat.SelectedIndexChanged += new System.EventHandler(this.RefillItemParameters);

            this.cb_existingItem.SelectedIndexChanged += new System.EventHandler(this.RefillItemParameters);

            this.btn_accParams.Click += new EventHandler(btn_accParams_Click);
            this.btn_accParams.Click += new System.EventHandler(this.RefillItemParameters);

            this.btn_addPar.Click +=new EventHandler(btn_addPar_Click);
            this.btn_addPar.Click += new System.EventHandler(this.RefillAssociations);

            this.btn_addCat.Click += new System.EventHandler(this.btn_addCat_Click);
            this.btn_addCat.Click += new System.EventHandler(this.RefillCategories);

            this.btn_addItem.Click += new System.EventHandler(this.btn_addItem_Click);
            this.btn_addItem.Click += new System.EventHandler(this.RefillItems);

            this.btn_accItem.Click += new System.EventHandler(this.btn_accItem_Click);

            this.DGV_catParameters.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.btn_checks);
            this.DGV_catParameters.CellValueChanged += new DataGridViewCellEventHandler(DGV_catParameters_CellValueChanged);
            this.DGV_itemParameters.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.btn_checks);

            #endregion

            #region context & entities
            database = new res.Model1Container(RegistryInteractor.GetFromReg("Connection String"));
            #endregion
            InitTables();
            FillPTypeSelector();
            RefillCategories(null, null);
        }
Example #9
0
 public FormLogin()
 {
     InitializeComponent();
     database = new res.Model1Container(RegistryInteractor.GetFromReg("Connection String"));
     try
     {
         #region Retrieving last user from registry
         tb_login.Text = RegistryInteractor.GetFromReg("Last User");
         if (tb_login.Text.ToString().Length != 0)
         {
             cb_remember.Checked = true;
         }
         #endregion
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ошибка взаимодействия с реестром");
     }
 }
Example #10
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            #region Writing current pwd & usr to registry
            Regex sep = new Regex("bin");
            pwd = sep.Split(Application.ExecutablePath)[0];
            if (!RegistryInteractor.SubkeyExists())
            {
                RegistryInteractor.CreateSubkey();
                RegistryInteractor.WriteToReg("Last User", "");
            }
            RegistryInteractor.WriteToReg("Root Directory", pwd);
            RegistryInteractor.WriteToReg("Database Directory", pwd + "DATA\\");
            RegistryInteractor.WriteToReg("Reports Directory", pwd + "Reports\\");
            RegistryInteractor.WriteToReg("Resource Directory", pwd + "res\\");
            #endregion
            #region Set proper location for DB in application config file
            string connectionString = ConfigurationManager.ConnectionStrings["Model1Container"].ConnectionString.Replace("|DataDirectory|", RegistryInteractor.GetFromReg("Database Directory"));
            RegistryInteractor.WriteToReg("Connection String", connectionString);
            #endregion
            res.Model1Container database = new res.Model1Container(RegistryInteractor.GetFromReg("Connection String"));

            if (!Directory.EnumerateFiles(RegistryInteractor.GetFromReg("Database Directory"), "STORE.mdf").Any())
            {
                #region Deployment
                if (MessageBox.Show("Похоже, это первый запуск приложения. Создать базу данных? В неё будет занесен пока единственный пользователь admin (пароль 'admin') и категории параметров товаров по умлочанию: Наименование, Цена закупки и Цена продажи.", "Внимание", MessageBoxButtons.YesNo) == DialogResult.No)
                    Application.Exit();
                try
                {
                    if (database.DatabaseExists())
                    {
                        database.DeleteDatabase();
                    }
                    database.CreateDatabase();
                    database.SaveChanges();

                    res.Appointment adm = res.Appointment.CreateAppointment(0, (short)accessModifiers.acc_adm, "Полный");
                    database.AddToAppointmentSet(res.Appointment.CreateAppointment(0, (short)accessModifiers.acc_none, "Нет"));
                    database.AddToAppointmentSet(res.Appointment.CreateAppointment(0, (short)accessModifiers.acc_stock, "Склад"));
                    database.AddToAppointmentSet(res.Appointment.CreateAppointment(0, (short)accessModifiers.acc_ord, "Заказы"));
                    database.AddToAppointmentSet(adm);

                    res.Employee admin = res.Employee.CreateEmployee(0, "admin", "admin", "admin", 0);
                    admin.Appointment = adm;
                    database.AddToEmployeeSet(admin);

                    database.AddToParameterCategorySet(res.ParameterCategory.CreateParameterCategory(0, "Наименование", 1));
                    database.AddToParameterCategorySet(res.ParameterCategory.CreateParameterCategory(0, "Цена закупки", 2));
                    database.AddToParameterCategorySet(res.ParameterCategory.CreateParameterCategory(0, "Цена продажи", 2));

                    database.SaveChanges();
                }
                catch (Exception exc)
                {
                    MessageBox.Show("Произошла ошибка при создании базы данных: \n" + exc.Message);
                    Application.Exit();
                }
                #endregion
            }

            FormMain formMain = new FormMain();
            formMain.Hide();
            Application.Run(formMain);
        }
Example #11
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;
            }
        }