Esempio n. 1
0
        public void Update()
        {
            DTO.Types c = new DTO.Types();
            c.type_id     = int.Parse(txtId.Text);
            c.type_name   = txtName.Text;
            c.cat_id      = int.Parse(cbxCat.SelectedValue.ToString());
            c.status      = chkStatus.Checked == true ? true : false;
            c.date_create = DateTime.Now;
            int result = TypeDAO.Instance.Update_Types(c);

            if (result <= 0)
            {
                btnSave.Visible = false;
            }
            else
            {
                MessageBox.Show("Update success");
                load();
            }
        }
Esempio n. 2
0
 public void AddNew()
 {
     if (txtName.Text == "")
     {
         txtError.Text = "* Vui lòng không để trống";
     }
     else
     {
         DTO.Types c = new DTO.Types();
         c.type_name   = txtName.Text;
         c.cat_id      = int.Parse(cbxCat.SelectedValue.ToString());
         c.status      = chkStatus.Checked == true ? true : false;
         c.date_create = DateTime.Now;
         int result = TypeDAO.Instance.Insert_Types(c);
         if (result > 0)
         {
             MessageBox.Show("Insert Success");
             load();
             txtName.Text = "";
             edit         = false;
             btnSave.Text = "Lưu";
         }
     }
 }