public void Insert(int MaBn,string CanhBao,string NguoiTao,DateTime NgayTao,string NguoiSua,DateTime? NgaySua)
        {
            DmucCanhbao item = new DmucCanhbao();

            item.MaBn = MaBn;

            item.CanhBao = CanhBao;

            item.NguoiTao = NguoiTao;

            item.NgayTao = NgayTao;

            item.NguoiSua = NguoiSua;

            item.NgaySua = NgaySua;

            item.Save(UserName);
        }
 private void cmdsave_Click(object sender, EventArgs e)
 {
     try
     {
         if (Utility.Int32Dbnull(txtPatient_ID.Text, -1) <= 0) return;
         var lst =
             new Select().From(DmucCanhbao.Schema)
                 .Where(DmucCanhbao.MaBnColumn)
                 .IsEqualTo(txtPatient_ID.Text)
                 .ExecuteAsCollection<DmucCanhbaoCollection>();
         if (lst.Count > 0) //Update or Delete
         {
             if (txtCanhbao.Text.TrimStart().TrimEnd() == "")
             {
                 new Delete().From(DmucCanhbao.Schema)
                     .Where(DmucCanhbao.Columns.MaBn)
                     .IsEqualTo(txtPatient_ID.Text)
                     .Execute();
                 cmdxoa.Enabled = false;
             }
             else
             {
                 new Update(DmucCanhbao.Schema).Set(DmucCanhbao.CanhBaoColumn)
                     .EqualTo(txtCanhbao.Text.TrimStart().TrimEnd())
                     .Set(DmucCanhbao.NgaySuaColumn).EqualTo(globalVariables.SysDate)
                     .Set(DmucCanhbao.NguoiSuaColumn).EqualTo(globalVariables.UserName)
                     .Where(DmucCanhbao.Columns.MaBn)
                     .IsEqualTo(txtPatient_ID.Text)
                     .Execute();
             }
             Utility.SetMsg(lblwarningMsg, "Đã cập nhật thông tin cảnh báo thành công!", false);
         }
         else //Insert
         {
             if (txtCanhbao.Text.TrimStart().TrimEnd() == "")
             {
                 Utility.SetMsg(lblwarningMsg, "Bạn cần nhập thông tin cảnh báo!", true);
                 txtCanhbao.Focus();
                 return;
             }
             var _newItem = new DmucCanhbao();
             _newItem.CanhBao = txtCanhbao.Text.TrimStart().TrimEnd();
             _newItem.MaBn = Utility.Int32Dbnull(txtPatient_ID.Text, -1);
             _newItem.NgayTao = globalVariables.SysDate.Date;
             _newItem.NguoiTao = globalVariables.UserName;
             _newItem.IsNew = true;
             _newItem.Save();
             Utility.SetMsg(lblwarningMsg, "Đã lưu thông tin cảnh báo thành công!", false);
             cmdxoa.Enabled = true;
         }
     }
     catch
     {
     }
 }
        public void Update(int MaBn,string CanhBao,string NguoiTao,DateTime NgayTao,string NguoiSua,DateTime? NgaySua)
        {
            DmucCanhbao item = new DmucCanhbao();
            item.MarkOld();
            item.IsLoaded = true;

            item.MaBn = MaBn;

            item.CanhBao = CanhBao;

            item.NguoiTao = NguoiTao;

            item.NgayTao = NgayTao;

            item.NguoiSua = NguoiSua;

            item.NgaySua = NgaySua;

            item.Save(UserName);
        }