Пример #1
0
        private void SearchText(bool fromfirst = true, bool forward = true)
        {
            if (dgvDocs0.CurrentRow == null || dgvDocs0.CurrentRow.IsNewRow)
            {
                return;
            }
            if (!dgvDocs0.EndEditX())
            {
                return;
            }

            int startindex = dgvDocs0.CurrentRow.Index;

            startindex = fromfirst ? 0 : (forward ? startindex + 1 : startindex - 1);
            string text = tsbSearch.Text;

            if (text == "")
            {
                return;
            }
            int newindex = SearchText(text, dgvDocs0.CurrentCell.ColumnIndex, startindex, forward);

            if (newindex == -1)
            {
                MyMainForm.ShowInfo("Tekts [" + text + "] netika atrasts.");
                return;
            }
            dgvDocs0.CurrentCell = dgvDocs0[dgvDocs0.CurrentCell.ColumnIndex, newindex];
        }
Пример #2
0
        private void DoIt()
        {
            string rt = Check();

            if (rt != "OK")
            {
                MyMainForm.ShowWarning(rt);
                return;
            }

            try
            {
                MyData.CreateNewDB(name, descr);
            }
            catch (Exception ex)
            {
                Form_Error.ShowException(this,
                                         new Exception("Neizdevās izveidot jaunu datubāzi.", ex));
                return;
            }
            MyData.SaveMasterList();
            MyMainForm.ShowInfo
            (
                "Pēc jaunas datubāzes izveidošanas neaizmirstam idarīt sekojošo:\n" +
                "1. Aizpildīt formu 'Ziņas par uzņēmumu'\n" +
                "2. Formā 'Kā strādādim?' norādīt darba parametrus"
            );
            DialogResult = DialogResult.OK;
        }
Пример #3
0
        private void cmReport_Click(object sender, EventArgs e)
        {
            if (bsRows.DataSource == null || bsRows.Count == 0)
            {
                MyMainForm.ShowInfo("Pārskatam nav datu.");
                return;
            }

            MyData.ReportHelper.CheckForErrors(() =>
            {
                if (DoGrouping)
                {
                    if (GroupFieldsOrderA[1] == -1)
                    {
                        MakeReport2();
                    }
                    else if (GroupFieldsOrderA[3] == -1)
                    {
                        MakeReport3();
                    }
                    else
                    {
                        MyMainForm.ShowWarning("Atlasītajiem datiem programma atskaiti nevar izveidot.");
                    }
                }
                else
                {
                    MakeReport1();
                }
            });
        }
Пример #4
0
        private void DoIt()
        {
            string rt = Check();

            if (rt != "OK")
            {
                MyMainForm.ShowWarning(rt);
                return;
            }

            try
            {
                MyData.CreateNewDB(name, descr);
            }
            catch (Exception ex)
            {
                Form_Error.ShowException(this,
                                         new Exception("Neizdevās izveidot jaunu datubāzi.", ex));
                return;
            }
            MyData.SaveMasterList();
            MyMainForm.ShowInfo
            (
                "Pēc jaunas datubāzes izveidošanas neaizmirstam idarīt sekojošo:\n" +
                "1. Rediģēt lietotāju sarakstu\n" +
                "2. Aizpildīt formu 'Ziņas par uzņēmumu'\n" +
                "3. Formā 'Kā strādādim?' atzīmēt nepieciešamās kontējuma pazīmes\n" +
                "4. Rediģēt kontu plānu\n" +
                "5. Aizpildīt formu 'Kontējumu korekcijas'"
            );
            DialogResult = DialogResult.OK;
        }
Пример #5
0
        private void tsbInfo_Click(object sender, EventArgs e)
        {
            string s1 = bsDocTyp.GetStats();
            string s2 = bsDocTypA.GetStats();
            string s3 = bsDocTypB.GetStats();
            var    s  = string.Format("Mainīti ieraksti:\n  dokumentu veidi - {0}\n" +
                                      "  dokumentu grupas - {1}\n  grupas saturs - {2}", s1, s2, s3);

            MyMainForm.ShowInfo(s);
        }
Пример #6
0
 private void DoIt()
 {
     if (!decimal.TryParse(tbSumm.Text, out Summ) ||
         !decimal.TryParse(tbPVN.Text, out PVN))
     {
         MyMainForm.ShowInfo("Ievadīta nekorekta summa.");
         return;
     }
     DialogResult = DialogResult.OK;
 }
Пример #7
0
 private void tsbReport_Click(object sender, EventArgs e)
 {
     if (bsRows.Count == 0 || YearCurrent == 0 || Year1 == 0)
     {
         MyMainForm.ShowInfo("Pārskatam nav datu.");
         return;
     }
     MyData.ReportHelper.CheckForErrors(() =>
     {
         MakeReport();
     });
 }
