Esempio n. 1
0
        //---------CRUD---------//

        private void createButton_Click(object sender, EventArgs e)
        {
            string fantasyName    = txtFantasyName.Text;
            string society        = txtSocietyName.Text;
            string legalDoc       = txtlegalCertification.Text;
            string telephone      = mtxtTelephone.Text;
            string mainAddress    = txaMainAddress.Text;
            string generalAddress = txaGeneralAddress.Text;
            string email          = txtEmail.Text;
            string webPage        = txtWebPage.Text;

            logo = ImageManagement.ImageToByte(file);

            try
            {
                if (BusinessManagement.InsertBusiness(fantasyName, society, legalDoc, telephone, mainAddress, generalAddress,
                                                      email, webPage, logo))
                {
                    Clear();
                    businessModels = BusinessManagement.SelectAllBusiness();
                    WireUpBusinessGridView();
                    FrmMain.Instance.ToolStripLabel.Text = "Negocio agregado correctamente";
                }
                else
                {
                    FrmMain.Instance.ToolStripLabel.Text = "Error al agregar el negocio";
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 2
0
        private void ReloadBusiness()
        {
            businessModels = BusinessManagement.SelectAllBusiness();
            BusinessDataGridView.MultiSelect = false;
            BusinessDataGridView.DataSource  = businessModels;

            BusinessDataGridView.Columns["Id_Business"].AutoSizeMode        = DataGridViewAutoSizeColumnMode.AllCells;
            BusinessDataGridView.Columns["Name"].AutoSizeMode               = DataGridViewAutoSizeColumnMode.Fill;
            BusinessDataGridView.Columns["Society_Name"].AutoSizeMode       = DataGridViewAutoSizeColumnMode.Fill;
            BusinessDataGridView.Columns["LegalCertification"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            BusinessDataGridView.Columns["Telephone"].AutoSizeMode          = DataGridViewAutoSizeColumnMode.AllCells;
            BusinessDataGridView.Columns["Main_Address"].AutoSizeMode       = DataGridViewAutoSizeColumnMode.AllCells;
            BusinessDataGridView.Columns["Email"].AutoSizeMode              = DataGridViewAutoSizeColumnMode.Fill;
            BusinessDataGridView.Columns["WebPage"].AutoSizeMode            = DataGridViewAutoSizeColumnMode.AllCells;
            BusinessDataGridView.Columns["Logo"].AutoSizeMode               = DataGridViewAutoSizeColumnMode.AllCells;

            BusinessDataGridView.Columns["Id_Business"].HeaderText        = "Id";
            BusinessDataGridView.Columns["Name"].HeaderText               = "Nombre";
            BusinessDataGridView.Columns["Society_Name"].HeaderText       = "Nombre de Sociedad";
            BusinessDataGridView.Columns["LegalCertification"].HeaderText = "Cédula Jurídica";
            BusinessDataGridView.Columns["Telephone"].HeaderText          = "Teléfono";
            BusinessDataGridView.Columns["Main_Address"].HeaderText       = "Dirección";
            BusinessDataGridView.Columns["Email"].HeaderText              = "Correo Electronico";
            BusinessDataGridView.Columns["WebPage"].HeaderText            = "Página Web";
            BusinessDataGridView.Columns["Logo"].HeaderText               = "Logo";

            BusinessDataGridView.Columns["Id_Business"].Visible = false;
            BusinessDataGridView.Columns["Logo"].Visible        = false;

            BusinessDataGridView.Columns["LegalCertification"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
        }
Esempio n. 3
0
 private void UcAparts_Load(object sender, EventArgs e)
 {
     employeeComboBox.DataSource    = EmployeeManagement.SelectAllEmployees();
     employeeComboBox.DisplayMember = "Name";
     StoreComboBox.DataSource       = BusinessManagement.SelectAllBusiness();
     StoreComboBox.DisplayMember    = "fantasyName";
     clientComboBox.DataSource      = ClientManagement.SelectAllClients();
     clientComboBox.DisplayMember   = "Name";
     WrapProductsGridView();
 }
 private void UcInputInvoice_Load(object sender, EventArgs e)
 {
     EmployeeComboBox.DataSource    = EmployeeManagement.SelectAllEmployees();
     EmployeeComboBox.DisplayMember = "Name";
     DestinyComboBox.DataSource     = BusinessManagement.SelectAllBusiness();
     DestinyComboBox.DisplayMember  = "fantasyName";
     ProviderComboBox.DataSource    = BusinessManagement.SelectAllBusiness();
     ProviderComboBox.DisplayMember = "fantasyName";
     WrapProductsGridView();
 }
Esempio n. 5
0
        //---------EVENTS---------//

        private void businessFantasyNameSearchTextBox_KeyUp(object sender, KeyEventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(businessFantasyNameSearchTextBox.Text))
                {
                    businessGridView.DataSource = BusinessManagement.SelectBusinessByName(businessFantasyNameSearchTextBox.Text);
                }
                else
                {
                    WireUpBusinessGridView();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Esempio n. 6
0
 private void UcBusiness_Load(object sender, EventArgs e)
 {
     //dgvBusiness.Columns["idBusiness"].DisplayIndex = 0;
     //dgvBusiness.Columns["idBusiness"].HeaderText = "Id";
     try
     {
         if (BusinessManagement.SelectAllBusiness() != null)
         {
             businessModels = BusinessManagement.SelectAllBusiness();
             WireUpBusinessGridView();
             FrmMain.Instance.ToolStripLabel.Text = "Los registros de la base de datos fueron cargados.";
         }
     }
     catch (Exception)
     {
         FrmMain.Instance.ToolStripLabel.Text = "No se encontraron registros en la base de datos.";
         throw;
     }
 }
Esempio n. 7
0
        //---------SUBCATEGORY---------//

        //---------EVENTS---------//

        private void subCategoryNameSearchTextBox_KeyPress(object sender, KeyPressEventArgs e)
        {
            string text = subCategoryNameSearchTextBox.Text;

            try
            {
                if (!string.IsNullOrEmpty(subCategoryNameSearchTextBox.Text))
                {
                    subCategoryGridView.DataSource = BusinessManagement.SelectBusinessByName(subCategoryNameSearchTextBox.Text);
                }
                else
                {
                    WireUpSubCategoryGridView();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 8
0
        private void deleteButton_Click(object sender, EventArgs e)
        {
            try
            {
                string id = businessGridView.CurrentRow.Cells[0].Value.ToString();

                if (BusinessManagement.DeleteBusinessById(id))
                {
                    Clear();
                    businessModels = BusinessManagement.SelectAllBusiness();
                    WireUpBusinessGridView();
                    FrmMain.Instance.ToolStripLabel.Text = "El negocio ha sido elimado correctamente";
                }
                else
                {
                    FrmMain.Instance.ToolStripLabel.Text = "Error al eliminar el negocio";
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 9
0
        private void updateButton_Click(object sender, EventArgs e)
        {
            string id             = businessGridView.CurrentRow.Cells[0].Value.ToString();
            string fantasyName    = txtFantasyName.Text;
            string society        = txtSocietyName.Text;
            string legalDoc       = txtlegalCertification.Text;
            string telephone      = mtxtTelephone.Text;
            string mainAddress    = txaMainAddress.Text;
            string generalAddress = txaGeneralAddress.Text;
            string email          = txtEmail.Text;
            string webPage        = txtWebPage.Text;

            if (!string.IsNullOrEmpty(file))
            {
                logo = ImageManagement.ImageToByte(file);
            }

            try
            {
                if (BusinessManagement.UpdateBusinessById(id, fantasyName, society, legalDoc, telephone, mainAddress, generalAddress,
                                                          email, webPage, logo))
                {
                    Clear();
                    businessModels = BusinessManagement.SelectAllBusiness();
                    WireUpBusinessGridView();
                    FrmMain.Instance.ToolStripLabel.Text = "Negocio modificado correctamente";
                }
                else
                {
                    FrmMain.Instance.ToolStripLabel.Text = "Error al modificar el negocio";
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 10
0
        private void ImportDodiInfo()
        {
            var businessManagement = new BusinessManagement();

            //var document = new HtmlAgilityPack.HtmlDocument();

            //document.LoadHtml(File.ReadAllText(@"D:\Badoucai\Dodi\2363\2363038\Mian_2363038.txt"));

            //var userInfo = businessManagement.FormatUserInfomation(document);

            //var business = businessManagement.FormatBusiness(document);

            var pathQueue = new ConcurrentQueue <string>();

            var filePathQueue = new ConcurrentQueue <string>();

            var count = 0;

            var index = 0;

            var pathList = Directory.GetDirectories(@"D:\Badoucai\Dodi\").ToList();

            //pathList.Reverse();

            pathList.ForEach(t => pathQueue.Enqueue(t));

            Task.Run(() =>
            {
                while (true)
                {
                    if (filePathQueue.Count > 1000)
                    {
                        continue;
                    }

                    string path;

                    if (!pathQueue.TryDequeue(out path))
                    {
                        continue;
                    }

                    var files = Directory.GetFiles(path, "*", SearchOption.AllDirectories);

                    count += files.Length;

                    files.ToList().ForEach(t => filePathQueue.Enqueue(t));
                }
            });

            for (var i = 0; i < 16; i++)
            {
                Task.Run(() =>
                {
                    while (true)
                    {
                        string path;

                        if (!filePathQueue.TryDequeue(out path))
                        {
                            continue;
                        }

                        try
                        {
                            var document = new HtmlAgilityPack.HtmlDocument();

                            document.LoadHtml(File.ReadAllText(path));

                            try
                            {
                                var userInfo = businessManagement.FormatUserInfomation(document);

                                var business = businessManagement.FormatBusiness(document);

                                using (var db = new MangningXssDBEntities())
                                {
                                    db.DodiUserInfomation.AddOrUpdate(a => a.Id, userInfo);

                                    db.DodiBusiness.AddOrUpdate(a => a.Id, business);

                                    try
                                    {
                                        db.TransactionSaveChanges();
                                    }
                                    catch (Exception ex)
                                    {
                                        while (true)
                                        {
                                            if (ex.InnerException == null)
                                            {
                                                break;
                                            }

                                            ex = ex.InnerException;
                                        }

                                        Program.SetLog(this.tbx_Log, $"多迪信息SaveChanges异常!异常文件路径:{path}, {ex.Message}");

                                        LogFactory.Warn($"多迪信息SaveChanges异常!异常文件路径:{path}, {ex.Message}");
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                continue;
                            }

                            var indexTemp = Interlocked.Increment(ref index);

                            var destPath = path.Replace("Dodi", "Dodi-Success");

                            var destDirectoryPath = Path.GetDirectoryName(destPath);

                            if (!string.IsNullOrEmpty(destDirectoryPath) && !Directory.Exists(destDirectoryPath))
                            {
                                Directory.CreateDirectory(destDirectoryPath);
                            }

                            if (File.Exists(destPath))
                            {
                                File.Delete(destPath);
                            }

                            File.Move(path, destPath);

                            RunInMainthread(() =>
                            {
                                Program.SetLog(this.tbx_Log, $"导入成功!进度:{indexTemp}/{count} {Path.GetFileNameWithoutExtension(path)}");
                            });
                        }
                        catch (Exception ex)
                        {
                            RunInMainthread(() =>
                            {
                                Program.SetLog(this.tbx_Log, $"多迪信息导入异常!异常文件路径:{path}, {ex.Message}");
                            });

                            LogFactory.Warn($"多迪信息导入异常!异常文件路径:{path}, {ex.Message}{Environment.NewLine}{ex.StackTrace}");
                        }
                    }
                });
            }
        }