/// <summary>
 /// 將新物件加入 tblSysRole EntitySet 的方法已被取代。請考慮改為使用關聯的 ObjectSet&lt;T&gt; 屬性的 .Add 方法。
 /// </summary>
 public void AddTotblSysRole(tblSysRole tblSysRole)
 {
     base.AddObject("tblSysRole", tblSysRole);
 }
        //新增磁卡資料
        async Task AddMagneticCardAsync()
        {
            //1.新增磁卡資料
            //2.新增磁卡權限群組資料
            string tempABA = "";
            tempABA = (Convert.ToUInt32(txt_ABA.Text)).ToString("0000000000");

            tblSysRole role = new tblSysRole()
            {
                // RoleID = bc2.RoleID + 1,
                RoleName = tempABA,
                UpdateDate = DateTime.Now
            };
            DateTime tmp_StartDate = (DateTime)dp_StartDate.SelectedDate;
            DateTime tmp_EndDate = (DateTime)dp_EndDate.SelectedDate;

            string s_StartDate = tmp_StartDate.ToShortDateString() + " 00:00:00";
            string s_EndDate = tmp_EndDate.ToShortDateString() + " 23:59:59";

            role.tblMagneticCard.Add(new tblMagneticCard()
            {
                //MagneticID = bc.MagneticID + 1,
                ABA = tempABA,//txt_ABA.Text,
                WEG1 = GetWEG(tempABA).Substring(0, 5),
                WEG2 = GetWEG(tempABA).Substring(5, 5),
                Name = txt_Name.Text,
                Type = (short)cb_Type.SelectedIndex,
                NormalID = cb_NormalName.SelectedIndex,
                IDNumber = txt_IDNumber.Text,
                Company = txt_Company.Text,
                EmployeeNo = txt_EmployeeNo.Text,
                JobTitle = txt_JobTitle.Text,
                Tel = txt_Tel.Text,
                Mobile = txt_Mobile.Text,
                Timestamp = (DateTime)dp_Timestamp.SelectedDate,
                ReturnDate = dp_ReturnDate.SelectedDate,
                //StartDate = dp_StartDate.SelectedDate,
                StartDate = Convert.ToDateTime(s_StartDate),
                //EndDate = (DateTime)dp_EndDate.SelectedDate,
                EndDate = Convert.ToDateTime(s_EndDate),
                Enable = cb_Enable.SelectedValue.ToString(),
                Memo = tb_Memo.Text,
                //RoleID = bc2.RoleID + 1
            });
            db.tblSysRoles.Add(
                role
               );
            try
            {
                bool res = await db.SubmitChangesAsync();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Role-Adding Data failed due to " + ex.Message);
            }
            //2.加入磁卡權限清單
            await AddGroup(role.RoleID);

            MessageBox.Show("新增磁卡成功!");
        }
 /// <summary>
 /// 建立新 tblSysRole 物件。
 /// </summary>
 /// <param name="roleID">RoleID 屬性的初始值。</param>
 public static tblSysRole CreatetblSysRole(global::System.Int32 roleID)
 {
     tblSysRole tblSysRole = new tblSysRole();
     tblSysRole.RoleID = roleID;
     return tblSysRole;
 }