Пример #8
0
        private void cmReport_Click(object sender, EventArgs e)
        {
            if (bsRows.DataSource == null || bsRows.Count == 0)
            {
                MyMainForm.ShowInfo("Pārskatam nav datu.");
                return;
            }

            MyData.ReportHelper.CheckForErrors(() =>
            {
                MakeReport();
            });
        }
Пример #9
0
        private void CheckFormulasA(bool pza = false)
        {
            if (!SaveData())
            {
                return;
            }
            var o = dgvBalA1.GetCurrentDataItem();

            if (o == null)
            {
                return;
            }

            string balid = (string)dgvBalA1.CurrentRow.Cells[dgcBalA1balid.Index].Value;

            var dt = MyData.KlonsTableAdapterManager.AcP21TableAdapter.GetDataBy_bal_13(balid);

            if (pza)
            {
                dt.DefaultView.RowFilter = "AC >= '6' AND AC < '9'";
            }
            int k = dt.DefaultView.Count;

            if (k == 0)
            {
                MyMainForm.ShowInfo("Kļūdas netika atrastas\n(bet tas nenozīmē kā tādu tur nav)");
                return;
            }
            if (k > 20)
            {
                k = 20;
            }
            StringBuilder sb = new StringBuilder();

            sb.Append("Šie konti nav iekļauti formulās:\n");
            for (int i = 0; i < k; i++)
            {
                sb.Append(dt.DefaultView[i].Row[0]);
                if (i < k - 1)
                {
                    sb.Append(", ");
                }
            }
            if (k < dt.DefaultView.Count)
            {
                sb.Append(", ...");
            }

            MyMainForm.ShowInfo(sb.ToString());
        }
Пример #10
0
        public void DoRead()
        {
            if (tbDate1.Text.IsNOE() || tbDate2.Text.IsNOE())
            {
                MyMainForm.ShowWarning("Nav norādīti datumi.");
                return;
            }

            if (!Utils.StringToDate(tbDate1.Text, out var dt1) ||
                !Utils.StringToDate(tbDate2.Text, out var dt2) ||
                dt2 < dt1)
            {
                MyMainForm.ShowWarning("Norādīts nekorekts datums");
                return;
            }

            var ofd = new OpenFileDialog();

            ofd.Filter           = "XML faili (*.xml)|*.xml";
            ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            ofd.CheckFileExists  = true;
            ofd.Multiselect      = false;
            ofd.Title            = "Norādi EDS pārskata xml failu";
            if (ofd.ShowDialog(MyMainForm) != DialogResult.OK)
            {
                return;
            }
            var fnm = ofd.FileName;

            var importer = new EGrmUntMinImporter();
            var rt_msg   = importer.GetUntMinResult(fnm, dt1, dt2, out var missingnames, out var changes);

            Changes           = changes;
            bsRows.DataSource = changes;
            if (rt_msg != "OK")
            {
                MyMainForm.ShowWarning(rt_msg);
                return;
            }
            if (missingnames.Count > 0)
            {
                var msg = string.Join("\n", missingnames);
                MyMainForm.ShowInfo("Nav datu par šiem darbiniekiem:\n" + msg);
            }
            if (changes.Count == 0)
            {
                MyMainForm.ShowInfo("Pārskats nesatur jaunus datus.");
            }
        }
Пример #11
0
        private void miSaglabātSarēķinātosKasesMaksājumus_Click(object sender, EventArgs e)
        {
            if (PersonPayRows == null || PersonPayRows.Count == 0)
            {
                return;
            }
            var rt = SaveCalcVal(PersonPayRows);

            if (rt != "OK")
            {
                MyMainForm.ShowWarning(rt);
                return;
            }
            MyMainForm.ShowInfo("Dati saglabāti.\nNeaizmirsti veikt maksājumu sarakstu pārrēķinu");
        }
Пример #12
0
        private void cmShowErrors_Click(object sender, EventArgs e)
        {
            if (ErrorList == null || ErrorList.Count == 0)
            {
                MyMainForm.ShowInfo("Kļūdu saraksts ir tukšs.");
                return;
            }
            var fm = MyMainForm.ShowFormDialog(typeof(Form_ImportErrors)) as Form_ImportErrors;

            if (fm == null)
            {
                return;
            }
            fm.SetErrorList(ErrorList);
        }
