Пример #1
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            ChiTietPhieuNhapSach ctpn = (ChiTietPhieuNhapSach)comboBoxMaSach.SelectedItem;
            int soluongnhap           = int.Parse(textBoxSoLuong.Text);

            if (soluongnhap >= soLuongNhapToiThieu && ctpn.SoLuongTon < soLuongTonDeNhapToiDa)
            {
                ctpn.SoLuong    = soluongnhap;
                ctpn.DonGiaNhap = decimal.Parse(textBoxDonGiaNhap.Text);
                list.Add(ctpn);
                comboBoxList.Remove(ctpn);
                comboBoxMaSach.SelectedIndex = -1;
                ClearAllTextBox();
                decimal sum = 0;
                foreach (var x in list)
                {
                    sum += x.ThanhTien;
                }
                textBoxTongTien.Text = sum.ToString();
            }
            else
            {
                MessageBox.Show("Không thỏa điều kiện để nhập sách");
            }
        }
Пример #2
0
        protected void InitComboBoxList()
        {
            List <long> maSachList = new List <long>();
            string      query      = "SELECT MaSach FROM SACH";

            using (SqlCommand cmd = new SqlCommand(query, QuanLyNhaSach.MainWindow.sqlConnection))
            {
                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            maSachList.Add((long)reader[0]);
                        }
                    }
                }
            }
            if (maSachList.Count > 0)
            {
                foreach (var x in maSachList)
                {
                    using (SqlCommand cmd = new SqlCommand("EXEC spSupportLapPhieuNhapSach " + x, QuanLyNhaSach.MainWindow.sqlConnection))
                    {
                        using (SqlDataReader reader = cmd.ExecuteReader())
                        {
                            if (reader.HasRows)
                            {
                                ChiTietPhieuNhapSach ctpn = new ChiTietPhieuNhapSach();
                                bool readFlag             = false;
                                while (reader.Read())
                                {
                                    if (readFlag)
                                    {
                                        ctpn.TacGia += "; " + (string)reader[2];
                                    }
                                    else
                                    {
                                        ctpn.MaSach     = x;
                                        ctpn.TenSach    = (string)reader[0];
                                        ctpn.TheLoai    = (string)reader[1];
                                        ctpn.TacGia     = (string)reader[2];
                                        ctpn.SoLuongTon = (int)reader[3];
                                        readFlag        = true;
                                    }
                                }
                                comboBoxList.Add(ctpn);
                            }
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Không có dữ liệu sách");
            }
        }
Пример #3
0
 private void comboBoxMaSach_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (comboBoxMaSach.SelectedIndex >= 0)
     {
         ChiTietPhieuNhapSach ctpn = (ChiTietPhieuNhapSach)comboBoxMaSach.SelectedItem;
         textBoxTenSach.Text    = ctpn.TenSach;
         textBoxTheLoai.Text    = ctpn.TheLoai;
         textBoxTacGia.Text     = ctpn.TacGia;
         textBoxSoLuongTon.Text = ctpn.SoLuongTon.ToString();
         textBoxSoLuong.Text    = textBoxDonGiaNhap.Text = "0";
     }
 }
Пример #4
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ChiTietPhieuNhapSach ctpn = (ChiTietPhieuNhapSach)dataGrid.SelectedItem;

            comboBoxList.Add(ctpn);
            list.Remove(ctpn);
            decimal sum = 0;

            foreach (var x in list)
            {
                sum += x.ThanhTien;
            }
            textBoxTongTien.Text = sum.ToString();
        }