Exemplo n.º 1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            int id = 0;

            int.TryParse(tbId.Text, out id);
            if (id != 0)
            {
                Project currentProject = BLProject.GetProjectById(APCContext, id);
                if (currentProject != null)
                {
                    currentProject.Name = tbName.Text;
                    int currentClientId = 0;
                    int.TryParse(cbClient.SelectedValue.ToString(), out currentClientId);
                    Client currentClient = BLClient.GetClientById(APCContext, currentClientId);
                    currentProject.Client = currentClient;
                    APCContext.SaveChanges();
                    ClearContent();
                    MessageBox.Show("Project Details Successfully Updated");
                }
                else
                {
                    MessageBox.Show("Project Id not found");
                }
            }
            else
            {
                MessageBox.Show("Project Id not found");
            }
        }
Exemplo n.º 2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            int id = 0;

            int.TryParse(tbId.Text, out id);
            if (id != 0)
            {
                Project currentProject = BLProject.GetProjectById(APCContext, id);
                if (currentProject != null)
                {
                    APCContext.DeleteObject(currentProject);
                    APCContext.SaveChanges();
                    ClearContent();
                    MessageBox.Show("Delete Successfully");
                }
                else
                {
                    MessageBox.Show("Project Id not found");
                }
            }
            else
            {
                MessageBox.Show("Project Id not found");
            }
        }
Exemplo n.º 3
0
        public List <Project> searchById(int id)
        {
            if (id != 0)
            {
                List <Project> projectList = BLProject.GetProjectListById(APCContext, id);

                if (projectList != null)
                {
                    tbId.Text   = projectList[0].Id.ToString();
                    tbName.Text = projectList[0].Name;
                    Client currentClient = BLClient.GetClientByName(APCContext, projectList[0].Client.Name)[0];
                    cbClient.SelectedValue = currentClient.Id;
                    return(projectList);
                }
                else
                {
                    MessageBox.Show("Project Id not found");
                }
            }
            else
            {
                MessageBox.Show("Project Id not found");
            }
            return(null);
        }
Exemplo n.º 4
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            Supplier selectedSupplier = BLSupplier.GetSupplierById(APCContext, int.Parse(cbSupplier.SelectedValue.ToString()));
            Project  selectedProject  = BLProject.GetProjectById(APCContext, int.Parse(cbProject.SelectedValue.ToString()));
            int      id = 0;

            int.TryParse(tbId.Text, out id);
            if (id != 0)
            {
                PO currentPO = BLPO.GetPOById(APCContext, id);
                if (currentPO != null)
                {
                    currentPO.Supplier = selectedSupplier;
                    currentPO.Project  = selectedProject;
                    APCContext.SaveChanges();

                    deletePO_Product(currentPO);
                    insertPO_Product(currentPO);

                    MessageBox.Show("PO Details Successfully Updated");
                    ClearContent();
                    SetComboToDefault();
                }
                else
                {
                    MessageBox.Show("PO Id not found");
                }
            }
            else
            {
                MessageBox.Show("PO Id not found");
            }
        }
Exemplo n.º 5
0
        private void InvoiceForm_Load(object sender, EventArgs e)
        {
            APCContext = new APCEntities();

            List <Project> projectList = BLProject.GetAllProject(APCContext);

            ddlProject.DataSource    = projectList;
            ddlProject.DisplayMember = "Name";
            ddlProject.ValueMember   = "Id";

            dgInvoiceProduct.AutoGenerateColumns = false;
            dgInvoiceProduct.DataSource          = createInvoiceProductTable();
            //dgInvoiceProduct.Columns.Remove("Name");
            //dgInvoiceProduct.Columns.Remove("Kurs");
            //dgInvoiceProduct.Columns.Remove("SubCon");

            DataGridViewComboBoxColumn colName = BLHelper.ReturnDataGridComboBoxColumn("Name", "Name", "Name", "Name");

            colName.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet;
            colName.DataSource   = APCContext.Category;

            DataGridViewComboBoxColumn colKurs = BLHelper.ReturnDataGridComboBoxColumn("Name", "Name", "Name", "Name");

            colName.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet;
            colKurs.DataSource   = APCContext.Kurs;

            DataGridViewCheckBoxColumn colSubCon = BLHelper.ReturnDataGridCBColumn("SubCon");

            //dgInvoiceProduct.Columns.Insert(0, colName);
            //dgInvoiceProduct.Columns.Insert(5, colKurs);
            dgInvoiceProduct.Columns.Add(colName);
            dgInvoiceProduct.Columns.Add(colKurs);
            dgInvoiceProduct.Columns.Add(colSubCon);
        }
