本文整理汇总了C#中Tingle_WebForms.Models.FormContext.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# FormContext.SaveChanges方法的具体用法?C# FormContext.SaveChanges怎么用?C# FormContext.SaveChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tingle_WebForms.Models.FormContext
的用法示例。
在下文中一共展示了FormContext.SaveChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendInventoryNotification
public Boolean SendInventoryNotification(List<string> emailList, string bodyHtml, SystemUsers sentUser)
{
try
{
MailMessage completeMessage = new MailMessage();
completeMessage.From = new MailAddress("[email protected]");
completeMessage.Subject = "Inventory Approval Notification";
completeMessage.Body = bodyHtml;
completeMessage.IsBodyHtml = true;
//SmtpClient client = new SmtpClient("TingleNT30.wctingle.com");
//client.UseDefaultCredentials = true;
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
client.Credentials = new NetworkCredential("[email protected]", "ZXCasdQWE123!");
client.EnableSsl = true;
using (FormContext ctx = new FormContext())
{
foreach (string email in emailList)
{
InventoryApprovalNotifications newRN = new InventoryApprovalNotifications
{
BodyHtml = bodyHtml,
SentBy = ctx.SystemUsers.FirstOrDefault(x => x.SystemUserID == sentUser.SystemUserID),
Status = 0,
Timestamp = DateTime.Now,
ToEmailAddress = email
};
ctx.InventoryApprovalNotifications.Add(newRN);
ctx.SaveChanges();
try
{
completeMessage.To.Clear();
completeMessage.To.Add(email);
client.Send(completeMessage);
newRN.Status = 1;
ctx.SaveChanges();
}
catch (Exception exc)
{ }
}
}
return true;
}
catch (Exception ex)
{
return false;
}
}
示例2: AddExpeditedOrderForm
public bool AddExpeditedOrderForm(string oowOrderNumber, string customer, string accountNumber, ExpediteCode expediteCode, string purchaseOrderNumber, string materialSku, string quantityOrdered,
Nullable<DateTime> installDate, string sM, string contactName, string phoneNumber, string shipToName, string shipToAddress, string shipToCity, string shipToState, string shipToZip,
string additionalInfo, Status status, string submittedByUser, string ccFormToEmail, string company, out Int32 formId)
{
try
{
using (FormContext _db = new FormContext())
{
var expCode = _db.ExpediteCodes.SingleOrDefault(ec => ec.ExpediteCodeID == expediteCode.ExpediteCodeID);
var submissionStatus = _db.Statuses.SingleOrDefault(s => s.StatusId == status.StatusId);
var newForm = new ExpeditedOrderForm();
newForm.Timestamp = DateTime.Now;
newForm.OowOrderNumber = oowOrderNumber;
newForm.Customer = customer;
newForm.AccountNumber = accountNumber;
newForm.ExpediteCode = expCode;
newForm.PurchaseOrderNumber = purchaseOrderNumber;
newForm.InstallDate = installDate;
newForm.SM = sM;
newForm.ContactName = contactName;
newForm.PhoneNumber = phoneNumber;
newForm.ShipToName = shipToName;
newForm.ShipToAddress = shipToAddress;
newForm.ShipToCity = shipToCity;
newForm.ShipToState = shipToState;
newForm.ShipToZip = shipToZip;
newForm.AdditionalInfo = additionalInfo;
newForm.Status = submissionStatus;
newForm.SubmittedByUser = submittedByUser;
newForm.CCFormToEmail = ccFormToEmail;
newForm.Company = company;
_db.ExpeditedOrderForms.Add(newForm);
_db.SaveChanges();
formId = newForm.RecordId;
}
return true;
}
catch (Exception ex)
{
formId = 0;
return false;
//throw ex;
}
}
示例3: fvEmailInsert_InsertItem
public void fvEmailInsert_InsertItem()
{
try
{
TextBox txtNameInsert = (TextBox)fvEmailInsert.FindControl("txtNameInsert");
TextBox txtAddressInsert = (TextBox)fvEmailInsert.FindControl("txtAddressInsert");
RadioButtonList rblCompanyInsert = (RadioButtonList)fvEmailInsert.FindControl("rblCompanyInsert");
RadioButtonList rblStatusInsert = (RadioButtonList)fvEmailInsert.FindControl("rblStatusInsert");
Int16 status = Convert.ToInt16(rblStatusInsert.SelectedValue);
int id = Convert.ToInt32(ddlFormName.SelectedValue);
using (FormContext ctx = new FormContext())
{
var tForm = ctx.TForms.Where(f => f.FormID == id).FirstOrDefault();
EmailAddress newEmail = new EmailAddress();
newEmail.Name = txtNameInsert.Text;
newEmail.Address = txtAddressInsert.Text;
newEmail.Company = rblCompanyInsert.SelectedValue;
newEmail.Status = status;
newEmail.TForm = tForm;
newEmail.Timestamp = DateTime.Now;
ctx.EmailAddresses.Add(newEmail);
if (ModelState.IsValid)
{
ctx.SaveChanges();
gvEmailList.DataBind();
}
lblEmailMessage.Text = "";
}
}
catch (Exception ex)
{
lblEmailMessage.Text = "Unable to insert new Email Address. Please contact your system administrator.";
}
}
示例4: gvEmailList_RowUpdating
protected void gvEmailList_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
try
{
GridView gv = (GridView)sender;
GridViewRow gvr = (GridViewRow)gv.Rows[e.RowIndex];
Label lblEmailAddressID = (Label)gvr.FindControl("lblEmailAddressIDEdit");
int id = Convert.ToInt32(lblEmailAddressID.Text);
using (FormContext ctx = new FormContext())
{
var emailAddress = ctx.EmailAddresses.Where(ea => ea.EmailAddressID == id).FirstOrDefault();
emailAddress.Name = ((TextBox)gvr.FindControl("txtNameEdit")).Text;
emailAddress.Address = ((TextBox)gvr.FindControl("txtAddressEdit")).Text;
emailAddress.Status = Convert.ToInt16(((RadioButtonList)gvr.FindControl("rblStatusEdit")).SelectedValue);
emailAddress.Company = ((DropDownList)gvr.FindControl("ddlCompanyEdit")).SelectedValue;
ctx.EmailAddresses.Attach(emailAddress);
ctx.Entry(emailAddress).State = EntityState.Modified;
ctx.SaveChanges();
gvEmailList.DataBind();
lblEmailMessage.Text = "";
}
}
catch (Exception ex)
{
lblEmailMessage.Text = "Unable to update Email Address. Please contact your system administrator.";
}
}
示例5: btnAddComment_Click
protected void btnAddComment_Click(object sender, EventArgs e)
{
try
{
Label lblRecordId = (Label)fvReport.FindControl("lblRecordId");
int recordId;
Int32.TryParse(lblRecordId.Text, out recordId);
RadTextBox txtNewComment = (RadTextBox)fvReport.FindControl("txtNewComment");
Repeater rptrComments = (Repeater)fvReport.FindControl("rptrComments");
UserLogic newLogic = new UserLogic();
System.Security.Principal.IPrincipal user = System.Web.HttpContext.Current.User;
SystemUsers currentUser = newLogic.GetCurrentUser(user);
using (var ctx = new FormContext())
{
var thisForm = ctx.MustIncludeForms.FirstOrDefault(eof => eof.RecordId == recordId);
Comments newComment = new Comments
{
Form = ctx.TForms.FirstOrDefault(x => x.FormName == "Must Include"),
Note = txtNewComment.Text,
RelatedFormId = thisForm.RecordId,
SystemComment = false,
Timestamp = DateTime.Now,
User = ctx.SystemUsers.FirstOrDefault(x => x.SystemUserID == currentUser.SystemUserID)
};
ctx.Comments.Add(newComment);
ctx.SaveChanges();
txtNewComment.Text = "";
txtNewComment.Invalid = false;
rptrComments.DataBind();
}
}
catch (Exception ex)
{
throw;
}
}
示例6: gvSkus_RowUpdating
protected void gvSkus_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
try
{
GridView gv = (GridView)sender;
GridViewRow gvr = (GridViewRow)gv.Rows[e.RowIndex];
Label lblRecordIdEdit = (Label)gvr.FindControl("lblRecordIdEdit");
int id = Convert.ToInt32(lblRecordIdEdit.Text);
using (FormContext ctx = new FormContext())
{
var sku = ctx.SkuQuantityItems.FirstOrDefault(x => x.RecordId == id);
sku.Completed = ((CheckBox)gvr.FindControl("cbCompletedEdit")).Checked;
sku.MaterialSku = ((TextBox)gvr.FindControl("txtMaterialSkuEdit")).Text;
sku.Quantity = ((TextBox)gvr.FindControl("txtQuantityEdit")).Text;
ctx.SaveChanges();
gvSkus.DataBind();
lblAddSkuMessage.Text = "";
}
}
catch (Exception ex)
{
lblAddSkuMessage.Text = "Unable to update Material SKU# and/or Quantity. Please contact your system administrator.";
}
}
示例7: gvSkus_DeleteItem
public void gvSkus_DeleteItem(int RecordId)
{
try
{
using (FormContext ctx = new FormContext())
{
SkuQuantity SkuToDelete = ctx.SkuQuantityItems.FirstOrDefault(x => x.RecordId == RecordId);
if (SkuToDelete != null)
{
ctx.SkuQuantityItems.Remove(SkuToDelete);
ctx.SaveChanges();
}
lblAddSkuMessage.Text = "";
}
}
catch (Exception ex)
{
lblAddSkuMessage.Text = "Unable to delete Material SKU# and Quantity. Please contact your system administrator.";
}
}
示例8: btnAddComment_Click
protected void btnAddComment_Click(object sender, EventArgs e)
{
try
{
int recordId;
Int32.TryParse(lblRecordId.Text, out recordId);
UserLogic newLogic = new UserLogic();
System.Security.Principal.IPrincipal user = System.Web.HttpContext.Current.User;
SystemUsers currentUser = newLogic.GetCurrentUser(user);
using (var ctx = new FormContext())
{
var thisForm = ctx.CannotWaitForContainerForms.FirstOrDefault(eof => eof.RecordId == recordId);
Comments newComment = new Comments
{
Form = ctx.TForms.FirstOrDefault(x => x.FormName == "Cannot Wait For Container"),
Note = txtNewComment.Text,
RelatedFormId = thisForm.RecordId,
SystemComment = false,
Timestamp = DateTime.Now,
User = ctx.SystemUsers.FirstOrDefault(x => x.SystemUserID == currentUser.SystemUserID)
};
ctx.Comments.Add(newComment);
ctx.SaveChanges();
txtNewComment.Text = "";
txtNewComment.Invalid = false;
rptrComments.DataBind();
Session["NewComment"] = "true";
}
}
catch (Exception ex)
{
throw;
}
}
示例9: btnSaveAccountSettings_Click
protected void btnSaveAccountSettings_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
try
{
UserLogic uLogic = new UserLogic();
System.Security.Principal.IPrincipal user = System.Web.HttpContext.Current.User;
SystemUsers currentUser = uLogic.GetCurrentUser(user);
using (FormContext ctx = new FormContext())
{
var updateUser = ctx.SystemUsers.FirstOrDefault(x => x.SystemUserID == currentUser.SystemUserID);
updateUser.Greeting = txtGreeting.Text;
updateUser.DisplayName = txtDisplayName.Text;
updateUser.UserStatus = ctx.UserStatuses.FirstOrDefault(x => x.StatusText == ddlUserStatus.SelectedText);
ctx.SaveChanges();
divSaveCancel.Visible = false;
divLabelEdit.Visible = true;
divDisplayNameEdit.Visible = false;
ddlUserStatus.Enabled = false;
txtGreeting.Enabled = false;
lblUser.Text = txtDisplayName.Text;
}
}
catch (Exception ex)
{
throw;
}
}
}
示例10: fvVendors_InsertItem
public void fvVendors_InsertItem()
{
try
{
TextBox txtVendorNameInsert = (TextBox)fvVendors.FindControl("txtVendorNameInsert");
TextBox txtVendorPhoneInsert = (TextBox)fvVendors.FindControl("txtVendorPhoneInsert");
TextBox txtVendorFaxInsert = (TextBox)fvVendors.FindControl("txtVendorFaxInsert");
using (FormContext ctx = new FormContext())
{
if (!ctx.Vendors.Any(x => x.VendorName == txtVendorNameInsert.Text.Trim()))
{
Vendor newVendor = new Vendor();
newVendor.VendorName = txtVendorNameInsert.Text;
newVendor.VendorPhone = txtVendorPhoneInsert.Text;
newVendor.VendorPhone = txtVendorFaxInsert.Text;
newVendor.CurrentStock = 0;
newVendor.Timestamp = DateTime.Now;
ctx.Vendors.Add(newVendor);
ctx.SaveChanges();
gvVendors.DataBind();
lblVariableMessage.Text = "";
}
else
{
lblVariableMessage.Text = "A Vendor named: " + txtVendorNameInsert.Text + " already exists. Please try again.";
}
}
}
catch (Exception ex)
{
lblVariableMessage.Text = "Unable to add this Vendor. Please contact your system administrator.";
}
}
示例11: fvUserInsert_InsertItem
public void fvUserInsert_InsertItem()
{
try
{
TextBox txtUserNameInsert = (TextBox)fvUserInsert.FindControl("txtUserNameInsert");
TextBox txtDisplayNameInsert = (TextBox)fvUserInsert.FindControl("txtDisplayNameInsert");
TextBox txtEmailAddressInsert = (TextBox)fvUserInsert.FindControl("txtEmailAddressInsert");
RadioButtonList rblUserStatusInsert = (RadioButtonList)fvUserInsert.FindControl("rblUserStatusInsert");
CheckBox cbInventoryApproval = (CheckBox)fvUserInsert.FindControl("cbInventoryApproval");
int roleId = Convert.ToInt32(((DropDownList)fvUserInsert.FindControl("ddlUserRoleInsert")).SelectedValue);
Int16 status = Convert.ToInt16(rblUserStatusInsert.SelectedValue);
using (FormContext ctx = new FormContext())
{
if (ctx.SystemUsers.Where(su => su.UserName == txtUserNameInsert.Text).FirstOrDefault() == null)
{
SystemUsers newUser = new SystemUsers();
UserRoles newRole = ctx.UserRoles.Where(ur => ur.UserRoleId == roleId).FirstOrDefault();
newUser.UserName = txtUserNameInsert.Text;
newUser.DisplayName = txtDisplayNameInsert.Text;
newUser.EmailAddress = txtEmailAddressInsert.Text;
newUser.Status = status;
newUser.UserRole = newRole;
newUser.InventoryApprovalUser = cbInventoryApproval.Checked;
ctx.SystemUsers.Add(newUser);
if (ModelState.IsValid)
{
ctx.SaveChanges();
gvUsers.DataBind();
}
lblUserMessage.Text = "";
}
else
{
lblUserMessage.Text = "A User with the username: " + txtUserNameInsert.Text + " already exists.";
}
}
}
catch (Exception ex)
{
lblUserMessage.Text = "Unable to add new User. Please contact your system administrator.";
}
}
示例12: gvVendors_RowUpdating
protected void gvVendors_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
try
{
GridView gv = (GridView)sender;
GridViewRow gvr = (GridViewRow)gv.Rows[e.RowIndex];
Label lblRecordId = (Label)gvr.FindControl("lblRecordIdEdit");
int id = Convert.ToInt32(lblRecordId.Text);
using (FormContext ctx = new FormContext())
{
var vendor = ctx.Vendors.FirstOrDefault(x => x.RecordId == id);
vendor.VendorName = ((TextBox)gvr.FindControl("lblVendorNameEdit")).Text;
vendor.VendorPhone = ((TextBox)gvr.FindControl("lblVendorPhoneEdit")).Text;
vendor.VendorFax = ((TextBox)gvr.FindControl("lblVendorFaxEdit")).Text;
ctx.SaveChanges();
gvVendors.DataBind();
lblVariableMessage.Text = "";
}
}
catch (Exception ex)
{
lblVariableMessage.Text = "Unable to update Vendor. Please contact your system administrator.";
}
}
示例13: gvUsers_RowUpdating
protected void gvUsers_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
try
{
GridView gv = (GridView)sender;
GridViewRow gvr = (GridViewRow)gv.Rows[e.RowIndex];
Label lblSystemUserID = (Label)gvr.FindControl("lblSystemUserIDEdit");
int id = Convert.ToInt32(lblSystemUserID.Text);
int userRoleID = Convert.ToInt32(((DropDownList)gvr.FindControl("ddlUserRoleEdit")).SelectedValue);
Boolean invMgmt = Convert.ToBoolean(((CheckBox)gvr.FindControl("cbInventoryManagementEdit")).Checked);
using (FormContext ctx = new FormContext())
{
var systemUser = ctx.SystemUsers.Where(su => su.SystemUserID == id).FirstOrDefault();
systemUser.DisplayName = ((TextBox)gvr.FindControl("txtDisplayNameEdit")).Text;
systemUser.EmailAddress = ((TextBox)gvr.FindControl("txtEmailAddressEdit")).Text;
systemUser.Status = Convert.ToInt16(((RadioButtonList)gvr.FindControl("rblUserStatusEdit")).SelectedValue);
systemUser.UserRole = ctx.UserRoles.Where(ur => ur.UserRoleId == userRoleID).FirstOrDefault();
systemUser.InventoryApprovalUser = invMgmt;
ctx.SystemUsers.Attach(systemUser);
ctx.Entry(systemUser).State = EntityState.Modified;
ctx.SaveChanges();
gvUsers.DataBind();
lblUserMessage.Text = "";
}
}
catch (Exception ex)
{
lblUserMessage.Text = "Unable to update user. Please contact your system administrator.";
}
}
示例14: gvNotificationEmails_RowUpdating
protected void gvNotificationEmails_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
try
{
GridView gv = (GridView)sender;
GridViewRow gvr = (GridViewRow)gv.Rows[e.RowIndex];
Label lblRecorIdEdit = (Label)gvr.FindControl("lblRecorIdEdit");
int id = Convert.ToInt32(lblRecorIdEdit.Text);
using (FormContext ctx = new FormContext())
{
var notiEmail = ctx.NotificationEmailAddresses.FirstOrDefault(x => x.RecordId == id);
notiEmail.Name = ((TextBox)gvr.FindControl("txtNameEdit")).Text;
notiEmail.Address = ((TextBox)gvr.FindControl("txtAddressEdit")).Text;
notiEmail.Status = Convert.ToInt16(((RadioButtonList)gvr.FindControl("rblNotificationEmailStatusEdit")).SelectedValue);
ctx.SaveChanges();
gvNotificationEmails.DataBind();
lblNotificationEmailMessage.Text = "";
}
}
catch (Exception ex)
{
lblNotificationEmailMessage.Text = "Unable to update Notification Email Address. Please contact your system administrator.";
}
}
示例15: gvExpediteCodes_RowUpdating
protected void gvExpediteCodes_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
try
{
GridView gv = (GridView)sender;
GridViewRow gvr = (GridViewRow)gv.Rows[e.RowIndex];
Label lblExpediteCodeID = (Label)gvr.FindControl("lblExpediteCodeIDEdit");
int id = Convert.ToInt32(lblExpediteCodeID.Text);
using (FormContext ctx = new FormContext())
{
var expCode = ctx.ExpediteCodes.FirstOrDefault(x => x.ExpediteCodeID == id);
expCode.Code = ((TextBox)gvr.FindControl("txtCodeEdit")).Text;
expCode.Description = ((TextBox)gvr.FindControl("txtDescriptionEdit")).Text;
expCode.Status = Convert.ToInt16(((RadioButtonList)gvr.FindControl("rblCodeStatusEdit")).SelectedValue);
ctx.SaveChanges();
gvExpediteCodes.DataBind();
lblVariableMessage.Text = "";
}
}
catch (Exception ex)
{
lblVariableMessage.Text = "Unable to update Expedite Code. Please contact your system administrator.";
}
}