コード例 #1
0
 private void button2_Click(object sender, EventArgs e)
 {
     //MÜŞTERİ SEÇ BUTONU
     cm = HelperCustomer.GetByID(Convert.ToInt32(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value));
     MessageBox.Show("Müşteri seçildi");
     this.Close();
 }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Müşteri arama butonu
            dataGridView1.Rows.Clear();
            List <Customer> cm = new List <Customer>();

            if (comboBox1.SelectedIndex == 0)
            {
                cm = HelperCustomer.GetListByName(textBox1.Text);
            }
            else if (comboBox1.SelectedIndex == 1)
            {
                cm = HelperCustomer.GetListBySurname(textBox1.Text);
            }
            else if (comboBox1.SelectedIndex == 2)
            {
                cm = HelperCustomer.GetListByTc(textBox1.Text);
            }
            foreach (var item in cm)
            {
                if (item.IsActive == true)
                {
                    dataGridView1.Rows.Add(item.CustomerID, item.name, item.surname, item.tcNo, item.gsm, item.address);
                }
            }
            textBox1.Clear();
            textBox2.Clear();
            textBox3.Clear();
            textBox4.Clear();
            maskedTextBox1.Clear();
            textBox5.Clear();
        }
コード例 #3
0
 private void button2_Click(object sender, EventArgs e)
 {
     //Müşteri ekleme butonu
     if (!String.IsNullOrEmpty(textBox2.Text) && !String.IsNullOrEmpty(textBox3.Text) && !String.IsNullOrEmpty(textBox4.Text) && !String.IsNullOrEmpty(textBox5.Text) && !String.IsNullOrEmpty(maskedTextBox1.Text))
     {
         Customer cm = new Customer()
         {
             name     = textBox2.Text,
             surname  = textBox3.Text,
             tcNo     = textBox4.Text,
             gsm      = maskedTextBox1.Text,
             address  = textBox5.Text,
             IsActive = true
         };
         var ekle = HelperCustomer.CUD(cm, System.Data.Entity.EntityState.Added);
         if (ekle.Item2)
         {
             MessageBox.Show("Müşteri ekleme başarılı.");
         }
         else
         {
             MessageBox.Show("Müşteri eklenemedi");
         }
         Yenile();
     }
     else
     {
         MessageBox.Show("Lütfen tüm alanları doldurunuz.");
     }
     textBox2.Clear();
     textBox3.Clear();
     textBox4.Clear();
     maskedTextBox1.Clear();
     textBox5.Clear();
 }
コード例 #4
0
        private void DgvCustomers_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (command == "delCustomer")
            {
                int cusID = 0;
                if (dgvCustomers.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
                {
                    dgvCustomers.CurrentRow.Selected = true;
                    cusID = Convert.ToInt32(dgvCustomers.Rows[e.RowIndex].Cells["customerID"].FormattedValue.ToString());
                }

                var cus  = HelperCustomer.GetCustomer(cusID);
                var sign = HelperSignin.GetUserCus(cus.Signin.signinID);
                if (cus != null)
                {
                    if (HelperOrder.ActiveCustomersList().Contains(cusID))
                    {
                        MessageBox.Show("Bu müşteri daha önce satın alım yaptığı için sistemden çıkaramazsınız!");
                    }
                    else
                    {
                        cus.Signin.signinID = 0;
                        HelperCustomer.CUD(cus, EntityState.Modified);
                        var result1 = HelperCustomer.CUD(cus, EntityState.Deleted);
                        var result2 = HelperSignin.CUD(sign, EntityState.Deleted);
                        MessageBox.Show(result1 == true && result2 == true ? "Müşteri başarıyla sistemden çıkarıldı!" : "HATA!");
                    }
                }
            }

            else if (command == "maintenance")
            {
                MessageBox.Show("Sistemin bakımda olması sebebiyle bu işlem geçici bir süreliğine askıya alınmıştır!");
            }
        }
