Example #1
0
        private void btn_AddClient_Click(object sender, EventArgs e)
        {
            MyClient myClient = new MyClient();
            bool     ok       = true;

            errP.Clear();

            try
            {
                myClient.ClientNo = Convert.ToInt32(lbl_ClientNoText.Text.Trim());
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(lbl_ClientNoText, MyEx.tostring());
            }

            try
            {
                myClient.Title = cmb_Title.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(cmb_Title, MyEx.tostring());
            }

            try
            {
                myClient.Surname = txt_Surname.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txt_Surname, MyEx.tostring());
            }

            try
            {
                myClient.Forename = txt_Forename.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txt_Forename, MyEx.tostring());
            }

            try
            {
                myClient.Street = richTxt_Street.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(richTxt_Street, MyEx.tostring());
            }

            try
            {
                myClient.Town = txt_Town.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txt_Town, MyEx.tostring());
            }

            try
            {
                myClient.County = txt_County.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txt_County, MyEx.tostring());
            }

            try
            {
                myClient.Postcode = txt_Postcode.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txt_Postcode, MyEx.tostring());
            }

            try
            {
                myClient.Country = txt_Country.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txt_Country, MyEx.tostring());
            }

            try
            {
                myClient.TelNo = txt_Telephone.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txt_Telephone, MyEx.tostring());
            }

            try
            {
                myClient.Email = txt_Email.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txt_Email, MyEx.tostring());
            }

            try
            {
                if (chk_Skin.Checked)
                {
                    myClient.SkinTest = "Yes";
                }
                else
                {
                    myClient.SkinTest = "No";
                }
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(chk_Skin, MyEx.tostring());
            }

            try
            {
                if (ok)
                {
                    drclient             = dsNWRC_HairBeauty.Tables["Client"].NewRow();
                    drclient["ClientNo"] = myClient.ClientNo;
                    drclient["Title"]    = myClient.Title;
                    drclient["Surname"]  = myClient.Surname;
                    drclient["Forename"] = myClient.Forename;
                    drclient["Street"]   = myClient.Street;
                    drclient["Town"]     = myClient.Town;
                    drclient["County"]   = myClient.County;
                    drclient["PostCode"] = myClient.Postcode;
                    drclient["Country"]  = myClient.Country;
                    drclient["TelNo"]    = myClient.TelNo;
                    drclient["Email"]    = myClient.Email;
                    drclient["SkinTest"] = myClient.SkinTest;

                    dsNWRC_HairBeauty.Tables["Client"].Rows.Add(drclient);
                    daClient.Update(dsNWRC_HairBeauty, "Client");

                    MessageBox.Show("New Customer " + lbl_ClientNoText.Text + " added !!!");

                    if (MessageBox.Show("Do you wish to add another Client?", "Add Client", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        clearAddForm();
                        getNumber(dsNWRC_HairBeauty.Tables["Client"].Rows.Count);
                    }
                    else
                    {
                        tab_Client.SelectedIndex = 0;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("" + ex.TargetSite + "" + ex.Message, "Error!", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
            }
        }
Example #2
0
        private void btn_Multibook_Click(object sender, EventArgs e)
        {
            if (lbl_ClientNoTextBook.Text != "")
            {
                drclient = dsNWRC_HairBeauty.Tables["Client"].Rows.Find(lbl_ClientNoTextBook.Text);

                if (btn_Multibook.Text == "Edit Client")
                {
                    //enable Form Entries
                    formEnable(true);
                    btn_CancelBook.Visible = true;
                    btn_Multibook.Text     = "Save Client";
                }
                else
                {
                    MyClient myClient = new MyClient();
                    bool     ok       = true;
                    errP.Clear();

                    try
                    { myClient.ClientNo = Convert.ToInt32(lbl_ClientNoTextBook.Text.Trim()); }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(lbl_ClientNoTextBook, MyEx.ToString());
                    }

                    try
                    { myClient.Title = cmb_TitleBook.Text.Trim(); }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(cmb_TitleBook, MyEx.tostring());
                    }

                    try
                    { myClient.Surname = txt_SurnameBook.Text.Trim(); }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(txt_SurnameBook, MyEx.tostring());
                    }

                    try
                    { myClient.Forename = txt_ForenameBook.Text.Trim(); }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(txt_ForenameBook, MyEx.tostring());
                    }

                    try
                    { myClient.Street = rt_StreetBook.Text.Trim(); }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(rt_StreetBook, MyEx.tostring());
                    }

                    try
                    { myClient.Town = txt_TownBook.Text.Trim(); }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(txt_TownBook, MyEx.tostring());
                    }

                    try
                    { myClient.County = txt_CountyBook.Text.Trim(); }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(txt_CountyBook, MyEx.tostring());
                    }

                    try
                    { myClient.Postcode = txt_PostcodeBook.Text.Trim(); }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(txt_PostcodeBook, MyEx.tostring());
                    }

                    try
                    { myClient.Country = txt_CountryBook.Text.Trim(); }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(txt_CountryBook, MyEx.tostring());
                    }

                    try
                    { myClient.TelNo = txt_TelephoneBook.Text.Trim(); }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(txt_TelephoneBook, MyEx.tostring());
                    }

                    try
                    { myClient.Email = txt_EmailBook.Text.Trim(); }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(txt_EmailBook, MyEx.tostring());
                    }

                    try
                    {
                        if (chk_SkinBook.Checked)
                        {
                            myClient.SkinTest = "Yes";
                        }
                        else
                        {
                            myClient.SkinTest = "No";
                        }
                    }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(chk_SkinBook, MyEx.tostring());
                    }
                    if (newClient)
                    {
                        drclient             = dsNWRC_HairBeauty.Tables["Client"].NewRow();
                        drclient["ClientNo"] = myClient.ClientNo;
                        drclient["Title"]    = myClient.Title;
                        drclient["Surname"]  = myClient.Surname;
                        drclient["Forename"] = myClient.Forename;
                        drclient["Street"]   = myClient.Street;
                        drclient["Town"]     = myClient.Town;
                        drclient["County"]   = myClient.County;
                        drclient["PostCode"] = myClient.Postcode;
                        drclient["Country"]  = myClient.Country;
                        drclient["TelNo"]    = myClient.TelNo;
                        drclient["Email"]    = myClient.Email;
                        drclient["SkinTest"] = myClient.SkinTest;

                        dsNWRC_HairBeauty.Tables["Client"].Rows.Add(drclient);
                        daClient.Update(dsNWRC_HairBeauty, "Client");

                        MessageBox.Show("New Customer " + lbl_ClientNoTextBook.Text + " added !!!");
                    }
                    else
                    {
                        try
                        {
                            if (ok)
                            {
                                drclient.BeginEdit();
                                drclient["Title"]    = myClient.Title;
                                drclient["Surname"]  = myClient.Surname;
                                drclient["Forename"] = myClient.Forename;
                                drclient["Street"]   = myClient.Street;
                                drclient["Town"]     = myClient.Town;
                                drclient["County"]   = myClient.County;
                                drclient["PostCode"] = myClient.Postcode;
                                drclient["Country"]  = myClient.Country;
                                drclient["TelNo"]    = myClient.TelNo;
                                drclient["Email"]    = myClient.Email;
                                drclient["SkinTest"] = myClient.SkinTest;

                                drclient.EndEdit();
                                daClient.Update(dsNWRC_HairBeauty, "Client");

                                MessageBox.Show("Customer " + lbl_ClientNoTextBook.Text + " Details have been Updated !!!");
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("" + ex.TargetSite + "" + ex.Message, "Error!", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
                        }
                    }
                    //Disable Form entries
                    formEnable(false);
                    btn_CancelBook.Visible = false;
                    btn_Multibook.Text     = "Edit Client";
                }
            }
        }
