Beispiel #1
0
        private void Insert(object sender, EventArgs e)
        {
            try
            {
                docGia d = new docGia();
                d.maDG   = ReaderID.Text;
                d.tenDG  = ReaderName.Text;
                d.diaChi = Address.Text;
                if (CardID.SelectedValue == null)
                {
                    string temp = new CardForm().addCard();
                    if (temp == null)
                    {
                        throw new Exception("Add card unsuccessful");
                    }
                    else
                    {
                        d.maThe = temp;
                    }
                }
                else
                {
                    d.maThe = CardID.SelectedValue.ToString();
                }

                d.ghiChu = Note.Text;
                if (d.isNull())
                {
                    toolTip1.ToolTipTitle = "Warning";
                    toolTip1.Show("Please enter full information", windowsUIButtonPanel1, windowsUIButtonPanel1.Location, 5000);
                    return;
                }
                else
                {
                    if (docGia.them(d))
                    {
                        the.capNhatTT(d.maThe, "Đang sử dụng");
                        ReaderForm_Load(sender, e);
                        resetText();
                    }
                    else
                    {
                        if (docGia.sua(d))
                        {
                            ReaderForm_Load(sender, e);
                            resetText();
                        }
                        else
                        {
                            throw new Exception("Can't insert or update!!");
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Oops", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public bool sua(docGia d)
 {
     if (string.IsNullOrEmpty(d.maDG))
     {
         return(false);
     }
     dG.update(d);
     return(true);
 }
Beispiel #3
0
        public bool insert(docGia d)
        {
            if (dataTable("select * from DOCGIA where MaDG ='" + d.maDG + "'").Rows.Count > 0)
            {
                return(false);
            }
            string sqlCommand = string.Format("insert into DOCGIA values ('{0}',N'{1}',N'{2}','{3}',N'{4}')", d.maDG, d.tenDG, d.diaChi, d.maThe, d.ghiChu);

            Excute(sqlCommand);
            return(true);
        }
 public bool them(docGia d)
 {
     return(dG.insert(d));
 }
Beispiel #5
0
        public void update(docGia d)
        {
            string sqlCommand = string.Format("update DOCGIA set TenDG = N'{0}',DiaChi = N'{1}' ,GhiChu = N'{2}' where MaDG = '{3}'", d.tenDG, d.diaChi, d.ghiChu, d.maDG);

            Excute(sqlCommand);
        }