Exemplo n.º 6
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            int     id = 0;
            int     currentWorkerId   = 0;
            int     currentProjectId  = 0;
            decimal totalWorkingHours = 0;
            decimal salary            = 0;

            int.TryParse(tbId.Text, out id);
            if (id != 0)
            {
                Project_Workers currentProject_Workers = BLProject_Workers.GetProject_WorkersById(APCContext, id);
                if (currentProject_Workers != null)
                {
                    if (int.TryParse(ddlWorker.SelectedValue.ToString(), out currentWorkerId))
                    {
                        if (int.TryParse(ddlProject.SelectedValue.ToString(), out currentProjectId))
                        {
                            if (decimal.TryParse(tbWorkingHours.Text, out totalWorkingHours))
                            {
                                if (decimal.TryParse(tbSalary.Text, out salary))
                                {
                                    Workers currentWorker  = BLWorkers.GetWorkersById(APCContext, currentWorkerId);
                                    Project currentProject = BLProject.GetProjectById(APCContext, currentProjectId);
                                    currentProject_Workers.Project     = currentProject;
                                    currentProject_Workers.Workers     = currentWorker;
                                    currentProject_Workers.StartDate   = calStartDate.Value;
                                    currentProject_Workers.EndDate     = calEndDate.Value;
                                    currentProject_Workers.TotalHours  = totalWorkingHours;
                                    currentProject_Workers.Salary      = salary;
                                    currentProject_Workers.TotalSalary = totalWorkingHours * salary;
                                    APCContext.SaveChanges();
                                    MessageBox.Show("Project Workers Details Successfully Updated");
                                    ClearContent();
                                }
                                else
                                {
                                    MessageBox.Show("Salary has to be decimal");
                                }
                            }
                            else
                            {
                                MessageBox.Show("Working hours has to be decimal");
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Project_Workers Id not found");
                }
            }
            else
            {
                MessageBox.Show("Project_Workers Id not found");
            }
        }
Exemplo n.º 7
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            Supplier selectedSupplier = BLSupplier.GetSupplierById(APCContext, int.Parse(cbSupplier.SelectedValue.ToString()));
            Project  selectedProject  = BLProject.GetProjectById(APCContext, int.Parse(cbProject.SelectedValue.ToString()));
            PO       po = BLPO.insertPO(APCContext, selectedSupplier, selectedProject);

            insertPO_Product(po);

            MessageBox.Show("PO Successfully Added");
            ClearContent();
            SetComboToDefault();
        }
Exemplo n.º 8
0
        public void TestGetTemplatePlaceHolderList()
        {
            BLProject blProject = new BLProject();
            //TemplateDTO templateDTO = BLL.BLTemplateType.getTypeByName("");// blProject.getTemplate(1);

            BLTemplateType  bLTemplateType  = new BLTemplateType();
            TemplateTypeDTO templateTypeDTO = bLTemplateType.getTypeByName("angularJs-Materil");

            List <string> tokenList = Parser.getPlaceHolderList(templateTypeDTO.TokenizeString, Constant.pattern);

            Assert.AreEqual(tokenList.Count, 15);
            Assert.AreEqual(tokenList[3], "<<<Page.AppName>>>");
        }
Exemplo n.º 9
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            decimal paymentDue = 0;

            if (decimal.TryParse(tbPaymentDue.Text, out paymentDue))
            {
                if (calDueDate.Value != null)
                {
                    //if (ddlPO.SelectedValue != null)
                    //{
                    if (ddlProject.SelectedValue != null)
                    {
                        Project selectedProject = BLProject.GetProjectById(APCContext, int.Parse(ddlProject.SelectedValue.ToString()));
                        bool    success         = false;
                        Invoice selectedInvoice = BLInvoice.insertInvoice(APCContext, DateTime.Today, paymentDue, calDueDate.Value, tbScannedDoc.Text, selectedProject);

                        if (InsertInvoicePO(selectedInvoice))
                        {
                            insertInvoice_Product(selectedInvoice);
                            success = true;
                        }

                        if (success == true)
                        {
                            MessageBox.Show("Invoice Successfully Added");
                            ClearContent();
                        }
                        else
                        {
                            MessageBox.Show("Please check your input");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please select the associated Project Number");
                    }
                    //}
                    //else
                    //    MessageBox.Show("Please select the associated PO Number");
                }
                else
                {
                    MessageBox.Show("Please specify Due Date");
                }
            }
            else
            {
                MessageBox.Show("Please specify correct amount of Payment Due");
            }
        }
Exemplo n.º 10
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            int currentClientId = 0;

            int.TryParse(cbClient.SelectedValue.ToString(), out currentClientId);
            Client currentClient = BLClient.GetClientById(APCContext, currentClientId);

            if (BLProject.insertProject(APCContext, tbName.Text, currentClient))
            {
                ClearContent();
                MessageBox.Show("Project Successfully Added");
            }
            else
            {
                MessageBox.Show("Please check your input");
            }
        }
