當前位置: 首頁>>代碼示例>>C#>>正文


C# FormContext.Entry方法代碼示例

本文整理匯總了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.";
            }
        }
開發者ID:WCTingle,項目名稱:InfoShare_Public,代碼行數:34,代碼來源:Administration.aspx.cs

示例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.";
            }
        }
開發者ID:WCTingle,項目名稱:InfoShare_Public,代碼行數:32,代碼來源:ReportDirectOrder.aspx.cs

示例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.";
            }
        }
開發者ID:WCTingle,項目名稱:InfoShare_Public,代碼行數:32,代碼來源:Administration.aspx.cs


注:本文中的Tingle_WebForms.Models.FormContext.Entry方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。