示例#1
0
        public void SaveClient()
        {
            if (this.clientId == 0)
            {
                int idInserted = 0;

                BLClient bip  = new BLClient();
                string   info = bip.InsertClientBI(txtClientName.Text, txtClientSurName.Text,
                                                   txtClientCode.Text, txtClientPhone.Text, txtClientEmail.Text, out idInserted);
                this.clientId = idInserted;

                if (String.IsNullOrEmpty(info))
                {
                    foreach (ClientAddressModel model in listAddress)
                    {
                        model.ClientId = idInserted;
                    }
                    BLClientAddress bla = new BLClientAddress();
                    bla.BIPrepareClientAddress(listAddress);
                    MessageBox.Show("Clientul a fost inserat cu succes", "Succes", MessageBoxButtons.OK, MessageBoxIcon.None);
                }
                else
                {
                    MessageBox.Show(info, "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                bool ok;
                this.clientCodeFinal = txtClientCode.Text;
                if (clientCodeInitial == clientCodeFinal)
                {
                    ok = true;
                }
                else
                {
                    ok = false;
                }

                BLClient bl   = new BLClient();
                string   info = bl.BIUpdateClient(txtClientName.Text, txtClientSurName.Text,
                                                  txtClientCode.Text, txtClientPhone.Text, txtClientEmail.Text, clientId, ok);

                if (String.IsNullOrWhiteSpace(info))
                {
                    BLClientAddress bla = new BLClientAddress();
                    bla.BIPrepareClientAddress(listAddress);
                    MessageBox.Show("Datele clientului au fost modificate cu succes", "Succes", MessageBoxButtons.OK, MessageBoxIcon.None);
                    this.clientCodeInitial = this.clientCodeFinal;
                }
                else
                {
                    MessageBox.Show(info, "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
        }