Пример #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            int id = 0;

            int.TryParse(tbId.Text, out id);
            if (id != 0)
            {
                Client currentClient = BLClient.GetClientById(APCContext, id);
                if (currentClient != null)
                {
                    APCContext.DeleteObject(currentClient);
                    APCContext.SaveChanges();
                    MessageBox.Show("Delete Successfully");
                    ClearContent();
                }
                else
                {
                    MessageBox.Show("Client Id not found");
                }
            }
            else
            {
                MessageBox.Show("Client Id not found");
            }
        }
Пример #2
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");
            }
        }
Пример #3
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            int id = 0;

            int.TryParse(tbId.Text, out id);
            if (id != 0)
            {
                Client currentClient = BLClient.GetClientById(APCContext, id);
                if (currentClient != null)
                {
                    currentClient.Name = tbClientName.Text;
                    APCContext.SaveChanges();
                    MessageBox.Show("Client Details Successfully Updated");
                    ClearContent();
                }
                else
                {
                    MessageBox.Show("Client Id not found");
                }
            }
            else
            {
                MessageBox.Show("Client Id not found");
            }
        }
Пример #4
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");
            }
        }