Esempio n. 1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Layer.CompanyBL BL = new Layer.CompanyBL();
            BL.CompanyCode = txtCode.Text.Trim();
            BL.CompanyName = txtName.Text.Trim();
            if (BL.CompanyCode == "" || BL.CompanyName == "")
            {
                MessageBox.Show("Company Code/Name cannot be blank", "Add Company");
                return;
            }

            if (this._IsAdd)
            {
                if (BL.Exist())
                {
                    MessageBox.Show("Company Code already exist.", "Add Company");
                    return;
                }
                BL.Insert();
            }
            else
            {
                BL.UpdateByPK();
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Esempio n. 2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (lstCompany.SelectedIndex == -1)
            {
                return;
            }

            Item item = (Item)lstCompany.SelectedItem;

            DialogResult result = MessageBox.Show("Are you sure you want to delete this company :" + Environment.NewLine + item.Value + " - " + item.Text, "Delete Comapny", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);

            if (result == DialogResult.Yes)
            {
                Layer.CompanyBL BL = new Layer.CompanyBL();
                BL.CompanyCode = item.Value;
                BL.DeleteByPK();
                LoadCompany();
            }
        }