Ejemplo n.º 1
0
        public String WymiaryOkienka()
        {
            String WordWidth  = "Width:";
            String WordHeight = "Height:";
            String WymiarWidth;
            String WymiarHeight;
            String Zwrot;;

            Okno.Click();
            Zwrot        = Okno.GetAttribute("BoundingRectangle");
            WymiarWidth  = Zwrot.Substring(Zwrot.IndexOf(WordWidth) + WordWidth.Length, Zwrot.IndexOf(" ", Zwrot.IndexOf(WordWidth) + 1) - Zwrot.IndexOf(WordWidth) - WordWidth.Length);
            WymiarHeight = Zwrot.Substring(Zwrot.IndexOf(WordHeight) + WordHeight.Length);

            return(WymiarWidth + " " + WymiarHeight);
        }
Ejemplo n.º 2
0
        private void połaczButton_Click(object sender, EventArgs e)
        {
            if (this.DataGrid.SelectedRows.Count > 1 &&
                MessageBox.Show("czy napewno chcesz połaczyć zwroty?", "EnovaTools", MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
            {
                Kontrahent   kontrahent = null;
                StatusZwrotu status     = null;
                List <Zwrot> zwroty     = new List <Zwrot>();

                foreach (DataGridViewRow row in this.DataGrid.SelectedRows)
                {
                    if (row.DataBoundItem != null)
                    {
                        Zwrot zwrot = (Zwrot)row.DataBoundItem;
                        if (kontrahent == null)
                        {
                            kontrahent = zwrot.Kontrahent;
                        }
                        else if (kontrahent.ID != zwrot.KontrahentID)
                        {
                            MessageBox.Show("Nie można łaczyć zwrotów dla różnych kontrahentów");
                            return;
                        }

                        if (status == null)
                        {
                            status = zwrot.OstHistoriaZwrotu.Status;
                        }
                        else if (status.ID != zwrot.OstHistoriaZwrotu.StatusID)
                        {
                            MessageBox.Show("Nie można łaczyć zwrotów o różnym statusie");
                            return;
                        }

                        zwroty.Add(zwrot);
                    }
                }

                if (zwroty.Count > 1)
                {
                    string opis = "Połączone zwroty: ";

                    Zwrot nowyZwrot = new Zwrot()
                    {
                        DataDodania     = DateTime.Now,
                        DataModyfikacji = DateTime.Now,
                        Deleted         = false,
                        Guid            = Guid.NewGuid(),
                        IloscPaczek     = zwroty.Sum(z => z.IloscPaczek),
                        Kontrahent      = kontrahent,
                        Synchronizacja  = (int)RowSynchronizeOld.NotsynchronizedNew
                    };



                    nowyZwrot.HistoriaZwrotu.Add(new HistoriaZwrotu()
                    {
                        Data        = DateTime.Now,
                        Deleted     = false,
                        Guid        = Guid.NewGuid(),
                        Status      = status,
                        Synchronize = (int)RowSynchronizeOld.NotsynchronizedNew,
                        Uzytkownik  = User.LoginedUser
                    });

                    foreach (var zwrot in zwroty)
                    {
                        opis += zwrot.ID + ", ";

                        if (!string.IsNullOrEmpty(zwrot.Opis))
                        {
                            if (nowyZwrot.Opis == null)
                            {
                                nowyZwrot.Opis = "";
                            }
                            if (nowyZwrot.Opis != "")
                            {
                                nowyZwrot.Opis += "\r\n";
                            }
                            nowyZwrot.Opis += zwrot.Opis;
                        }

                        foreach (var poz in zwrot.Pozycje.Where(p => p.Deleted == false && p.Synchronizacja != (int)RowSynchronizeOld.NotsynchronizedDelete).ToList())
                        {
                            nowyZwrot.Pozycje.Add(new PozycjaZwrotu()
                            {
                                Cena             = poz.Cena,
                                Deleted          = false,
                                Guid             = Guid.NewGuid(),
                                Ident            = nowyZwrot.GetMaxIdent() + 1,
                                IlocsDeklarowana = poz.IlocsDeklarowana,
                                Ilosc            = poz.Ilosc,
                                Opis             = poz.Opis,
                                Synchronizacja   = (int)RowSynchronizeOld.NotsynchronizedNew,
                                Towar            = poz.Towar,
                                TowarNazwa       = poz.TowarNazwa
                            });
                            poz.Deleted = true;
                        }

                        zwrot.Deleted = true;
                    }

                    if (!string.IsNullOrEmpty(nowyZwrot.Opis))
                    {
                        nowyZwrot.Opis += "\r\n";
                    }
                    nowyZwrot.Opis += opis;

                    nowyZwrot.PrzeliczWartosc();

                    Enova.Business.Old.Core.ContextManager.WebContext.SaveChanges();
                    Enova.Business.Old.Core.ContextManager.WebContext.Refresh(RefreshMode.StoreWins, nowyZwrot);

                    MessageBox.Show("Został stworzony nowy zwrot o numerze " + nowyZwrot.ID);
                    this.Reload();
                }
            }
        }