Пример #13
0
        private void cmNrKIZO_Click(object sender, EventArgs e)
        {
            string rt = Check();

            if (rt != "OK")
            {
                MyMainForm.ShowWarning(rt);
                return;
            }
            SaveParams();

            var ad = MyData.KlonsQueriesTableAdapter;

            ad.sp_set_kizonr(startDate, endDate, ac, nr2);
            MyMainForm.ShowInfo("Darīts!");
        }
Пример #14
0
        public void UpdateDB()
        {
            if (Changes == null || Changes.Count == 0)
            {
                MyMainForm.ShowInfo("Iegrāmatošanai nav datu.");
                return;
            }
            var table = MyData.DataSetKlons.UNTAXED_MIN;

            foreach (var change in Changes)
            {
                var dr_um = table
                            .WhereX(d => d.IDP == change.IDP && d.ONDATE == change.Dt)
                            .FirstOrDefault();
                if (dr_um == null)
                {
                    dr_um               = table.NewUNTAXED_MINRow();
                    dr_um.ID            = (int)MyData.KlonsQueriesTableAdapter.SP_GEN_UNTAXED_MIN_ID();
                    dr_um.IDP           = change.IDP;
                    dr_um.ONDATE        = change.Dt;
                    dr_um.UNTAXED_MIN   = change.UntMin;
                    dr_um.IIN_RATE_TYPE = change.IINRateType;
                    table.Rows.Add(dr_um);
                }
                else
                {
                    dr_um.UNTAXED_MIN   = change.UntMin;
                    dr_um.IIN_RATE_TYPE = change.IINRateType;
                }

                try
                {
                    MyData.UpdateTable(table);
                }
                catch (Exception ex)
                {
                    try
                    {
                        table.RejectChanges();
                    }
                    catch (Exception) {}
                    MyMainForm.ShowWarning("Neizdevās saglabāt iegrāmatotās izmaiņas.");
                }
            }
        }
Пример #15
0
        private void ShowDateSetInfo()
        {
            if (DateSet1 == DateTime.MinValue || DateSet2 == DateTime.MinValue)
            {
                return;
            }
            if (DateSet1 == DateSet2)
            {
                return;
            }
            if (DateSet1 > DateSet2)
            {
                var dtt = DateSet1;
                DateSet1 = DateSet2;
                DateSet2 = dtt;
            }
            var table     = KlonsData.St.DataSetKlons.HOLIDAYS;
            var dts_hdays = table
                            .WhereX(d => d.DT >= DateSet1 && d.DT <= DateSet2)
                            .Select(d => d.DT)
                            .ToList();
            int daysct               = (int)(DateSet2 - DateSet1).TotalDays + 1;
            int holydaysct           = dts_hdays.Count();
            int workdaysct           = 0;
            int holydaysinworkdaysct = 0;

            for (var dti = DateSet1; dti <= DateSet2; dti = dti.AddDays(1))
            {
                if (dti.DayOfWeekA() < 6)
                {
                    workdaysct++;
                }
            }
            holydaysinworkdaysct = dts_hdays.Where(d => d.DayOfWeekA() < 6).Count();
            var msg = $"Periods: {Utils.DateToString(DateSet1)} - {Utils.DateToString(DateSet2)}\n" +
                      $"Dienas: {daysct}\n" +
                      $"Darba dienas, neatskaitot svētku dienas: {workdaysct}\n" +
                      $"Svētku dienas: {holydaysct}\n" +
                      $"Svētku dienas, kas iekrīt darba dienās: {holydaysinworkdaysct}\n" +
                      $"Darba dienas, atskaitot svētku dienas: {workdaysct - holydaysinworkdaysct}\n";

            MyMainForm.ShowInfo(msg, "Informācija par iezīmēto periodu");
        }
Пример #16
0
 private void cmImport_Click(object sender, EventArgs e)
 {
     if (WorkBookConfig == null)
     {
         MyMainForm.ShowInfo("Nav norādīts importējamais XLS fails.");
         return;
     }
     if (WorkBookConfig.ImportDone)
     {
         MyMainForm.ShowInfo("Dati tika jau importēti.");
         return;
     }
     WorkBookConfig.GetCount();
     if (WorkBookConfig.RowCountBad > 0)
     {
         MyMainForm.ShowInfo("Norādītajā XLS failā tika atrastas kļūdas.");
         return;
     }
     DoImport();
 }
