Example #1
0
        public static void SuaNCU(DTO_NCU ncu)
        {
            SqlCommand cmd = new SqlCommand("sp_suaNCU", DataProvider.con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@mancu", SqlDbType.VarChar, 50);
            cmd.Parameters.Add("@tenncu", SqlDbType.NVarChar, 100);
            cmd.Parameters.Add("@diachi", SqlDbType.NVarChar, 500);
            cmd.Parameters.Add("@sdt", SqlDbType.VarChar, 50);
            cmd.Parameters.Add("@quymoncu", SqlDbType.NVarChar, 50);

            //Gan gia tri
            cmd.Parameters["@mancu"].Value    = ncu.Mancu;
            cmd.Parameters["@tenncu"].Value   = ncu.Tenncu;
            cmd.Parameters["@diachi"].Value   = ncu.Diachi;
            cmd.Parameters["@sdt"].Value      = ncu.Sdt;
            cmd.Parameters["@quymoncu"].Value = ncu.Quymoncu;

            if (DataProvider.con.State == ConnectionState.Closed)
            {
                DataProvider.con.Open();
            }
            cmd.ExecuteNonQuery();
            DataProvider.disconnect();
        }
Example #2
0
        private void btntimkiem_Click(object sender, EventArgs e)
        {
            if (txtTenNCU.Text == string.Empty && txtSĐT.Text == string.Empty && cbQuymoNCU.Text == string.Empty)
            {
                MessageBox.Show("Bạn phải nhập điều kiện tìm kiếm!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            DTO_NCU ncu = new DTO_NCU();

            ncu.Tenncu   = txtTenNCU.Text;
            ncu.Sdt      = txtSĐT.Text;
            ncu.Quymoncu = cbQuymoNCU.Text;
            DataTable dt = BUS_NCU.timkiemNCU(ncu.Tenncu, ncu.Sdt, ncu.Quymoncu);

            DGVNCU.DataSource = dt;

            if (dt.Rows.Count == 0)
            {
                lblkqtkncu.Text = "Không có nhà cung ứng nào thoả mãn điều kiện tìm kiếm!";
            }
            else
            {
                lblkqtkncu.Text = "Có " + dt.Rows.Count + " nhà cung ứng nào thoả mãn điều kiện tìm kiếm!";
            }
            DANGNHAP.thaotac += "Tìm kiếm, ";
        }
Example #3
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            if (ncu.Rows.Count == 0)
            {
                MessageBox.Show("Không còn dữ liệu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (txtMaNCU.Text == "Mã nhà cung ứng sẽ tự động thêm!")
            {
                MessageBox.Show("Bạn chưa chọn bản ghi nào", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (txtTenNCU.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập tên nhà cung ứng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtTenNCU.Focus();
                return;
            }
            if (txtDiaChi.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập địa chỉ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtDiaChi.Focus();
                return;
            }
            if (txtSĐT.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập điện thoại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtSĐT.Focus();
                return;
            }
            if (cbQuymoNCU.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập quy mô NCƯ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                cbQuymoNCU.Focus();
                return;
            }

            DTO_NCU NCU = new DTO_NCU(txtMaNCU.Text, txtTenNCU.Text, txtDiaChi.Text, txtSĐT.Text, cbQuymoNCU.Text, txtconnoncu.Text);

            BUS_NCU.suaNCU(NCU);
            LoadDataGridView();
            ResetValues();

            DANGNHAP.thaotac += "Sửa, ";
        }
Example #4
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (txtTenNCU.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập tên nhà cung ứng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtTenNCU.Focus();
                return;
            }
            if (txtDiaChi.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập địa chỉ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtDiaChi.Focus();
                return;
            }
            if (txtSĐT.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập điện thoại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtSĐT.Focus();
                return;
            }
            if (cbQuymoNCU.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập quy mô NCƯ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                cbQuymoNCU.Focus();
                return;
            }

            //tạo mã ngẫu nhiên
            int    value;
            bool   kt   = false;
            Random rand = new Random();

            value = rand.Next(100000000, 999999999);
            string  mancu = "NCU" + value;
            DataRow dr;

            if (BUS_NCU.hienthiNCU().Rows.Count > 0)
            {
                while (kt == false)
                {
                    for (int i = 0; i < BUS_NCU.hienthiNCU().Rows.Count; ++i)
                    {
                        dr = BUS_NCU.hienthiNCU().Rows[i];
                        if (mancu == dr["IdNCU"].ToString())
                        {
                            kt    = false;
                            value = rand.Next(100000000, 999999999);
                            mancu = "NCU" + value;
                            break;
                        }
                        else
                        {
                            kt = true;
                        }
                    }
                }
            }

            //Kiểm tra đã tồn tại mã nhà cung ứng chưa
            if (!BUS_NCU.ktncutrung(mancu))
            {
                MessageBox.Show("Mã nhà cung ứng này đã tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtMaNCU.Focus();
                return;
            }

            //Chèn thêm
            DTO_NCU ncu = new DTO_NCU(mancu, txtTenNCU.Text, txtDiaChi.Text, txtSĐT.Text, cbQuymoNCU.Text, txtconnoncu.Text);

            BUS_NCU.themNCU(ncu);

            LoadDataGridView();
            ResetValues();

            //Cập nhật lại mã nhà cung ứng trên combobx mã nhà cung ứng trên form sản phẩm.
            CapnhatCB_NCU();

            DANGNHAP.thaotac += "Thêm, ";
        }
Example #5
0
 public static void suaNCU(DTO_NCU ncu)
 {
     DAO_NCU.SuaNCU(ncu);
 }
Example #6
0
 public static void themNCU(DTO_NCU ncu)
 {
     DAO_NCU.Themncu(ncu);
 }