Exemplo n.º 1
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            NhaXuatBanObj khObj = new NhaXuatBanObj();

            addData(khObj);
            if (flagLuu == 0)
            {
                if (nxbCtr.AddData(khObj))
                {
                    MessageBox.Show("Thêm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Thêm không thành công!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                if (nxbCtr.UpdData(khObj))
                {
                    MessageBox.Show("Sửa thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Sửa không thành công!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            frmNhaXuatBan_Load(sender, e);
        }
Exemplo n.º 2
0
 private void addData(NhaXuatBanObj nxb)
 {
     nxb.MaNhaXuatBan  = txtMaNXB.Text.Trim();
     nxb.TenNhaXuatBan = txtTenNXB.Text.Trim();
     nxb.DiaChi        = txtDiaChi.Text.Trim();
     nxb.Email         = txtEmail.Text.Trim();
     nxb.SoDT          = txtSoDT.Text.Trim();
 }
Exemplo n.º 3
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            NhaXuatBanObj khObj = new NhaXuatBanObj();

            addData(khObj);
            if (txtTenNXB.Text == "" || txtEmail.Text == "" || txtDiaChi.Text == "" || txtSoDT.Text == "" || txtMaNXB.Text == "")
            {
                MessageBox.Show("Chưa nhập đầy đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            else
            {
                SqlConnection  con = new SqlConnection("Data Source=DESKTOP-D617688;Initial Catalog=PhanMemBanSach;Integrated Security=True");
                SqlDataAdapter sda = new SqlDataAdapter("Select * from  NhaXuatBan where MaNXB='" + txtEmail.Text + "'", con);
                DataSet        ds  = new DataSet();
                sda.Fill(ds);
                int i = ds.Tables[0].Rows.Count;
                if (i > 0)
                {
                    MessageBox.Show("Email " + txtEmail.Text + "đã tồn tại!");
                    ds.Clear();
                }
                else
                {
                    if (flagLuu == 0)
                    {
                        if (nxbCtr.AddData(khObj))
                        {
                            MessageBox.Show("Thêm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Thêm không thành công!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        if (nxbCtr.UpdData(khObj))
                        {
                            MessageBox.Show("Sửa thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Sửa không thành công!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }

            frmNhaXuatBan_Load(sender, e);
        }
Exemplo n.º 4
0
 public bool UpdData(NhaXuatBanObj nxbObj)
 {
     cmd.CommandText = "Update NhaXuatBan set TenNXB =  N'" + nxbObj.TenNhaXuatBan + "', DiaChi = N'" + nxbObj.DiaChi + "', Email = N'" + nxbObj.Email + "',SoDT = '" + nxbObj.SoDT + "' Where MaNXB = '" + nxbObj.MaNhaXuatBan + "'";
     cmd.CommandType = CommandType.Text;
     cmd.Connection  = con.Connection;
     try
     {
         con.OpenConn();
         cmd.ExecuteNonQuery();
         return(true);
     }
     catch (Exception ex)
     {
         string mex = ex.Message;
         cmd.Dispose();
         con.CloseConn();
     }
     return(false);
 }
Exemplo n.º 5
0
 public bool AddData(NhaXuatBanObj nxbObj)
 {
     cmd.CommandText = "Insert into NhaXuatBan values ('" + nxbObj.MaNhaXuatBan + "',N'" + nxbObj.TenNhaXuatBan + "',N'" + nxbObj.DiaChi + "',N'" + nxbObj.Email + "','" + nxbObj.SoDT + "')";
     cmd.CommandType = CommandType.Text;
     cmd.Connection  = con.Connection;
     try
     {
         con.OpenConn();
         cmd.ExecuteNonQuery();
         return(true);
     }
     catch (Exception ex)
     {
         string mex = ex.Message;
         cmd.Dispose();
         con.CloseConn();
     }
     return(false);
 }
 public bool UpdData(NhaXuatBanObj nxbObj)
 {
     return(nxbMod.UpdData(nxbObj));
 }