Exemplo n.º 1
0
        private void add_Click(object sender, RoutedEventArgs e)
        {
            newClient = mainGrid.DataContext as DB.Client;

            var gender = cbGender.SelectedItem as DB.Gender;

            newClient.GenderCode = gender.Code;

            newClient.RegistrationDate = dt2.DisplayDate;

            newClient.Birthday = dt.SelectedDate;


            try
            {
                DB.DETLT2020Entities entities = new DB.DETLT2020Entities();
                entities.Clients.Add(newClient);

                entities.SaveChanges();

                MessageBox.Show("сохранение прошло  успешно");

                DialogResult = true;
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 2
0
        public int Save(Models.MClients model)
        {
            Common.Logger l         = new Common.Logger();
            string        ClassName = "CClients";

            try
            {
                DB.Client bs = new DB.Client();
                bs.id           = Convert.ToInt32(model.id);
                bs.ClientTypeId = Convert.ToInt32(model.ClientTypeld);
                bs.Name         = model.Name;
                bs.phone        = model.phone;
                bs.EmailAddress = model.EmailAddress;
                bs.Address1     = model.Address1;
                bs.Address2     = model.Address2;
                bs.City         = model.City;
                bs.isVendor     = model.isVendor;
                bs.eDate        = Convert.ToDateTime(model.edate);
                bs.WareHouseId  = Convert.ToInt32(model.WareHouseId);
                bs.NIC          = model.NIC;
                bs.GrantorName  = model.GrantorName;
                bs.GrantorNIC   = model.GrantorNIC;
                l.Print(ClassName, Common.LogPointer.Info.ToString(), "Model id[" + model.id + "] ClientTypeId[" + model.ClientTypeld + "] Name[" + model.Name + "] phone[" + model.phone + "] EmailAddress[ " + model.EmailAddress + "] Address1 [" + model.Address1 + "] Address2 [" + model.Address2 + "] City [" + model.City + "] isVendor[ " + model.isVendor + "] eDate[ " + model.edate + "]");
                obj.Clients.InsertOnSubmit(bs);
                obj.SubmitChanges();
                l.Print(ClassName, Common.LogPointer.Info.ToString(), "Record Inserted Successfully");
                return(1);
            }
            catch (Exception ex)
            {
                l.Print(ClassName, Common.LogPointer.Error.ToString(), ex.ToString());
                return(-1);
            }
        }
Exemplo n.º 3
0
        public AddClient()
        {
            InitializeComponent();

            DB.DETLT2020Entities entities = new DB.DETLT2020Entities();

            newClient            = new DB.Client();
            mainGrid.DataContext = newClient;
            cbGender.ItemsSource = entities.Genders.ToList();
        }