Пример #1
0
        private void ButtonAdd_Click(object sender, RoutedEventArgs e)
        {
            MsAccess acs    = new MsAccess();
            string   result = "0";
            string   sql    = $@"
                Select
                  nrm.nrm_id
                From
                  nrm
                Where
                  nrm.nrm_dt = {DatePickerNorm.SelectedDate:#M-d-yyyy#}
                ";

            result = acs.GetValueSql(sql);
            if (result != "0")
            {
                MessageBox.Show($@"Данные на {DatePickerNorm.SelectedDate:#M-d-yyyy#} уже есть в системе");
                return;
            }
            else
            {
                sql =
                    $@"INSERT INTO nrm (nrm_dt, stf_tn, nrm_hr, nrm_scr) 
                    SELECT {DatePickerNorm.SelectedDate:#M-d-yyyy#}, stf_tn, nrm_hr, nrm_scr 
                    FROM nrm WHERE nrm_dt = (SELECT MAX(nrm_dt) FROM nrm WHERE nrm_dt <= {
                            DatePickerNorm.SelectedDate
                        :#M-d-yyyy#})";
                acs.GetValueSql(sql);
                GenerateNormsDep();

                //Запись лога
                acs.Log(DatePickerNorm.SelectedDate.Value.ToShortDateString(), "Создание");
            }
        }
Пример #2
0
        private void editButton_Click(object sender, RoutedEventArgs e)
        {
            string   dep        = ((TextBlock)((StackPanel)((Button)sender).Parent).Children[0]).Text;
            MsAccess acs        = new MsAccess();
            string   normDbPath = Environment.CurrentDirectory + @"\Resources\Norm.accdb";
            //Uri uri = new Uri(@"pack://*****:*****@"INSERT INTO nrm (nrm_dt, stf_tn, stf_fln, pos_nm, nrm_hr, nrm_scr) IN '{normDbPath}' 
                    SELECT nrm.nrm_dt, nrm.stf_tn, stf.stf_fln, pos.pos_nm, nrm.nrm_hr, nrm.nrm_scr 
                    FROM pos INNER JOIN ((dep INNER JOIN stf ON dep.dep_id = stf.dep_id) INNER JOIN nrm ON stf.stf_tn = nrm.stf_tn) ON pos.pos_id = stf.pos_id
                    WHERE dep.dep_mn = ""{dep}"" AND nrm.nrm_dt = {DatePickerNorm.SelectedDate:#M-d-yyyy#} ; ";
            acs.GetValueSql(sql);
            acs.PathToBase = normDbPath;
            acs.AccessFormsOpen("nrm");
            //Подсвечиваю отдел в котором были изменения
            ((TextBlock)((StackPanel)((Button)sender).Parent).Children[0]).Background = Brushes.OrangeRed;
            ButtonUpdate.Visibility = Visibility.Visible;
            ButtonReset.Visibility  = Visibility.Visible;
            _dep = dep;
        }