コード例 #5
0
        private void BtRowDelCus_Click(object sender, EventArgs e)
        {
            var cus = HelperCustomer.GetCustomer(cusID);

            if (cus != null)
            {
                var result = MessageBox.Show("Bu işlem geri alınamaz. Yine de silinsin mi?", "SİL?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (result == DialogResult.Yes)
                {
                    r = Helper.CRUD(cus, null, null, null, null, EntityState.Deleted, "customer");
                    if (r.isSuccess)
                    {
                        DisplayCustomers();
                        cbCustomers.DataSource = HelperCustomer.GetCustomerList();

                        lblWarningCus.Visible = true;
                        lblWarningCus.Text    = "Müşteri silindi!";
                    }
                    else
                    {
                        lblWarningCus.Visible = true;
                        lblWarningCus.Text    = r.Message;
                    }
                }
            }
        }
コード例 #6
0
 private void button3_Click(object sender, EventArgs e)
 {
     //Müşteri Silme Butonu
     if (!String.IsNullOrEmpty(textBox2.Text) && !String.IsNullOrEmpty(textBox3.Text) && !String.IsNullOrEmpty(textBox4.Text) && !String.IsNullOrEmpty(textBox5.Text) && !String.IsNullOrEmpty(maskedTextBox1.Text))
     {
         var a = MessageBox.Show(" Silmek istediğinize emin misiniz?", "Bilgilendirme", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (a == DialogResult.Yes)
         {
             Customer cm = HelperCustomer.GetByID(Convert.ToInt32(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value));
             cm.IsActive = false;
             var b = HelperCustomer.CUD(cm, System.Data.Entity.EntityState.Modified);
             if (b.Item2)
             {
                 MessageBox.Show("Silme işlemi başarılı");
             }
             else
             {
                 MessageBox.Show("Silme yapılamadı");
             }
         }
         Yenile();
     }
     else
     {
         MessageBox.Show("Lütfen seçim yapınız.");
     }
 }
コード例 #7
0
 private void button4_Click(object sender, EventArgs e)
 {
     //Müşteri Düzenleme butonu
     if (!String.IsNullOrEmpty(textBox2.Text) && !String.IsNullOrEmpty(textBox3.Text) && !String.IsNullOrEmpty(textBox4.Text) && !String.IsNullOrEmpty(textBox5.Text) && !String.IsNullOrEmpty(maskedTextBox1.Text))
     {
         Customer cm = HelperCustomer.GetByID(Convert.ToInt32(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value));
         cm.name    = textBox2.Text;
         cm.surname = textBox3.Text;
         cm.tcNo    = textBox4.Text;
         cm.gsm     = maskedTextBox1.Text;
         cm.address = textBox5.Text;
         var degistir = HelperCustomer.CUD(cm, System.Data.Entity.EntityState.Modified);
         if (degistir.Item2)
         {
             MessageBox.Show("Güncelleme başarılı.");
         }
         else
         {
             MessageBox.Show("Güncelleme yapılamadı.");
         }
         Yenile();
     }
     else
     {
         MessageBox.Show("Lütfen tüm alanları doldurunuz.");
     }
     textBox2.Clear();
     textBox3.Clear();
     textBox4.Clear();
     maskedTextBox1.Clear();
     textBox5.Clear();
 }
コード例 #8
0
        public static ResultSet CRUD(Customers cus, Cate cate, Products pro, Orders ord, Signin sign, EntityState state, string table)
        {
            ResultSet r = new ResultSet();

            try {
                switch (table)
                {
                case "customer": r = HelperCustomer.CRUD(cus, state); break;

                case "category": r = HelperCate.CRUD(cate, state); break;

                case "product": r = HelperProduct.CRUD(pro, state); break;

                case "order": r = HelperOrder.CRUD(ord, state); break;

                case "signin": r = HelperSignin.CRUD(sign, state); break;

                default: break;
                }
                if (r.Message != null)
                {
                    MessageBox.Show(r.Message, "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                return(r);
            }
            catch (Exception e) {
                r.Message = e.Message;
            }
            return(r);
        }
コード例 #9
0
 void DisplayCustomers()
 {
     dgvCustomers.Rows.Clear();
     foreach (var item in HelperCustomer.GetCustomerList())
     {
         dgvCustomers.Rows.Add(item.cFirstName, item.cLastName, item.phone, item.addressLine);
     }
 }
コード例 #10
0
        private void FormDisplayCus_Load(object sender, EventArgs e)
        {
            var list = HelperCustomer.GetCustomerModelList();

            foreach (var item in list)
            {
                dgvCustomers.Rows.Add(item.customerID, item.cFirstName, item.cLastName, item.creditLimit, item.phone, item.addressLine, item.region, item.city, item.postalCode);
            }
        }
コード例 #11
0
        private void dataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            dataGridView1.ClearSelection();
            Customer cm = HelperCustomer.GetByID(Convert.ToInt32(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value));

            textBox2.Text       = cm.name;
            textBox3.Text       = cm.surname;
            textBox4.Text       = cm.tcNo;
            maskedTextBox1.Text = cm.gsm;
            textBox5.Text       = cm.address;
        }
コード例 #12
0
        private void BtRowEditCus_Click(object sender, EventArgs e)
        {
            var cus = HelperCustomer.GetCustomer(cusID);

            if (cus != null)
            {
                gbEditCus.Enabled = true;
                tbName1.Clear(); tbSname1.Clear();
                mtbPhone1.Clear(); tbAddress1.Clear();
            }
        }
コード例 #13
0
        private void BtAddCus_Click(object sender, EventArgs e)
        {
            bool result = Helper.I(tbName.Text) || Helper.I(tbSname.Text) || Helper.I(mtbPhone.Text) || Helper.I(tbAddress.Text);

            if (result)
            {
                MessageBox.Show("Tüm alanları doldurunuz!", "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            else
            {
                var list = HelperCustomer.GetPhoneNumbers();
                if (list.Contains(mtbPhone.Text))
                {
                    MessageBox.Show("Bu telefon numarası sistemde kayıtlıdır!", "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                else
                {
                    if (mtbPhone.Text.Length == 14)
                    {
                        Customers cus = new Customers {
                            cFirstName  = tbName.Text,
                            cLastName   = tbSname.Text,
                            phone       = mtbPhone.Text,
                            addressLine = tbAddress.Text,
                            addDate     = DateTime.Now.Date
                        };

                        r = Helper.CRUD(cus, null, null, null, null, EntityState.Added, "customer");
                        if (r.isSuccess)
                        {
                            tbName.Clear(); tbSname.Clear();
                            mtbPhone.Clear(); tbAddress.Clear();

                            DisplayCustomers();
                            cbCustomers.DataSource = HelperCustomer.GetCustomerList();
                        }

                        else
                        {
                            lblWarningCus.Visible = true;
                            lblWarningCus.Text    = r.Message;
                        }
                    }

                    else
                    {
                        mtbPhone1.Clear();
                        MessageBox.Show("Girdiğiniz telefon numarası geçersizdir!", "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
        }
コード例 #14
0
        public void Yenile()
        {
            dataGridView1.Rows.Clear();
            List <Customer> customer = HelperCustomer.GetList();

            foreach (var item in customer)
            {
                if (item.IsActive == true)
                {
                    dataGridView1.Rows.Add(item.CustomerID, item.name, item.surname, item.tcNo, item.gsm, item.address);
                }
            }
        }
コード例 #15
0
        private void BtCompleteOrder_Click(object sender, EventArgs e)
        {
            bool result = Helper.I(tbQuantity.Text);

            if (result)
            {
                MessageBox.Show("Adet bilgisini giriniz!", "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                int custID = HelperCustomer.GetCustomerID(cbCustomers.GetItemText(cbCustomers.SelectedItem));
                var pro    = HelperProduct.GetProduct(sellProID);

                if (pro != null)
                {
                    if (pro.quantity < Convert.ToInt32(tbQuantity.Text))
                    {
                        if (pro.quantity == 0)
                        {
                            MessageBox.Show("Bu ürün tükenmiştir!", "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        else
                        {
                            MessageBox.Show($"Bu üründen stokta {pro.quantity} adet kaldı!", "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }

                    else
                    {
                        Orders ord = new Orders {
                            piece      = Convert.ToInt32(tbQuantity.Text),
                            orderDate  = DateTime.Now.Date,
                            productID  = sellProID,
                            customerID = custID
                        };

                        r = Helper.CRUD(null, null, null, ord, null, EntityState.Added, "order");
                        if (r.isSuccess)
                        {
                            pro.quantity -= Convert.ToInt32(tbQuantity.Text);
                            rr            = Helper.CRUD(null, null, pro, null, null, EntityState.Modified, "product");
                        }

                        tbQuantity.Clear();
                        DisplayProducts();
                        DisplayOrders();
                    }
                }
            }
        }
コード例 #16
0
        private void BtEditCus_Click(object sender, EventArgs e)
        {
            var cus = HelperCustomer.GetCustomer(cusID);

            if (cus != null)
            {
                int c = 0;
                if (!Helper.I(tbName1.Text))
                {
                    cus.cFirstName = tbName1.Text; c++;
                }
                if (!Helper.I(tbSname1.Text))
                {
                    cus.cLastName = tbSname1.Text; c++;
                }
                if (mtbPhone1.Text.Length == 14)
                {
                    cus.phone = mtbPhone1.Text; c++;
                }
                if (!Helper.I(tbAddress1.Text))
                {
                    cus.addressLine = tbAddress1.Text; c++;
                }

                r = Helper.CRUD(cus, null, null, null, null, EntityState.Modified, "customer");
                if (r.isSuccess)
                {
                    tbName1.Clear(); tbSname1.Clear();
                    mtbPhone1.Clear(); tbAddress1.Clear();

                    DisplayCustomers();
                    cbCustomers.DataSource = HelperCustomer.GetCustomerList();

                    if (c != 0)
                    {
                        lblWarningCus.Visible = true;
                        lblWarningCus.Text    = "Müşteri bilgileri düzenlendi!";
                    }
                }

                else
                {
                    lblWarningCus.Visible = true;
                    lblWarningCus.Text    = r.Message;
                }
            }

            gbEditCus.Enabled = false;
        }
コード例 #17
0
ファイル: FormUpdateCus.cs プロジェクト: tamercobanoglu/Store
        private void FormUpdateCus_Load(object sender, EventArgs e)
        {
            cBoxCity.ValueMember   = "cityID";
            cBoxCity.DisplayMember = "cityName";
            cBoxCity.DataSource    = HelperCity.GetCityList();

            tbName.Text      = HelperCustomer.GetCustomer(cusID).cFirstName;
            tbSname.Text     = HelperCustomer.GetCustomer(cusID).cLastName;
            mtbPhone.Text    = HelperCustomer.GetCustomer(cusID).phone;
            tbCredit.Text    = HelperCustomer.GetCustomer(cusID).creditLimit.ToString();
            cBoxCountry.Text = HelperCustomer.GetCustomer(cusID).country;
            cBoxCity.Text    = HelperCustomer.GetCustomer(cusID).city;
            cBoxRegion.Text  = HelperCustomer.GetCustomer(cusID).region;
            tbAdress.Text    = HelperCustomer.GetCustomer(cusID).addressLine;
        }
コード例 #18
0
ファイル: FormCustomer.cs プロジェクト: tamercobanoglu/Store
        public FormCustomer(int cusID)
        {
            FormCustomer.cusID = cusID;
            name       = HelperCustomer.GetCustomer(FormCustomer.cusID).cFirstName;
            sname      = HelperCustomer.GetCustomer(FormCustomer.cusID).cLastName;
            phone      = HelperCustomer.GetCustomer(FormCustomer.cusID).phone;
            credit     = HelperCustomer.GetCustomer(FormCustomer.cusID).creditLimit.ToString();
            adress     = HelperCustomer.GetCustomer(FormCustomer.cusID).addressLine;
            region     = HelperCustomer.GetCustomer(FormCustomer.cusID).region;
            city       = HelperCustomer.GetCustomer(FormCustomer.cusID).city;
            country    = HelperCustomer.GetCustomer(FormCustomer.cusID).country;
            postalCode = HelperCustomer.GetCustomer(FormCustomer.cusID).postalCode;

            InitializeComponent();
        }
コード例 #19
0
        public static ResultSet ResultCUD(Customers cus, EntityState state)
        {
            ResultSet r = new ResultSet();

            try {
                r = HelperCustomer.ResultCUD(cus, state);
                if (r.iconType == IconType.ok)
                {
                }
                return(r);
            }
            catch (Exception e) {
                r.Message = e.Message;
            }
            return(r);
        }
コード例 #20
0
        private void DgvCustomers_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            lblWarningCus.Visible = false;
            string name = null, sname = null, phone = null, addressLine = null;

            if (dgvCustomers.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
            {
                dgvCustomers.CurrentRow.Selected = true;
                name        = dgvCustomers.Rows[e.RowIndex].Cells["cFirstName"].FormattedValue.ToString();
                sname       = dgvCustomers.Rows[e.RowIndex].Cells["cLastName"].FormattedValue.ToString();
                phone       = dgvCustomers.Rows[e.RowIndex].Cells["phone"].FormattedValue.ToString();
                addressLine = dgvCustomers.Rows[e.RowIndex].Cells["addressLine"].FormattedValue.ToString();
            }

            cusID = HelperCustomer.GetCustomerID(name, sname, phone, addressLine);
        }
コード例 #21
0
ファイル: FormLogin.cs プロジェクト: tamercobanoglu/Store
        private void BtLoginC_Click(object sender, EventArgs e)
        {
            var       List = HelperCustomer.GetCustomerList();
            Customers cus  = HelperCustomer.Item(List, tbUserC.Text, tbPwC.Text);

            if (cus != null)
            {
                FormCustomer f2 = new FormCustomer(cus.customerID);
                f2.Show();
                this.Hide();
            }
            else
            {
                tbUserC.Clear(); tbPwC.Clear();
                lblWrongC.Visible = true;
            }
        }
コード例 #22
0
ファイル: FormPayment.cs プロジェクト: tamercobanoglu/Store
        private void BtPay_Click(object sender, EventArgs e)
        {
            var control1 = HelperOrder.GetOrder(ordID).amount - HelperPayment.GetAmountPayed(ordID) - Convert.ToDouble(tbPay.Text);
            var control2 = HelperCustomer.GetCustomer(cusID).creditLimit - Convert.ToDouble(tbPay.Text);

            if (control1 < 0 || control2 < 0)
            {
                if (control1 < 0)
                {
                    MessageBox.Show("Lütfen borcunuza eşit veya daha düşük bir miktar giriniz!");
                }
                else
                {
                    MessageBox.Show("Bakiyeniz bu işlem için yetersizdir!");
                }
            }

            else
            {
                Payment p = new Payment {
                    paymentDate = DateTime.Now.Date,
                    amountPayed = Convert.ToInt32(tbPay.Text),
                    customerID  = cusID,
                    orderID     = ordID
                };
                HelperPayment.CUD(p, EntityState.Added);

                var cus = HelperCustomer.GetCustomer(cusID);
                if (cus != null)
                {
                    cus.creditLimit -= p.amountPayed;
                    HelperCustomer.CUD(cus, EntityState.Modified);
                }

                var debt = HelperOrder.GetOrder(ordID).amount - HelperPayment.GetAmountPayed(ordID);
                dgvPayment.Rows.Add(p.paymentID, Convert.ToDateTime(p.paymentDate).ToShortDateString(), p.amountPayed);
                lblDebt.Text      = $"Bu siparişe ait kalan borç: {debt}";
                lblCredit.Visible = true;
                lblCredit.Text    = $"Kalan bakiyeniz: {cus.creditLimit}";
                if (debt == 0)
                {
                    MessageBox.Show("Bu siparişe ait borcunuzun tamamını ödediniz!");
                }
            }
        }
コード例 #23
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            lblWelcome.Text = $"Hoşgeldiniz Sn. {userName}";

            DisplayCustomers();
            DisplayCategories();
            DisplayProducts();
            DisplayOrders();

            cbCustomers.DataSource = HelperCustomer.GetCustomerList();
            ComboBoxCateSources();

            rbCustomers.Checked = true;

            // The date the first orders added to database..
            dtpFirstDate.Value   = new System.DateTime(2019, 09, 28);
            dtpFirstDate.MaxDate = DateTime.Now.Date;
            dtpLastDate.MaxDate  = DateTime.Now.Date;
        }
コード例 #24
0
ファイル: FormUpdateCus.cs プロジェクト: tamercobanoglu/Store
        private void BtUpdCusInfo_Click(object sender, EventArgs e)
        {
            bool result = I(tbName.Text) || I(tbSname.Text) || I(mtbPhone.Text) || I(tbCredit.Text) || I(tbAdress.Text);

            if (result)
            {
                MessageBox.Show("Tüm alanları doldurunuz!");
            }

            else
            {
                if (!Helper.isNumber(tbCredit.Text))
                {
                    MessageBox.Show("Kredi miktarını sayı olarak giriniz!");
                }

                else
                {
                    var c = HelperCustomer.GetCustomer(cusID);
                    if (c != null)
                    {
                        c.cFirstName  = tbName.Text;
                        c.cLastName   = tbSname.Text;
                        c.phone       = mtbPhone.Text;
                        c.creditLimit = Convert.ToDouble(tbCredit.Text);
                        c.addressLine = tbAdress.Text;
                        c.region      = cBoxRegion.Text;
                        c.city        = cBoxCity.Text;
                        c.country     = cBoxCountry.Text;
                        c.postalCode  = HelperRegion.GetPostalCode(Convert.ToInt32(cBoxRegion.SelectedValue));
                        var result2 = HelperCustomer.CUD(c, EntityState.Modified);
                        MessageBox.Show(result2 == true ? "Müşteri bilgileri güncellendi!" : "HATA!");
                    }
                }
            }
        }
コード例 #25
0
        private void BtUpdPassword_Click(object sender, EventArgs e)
        {
            bool result = I(tbOldPassWord.Text) || I(tbPassWord.Text) || I(tbPassWord1.Text);

            if (result)
            {
                MessageBox.Show("Tüm alanları doldurunuz!");
            }

            else
            {
                if (userType == 1)
                {
                    var user1 = HelperEmployee.GetEmployee(userID);
                    var user  = HelperEmployee.GetEmployeeModel(userID);
                    var user2 = HelperSignin.GetUserEmp(user.Signin.signinID);
                    if (user != null)
                    {
                        if (user1.eUserPassword == tbOldPassWord.Text && tbPassWord.Text == tbPassWord1.Text)
                        {
                            user1.eUserPassword = tbPassWord.Text;
                            user2.userPassword  = tbPassWord.Text;
                            var result1 = HelperEmployee.CUD(user1, EntityState.Modified);
                            var result2 = HelperSignin.CUD(user2, EntityState.Modified);
                            if (result1 && result2)
                            {
                                MessageBox.Show("Kayıt başarılı!");
                            }
                            else
                            {
                                MessageBox.Show("Kayıt başarısız!");
                            }
                        }
                        //MessageBox.Show("Eski şifrenizi doğru giriniz!");
                    }
                    else
                    {
                        MessageBox.Show("Kayıt başarısız!");
                    }
                }
                else if (userType == 2)
                {
                    var user1 = HelperCustomer.GetCustomer(userID);
                    var user  = HelperCustomer.GetCustomerModel(userID);
                    var user2 = HelperSignin.GetUserCus(user.Signin.signinID);
                    if (user != null)
                    {
                        if (user1.cUserPassword == tbOldPassWord.Text && tbPassWord.Text == tbPassWord1.Text)
                        {
                            user1.cUserPassword = tbPassWord.Text;
                            user2.userPassword  = tbPassWord.Text;
                            var result1 = HelperCustomer.CUD(user1, EntityState.Modified);
                            var result2 = HelperSignin.CUD(user2, EntityState.Modified);
                            if (result1 && result2)
                            {
                                MessageBox.Show("Kayıt başarılı!");
                            }
                            else
                            {
                                MessageBox.Show("Kayıt başarısız!");
                            }
                        }
                        //MessageBox.Show("Eski şifrenizi doğru giriniz!");
                    }
                    else
                    {
                        MessageBox.Show("Kayıt başarısız!");
                    }
                }
            }
        }
コード例 #26
0
        private void button2_Click(object sender, EventArgs e)
        {
            //Satışı tamamla butonu
            //toplam tutar hesapla
            int totalPrice = 0;

            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                totalPrice += Convert.ToInt32(dataGridView1.Rows[i].Cells[5].Value);
            }
            label1.Text = totalPrice.ToString();

            Cashier cashier = HelperCashier.GetByName(label3.Text);

            customer = HelperCustomer.GetByID(customer.CustomerID);
            Order or = new Order()
            {
                customerID = customer.CustomerID,
                orderDate  = DateTime.Now,
                cashierID  = cashier.cashierID,
                totalPrice = Convert.ToInt32(label1.Text),
            };
            var ekle = HelperOrder.CUD(or, System.Data.Entity.EntityState.Added);

            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                p.Add(HelperProduct.GetByID(Convert.ToInt32(dataGridView1.Rows[i].Cells[1].Value)));
            }
            int k = 0;

            foreach (var item in p)
            {
                for (; k < dataGridView1.Rows.Count;)
                {
                    item.stock -= Convert.ToInt32(dataGridView1.Rows[k].Cells[4].Value);
                    var a = HelperProduct.CUD(item, System.Data.Entity.EntityState.Modified);
                    break;
                }
                k++;
            }

            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                //fiş için yapılanlar
                List <string> temp       = new List <string>();
                string        ad         = dataGridView1.Rows[i].Cells[0].Value.ToString();
                string        id         = dataGridView1.Rows[i].Cells[1].Value.ToString();
                string        birimFiyat = dataGridView1.Rows[i].Cells[2].Value.ToString();
                string        indirim    = dataGridView1.Rows[i].Cells[3].Value.ToString();
                string        adet       = dataGridView1.Rows[i].Cells[4].Value.ToString();
                string        tutar      = dataGridView1.Rows[i].Cells[5].Value.ToString();
                temp.Add(ad);
                temp.Add(id);
                temp.Add(birimFiyat);
                temp.Add(indirim);
                temp.Add(adet);
                temp.Add(tutar);
                receipt.Add(temp);
            }
            foreach (var item in p)
            {
                ord = new OrderDetail();

                ord.orderID   = or.orderID;
                ord.productID = item.productID;
                ord.unitPrice = item.unitPrice;
                for (; j < dataGridView1.Rows.Count; j++)
                {
                    ord.count = Convert.ToInt32(dataGridView1.Rows[j].Cells[4].Value);
                    break;
                }
                j++;

                var ekle2 = HelperOrderDetail.CUD(ord, System.Data.Entity.EntityState.Added);
            }

            ReceiptForm rpf = new ReceiptForm(receipt, customer, label1.Text);

            rpf.Show();
            this.Hide();
        }
コード例 #27
0
ファイル: FormLogin.cs プロジェクト: tamercobanoglu/Store
        private void BtRegister_Click(object sender, EventArgs e)
        {
            bool result = I(tbUsername.Text) || I(tbPassword.Text) || I(tbName.Text) || I(tbSname.Text) || I(mtbPhone.Text) || I(tbCredit.Text) || I(tbAdress.Text);

            if (result)
            {
                MessageBox.Show("Tüm alanları doldurunuz!");
            }

            else
            {
                if (!Helper.isNumber(tbCredit.Text))
                {
                    MessageBox.Show("Kredi miktarını sayı olarak giriniz!");
                }

                else
                {
                    var list = HelperSignin.GetUserNameList();
                    if (list.Contains(tbUsername.Text))
                    {
                        MessageBox.Show("Bu kullanıcı adı kullanılmaktadır!");
                    }

                    else
                    {
                        Signin user = new Signin {
                            userName     = tbUsername.Text,
                            userPassword = tbPassword.Text,
                            userType     = 2
                        };

                        var resultUser = HelperSignin.CUD(user, EntityState.Added);
                        if (resultUser)
                        {
                            lblMessageR.Text = "Kayıt başarılı";
                            Helper.countUser++;
                        }
                        else
                        {
                            lblMessageR.ForeColor = Color.Blue;
                            lblMessageR.Text      = "Kayıt başarısız";
                        }

                        Customers cus = new Customers {
                            cUserName     = tbUsername.Text,
                            cUserPassword = tbPassword.Text,
                            cFirstName    = tbName.Text,
                            cLastName     = tbSname.Text,
                            phone         = mtbPhone.Text,
                            creditLimit   = Convert.ToDouble(tbCredit.Text),
                            addressLine   = tbAdress.Text,
                            region        = cBoxRegion.Text,
                            city          = cBoxCity.Text,
                            country       = cBoxCountry.Text,
                            postalCode    = HelperRegion.GetPostalCode(Convert.ToInt32(cBoxRegion.SelectedValue)),
                            signinID      = Helper.countUser
                        };

                        var resultEmp = HelperCustomer.CUD(cus, EntityState.Added);
                        if (resultEmp)
                        {
                            lblMessageR.Text = "Kayıt başarılı";
                            MessageBox.Show("Kayıt başarılı!");
                            Helper.countEmp++;
                        }
                        else
                        {
                            lblMessageR.ForeColor = Color.Red;
                            lblMessageR.Text      = "Kayıt başarısız";
                            MessageBox.Show("Kayıt başarısız!");
                        }
                    }
                }
            }
        }
コード例 #28
0
        private void BtUpdUsername_Click(object sender, EventArgs e)
        {
            bool result = I(tbOldUsername.Text) || I(tbUsername.Text) || I(tbUsername1.Text);

            if (result)
            {
                MessageBox.Show("Tüm alanları doldurunuz!");
            }

            else
            {
                if (userType == 1)
                {
                    var list = HelperSignin.GetUserNameList();
                    if (list.Contains(tbUsername.Text))
                    {
                        MessageBox.Show("Bu kullanıcı adı kullanılmaktadır!");
                    }
                    else
                    {
                        var user1 = HelperEmployee.GetEmployee(userID);
                        var user  = HelperEmployee.GetEmployeeModel(userID);
                        var user2 = HelperSignin.GetUserEmp(user.Signin.signinID);
                        if (user1 != null && user2 != null)
                        {
                            if (user1.eUserName == tbOldUsername.Text && tbUsername.Text == tbUsername1.Text)
                            {
                                user1.eUserName = tbUsername.Text;
                                user2.userName  = tbUsername.Text;
                                var result1 = HelperEmployee.CUD(user1, EntityState.Modified);
                                var result2 = HelperSignin.CUD(user2, EntityState.Modified);
                                if (result1 && result2)
                                {
                                    MessageBox.Show("Kayıt başarılı!");
                                }
                                else
                                {
                                    MessageBox.Show("Kayıt başarısız!");
                                }
                            }
                            //MessageBox.Show("Eski kullanıcı adınızı doğru giriniz!");
                        }
                        else
                        {
                            MessageBox.Show("Kayıt başarısız!");
                        }
                    }
                }
                else if (userType == 2)
                {
                    var list = HelperSignin.GetUserNameList();
                    if (list.Contains(tbUsername.Text))
                    {
                        MessageBox.Show("Bu kullanıcı adı kullanılmaktadır!");
                    }
                    else
                    {
                        var user1 = HelperCustomer.GetCustomer(userID);
                        var user  = HelperCustomer.GetCustomerModel(userID);
                        var user2 = HelperSignin.GetUserCus(user.Signin.signinID);
                        if (user1 != null && user2 != null)
                        {
                            if (user1.cUserName == tbOldUsername.Text && tbUsername.Text == tbUsername1.Text)
                            {
                                user1.cUserName = tbUsername.Text;
                                user2.userName  = tbUsername.Text;
                                var result1 = HelperCustomer.CUD(user1, EntityState.Modified);
                                var result2 = HelperSignin.CUD(user2, EntityState.Modified);
                                if (result1 && result2)
                                {
                                    MessageBox.Show("Kayıt başarılı!");
                                }
                                else
                                {
                                    MessageBox.Show("Kayıt başarısız!");
                                }
                            }
                            //MessageBox.Show("Eski kullanıcı adınızı doğru giriniz!");
                        }
                        else
                        {
                            MessageBox.Show("Kayıt başarısız!");
                        }
                    }
                }
            }
        }