示例#1
0
        private void btn_s_s_Click(object sender, EventArgs e)
        {
            sach_DTO s = new sach_DTO();

            s.mads      = cbb_ds.SelectedValue.ToString();
            s.mas       = txb_s_ms.Text;
            s.tinhtrang = txb_s_tt.Text;
            int check = s_bus.sua(s);

            try
            {
                if (check == 0)
                {
                    MessageBox.Show("Mời nhập đầy đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                if (check == 2)
                {
                    MessageBox.Show("Mã đầu sách không tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                if (check == -1)
                {
                    MessageBox.Show("Mã sách không tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                if (check == 1)
                {
                    Urc_sach_Load(sender, e);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            txb_s_ms.Text = "";
            txb_s_tt.Text = "";
        }
示例#2
0
        private void btn_s_x_Click(object sender, EventArgs e)
        {
            sach_DTO s = new sach_DTO();

            s.mas = txb_s_ms.Text;
            int check = s_bus.xoa(s);

            try
            {
                if (check == 0)
                {
                    MessageBox.Show("Mời nhập mã sách muốn xóa", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                if (check == -1)
                {
                    MessageBox.Show("Mã sách không tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                if (check == 1)
                {
                    Urc_sach_Load(sender, e);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#3
0
        public bool checkDS(sach_DTO s)
        {
            string sql = "select * from Dau_Sach where MaDS = '" + s.mads + "'";

            if (getdata(sql).Rows.Count == 0)
            {
                return(false);
            }
            return(true);
        }
示例#4
0
        public bool xoasach(sach_DTO s)
        {
            if (getdata("select * from Sach where MaSach=N'" + s.mas + "'").Rows.Count == 0)
            {
                return(false);
            }
            string sql = string.Format("dbo.delete_sach N'{0}'", s.mas);

            Execute(sql);
            return(true);
        }
示例#5
0
        public bool suasach(sach_DTO s)
        {
            if (getdata("select * from Sach where MaSach=N'" + s.mas + "'").Rows.Count == 0)
            {
                return(false);
            }
            string sql = string.Format("dbo.update_sach N'{0}',N'{1}',N'{2}'", s.mas, s.mads, s.tinhtrang);

            Execute(sql);
            return(true);
        }
示例#6
0
 public int xoa(sach_DTO s)
 {
     if (string.IsNullOrEmpty(s.mas))
     {
         return(0);
     }
     if (s_dal.xoasach(s) == false)
     {
         return(-1);
     }
     return(1);
 }
示例#7
0
 public int sua(sach_DTO s)
 {
     if (string.IsNullOrEmpty(s.mads) || string.IsNullOrEmpty(s.mas) || string.IsNullOrEmpty(s.tinhtrang))
     {
         return(0);
     }
     if (s_dal.checkDS(s) == false)
     {
         return(2);
     }
     if (s_dal.suasach(s) == false)
     {
         return(-1);
     }
     return(1);
 }