Пример #1
0
        private void Button2_Click(object sender, EventArgs e)
        {
            try
            {
                Customer customerToDelete = new Customer
                {
                    CustomerID = Convert.ToInt32(listView1.SelectedItems[0].SubItems[1].Text),
                    Name       = listView1.SelectedItems[0].SubItems[2].Text,
                    Surname    = listView1.SelectedItems[0].SubItems[3].Text,
                    Phone      = listView1.SelectedItems[0].SubItems[4].Text,
                    Address    = listView1.SelectedItems[0].SubItems[5].Text
                };

                var sorgu = DalCustomer.CUD(customerToDelete, System.Data.Entity.EntityState.Deleted);

                if (sorgu)
                {
                    GuncelleMusteriler();
                    MessageBox.Show("Müşteri silindi.", "İşlem Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Müşteri seçilmedi.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        public DTOCustomer AddCustomerToBLL(DTOCustomer c)
        {
            DalCustomer dc = new DalCustomer();

            return(Converters.Converters.ConvertCustomerToDTO
                       (dc.addCusstomerToSQL(Converters.Converters.ConvertCustomerToDAL(c))));
        }
 public Customer MapToOrm(DalCustomer entity)
 {
     return(new Customer
     {
         id = entity.Id,
         address = entity.Address,
         contractLib_id = entity.ContractLib_id,
         organization = entity.Organization,
         phone = entity.Phone
     });
 }
        public List <DTOCustomer> GetAllCustomersFromBll()
        {
            DalCustomer        dalCus       = new DalCustomer();
            List <DTOCustomer> dtoCustomers = new List <DTOCustomer>();
            List <Customer>    c            = dalCus.GetAllCustomersFromDal();

            foreach (Customer currentCus in c)
            {
                dtoCustomers.Add(Converters.Converters.ConvertCustomerToDTO(currentCus));
            }
            return(dtoCustomers);
        }
Пример #5
0
        public BllCustomer MapToBll(DalCustomer entity)
        {
            BllCustomer bllEntity = new BllCustomer
            {
                Id          = entity.Id,
                Address     = entity.Address,
                ContractLib = entity.ContractLib_id != null?contractLibService.Get((int)entity.ContractLib_id) : null,
                                  Organization = entity.Organization,
                                  Phone        = entity.Phone
            };

            return(bllEntity);
        }
Пример #6
0
        public DalCustomer MapToDal(BllCustomer entity)
        {
            DalCustomer dalEntity = new DalCustomer
            {
                Id             = entity.Id,
                Address        = entity.Address,
                ContractLib_id = entity.ContractLib.Id,
                Organization   = entity.Organization,
                Phone          = entity.Phone
            };

            return(dalEntity);
        }
Пример #7
0
        private void Button3_Click(object sender, EventArgs e)
        {
            try
            {
                var anyEmptyArea = EmptyTextBoxControl(groupBox3);
                if (anyEmptyArea)
                {
                    MessageBox.Show("Eksik bilgi girdiniz.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    Customer newCustomer = new Customer
                    {
                        Name    = textBox1.Text,
                        Surname = textBox2.Text,
                        Phone   = textBox3.Text,
                        Address = textBox4.Text
                    };

                    var sorgu = DalCustomer.CUD(newCustomer, System.Data.Entity.EntityState.Added);

                    if (sorgu == true)
                    {
                        textBox1.Clear();
                        textBox2.Clear();
                        textBox3.Clear();
                        textBox4.Clear();

                        GuncelleMusteriler();
                        MessageBox.Show("Yeni müşteri eklendi.", "İşlem Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Müşteri ekleme başarısız.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Eksik bilgi girdiniz.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Пример #8
0
        private void TabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            var tab = sender as TabControl;

            switch (tab.SelectedIndex)
            {
            case 0:
                GuncelleMusteriler();
                break;

            case 1:
                label42.Text = karZararHesapla().ToString();
                break;

            case 2:
                comboBox3.DisplayMember = "CategoryName";
                comboBox3.ValueMember   = "CategoryID";
                comboBox3.DataSource    = DalCategory.GetCategories();

                comboBox4.ValueMember = "CustomerID";
                comboBox4.DataSource  = DalCustomer.GetCustomers();

                break;

            case 3:
                GuncelleUrunler();

                comboBox1.DisplayMember = "CategoryName";
                comboBox1.ValueMember   = "CategoryID";
                comboBox1.DataSource    = DalCategory.GetCategories();

                comboBox2.DisplayMember = "CategoryName";
                comboBox2.ValueMember   = "CategoryID";
                comboBox2.DataSource    = DalCategory.GetCategories();
                break;

            case 4:
                GuncelleKategoriler();
                break;
            }
        }
Пример #9
0
 /// <summary>
 /// Mise à jour d'un client.
 /// </summary>
 /// <param name="Cstmr"></param>
 public static void UpdteCstmr(Customer Cstmr)
 {
     if (Cstmr == null)
     {
         throw new ArgumentNullException(nameof(Cstmr));
     }
     try
     {
         DalCustomer.UpdteCstmr(Cstmr.Pers_Id, Cstmr.Name, Cstmr.Surname, Cstmr.BirthDate, Cstmr.Email, Cstmr.Phone);
     }
     #region Catch
     catch (CstmEx cstmEx)
     {
         throw new CstmEx(ExType.dtaRead, cstmEx);
     }
     catch (Exception ex)
     {
         throw new CstmEx(ExType.srvrError, ex);
     }
     #endregion Catch
 }
Пример #10
0
        private void GuncelleMusteriler()
        {
            listView1.Items.Clear();
            try
            {
                foreach (var customer in DalCustomer.GetCustomers())
                {
                    ListViewItem c = new ListViewItem();
                    c.SubItems.Add(customer.CustomerID.ToString());
                    c.SubItems.Add(customer.Name);
                    c.SubItems.Add(customer.Surname);
                    c.SubItems.Add(customer.Phone);
                    c.SubItems.Add(customer.Address);

                    listView1.Items.Add(c);
                }
            }
            catch (Exception)
            {
            }
        }
Пример #11
0
        private void Button4_Click(object sender, EventArgs e)
        {
            try
            {
                var anyEmptyArea = EmptyTextBoxControl(groupBox4);
                if (anyEmptyArea)
                {
                    MessageBox.Show("Eksik bilgi girdiniz.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    Customer customerToUpdate = new Customer
                    {
                        CustomerID = Convert.ToInt32(textBox27.Text),
                        Name       = textBox8.Text,
                        Surname    = textBox7.Text,
                        Phone      = textBox6.Text,
                        Address    = textBox5.Text
                    };

                    var sorgu = DalCustomer.CUD(customerToUpdate, System.Data.Entity.EntityState.Modified);

                    if (sorgu)
                    {
                        textBox5.Clear();
                        textBox6.Clear();
                        textBox7.Clear();
                        textBox8.Clear();

                        GuncelleMusteriler();
                        MessageBox.Show("Müşteri bilgileri güncellendi.", "İşlem Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Eksik bilgi girdiniz.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Пример #12
0
        /// <summary>
        /// Renvoie les détails d'un client par son ID.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static Customer GetCustomer(int id)
        {
            Customer _customer = new Customer();

            try
            {
                DataTable _table = DalCustomer.GetCstmrDetails(id);
                if (_table != null)
                {
                    if (_table.Rows.Count != 0)
                    {
                        DataRowView row  = _table.DefaultView[0];
                        Customer    temp = new Customer
                        {
                            Name      = row["Name"].ToString(),
                            Surname   = row["Surname"].ToString(),
                            BirthDate = DateTime.Parse(row["BirthDate"].ToString()),
                            Email     = row["Email"].ToString(),
                            Phone     = row["Phone"].ToString()
                        };

                        _customer = temp;
                    }
                }
                return(_customer);
            }
            #region Catch
            catch (CstmEx cstmEx)
            {
                throw new CstmEx(ExType.dtaRead, cstmEx);
            }
            catch (Exception ex)
            {
                throw new CstmEx(ExType.srvrError, ex);
            }
            #endregion Catch
        }