Пример #17
0
        private void Form_PersonsR_Load(object sender, EventArgs e)
        {
            if (bsPersons.Count == 0)
            {
                MyMainForm.ShowInfo("Darbinieku saraksts it tukšs.");
                this.Close();
                return;
            }

            SetupToolStrips();

            try
            {
                MakeGrid();
            }
            catch (Exception ex)
            {
                Form_Error.ShowException(ex);
            }

            cbSelectTab.SelectedIndex = 0;

            dgcPSRateType.DataSource    = SomeDataDefs.ProcOrEuro;
            dgcPSRateType.DisplayMember = "Val";
            dgcPSRateType.ValueMember   = "Key";

            sgrPersR.Select();

            MyData.DataSetKlons.POSITIONS_PLUSMINUS.ColumnChanged += POSITIONS_PLUSMINUS_ColumnChanged;

            LoadSettings();
            CheckEventsForAll();
            CheckPersonRedRows();

            this.bsPersonsR.CurrentChanged += new System.EventHandler(this.bsPersonsR_CurrentChanged);

            if (!mySplitContainer1.Panel1Collapsed)
            {
            }
        }
Пример #18
0
        public void ShowVacationUseData()
        {
            if (bsPersons.Position == -1 || bsPersons.Current == null || !Validate())
            {
                return;
            }
            var      dr   = (bsPersons.Current as DataRowView).Row as KlonsADataSet.PERSONSRow;
            var      rrvd = new RepRowVacDays();
            DateTime dt   = DateTime.Today;
            var      fim  = new Form_InputBox("Atvaļinājuma dienu aprēķins", "Aprēķina datums:", Utils.DateToString(dt));
            var      rt   = fim.ShowMyDialogModal();

            if (rt != DialogResult.OK)
            {
                return;
            }
            if (!Utils.StringToDate(fim.SelectedValue, out dt))
            {
                MyMainForm.ShowWarning("Norādīts nekorekts datums.");
                return;
            }
            var er1 = Report_VacDays.GetVacDaysNotUsed(dr, dt, rrvd);

            if (er1 == "OK")
            {
                string msg = $"Darbinieks: {dr.YNAME}\n";
                msg += $"Datums: {Utils.DateToString(dt)}\n\n";
                msg += $"Pienākas atvaļinājuma dienas: {rrvd.ToUse}\n";
                msg += $"Izmantotās atvaļinājuma dienas: {rrvd.Used}\n";
                msg += $"Neizmantotās atvaļinājuma dienas: {rrvd.ToUse - rrvd.Used}\n";
                msg += $"Kompensētās atvaļinājuma dienas: {rrvd.Compansated}\n";
                msg += $"Atlikušās atvaļinājuma dienas: {rrvd.NotUsed}";
                MyMainForm.ShowInfo(msg, "Atvaļinājuma dati:");
            }
            else
            {
                MyMainForm.ShowWarning(er1);
            }
        }
Пример #19
0
        public void Export()
        {
            var fd = new OpenFileDialog();

            fd.CheckFileExists = false;
            fd.Title           = "Eksportēt uz XLS failu";
            fd.Filter          = "Excel files (*.xls)|*.xls";
            var rt = fd.ShowDialog(MyMainForm);

            if (rt != DialogResult.OK)
            {
                return;
            }
            var filename = fd.FileName;

            if (File.Exists(filename))
            {
                try
                {
                    File.Delete(filename);
                }
                catch (Exception)
                {
                    MyMainForm.ShowWarning("Neizdevās izdzēst failu:\n" + filename);
                    return;
                }
            }

            FileStream fs = null;

            try
            {
                fs = new FileStream(filename, FileMode.CreateNew);
            }
            catch (Exception)
            {
                MyMainForm.ShowWarning("Neizdevās izveidot failu:\n" + filename);
                return;
            }

            void InvokeAction(Action act)
            {
                if (InvokeRequired)
                {
                    Invoke(act);
                }
                else
                {
                    act();
                }
            }

            WorkBookConfig = new WorkBookConfig();
            WorkBookConfig.InitCellStyles();

            var fmpr = new Form_Progress();

            fmpr.Message     = "Notiek datu eksports ...";
            fmpr.MaxProgress = RowsData.TotalRowCount;

            WorkBookConfig.ProgressChanged += (sender, arg) =>
            {
                fmpr.Progress = WorkBookConfig.RowsDone;
            };

            fmpr.OnCancel = () =>
            {
                WorkBookConfig.Cancel = true;
            };

            fmpr.RunThis = () =>
            {
                Task.Factory.StartNew(() =>
                {
                    RowsData.ExportToXLS(WorkBookConfig);
                    if (WorkBookConfig.Cancel)
                    {
                        return;
                    }
                    WorkBookConfig.WB.Write(fs);
                }).ContinueWith((t) => {
                    WorkBookConfig.WB.Close();
                    fs.Close();
                    fmpr.Close();

                    if (WorkBookConfig.Cancel)
                    {
                        MyMainForm.ShowInfo("Datu eksports pātraukts.");
                    }
                    else if (t.IsFaulted)
                    {
                        var me = new MyException("Datu eksports neizdevās.", t.Exception);
                        Form_Error.ShowException(me);
                    }
                    else
                    {
                        MyMainForm.ShowInfo("Darīts!");
                    }
                }, TaskScheduler.FromCurrentSynchronizationContext());
            };

            fmpr.ShowDialog(MyMainForm);
        }
