Esempio n. 1
0
        public int getIdMax()
        {
            int    maxId             = 1;
            string currentdatasource = DAL.DAL.datasource;
            string currentuserid     = DAL.DAL.userid;
            string currentpass       = DAL.DAL.pass;
            string currentcatalog    = DAL.DAL.catalog;

            DataTable sites = new BLL.DICTON_BLL().selectall();

            foreach (DataRow row in sites.Rows)
            {
                DAL.DAL.datasource = row["IPADDRESS"].ToString();
                DAL.DAL.userid     = row["ACCOUNT"].ToString();
                DAL.DAL.pass       = row["PASS"].ToString();
                DAL.DAL.catalog    = row["NAMEDATABASE"].ToString();

                string query = "select max(id) from NHANVIEN";
                int    id    = new DAL.DAL().excutescalar(query, null, CommandType.Text);
                if (maxId < id)
                {
                    maxId = id + 1;
                }
            }

            DAL.DAL.datasource = currentdatasource;
            DAL.DAL.userid     = currentuserid;
            DAL.DAL.pass       = currentpass;
            DAL.DAL.catalog    = currentcatalog;
            return(maxId);
        }
Esempio n. 2
0
        private void button3_Click(object sender, EventArgs e)
        {
            List <int> tacgiasach  = new List <int>();
            List <int> theloaisach = new List <int>();

            //dua id cac tac gia da chon vao danh sach
            foreach (DataGridViewRow row in dgtacgia.Rows)
            {
                DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)row.Cells[3];
                if (Convert.ToBoolean(chk.Value) == true)
                {
                    tacgiasach.Add(int.Parse(row.Cells[0].Value.ToString()));
                }
            }
            //dua id the loai vao danh sach
            foreach (DataGridViewRow row in dgtheloai.Rows)
            {
                DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)row.Cells[2];
                if (Convert.ToBoolean(chk.Value) == true)
                {
                    theloaisach.Add(int.Parse(row.Cells[0].Value.ToString()));
                }
            }
            //them thông tin sách vào database
            DataTable sites = new BLL.DICTON_BLL().selectall();

            foreach (DataRow row in sites.Rows)
            {
                DAL.DAL.datasource = row["IPADDRESS"].ToString();
                DAL.DAL.userid     = row["ACCOUNT"].ToString();
                DAL.DAL.pass       = row["PASS"].ToString();
                DAL.DAL.catalog    = row["NAMEDATABASE"].ToString();
                new BLL.Sach_BLL().insert(txtname.Text, int.Parse(cbnxb.SelectedValue.ToString()), float.Parse(txtdongia.Text));
            }



            //Lay id sach vừa thêm
            int idsach = new BLL.Sach_BLL().getidmax();

            foreach (DataRow row in sites.Rows)
            {
                DAL.DAL.datasource = row["IPADDRESS"].ToString();
                DAL.DAL.userid     = row["ACCOUNT"].ToString();
                DAL.DAL.pass       = row["PASS"].ToString();
                DAL.DAL.catalog    = row["NAMEDATABASE"].ToString();
                //them  các tác giả của sách
                new BLL.Sach_Tacgia().insert(tacgiasach, idsach);
                //them các thể loại của sách
                new BLL.Sach_Theloai().insert(theloaisach, idsach);
            }

            MessageBox.Show("Đã thêm thành công");
            Chitiet_Sach_Load(sender, e);

            DAL.DAL.datasource = currentdatasource;
            DAL.DAL.userid     = currentuserid;
            DAL.DAL.pass       = currentpass;
            DAL.DAL.catalog    = currentcatalog;
        }
Esempio n. 3
0
        private void button3_Click(object sender, EventArgs e)
        {
            DataTable sites = new BLL.DICTON_BLL().selectall();

            foreach (DataRow drow in sites.Rows)
            {
                DAL.DAL.datasource = drow["IPADDRESS"].ToString();
                DAL.DAL.userid     = drow["ACCOUNT"].ToString();
                DAL.DAL.pass       = drow["PASS"].ToString();
                DAL.DAL.catalog    = drow["NAMEDATABASE"].ToString();
                //xóa thông tin tác giả cũ
                new BLL.Sach_Tacgia().dell(QL_Sach.idsachchon);
                //xóa thông tin thể loại đã chon
                new BLL.Sach_Theloai().delete(QL_Sach.idsachchon);
                //them lại thông tin tác giả
                List <int> tacgiasach = new List <int>();
                //dua id cac tac gia da chon vao danh sach
                foreach (DataGridViewRow row in dgtacgia.Rows)
                {
                    DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)row.Cells[3];
                    if (Convert.ToBoolean(chk.Value) == true)
                    {
                        tacgiasach.Add(int.Parse(row.Cells[0].Value.ToString()));
                    }
                }
                //thêm lại thông tin thể loại
                List <int> theloaisach = new List <int>();
                //dua id the loai vao danh sach
                foreach (DataGridViewRow row in dgtheloai.Rows)
                {
                    DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)row.Cells[2];
                    if (Convert.ToBoolean(chk.Value) == true)
                    {
                        theloaisach.Add(int.Parse(row.Cells[0].Value.ToString()));
                    }
                }
                //them  các tác giả của sách
                new BLL.Sach_Tacgia().insert(tacgiasach, QL_Sach.idsachchon);
                //them các thể loại của sách
                new BLL.Sach_Theloai().insert(theloaisach, QL_Sach.idsachchon);
                //update lại thông tin sách
                new BLL.Sach_BLL().update(QL_Sach.idsachchon, txtname.Text, int.Parse(cbnxb.SelectedValue.ToString()), float.Parse(txtdongia.Text));
            }

            DAL.DAL.datasource = currentdatasource;
            DAL.DAL.userid     = currentuserid;
            DAL.DAL.pass       = currentpass;
            DAL.DAL.catalog    = currentcatalog;
        }
Esempio n. 4
0
        private void btnupdate_Click(object sender, EventArgs e)
        {
            DataTable sites = new BLL.DICTON_BLL().selectall();

            foreach (DataRow row in sites.Rows)
            {
                DAL.DAL.datasource = row["IPADDRESS"].ToString();
                DAL.DAL.userid     = row["ACCOUNT"].ToString();
                DAL.DAL.pass       = row["PASS"].ToString();
                DAL.DAL.catalog    = row["NAMEDATABASE"].ToString();
                new BLL.TheLoai_BLL().update(int.Parse(txtid.Text), txtname.Text);
                load();
            }

            DAL.DAL.datasource = currentdatasource;
            DAL.DAL.userid     = currentuserid;
            DAL.DAL.pass       = currentpass;
            DAL.DAL.catalog    = currentcatalog;
        }
Esempio n. 5
0
        private void btninsert_Click(object sender, EventArgs e)
        {
            DataTable sites = new BLL.DICTON_BLL().selectall();

            foreach (DataRow row in sites.Rows)
            {
                DAL.DAL.datasource = row["IPADDRESS"].ToString();
                DAL.DAL.userid     = row["ACCOUNT"].ToString();
                DAL.DAL.pass       = row["PASS"].ToString();
                DAL.DAL.catalog    = row["NAMEDATABASE"].ToString();
                new BLL.TacGia_BLL().insert(txtten.Text, rtxtinfor.Text);
                TacGia_Load(sender, e);
            }

            DAL.DAL.datasource = currentdatasource;
            DAL.DAL.userid     = currentuserid;
            DAL.DAL.pass       = currentpass;
            DAL.DAL.catalog    = currentcatalog;
        }