Exemple #1
0
 public bool SaveClient(Client client)
 {
     using (var db = new DataContext())
     {
         db.Client.Add(client);
         return db.SaveChanges() > 0;
     }
 }
        private void btnAddnewclient_Click(object sender, EventArgs e)
        {
            if (!Validations())
            {
                return;
            }
            using (var context = new Database1Entities())
            {
                ((System.Data.SqlClient.SqlConnection)context.Database.Connection).ConnectionString = @"data source=(LocalDB)\MSSQLLocalDB;attachdbfilename=" + GlobalConstants.commondocsCOMPANYDBpath + "; integrated security=True;connect timeout=30;MultipleActiveResultSets=True;App=EntityFramework";

                DataAccess.Client objsaclient = new DataAccess.Client();
                objsaclient.Title = txtTitle.Text;
                objsaclient.FName = txtFirstName.Text;
                objsaclient.LName = txtLastName.Text;
                objsaclient.UTR   = txtUTR.Text;
                context.Clients.Add(objsaclient);
                int x = context.SaveChanges();
                int justaddedindex = objsaclient.Pk_Client_Id;


                DataAccess.SA100 objsa100 = new DataAccess.SA100();
                objsa100.Fk_Client_Id = justaddedindex;
                context.SA100.Add(objsa100);
                int y = context.SaveChanges();

                DataAccess.SA110 objsa110 = new DataAccess.SA110();
                objsa110.Fk_Client_Id = justaddedindex;
                context.SA110.Add(objsa110);
                int z = context.SaveChanges();

                DataAccess.Atttach objattach = new DataAccess.Atttach();
                objattach.Fk_Client_Id = justaddedindex;
                context.Atttaches.Add(objattach);
                z = context.SaveChanges();

                DataAccess.GGCredential objgg = new DataAccess.GGCredential();
                objgg.Fk_Client_Id = justaddedindex;
                context.GGCredentials.Add(objgg);
                z = context.SaveChanges();

                DataAccess.SelectedSupp objselfrm = new DataAccess.SelectedSupp();
                objselfrm.Fk_Client_Id = justaddedindex;
                context.SelectedSupps.Add(objselfrm);
                int a = context.SaveChanges();

                DataAccess.ClientAddress objcladd = new DataAccess.ClientAddress();
                objcladd.Fk_Client_Id = justaddedindex;
                objcladd.UTR          = txtUTR.Text;
                objcladd.TPStatus     = "UK";
                context.ClientAddresses.Add(objcladd);
                int b = context.SaveChanges();


                GlobalConstants.NewclientAdded = true;
                this.Close();
            }
        }
Exemple #3
0
 public void add(Client client)
 {
     this.add(client.nom, client.prenom, client.datenaissance);
 }