/// <summary> /// 新增 /// </summary> public bool Insert(EmailBccAccountEntity model) { Dictionary <string, object> dic = new Dictionary <string, object>(); dic["EmailBccAccountAddress"] = model.EmailBccAccountAddress; dic["EmailBccAccountName"] = model.EmailBccAccountName; dic["EmailBccAccountCategoryID"] = model.EmailBccAccountCategoryID; dic["EmailBccAccountCategoryName"] = model.EmailBccAccountCategoryName; return(SQLHelperFactory.Instance.ExecuteNonQuery("Insert_emailbccaccount", dic) > 0); }
private void BtnOK_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(tbAddress.Text.Trim())) { "請填寫完整再提交".ShowDialog(); return; } var category = this.cbCategory.SelectedItem as EmailBccAccountCategoryEntity; var entity = EBA_Repository.GetByAddress(tbAddress.Text.Trim()); if (this.EmailBccAccountID == -1 && entity != null) { "郵箱已存在,請不要重複添加".ShowDialog(); return; } if (this.EmailBccAccountID != -1 && entity != null && this.EmailBccAccountID != entity.EmailBccAccountID) { "郵箱已存在".ShowDialog(); return; } if (this.EmailBccAccountID == -1) { entity = new EmailBccAccountEntity { EmailBccAccountAddress = tbAddress.Text.Trim(), EmailBccAccountName = tbAddress.Text.Trim(), EmailBccAccountCategoryID = category.ID, EmailBccAccountCategoryName = category.Name }; EBA_Repository.Insert(entity); } else { entity = EBA_Repository.Get(this.EmailBccAccountID); entity.EmailBccAccountAddress = tbAddress.Text.Trim(); entity.EmailBccAccountName = tbAddress.Text.Trim(); entity.EmailBccAccountCategoryID = category.ID; entity.EmailBccAccountCategoryName = category.Name; EBA_Repository.Update(entity); } "成功".ShowDialog(); this.DialogResult = true; this.Close(); }