本文整理汇总了C#中Tingle_WebForms.Models.FormContext.Entry方法的典型用法代码示例。如果您正苦于以下问题:C# FormContext.Entry方法的具体用法?C# FormContext.Entry怎么用?C# FormContext.Entry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tingle_WebForms.Models.FormContext
的用法示例。
在下文中一共展示了FormContext.Entry方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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.";
}
}
示例2: gvSkus_RowUpdating
protected void gvSkus_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
Label lblAddSkuMessage = (Label)fvReport.FindControl("lblAddSkuMessage");
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.SkuQuantityItems.Attach(sku);
ctx.Entry(sku).State = EntityState.Modified;
ctx.SaveChanges();
gv.DataBind();
lblAddSkuMessage.Text = "";
}
}
catch (Exception ex)
{
lblAddSkuMessage.Text = "Unable to update Material SKU# and/or Quantity. Please contact your system administrator.";
}
}
示例3: 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.";
}
}