Пример #20
0
        public void DoTestRun()
        {
            FileStream fs = null;

            try
            {
                fs = new FileStream(FileName, FileMode.Open);
            }
            catch (Exception)
            {
                MyMainForm.ShowWarning("Neizdevās atvērt failu:\n" + FileName);
                return;
            }


            if (WorkBookConfig != null)
            {
                bsCount.DataSource = null;
                WorkBookConfig.WB.Close();
                WorkBookConfig.Stream.Close();
            }

            WorkBookConfig = new WorkBookConfig(fs);
            int rowscount = WorkBookConfig.GetFirstCount();

            ErrorList = null;

            var fmpr = new Form_Progress();

            fmpr.Message     = "Pārbaudam XLS failu ...";
            fmpr.MaxProgress = rowscount;


            WorkBookConfig.ProgressChanged += (sender, arg) =>
            {
                fmpr.Progress = WorkBookConfig.RowsDone;
            };

            fmpr.OnCancel = () =>
            {
                WorkBookConfig.Cancel = true;
            };

            fmpr.RunThis = () =>
            {
                Task.Factory.StartNew(() =>
                {
                    ErrorList = WorkBookConfig.TestXLS();
                }).ContinueWith((t) => {
                    fmpr.Close();

                    GetCounts();
                    SetSkipDocs(false);

                    if (WorkBookConfig.Cancel)
                    {
                        MyMainForm.ShowInfo("XLS faila pārbaude pātraukts.");
                    }
                    else if (t.IsFaulted)
                    {
                        var me = new MyException("XLS faila pārbaude neizdevās.", t.Exception);
                        Form_Error.ShowException(me);
                    }
                    else
                    {
                        MyMainForm.ShowInfo("XLS faila pārbaude pabeigta.");
                    }
                }, TaskScheduler.FromCurrentSynchronizationContext());
            };

            fmpr.ShowDialog(MyMainForm);
        }
Пример #21
0
        public void DoImport()
        {
            var fmpr = new Form_Progress();

            fmpr.Message     = "Importējam datus ...";
            fmpr.MaxProgress = WorkBookConfig.RowCount;

            WorkBookConfig.ProgressChanged += (sender, arg) =>
            {
                fmpr.Progress = WorkBookConfig.RowsDone;
            };

            fmpr.OnCancel = () =>
            {
                WorkBookConfig.Cancel = true;
            };

            ActOnRowUpdated = () =>
            {
                WorkBookConfig.RowsDone++;
                fmpr.Progress = WorkBookConfig.RowsDone;
            };

            string er = null;

            fmpr.RunThis = () =>
            {
                Task.Factory.StartNew(() =>
                {
                    er = WorkBookConfig.ImportXLS();
                    if (er != "OK")
                    {
                        return;
                    }

                    fmpr.Message = "Numurējam ierakstus ...";
                    SetNewIDs(myAdapterManager1);

                    fmpr.Message            = "Saglabājam izmaiņas ...";
                    WorkBookConfig.RowsDone = 0;
                    fmpr.Progress           = 0;
                    fmpr.MaxProgress        = WorkBookConfig.GetUpdateCount();
                    WireAdapterEvents();
                    myAdapterManager1.UpdateAll(true);
                }).ContinueWith((t) => {
                    UnWireAdapterEvents();
                    ActOnRowUpdated = null;

                    fmpr.Close();

                    if (WorkBookConfig.Cancel)
                    {
                        MyMainForm.ShowInfo("Datu imports pātraukts.");
                        RejectChanges();
                    }
                    else if (t.IsFaulted)
                    {
                        var me = new MyException("Datu imports neizdevās.", t.Exception);
                        Form_Error.ShowException(me);
                        RejectChanges();
                    }
                    else if (er != "OK")
                    {
                        var me = new MyException("Datu imports neizdevās.", new Exception(er));
                        Form_Error.ShowException(me);
                        RejectChanges();
                    }
                    else
                    {
                        MyMainForm.ShowInfo("Datu imports pabeigts.");
                        WorkBookConfig.ImportDone = true;
                    }
                }, TaskScheduler.FromCurrentSynchronizationContext());
            };

            fmpr.ShowDialog(MyMainForm);
        }