Exemplo n.º 11
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            int     currentWorkerId   = 0;
            int     currentProjectId  = 0;
            decimal totalWorkingHours = 0;
            decimal salary            = 0;

            if (int.TryParse(ddlWorker.SelectedValue.ToString(), out currentWorkerId))
            {
                if (int.TryParse(ddlProject.SelectedValue.ToString(), out currentProjectId))
                {
                    if (decimal.TryParse(tbWorkingHours.Text, out totalWorkingHours))
                    {
                        if (decimal.TryParse(tbSalary.Text, out salary))
                        {
                            Workers currentWorker  = BLWorkers.GetWorkersById(APCContext, currentWorkerId);
                            Project currentProject = BLProject.GetProjectById(APCContext, currentProjectId);
                            if (BLProject_Workers.insertProject_Workers(APCContext, currentProject, currentWorker, calStartDate.Value, calEndDate.Value, totalWorkingHours, salary))
                            {
                                MessageBox.Show("Project_Workers Successfully Added");
                                ClearContent();
                            }
                            else
                            {
                                MessageBox.Show("Please check your input");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Salary has to be decimal");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Working hours has to be decimal");
                    }
                }
            }
        }
Exemplo n.º 12
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            int id = 0;

            int.TryParse(tbId.Text, out id);
            if (id != 0)
            {
                Invoice currentInvoice = BLInvoice.GetInvoiceById(APCContext, id);
                if (currentInvoice != null)
                {
                    decimal paymentDue = 0;
                    if (decimal.TryParse(tbPaymentDue.Text, out paymentDue))
                    {
                        if (calDueDate.Value != null)
                        {
                            //if (ddlPO.SelectedValue != null)
                            //{
                            if (ddlProject.SelectedValue != null)
                            {
                                PO      selectedPO      = BLPO.GetPOById(APCContext, int.Parse(ddlPO.SelectedValue.ToString()));
                                Project selectedProject = BLProject.GetProjectById(APCContext, int.Parse(ddlProject.SelectedValue.ToString()));

                                currentInvoice.TotalDue   = paymentDue;
                                currentInvoice.DueDate    = calDueDate.Value;
                                currentInvoice.ScannedDoc = tbScannedDoc.Text;
                                currentInvoice.Project    = selectedProject;
                                APCContext.SaveChanges();

                                DeleteInvoicePO(currentInvoice);
                                InsertInvoicePO(currentInvoice);

                                deleteInvoice_Product(currentInvoice);
                                insertInvoice_Product(currentInvoice);

                                MessageBox.Show("Invoice Details Successfully Updated");
                                ClearContent();
                            }
                            else
                            {
                                MessageBox.Show("Please select the associated Project");
                            }
                            //}
                            //else
                            //    MessageBox.Show("Please select the associated PO Number");
                        }
                        else
                        {
                            MessageBox.Show("Please specify a correct due date");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please specify correct amount of Payment Due");
                    }
                }
                else
                {
                    MessageBox.Show("Invoice Id not found");
                }
            }
            else
            {
                MessageBox.Show("Invoice Id not found");
            }
        }
        static void Main(string[] args)
        {
            BLEmployee employee = new BLEmployee();
            BLProject  project  = new BLProject();

            Model.Project p1 = new Model.Project()
            {
                Name = "sfdsd"
            };
            Model.Project p2 = new Model.Project()
            {
                Name = "tyuhg"
            };
            Model.Employee e1 = new Model.Employee()
            {
                Name = "Tdfsdf", Age = 39, Status = Model.EnumStatus.Employee, Position = Model.EnumPosition.Developer, Salary = 5675
            };

            e1.Project.Add(p2);
            e1.Project.Add(p1);
            p1.Employees.Add(e1);

            //employee.CreateEmployee(e1);
            //project.CreateProject(p1);
            //project.CreateProject(p2);
            //employee.Commit();

            Console.WriteLine("\n GetAllEmployees \n");

            foreach (var employees in employee.GetAllEmployees())
            {
                foreach (var i in employees.Project)
                {
                    Console.Write("{0} ", i.Name);
                }
                Console.WriteLine("связанные проекты c Employee: {0} {1}", employees.Id, employees.Name);
            }

            Console.WriteLine("\n GetByIdEmployee \n");

            var employeeById = employee.GetByIdEmployee(19);

            Console.WriteLine("GetByIdEmployee Id: {0} Name: {1} Age: {2} Salary: {3} Status: {4} Position: {5}", employeeById.Id, employeeById.Name, employeeById.Age, employeeById.Salary, employeeById.Status, employeeById.Position);
            foreach (var i in employeeById.Project)
            {
                Console.WriteLine("Project: {0} {1}", i.Id, i.Name);
            }

            Console.WriteLine("\n GetAllProjects \n");

            foreach (var projects in project.GetAllProjects())
            {
                Console.WriteLine("Project: {0} {1}", projects.Id, projects.Name);
            }

            Console.WriteLine("\n GetByIdProject \n");

            var projectById = project.GetByIdProject(27);

            Console.WriteLine("GetByIdProject Id: {0}, Name: {1}", projectById.Id, projectById.Name);
            foreach (var i in projectById.Employees)
            {
                Console.WriteLine("Employee Id: {0} Name: {1} Age: {2} Salary: {3} Status: {4} Position: {5}", i.Id, i.Name, i.Age, i.Salary, i.Status, i.Position);
            }

            Console.WriteLine("\n End EntityRepository. \n");

            //ADOBLEmployee adoEmployee = new ADOBLEmployee();
            //ADOBLProject adoProject = new ADOBLProject();

            //Console.WriteLine("\n GetAllEmployees \n");

            //foreach (var employees in adoEmployee.GetAllEmployees())
            //{
            //    Console.WriteLine("Id: {0} Name: {1} Age: {2} Salary: {3} Status: {4} Position: {5}", employees.Id, employees.Name, employees.Age, employees.Salary, employees.Status, employees.Position);
            //    foreach (var projects in employees.Project)
            //    {
            //        Console.WriteLine("ProjectId: {0} ProjectName: {1}", projects.Id, projects.Name);
            //    }
            //}

            //Console.WriteLine("\n GetByIdEmployee \n");

            //var employeeById = adoEmployee.GetByIdEmployee(19);
            //Console.WriteLine("GetByIdEmployee Id: {0} Name: {1} Age: {2} Salary: {3} Status: {4} Position: {5}", employeeById.Id, employeeById.Name, employeeById.Age, employeeById.Salary, employeeById.Status, employeeById.Position);
            //foreach (var i in employeeById.Project)
            //{
            //   Console.WriteLine("Project 19: {0} {1}", i.Id, i.Name);
            //}

            //Console.WriteLine("\n GetAllProjects \n");

            //foreach (var project in adoProject.GetAllProjects())
            //{
            //    Console.WriteLine("Project: {0} {1}", project.Id, project.Name);
            //    foreach (var employees in project.Employees)
            //    {
            //        Console.WriteLine("Employees Id: {0} Name: {1} Age: {2} Salary: {3} Status: {4} Position: {5}", employees.Id, employees.Name, employees.Age, employees.Salary, employees.Status, employees.Position);
            //    }
            //}

            //Console.WriteLine("\n GetByIdProject \n");

            //var projectById = adoProject.GetByIdProject(27);
            //Console.WriteLine("GetByIdProject Id: {0}, Name: {1}", projectById.Id, projectById.Name);
            //foreach (var i in projectById.Employees)
            //{
            //    Console.WriteLine("Employee Id: {0} Name: {1} Age: {2} Salary: {3} Status: {4} Position: {5}", i.Id, i.Name, i.Age, i.Salary, i.Status, i.Position);
            //}

            //Console.WriteLine("\n End ADORepository.");
            Console.ReadKey();
        }