Пример #1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (button == "Add")
            {
                client = new ObjProductType(txtTypeCode.Text, txtTypeName.Text);
                server = new LogicProductType();
                DataSet dataset_Check = server.getDataBase(client);
                if (dataset_Check.Tables[0].Rows.Count > 0)
                {
                    MessageBox.Show("Sản phẩm này đã tồn tại trong danh sách", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    server.setDataBase(client, button);
                    dataset_Check           = server.getDataBase("LoaiSP");
                    dataGridView.DataSource = dataset_Check.Tables[0];
                }

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

            if (button == "Edit")
            {
                client_edited = new ObjProductType(txtTypeCode.Text, txtTypeName.Text);
                server        = new LogicProductType();
                server.editDataBase(client, client_edited);
                DataSet dataset_edit = server.getDataBase("LoaiSP");
                dataGridView.DataSource = dataset_edit.Tables[0];
                enable_button(0);
                button = "";
                return;
            }
        }
Пример #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 ObjProductType(txtTypeCode.Text, txtTypeName.Text);
                server = new LogicProductType();
                server.setDataBase(client, button);
                DataSet dataset_AfterDeleting = server.getDataBase("LoaiSP");
                dataGridView.DataSource = dataset_AfterDeleting.Tables[0];
            }
        }
Пример #3
0
        private void frmProductType_Load(object sender, EventArgs e)
        {
            enable_button(0);

            server = new LogicProductType();
            DataSet dataset = server.getDataBase("LoaiSP");

            dataGridView.DataSource            = dataset.Tables[0];
            dataGridView.Columns[0].Width      = 372;
            dataGridView.Columns[1].Width      = 375;
            dataGridView.Columns[0].HeaderText = "Mã Loại";
            dataGridView.Columns[1].HeaderText = "Tên Loại";
            dataGridView.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dataGridView.Columns[0].DefaultCellStyle.Alignment   = DataGridViewContentAlignment.MiddleCenter;
            dataGridView.Columns[1].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;
        }