Exemple #1
0
        private void SaveBut_Click(object sender, EventArgs e)
        {
            using (ScalaFtsDb_Parser_TestEntities db = new ScalaFtsDb_Parser_TestEntities())
            {
                var product = db.Products.First(x => x.Id == currentProduct.Id);
                if (nameFileCheckBox.Checked)
                {
                    product.Title = nameFileTextBox.Text;
                }
                else if (nameInputCheckBox.Checked)
                {
                    product.Title = nameInputTextBox.Text;
                }
                else if (nameSiteCheckBox.Checked)
                {
                    product.Title = nameSiteTextBox.Text;
                }
                else if (nameSiteEngCheckBox.Checked)
                {
                    product.Title = nameSiteEngTextBox.Text;
                }
                else if (nameFileEngCheckBox.Checked)
                {
                    product.Title = nameFileEngTextBox.Text;
                }

                db.SaveChanges();

                if (localProduct != null)
                {
                    localProduct.ProductName           = nameSiteTextBox.Text;
                    localProduct.ProductEngName        = nameSiteEngTextBox.Text;
                    localProduct.ProductModel          = modelTextBox.Text;
                    localProduct.ProductBrand          = brandTextBox.Text;
                    localProduct.ProductType           = typeTextBox.Text;
                    localProduct.ProductClassification = classificationTextBox.Text;
                    localProduct.ProductDepartmentName = departmentNameTextBox.Text;
                }

                if (localStatuses != null)
                {
                    localStatuses.ForbiddenStatus = forbiddenWordTextBox.Text;
                }

                ctx.SaveChanges();
            }
        }
