public void InitDOData(object id)
 {
     this.tableName = DMDiemTheoDoi.I.getTableName(this.LoaiCongViec._getSelectedID());
     doBangTheoDoi = DABangTheoDoi.Instance.LoadAll(HelpNumber.ParseInt64(id), this.tableName);
     if (this.IsAdd == true)
     {
         this.doBangTheoDoi.BTD_ID = HelpDB.getDatabase().GetID("G_NGHIEP_VU");
         this.SoPhieu.Text = DatabaseFB.getSoPhieu("BANG_THEO_DOI", "MA_BTD", DatabaseFB.GetThamSo("MA_BTD"));
     }
     else
     {
         if (doBangTheoDoi.DetailDataSet != null)
         {
             if (doBangTheoDoi.DetailDataSet.Tables[0].Rows.Count > 0)
             {
                 this.LoaiCongViec._setSelectedID(HelpNumber.ParseInt64(doBangTheoDoi.DetailDataSet.Tables[0].Rows[0]["LCV_ID"].ToString()));
                 this.tableName = DMDiemTheoDoi.I.getTableName(this.LoaiCongViec._getSelectedID());
             }
         }
         this.SoPhieu.Text = doBangTheoDoi.MA_BTD;
         this.txt_Name.Text = doBangTheoDoi.NAME;
         this.NgayLap.DateTime = Convert.ToDateTime(doBangTheoDoi.NGAY_LAP);
         this.NguoiLap._setSelectedID(doBangTheoDoi.NGUOI_LAP);
         this.NgayKy.DateTime = Convert.ToDateTime(doBangTheoDoi.NGAY_KY);
         this.NguoiKy._setSelectedID(doBangTheoDoi.NGUOI_KY);
         this.NgayHieuLuc.DateTime = Convert.ToDateTime(doBangTheoDoi.NGAY_HIEU_LUC);
         this.NguoiQuanLy._setSelectedID(doBangTheoDoi.NGUOI_QUAN_LY);
         this.txtTenTaiLieu.Text = this.doBangTheoDoi.TEN_TAI_LIEU;
         this.TinhTrang._setSelectedID(doBangTheoDoi.TINH_TRANG);
         if (doBangTheoDoi.HINH_THUC_THONG_BAO == 1) this.chkMail.Checked = true;
         else if (doBangTheoDoi.HINH_THUC_THONG_BAO == 2) this.chkDienThoai.Checked = true;
         else if (doBangTheoDoi.HINH_THUC_THONG_BAO == 3) this.chkGap.Checked = true;
         this.GhiChu.Text = doBangTheoDoi.GHI_CHU;
     }
     InitGrid();
 }
 public void update(DbCommand cmd, DbTransaction dbTrans, DatabaseFB db, DOBangTheoDoi doBangTheoDoi)
 {
     cmd = db.GetSQLStringCommand("update BANG_THEO_DOI set name=@name,ngay_lap=@ngay_lap,nguoi_lap=@nguoi_lap,ngay_ky=@ngay_ky,nguoi_ky=@nguoi_ky,ngay_hieu_luc=@ngay_hieu_luc,nguoi_quan_ly=@nguoi_quan_ly,tai_lieu=@tai_lieu,ten_tai_lieu=@ten_tai_lieu,tinh_trang=@tinh_trang,hinh_thuc_thong_bao=@hinh_thuc_thong_bao,ghi_chu=@ghi_chu,nguoi_cap_nhat=@nguoi_cap_nhat,ngay_cap_nhat=@ngay_cap_nhat "
                                     + "where btd_id=@btd_id" );
     db.AddInParameter(cmd, "@btd_id", DbType.Int64, doBangTheoDoi.BTD_ID);
     db.AddInParameter(cmd, "@name", DbType.String, doBangTheoDoi.NAME);
     db.AddInParameter(cmd, "@ngay_lap", DbType.DateTime, doBangTheoDoi.NGAY_LAP);
     db.AddInParameter(cmd, "@nguoi_lap", DbType.Int64, doBangTheoDoi.NGUOI_LAP);
     db.AddInParameter(cmd, "@ngay_ky", DbType.DateTime, doBangTheoDoi.NGAY_KY);
     db.AddInParameter(cmd, "@nguoi_ky", DbType.Int64, doBangTheoDoi.NGUOI_KY);
     db.AddInParameter(cmd, "@ngay_hieu_luc", DbType.DateTime, doBangTheoDoi.NGAY_HIEU_LUC);
     db.AddInParameter(cmd, "@nguoi_quan_ly", DbType.Int64, doBangTheoDoi.NGUOI_QUAN_LY);
     db.AddInParameter(cmd, "@tai_lieu", DbType.Binary, doBangTheoDoi.TAI_LIEU);
     db.AddInParameter(cmd, "@ten_tai_lieu", DbType.String, doBangTheoDoi.TEN_TAI_LIEU);
     db.AddInParameter(cmd, "@tinh_trang", DbType.Int64, doBangTheoDoi.TINH_TRANG);
     db.AddInParameter(cmd, "@hinh_thuc_thong_bao", DbType.Int32, doBangTheoDoi.HINH_THUC_THONG_BAO);
     db.AddInParameter(cmd, "@ghi_chu", DbType.String, doBangTheoDoi.GHI_CHU);
     db.AddInParameter(cmd, "@nguoi_cap_nhat", DbType.Int64, doBangTheoDoi.NGUOI_CAP_NHAT);
     db.AddInParameter(cmd, "@ngay_cap_nhat", DbType.DateTime, doBangTheoDoi.NGAY_CAP_NHAT);
     int result2 = db.ExecuteNonQuery(cmd, dbTrans);
 }
 public DOBangTheoDoi Load(long IDKey)
 {
     IDataReader reader = FWDBService.LoadRecord("BANG_THEO_DOI", KEY_FIELD_NAME, IDKey);
     using (reader)
     {
         if (reader.Read())
         {
             DOBangTheoDoi data = new DOBangTheoDoi(HelpNumber.ParseInt64(reader[KEY_FIELD_NAME].ToString()),
                                                      reader["MA_BTD"].ToString(),
                                                      reader["NAME"].ToString(),
                                                      Convert.ToDateTime(reader["NGAY_LAP"].ToString()),
                                                      HelpNumber.ParseInt64(reader["NGUOI_LAP"].ToString()),
                                                      Convert.ToDateTime(reader["NGAY_KY"].ToString()),
                                                      HelpNumber.ParseInt64(reader["NGUOI_KY"].ToString()),
                                                      Convert.ToDateTime(reader["NGAY_HIEU_LUC"].ToString()),
                                                      HelpNumber.ParseInt64(reader["NGUOI_QUAN_LY"].ToString()),
                                                      (reader["TAI_LIEU"].ToString() == "" ? null : (byte[])reader["TAI_LIEU"]),
                                                      reader["TEN_TAI_LIEU"].ToString(),
                                                      HelpNumber.ParseInt64(reader["TINH_TRANG"].ToString()),
                                                      HelpNumber.ParseInt32(reader["HINH_THUC_THONG_BAO"].ToString()),
                                                      reader["GHI_CHU"].ToString(),
                                                      HelpNumber.ParseInt64(reader["NGUOI_CAP_NHAT"].ToString()),
                                                      Convert.ToDateTime(reader["NGAY_CAP_NHAT"].ToString()));
             return data;
         }
     }
     return new DOBangTheoDoi();
 }
 public bool? saveData(DataSet GridDataSet, DOBangTheoDoi doBangTheoDoi, bool? isAdd)
 {
     DatabaseFB db = HelpDB.getDatabase();
     DbTransaction dbTrans = db.BeginTransaction(db.OpenConnection());
     DbCommand cmd = null;
     try
     {
         if (isAdd == true)
             insert(cmd, dbTrans, db, doBangTheoDoi);
         else
             update(cmd, dbTrans, db, doBangTheoDoi);
         if (GridDataSet.GetChanges() != null)
             db.UpdateDataSet(GridDataSet, dbTrans);
         db.CommitTransaction(dbTrans);
     }
     catch (Exception ex)
     {
         ex.StackTrace.ToString();
         db.RollbackTransaction(dbTrans);
         return false;
     }
     return true;
 }
 public void insert(DbCommand cmd, DbTransaction dbTrans, DatabaseFB db, DOBangTheoDoi doBangTheoDoi)
 {
     cmd = db.GetSQLStringCommand("insert into BANG_THEO_DOI(btd_id,ma_btd,name,ngay_lap,nguoi_lap,ngay_ky,nguoi_ky,ngay_hieu_luc,nguoi_quan_ly,tai_lieu,ten_tai_lieu,tinh_trang,hinh_thuc_thong_bao,ghi_chu,nguoi_cap_nhat,ngay_cap_nhat) "
                                     + "values(@btd_id,@ma_btd,@name,@ngay_lap,@nguoi_lap,@ngay_ky,@nguoi_ky,@ngay_hieu_luc,@nguoi_quan_ly,@tai_lieu,@ten_tai_lieu,@tinh_trang,@hinh_thuc_thong_bao,@ghi_chu,@nguoi_cap_nhat,@ngay_cap_nhat)");
     db.AddInParameter(cmd, "@btd_id", DbType.Int64, doBangTheoDoi.BTD_ID);
     db.AddInParameter(cmd, "@ma_btd", DbType.String, doBangTheoDoi.MA_BTD);
     db.AddInParameter(cmd, "@name", DbType.String, doBangTheoDoi.NAME);
     db.AddInParameter(cmd, "@ngay_lap", DbType.DateTime, doBangTheoDoi.NGAY_LAP);
     db.AddInParameter(cmd, "@nguoi_lap", DbType.Int64, doBangTheoDoi.NGUOI_LAP);
     db.AddInParameter(cmd, "@ngay_ky", DbType.DateTime, doBangTheoDoi.NGAY_KY);
     db.AddInParameter(cmd, "@nguoi_ky", DbType.Int64, doBangTheoDoi.NGUOI_KY);
     db.AddInParameter(cmd, "@ngay_hieu_luc", DbType.DateTime, doBangTheoDoi.NGAY_HIEU_LUC);
     db.AddInParameter(cmd, "@nguoi_quan_ly", DbType.Int64, doBangTheoDoi.NGUOI_QUAN_LY);
     db.AddInParameter(cmd, "@tai_lieu", DbType.Binary, doBangTheoDoi.TAI_LIEU);
     db.AddInParameter(cmd, "@ten_tai_lieu", DbType.String, doBangTheoDoi.TEN_TAI_LIEU);
     db.AddInParameter(cmd, "@tinh_trang", DbType.Int64, doBangTheoDoi.TINH_TRANG);
     db.AddInParameter(cmd, "@hinh_thuc_thong_bao", DbType.Int32, doBangTheoDoi.HINH_THUC_THONG_BAO);
     db.AddInParameter(cmd, "@ghi_chu", DbType.String, doBangTheoDoi.GHI_CHU);
     db.AddInParameter(cmd, "@nguoi_cap_nhat", DbType.Int64, doBangTheoDoi.NGUOI_CAP_NHAT);
     db.AddInParameter(cmd, "@ngay_cap_nhat", DbType.DateTime, doBangTheoDoi.NGAY_CAP_NHAT);
     int result2 = db.ExecuteNonQuery(cmd, dbTrans);
 }