예제 #1
0
파일: LcForm.cs 프로젝트: 308232/SE_ASS
        private void btnEditCustomerContracts_Click(object sender, EventArgs e)
        {
            NewClientForm NewClientForm = new NewClientForm();

            NewClientForm.btnAddNewClient.Visible        = false;
            NewClientForm.btnSaveNewClientRecord.Visible = false;
            NewClientForm.btnBack.Visible      = false;
            NewClientForm.btnBackOwner.Visible = false;
            NewClientForm.btnEDIT.Visible      = true;
            NewClientForm.btnUPDATE.Visible    = true;
            this.Hide();
            NewClientForm.Show();
        }
예제 #2
0
파일: MainForm.cs 프로젝트: 308232/SE_ASS
        private void btnCreateNewClientContract_Click(object sender, EventArgs e)
        {
            //hiding, showing the correct buttons depending on the label text that we changed when logged in  Owner
            if (lblTitle.Text == "WELCOME OWNER")
            {
                NewClientForm NewClientForm = new NewClientForm();
                NewClientForm.btnBackLC.Visible              = false;
                NewClientForm.btnBack.Visible                = false;
                NewClientForm.btnAddNewClient.Visible        = false;
                NewClientForm.btnSaveNewClientRecord.Visible = false;
                NewClientForm.btnEDIT.Visible                = false;
                NewClientForm.btnUPDATE.Visible              = false;
                NewClientForm.label1.Text = "Owner CLIENT FORM";

                this.Hide();
                NewClientForm.Show();
            }
            else if (lblTitle.Text == "WELCOME ADMIN")
            {
                //hiding, showing the correct buttons depending on the label text that we changed when logged in  Admin

                NewClientForm NewClientForm = new NewClientForm();
                NewClientForm.btnBackLC.Visible              = false;
                NewClientForm.btnBackOwner.Visible           = false;
                NewClientForm.btnAddNewClient.Visible        = true;
                NewClientForm.btnSaveNewClientRecord.Visible = true;
                NewClientForm.btnEDIT.Visible   = true;
                NewClientForm.btnUPDATE.Visible = false;
                NewClientForm.label1.Text       = "ADMIN CLIENT FORM";
                this.Hide();
                NewClientForm.Show();
            }
            else if (lblTitle.Text == "WELCOME LC")
            {
                //hiding, showing the correct buttons depending on the label text that we changed when logged in LC
                NewClientForm NewClientForm = new NewClientForm();
                NewClientForm.btnBack.Visible                = false;
                NewClientForm.btnBackLC.Visible              = true;
                NewClientForm.btnBackOwner.Visible           = false;
                NewClientForm.btnAddNewClient.Visible        = false;
                NewClientForm.btnSaveNewClientRecord.Visible = false;
                NewClientForm.btnEDIT.Visible                = true;
                NewClientForm.btnUPDATE.Visible              = false;
                NewClientForm.label1.Text = "LC CLIENT FORM";

                this.Hide();
                NewClientForm.Show();
            }
        }
예제 #3
0
        private void btnSaveNewClientRecord_Click(object sender, EventArgs e)
        {
            //button that gets the text from the text boxes and saves it as a new record in the database

            DataRow OneRecord = dsCustomer.Tables["Customers"].NewRow();

            OneRecord[0] = txtboxClientID.Text;
            OneRecord[1] = txtboxBusinessName.Text;
            OneRecord[2] = txtboxHouseNo.Text;
            OneRecord[3] = txtboxStreetName.Text;
            OneRecord[4] = txtboxPostCode.Text;
            OneRecord[5] = txtboxPhoneNumber.Text;
            OneRecord[6] = txtboxEmail.Text;
            OneRecord[7] = txtboxNotes.Text;
            OneRecord[8] = txtboxAssId.Text;
            OneRecord[9] = txtboxContracted.Text;



            dsCustomer.Tables["Customers"].Rows.Add(OneRecord);
            countrec++;
            whichrec = countrec - 1;

            //creating sqlbulder and a new instance of the databse in order to update it with the new record
            System.Data.SqlClient.SqlCommandBuilder myUpdateDB;
            myUpdateDB = new System.Data.SqlClient.SqlCommandBuilder(daCustomer);
            myUpdateDB.DataAdapter.Update(dsCustomer.Tables["Customers"]);
            MessageBox.Show("Record Saved");

            //reloading the form again with all the matching properties for the current user
            NewClientForm NewClientForm = new NewClientForm();

            NewClientForm.btnBackLC.Visible              = false;
            NewClientForm.btnBackOwner.Visible           = false;
            NewClientForm.btnAddNewClient.Visible        = true;
            NewClientForm.btnSaveNewClientRecord.Visible = true;
            NewClientForm.btnEDIT.Visible   = true;
            NewClientForm.btnUPDATE.Visible = false;
            NewClientForm.label1.Text       = "ADMIN CLIENT FORM";
            this.Hide();
            NewClientForm.Show();
        }