Exemple #2
0
        private void LoginBut_Click(object sender, EventArgs e)
        {
            ScalaFtsDb_Parser_TestEntities db = new ScalaFtsDb_Parser_TestEntities();
            var user = db.AspNetUsers.ToList().FirstOrDefault(x => x.UserName == loginTextBox.Text && VerifyHashedPassword(x.PasswordHash, passwordTextBox.Text));

            if (user != null)
            {
                Global.currentUser = user;
                Hide();

                if (user.AspNetRoles.First().Name == "Administrators")
                {
                    new AdminSms().Show();
                }
                else
                {
                    new MainForm().Show();
                }
            }
            else
            {
                MessageBox.Show("Неверный логин или пароль!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #3
0
        private void SaveBut_Click(object sender, EventArgs e)
        {
            //List<People> peoples = new List<People>();
            //List<Shipments> shipments = new List<Shipments>();
            //List<Products> products = new List<Products>();
            //try
            //{
            GenerateComparisonList();
            if (saveToResourcesCheckBox.Checked)
            {
                SaveSettings(settingsPath);
            }

            string    prevCode       = "";
            Shipments prevShip       = null;
            Guid      prevPeopleId   = Guid.Empty;
            Guid      prevShipmentId = Guid.Empty;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string ShipmentCode = GetColumn(i, "CodeShipments");
                Guid   PeopleId     = Guid.NewGuid();
                Guid   ShipmentId   = Guid.NewGuid();
                Guid   ProductId    = Guid.NewGuid();


                int currencyId    = (int)((ComboBox)radScrollablePanel1.Controls[0].Controls["CurrencyCB"]).SelectedValue;
                var currencyPrice = (((ComboBox)radScrollablePanel1
                                      .Controls[0]
                                      .Controls["CurrencyCB"])
                                     .SelectedItem as CurrencyEntity).Price;

                decimal cost        = GetColumn(i, "Cost").ToDecimalOrZero();
                double  grossWeight = GetColumn(i, "GrossWeight").ToDoubleOrZero();
                double  netWeight   = GetColumn(i, "NetWeight").ToDoubleOrZero();

                if (prevCode != ShipmentCode || prevCode == "")
                {
                    var fioItems = GetColumn(i, "FIO").Split(' ');


                    People ppl = new People()
                    {
                        Id                 = PeopleId,
                        Phone              = GetColumn(i, "Phone"),
                        IdentityCardName   = 21,  //GetColumn(i, "IdentityCardName").ToIntOrZero(),
                        IdentityCardNumber = GetColumn(i, "IdentityCardNumber"),
                        IdentityCardSeries = GetColumn(i, "IdentityCardSeries"),
                        IssuedBy           = GetColumn(i, "IssuedBy"),
                        INN                = GetColumn(i, "INN"),
                        Email              = GetColumn(i, "Email"),
                        Index              = GetColumn(i, "Index"),
                        Region             = GetColumn(i, "Region"),
                        City               = GetColumn(i, "City"),
                        Street             = GetColumn(i, "Street"),
                        House              = GetColumn(i, "House"),
                        Country            = 643,//GetColumn(i, "Country").ToIntOrZero(),
                        IssuedOn           = GetColumn(i, "IssuedOn").ToNullableDate(),
                        Birthdate          = GetColumn(i, "Birthdate").ToNullableDate(),
                        Name               = fioItems.ElementAtOrDefault(0).NullableToEmptyString(),
                        Surname            = fioItems.ElementAtOrDefault(1).NullableToEmptyString(),
                        Middlename         = fioItems.ElementAtOrDefault(2).NullableToEmptyString(),
                        UserId             = Global.currentUser.Id
                    };

                    Shipments ship = new Shipments()
                    {
                        Id                 = ShipmentId,
                        ExternalId         = GetColumn(i, "ExternalId"),
                        Code               = ShipmentCode,
                        Height             = GetColumn(i, "Height").ToDoubleOrZero(),
                        Length             = GetColumn(i, "Length").ToDoubleOrZero(),
                        Width              = GetColumn(i, "Width").ToIntOrZero(),
                        TotalGrossWeight   = (decimal)grossWeight,
                        TotalNetWeight     = (decimal)netWeight,
                        Currency           = currencyId,
                        TotalCost          = cost,
                        TotalCustomsValue  = cost * currencyPrice,
                        PackageAmount      = GetColumn(i, "PackageAmount").ToIntOrOne(),
                        InvoiceNumber      = GetColumn(i, "InvoiceNumber"),
                        InvoiceDate        = GetColumn(i, "InvoiceDate").ToDateOrNow(),
                        DispatchDate       = GetColumn(i, "DispatchDate").ToDateOrNow(),
                        CreationDate       = GetColumn(i, "CreationDate").ToDateOrNow(),
                        ParcelType         = GetColumn(i, "ParcelType").ToIntOrZero(),
                        DeliveryCategoryId = new Guid("610a507c-6222-0529-2edf-6fa19fb1fdc8"), //GetColumn(i, "DeliveryCategoryId").ToGuidOrZero(),
                        DispatchPlaceId    = 25,                                               //GetColumn(i, "DispatchPlaceId").ToLongOrZero(),
                        RegistryId         = GetColumn(i, "RegistryId").ToNullableGuid(),
                        Description        = GetColumn(i, "Description"),
                        ShipperType        = GetColumn(i, "ShipperType").ToIntOrZero(),
                        ShipperCompanyId   = GetColumn(i, "ShipperCompanyId").ToNullableGuid(),
                        ReceiverType       = GetColumn(i, "ReceiverType").ToIntOrZero(),
                        ReceiverCompanyId  = GetColumn(i, "ReceiverCompanyId").ToNullableGuid(),
                        ReceiverPersonId   = PeopleId,
                        StatusId           = new Guid("3ebc28f0-08a8-942c-236a-f921a45ffb18"),//GetColumn(i, "StatusId").ToGuidOrZero(),
                        Update             = false,
                        UserId             = Global.currentUser.Id
                    };

                    db.People.Add(ppl);
                    db.Shipments.Add(ship);
                    prevPeopleId   = PeopleId;
                    prevShipmentId = ShipmentId;
                    prevShip       = ship;
                }

                Products p = new Products()
                {
                    Title           = GetColumn(i, "Title"),
                    Code            = GetColumn(i, "CodeProducts"),
                    Quantity        = GetColumn(i, "Quantity").ToIntOrOne(),
                    Cost            = cost,
                    GrossWeight     = grossWeight,
                    NetWeight       = netWeight,
                    DescriptionLink = GetColumn(i, "DescriptionLink"),
                    CustomsValue    = cost * currencyPrice,
                    CostEUR         = cost * currencyPrice
                                      / Global.Currencies[1].Price,
                    Id         = ProductId,
                    ShipmentId = prevShipmentId,
                    //AddImage = true,
                    //DocumentScanId = null
                };
                db.Products.Add(p);

                if (prevCode == ShipmentCode)
                {
                    prevShip.TotalCost         += p.Cost;
                    prevShip.TotalGrossWeight  += Convert.ToDecimal(p.GrossWeight);
                    prevShip.TotalNetWeight    += Convert.ToDecimal(p.NetWeight);
                    prevShip.TotalCustomsValue += p.CustomsValue;
                }

                prevCode = ShipmentCode;
                if (i % 500 == 0 && i != 0)
                {
                    db.SaveChanges();
                    db = new ScalaFtsDb_Parser_TestEntities();
                }
            }
            //db.Shipments.AddRange(shipments);
            //db.People.AddRange(peoples);
            //db.Products.AddRange(products);
            db.SaveChanges();
            MessageBox.Show("Данные успешно занесены в базу!", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
            Close();
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //}
        }