Beispiel #1
0
 public static int Delete_Viet(Viet a)
 {
     SqlParameter[] para = new SqlParameter[]
     {
         new SqlParameter("@mats", a.MaTS),
         new SqlParameter("@matg", a.MaTG),
     };
     return(DataProvider.ExecuteNonQuery("Delete_V", para));
 }
Beispiel #2
0
 public static int Insert_Viet(Viet a)
 {
     SqlParameter[] para = new SqlParameter[]
     {
         new SqlParameter("@mats", a.MaTS),
         new SqlParameter("@matg", a.MaTG),
         new SqlParameter("@sotrang", a.SoTrang),
     };
     return(DataProvider.ExecuteNonQuery("Insert_V", para));
 }
        private void btn_save_Click(object sender, EventArgs e)
        {
            TuaSach ts2 = new TuaSach();

            ts2.MaTS    = txt_MaTS.Text; ts2.TenTS = txt_TenTS.Text;
            ts2.NamXB   = int.Parse(txt_XB.Text); ts2.TheLoai = txt_TL.Text;
            ts2.MaNXB   = cmb_NXB.SelectedValue.ToString(); ts2.MaKe = cmb_KS.Text;
            ts2.SoLuong = txt_SL.Text;
            Viet v = new Viet();

            v.MaTS    = txt_MaTS.Text;
            v.MaTG    = cmb_TG.SelectedValue.ToString();
            v.SoTrang = int.Parse(txt_ST.Text);

            if (insert)
            {
                if (MessageBox.Show("Bạn muốn lưu dữ liệu được thêm mới không???", "SAVE", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    DataTable test = new DataTable(); //  kiểm tra mã đã  có trong bảng chưa???

                    string sql = "select *from TuaSach where MaTS= '" + txt_MaTS.Text + "'";
                    test = DataProvider.GetData(sql);
                    int i = test.Rows.Count;
                    if (i > 0)
                    {
                        MessageBox.Show("Đã tồn tại " + txt_MaTS.Text, "Error !!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        BUS.Insert_TS(ts2);
                        BUS.Insert_Viet(v);
                        MessageBox.Show("Đã lưu thành công");
                        gridControl2.DataSource = BUS.Select_TS();
                    }
                }
            }
            if (update)
            {
                if (MessageBox.Show("Bạn muốn lưu thay đổi không???", "SAVE", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    gridControl2.DataSource = BUS.Update_TS(ts2);
                    gridControl2.DataSource = BUS.Update_Viet(v);
                    MessageBox.Show("Đã lưu thành công");
                    gridControl2.DataSource = BUS.Select_TS();
                }
            }
            txt_MaTS.Enabled   = false; txt_SL.Enabled = false;
            btn_cancel.Enabled = false;
            btn_save.Enabled   = false;
            btn_delete.Enabled = true;
            btn_update.Enabled = true;
            btn_insert.Enabled = true;
        }
Beispiel #4
0
 public static int sua_V(Viet a)
 {
     return(DAO.sua_V(a));
 }
Beispiel #5
0
 public static int them_V(Viet a)
 {
     return(DAO.them_V(a));
 }
Beispiel #6
0
 public static int Delete_Viet(Viet a)
 {
     return(DAO.Delete_Viet(a));
 }
Beispiel #7
0
 public static int Update_Viet(Viet a)
 {
     return(DAO.Update_Viet(a));
 }
Beispiel #8
0
 public static int Insert_Viet(Viet a)
 {
     return(DAO.Insert_Viet(a));
 }