Exemplo n.º 1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (button == "Add")
            {
                client = new ObjSupplier(txtSupplierCode.Text, txtName.Text, txtNote.Text);
                server = new LogicSupplier();
                DataSet dataset_Check = server.getDataBase(client);
                if (dataset_Check.Tables[0].Rows.Count > 0)
                {
                    MessageBox.Show("Nhà cung cấp này đã tồn tại trong danh sách", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    server.setDataBase(client, button);
                    dataset_Check           = server.getDataBase("NguonCungCap");
                    dataGridView.DataSource = dataset_Check.Tables[0];
                }

                enable_button(0);
                button = "";
                return;
            }

            if (button == "Edit")
            {
                client_edited = new ObjSupplier(txtSupplierCode.Text, txtName.Text, txtNote.Text);
                server        = new LogicSupplier();
                server.editDataBase(client, client_edited);
                DataSet dataset_edit = server.getDataBase("NguonCungCap");
                dataGridView.DataSource = dataset_edit.Tables[0];
                enable_button(0);
                button = "";
                return;
            }
        }
Exemplo n.º 2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult res = MessageBox.Show("Bạn có chắc muốn xóa loại sản phẩm này?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            button = "Delete";
            if (res == DialogResult.Yes)
            {
                client = new ObjSupplier(txtSupplierCode.Text, txtName.Text, txtNote.Text);
                server = new LogicSupplier();
                server.setDataBase(client, button);
                DataSet dataset_AfterDeleting = server.getDataBase("NguonCungCap");
                dataGridView.DataSource = dataset_AfterDeleting.Tables[0];
            }
        }
Exemplo n.º 3
0
        private void frmSupplier_Load(object sender, EventArgs e)
        {
            enable_button(0);

            server = new LogicSupplier();
            DataSet dataset = server.getDataBase("NguonCungCap");

            dataGridView.DataSource            = dataset.Tables[0];
            dataGridView.Columns[0].HeaderText = "Mã nguồn";
            dataGridView.Columns[1].HeaderText = "Tên nguồn";
            dataGridView.Columns[2].HeaderText = "Ghi chú";
            dataGridView.Columns[0].Width      = 190;
            dataGridView.Columns[1].Width      = 190;
            dataGridView.Columns[2].Width      = 190;
            dataGridView.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dataGridView.Columns[0].DefaultCellStyle.Alignment   = DataGridViewContentAlignment.MiddleCenter;
            dataGridView.Columns[1].DefaultCellStyle.Alignment   = DataGridViewContentAlignment.MiddleCenter;
            dataGridView.Columns[2].DefaultCellStyle.Alignment   = DataGridViewContentAlignment.MiddleCenter;
            dataGridView.EnableHeadersVisualStyles                 = false;
            dataGridView.RowHeadersDefaultCellStyle.BackColor      = Color.SkyBlue;
            dataGridView.ColumnHeadersDefaultCellStyle.BackColor   = Color.SkyBlue;
            dataGridView.RowsDefaultCellStyle.BackColor            = Color.WhiteSmoke;
            dataGridView.AlternatingRowsDefaultCellStyle.BackColor = Color.LightCyan;
        }