Example #3
0
        private void btn_EditClient_Click(object sender, EventArgs e)
        {
            if (btn_EditClient.Text == "Edit Client")
            {
                cmb_Title_Edit.Enabled    = true;
                txt_Forename_Edit.Enabled = true;
                txt_Surname_Edit.Enabled  = true;
                rt_Street_Edit.Enabled    = true;
                txt_Town_Edit.Enabled     = true;
                txt_County_Edit.Enabled   = true;
                txt_Postcode_Edit.Enabled = true;
                txt_Country_Edit.Enabled  = true;
                txt_TelNo_Edit.Enabled    = true;
                txt_Email_Edit.Enabled    = true;
                chk_Skin_Edit.Enabled     = true;

                btn_EditClient.Text = "Save Client";
            }
            else
            {
                MyClient myClient = new MyClient();
                bool     ok       = true;
                errP.Clear();


                try
                {
                    myClient.ClientNo = Convert.ToInt32(lbl_ClientNo_EditText.Text.Trim());
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(lbl_ClientNo_EditText, MyEx.ToString());
                }
                try
                {
                    myClient.Title = cmb_Title_Edit.Text.Trim();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(cmb_Title_Edit, MyEx.tostring());
                }

                try
                {
                    myClient.Surname = txt_Surname_Edit.Text.Trim();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txt_Surname_Edit, MyEx.tostring());
                }

                try
                {
                    myClient.Forename = txt_Forename_Edit.Text.Trim();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txt_Forename_Edit, MyEx.tostring());
                }

                try
                {
                    myClient.Street = rt_Street_Edit.Text.Trim();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(rt_Street_Edit, MyEx.tostring());
                }

                try
                {
                    myClient.Town = txt_Town_Edit.Text.Trim();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txt_Town_Edit, MyEx.tostring());
                }

                try
                {
                    myClient.County = txt_County_Edit.Text.Trim();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txt_County_Edit, MyEx.tostring());
                }

                try
                {
                    myClient.Postcode = txt_Postcode_Edit.Text.Trim();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txt_Postcode_Edit, MyEx.tostring());
                }

                try
                {
                    myClient.Country = txt_Country_Edit.Text.Trim();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txt_Country_Edit, MyEx.tostring());
                }

                try
                {
                    myClient.TelNo = txt_TelNo_Edit.Text.Trim();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txt_TelNo_Edit, MyEx.tostring());
                }

                try
                {
                    myClient.Email = txt_Email_Edit.Text.Trim();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txt_Email_Edit, MyEx.tostring());
                }

                try
                {
                    if (chk_Skin_Edit.Checked)
                    {
                        myClient.SkinTest = "Yes";
                    }
                    else
                    {
                        myClient.SkinTest = "No";
                    }
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(chk_Skin_Edit, MyEx.tostring());
                }
                try
                {
                    if (ok)
                    {
                        drclient.BeginEdit();

                        // drclient["ClientNo"] = myClient.ClientNo;
                        drclient["Title"]    = myClient.Title;
                        drclient["Surname"]  = myClient.Surname;
                        drclient["Forename"] = myClient.Forename;
                        drclient["Street"]   = myClient.Street;
                        drclient["Town"]     = myClient.Town;
                        drclient["County"]   = myClient.County;
                        drclient["PostCode"] = myClient.Postcode;
                        drclient["Country"]  = myClient.Country;
                        drclient["TelNo"]    = myClient.TelNo;
                        drclient["Email"]    = myClient.Email;
                        drclient["SkinTest"] = myClient.SkinTest;

                        drclient.EndEdit();
                        daClient.Update(dsNWRC_HairBeauty, "Client");

                        MessageBox.Show("Customer " + lbl_ClientNo_EditText.Text + " Details have been Updated !!!");

                        cmb_Title_Edit.Enabled    = false;
                        txt_Forename_Edit.Enabled = false;
                        txt_Surname_Edit.Enabled  = false;
                        rt_Street_Edit.Enabled    = false;
                        txt_Town_Edit.Enabled     = false;
                        txt_County_Edit.Enabled   = false;
                        txt_Postcode_Edit.Enabled = false;
                        txt_Country_Edit.Enabled  = false;
                        txt_TelNo_Edit.Enabled    = false;
                        txt_Email_Edit.Enabled    = false;
                        chk_Skin_Edit.Enabled     = false;

                        btn_EditClient.Text      = "Edit Client";
                        tab_Client.SelectedIndex = 0;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex.TargetSite + "" + ex.Message, "Error!", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
                }
            }
        }