コード例 #1
0
        protected void UsersGridView_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            BootstrapGridView grid = sender as BootstrapGridView;

            var manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();
            var user    = manager.FindById(e.Keys["Id"].ToString());

            if (user != null)
            {
                user.Email       = e.NewValues["Email"].ToString();
                user.PhoneNumber = e.NewValues["PhoneNumber"]?.ToString() ?? string.Empty;
                IdentityResult result = manager.Update(user);
                if (!result.Succeeded)
                {
                    grid.CancelEdit();
                    e.Cancel = true;
                    throw new Exception(result.Errors.FirstOrDefault());
                }
            }
            else
            {
                grid.CancelEdit();
                e.Cancel = true;
            }
            grid.DataBind();
        }
コード例 #2
0
        protected void RolesGridView_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            BootstrapGridView grid = sender as BootstrapGridView;

            var context = new ApplicationDbContext();
            var manager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context));
            var role    = manager.FindById(e.Keys["Id"].ToString());

            if (role != null)
            {
                role.Name = e.NewValues["Name"].ToString();
                IdentityResult result = manager.Update(role);
                if (!result.Succeeded)
                {
                    grid.CancelEdit();
                    e.Cancel = true;
                    throw new Exception(result.Errors.FirstOrDefault());
                }
                context.SaveChanges();
            }
            else
            {
                grid.CancelEdit();
                e.Cancel = true;
            }
            grid.DataBind();
        }
コード例 #3
0
        protected void gvFee_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            BootstrapGridView gv = (BootstrapGridView)sender;

            MasterDataModel.MasterDataTransporterFee item = new MasterDataModel.MasterDataTransporterFee();
            item.Transporter_ID          = Convert.ToInt32(e.Keys[0]);
            item.Region_ID               = Convert.ToByte(e.Keys[1]);
            item.HandlingFee             = Convert.ToDecimal(e.NewValues["HandlingFee"]);
            item.OATDistanceLimit        = Convert.ToInt32(e.NewValues["OATDistanceLimit"]);
            item.OATPriceUnderEqualLimit = Convert.ToDecimal(e.NewValues["OATPriceUnderEqualLimit"]);
            item.OATPriceAboveLimit      = Convert.ToDecimal(e.NewValues["OATPriceAboveLimit"]);
            item.UpdateBy = UserProfile.Username;

            string res = MasterDataEntity.EditMasterDataTransporterFee(item);

            gv.JSProperties["cpRes"] = res;

            e.Cancel = true;

            if (res.Contains("Success"))
            {
                gv.CancelEdit();
                gv.DataBind();
            }
        }
コード例 #4
0
        protected void gv_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            BootstrapGridView gv = (BootstrapGridView)sender;

            MasterDataModel.MasterDataSPSH item = GetGvValue(gv, e.Keys[0].ToString());

            string res = MasterDataEntity.EditMasterDataSPSH(item);

            gv.JSProperties["cpRes"] = res;

            e.Cancel = true;

            if (res.Contains("Success"))
            {
                gv.CancelEdit();
                gv.DataBind();
            }
        }
コード例 #5
0
        protected void gv_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            BootstrapGridView gv = (BootstrapGridView)sender;

            MasterDataModel.MasterDataKendaraan item = GetGvValue(gv);

            string res = MasterDataEntity.AddMasterDataVehicle(item);

            gv.JSProperties["cpRes"] = res;

            e.Cancel = true;

            if (res.Contains("Success"))
            {
                gv.CancelEdit();
                gv.DataBind();
            }
        }
コード例 #6
0
        protected void UsersGridView_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            BootstrapGridView grid = sender as BootstrapGridView;
            var manager            = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();
            var user = manager.FindById(e.Keys["Id"].ToString());

            grid.CancelEdit();
            e.Cancel = true;
            if (user != null)
            {
                IdentityResult result = manager.Delete(user);
                if (!result.Succeeded)
                {
                    throw new Exception(result.Errors.FirstOrDefault());
                }
            }
            grid.DataBind();
        }
コード例 #7
0
        protected void gvAuthParameter_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            string Response = string.Empty;

            try
            {
                //initialize control
                BootstrapGridView gv          = (BootstrapGridView)gvMasterDataUser;
                BootstrapTextBox  txtusername = (BootstrapTextBox)gv.FindEditFormTemplateControl("txtUserName");
                BootstrapGridView gridAuth    = (BootstrapGridView)gv.FindEditFormTemplateControl("gvAuthParameter");

                if (string.IsNullOrEmpty((string)e.NewValues["ParameterName"]) || string.IsNullOrEmpty((string)e.NewValues["ParameterValue"]))
                {
                    alert.MessageString(Alert.WARNING, "Add Authentication", "Parameter is not complete", this.Page, GetType());
                    e.Cancel = true;
                    return;
                }

                Response = DbTransaction.DbToString("dbo.sp_AddUserAuthentication", new
                {
                    username  = txtusername.Text,
                    name      = e.NewValues["ParameterName"],
                    value     = e.NewValues["ParameterValue"],
                    userlogin = UserProfile.Username
                }, true);

                if (Response.Contains("Success"))
                {
                    alert.MessageString(Alert.SUCCESS, "Add Authentication", Response, this.Page, GetType());
                    e.Cancel = true;
                    gridAuth.CancelEdit();
                }
                else
                {
                    alert.MessageString(Alert.WARNING, "Add Authentication", Response, this.Page, GetType());
                    e.Cancel = true;
                }
            }
            catch (Exception ex)
            {
                alert.MessageString(Alert.ERROR, "Add Authentication", ex.Message, this.Page, GetType());
            }
        }
コード例 #8
0
        protected void UsersGridView_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            BootstrapGridView grid = sender as BootstrapGridView;
            var manager            = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();
            var user = new ApplicationUser()
            {
                UserName = e.NewValues["Email"].ToString(), Email = e.NewValues["Email"].ToString(), PhoneNumber = e.NewValues["PhoneNumber"]?.ToString() ?? string.Empty
            };
            IdentityResult result = manager.Create(user, "password123");

            grid.CancelEdit();
            e.Cancel = true;
            if (!result.Succeeded)
            {
                throw new Exception(result.Errors.FirstOrDefault());
            }

            grid.DataBind();
        }
コード例 #9
0
        protected void gv_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            BootstrapGridView gv = (BootstrapGridView)sender;

            MasterDataModel.MasterDataDistance item = new MasterDataModel.MasterDataDistance();
            item.TBBM_ID     = Convert.ToInt32(e.Keys[0]);
            item.SPSH_ID     = Convert.ToString(e.Keys[1]);
            item.Distance    = Convert.ToDecimal(e.NewValues["Distance"]);
            item.NormalRate  = Convert.ToDecimal(e.NewValues["NormalRate"]);
            item.SpecialRate = Convert.ToDecimal(e.NewValues["SpecialRate"]);
            item.UpdateBy    = UserProfile.Username;

            string res = MasterDataEntity.EditMasterDataDistance(item);

            gv.JSProperties["cpRes"] = res;

            e.Cancel = true;

            if (res.Contains("Success"))
            {
                gv.CancelEdit();
                gv.DataBind();
            }
        }