예제 #4
0
        private void btnUPDATE_Click(object sender, EventArgs e)
        {
            // a separate connection in order to update an excisting record in the database
            dsCustomer = new DataSet();


            //a private string to pass the data from the database to.

            //in order to read the dataabse sql code is used as shown below

            String Update = "UPDATE ClientsTbl SET BusinessName='" + txtboxBusinessName.Text + "', HouseNo='" + txtboxHouseNo.Text + "', StreetName='" + txtboxStreetName.Text + "', PostCode='" + txtboxPostCode.Text + "', PhoneNumber='" + txtboxPhoneNumber.Text + "', Email='" + txtboxEmail.Text + "', Notes='" + txtboxNotes.Text + "', AssID='" + txtboxAssId.Text + "', Contracted='" + txtboxContracted.Text + "' WHERE ClientID='" + txtboxClientID.Text + "'";

            SqlConnection conn = new SqlConnection(newCon.ConnectionString);
            SqlCommand    cmd  = new SqlCommand(Update, conn);
            SqlDataReader read;


            try
            {
                //open the database connection
                conn.Open();
                read = cmd.ExecuteReader();
                MessageBox.Show("Record Updated");
            }
            catch
            {
                MessageBox.Show("Not able to update the databse ");
            }
            //close the database connection

            conn.Close();

            //hide and show buttons for current user

            btnFirstRecordClientsForm.Visible = true;
            btnNextRecordClientsForm.Visible  = true;
            btnLastRecord.Visible             = true;
            btnPreviusRecord.Visible          = true;
            btnEDIT.Visible = true;

            btnUPDATE.Visible = false;
            btnSaveNewClientRecord.Visible = true;
            btnAddNewClient.Visible        = true;
            if (label1.Text == "LC CLIENT FORM")
            {
                //depending on the update the database needs to be refreshed and show again only the buttons available for the current user
                //loads the form again with all its properties LC
                NewClientForm NewClientForm = new NewClientForm();
                NewClientForm.btnBack.Visible                = false;
                NewClientForm.btnBackLC.Visible              = true;
                NewClientForm.btnBackOwner.Visible           = false;
                NewClientForm.btnAddNewClient.Visible        = false;
                NewClientForm.btnSaveNewClientRecord.Visible = false;
                NewClientForm.btnEDIT.Visible                = true;
                NewClientForm.btnUPDATE.Visible              = false;
                NewClientForm.label1.Text = "LC CLIENT FORM";

                this.Hide();
                NewClientForm.Show();
            }
            else if (label1.Text == "ADMIN CLIENT FORM")
            {
                //depending on the update the database needs to be refreshed and show again only the buttons available for the current user
                //loads the form again with all its properties Admin
                NewClientForm NewClientForm = new NewClientForm();
                NewClientForm.btnBackLC.Visible              = false;
                NewClientForm.btnBackOwner.Visible           = false;
                NewClientForm.btnAddNewClient.Visible        = true;
                NewClientForm.btnSaveNewClientRecord.Visible = true;
                NewClientForm.btnEDIT.Visible   = true;
                NewClientForm.btnUPDATE.Visible = false;
                NewClientForm.label1.Text       = "ADMIN CLIENT FORM";
                this.Hide();
                NewClientForm.Show();
            }
        }