Exemplo n.º 1
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.º 2
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.º 3
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.º 4
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.º 5
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.º 6
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.º 7
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.º 8
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");
            }
        }