コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string    sErrMsg   = string.Empty;
            DataTable dataTable = new DataTable();
            DBUtility sqlObj    = null;

            sqlObj = new DBUtility();
            sqlObj.StoreProcedureName = "SP_Qry_MemberClass";
            sqlObj.SetupSqlCommand(ref sErrMsg);
            sqlObj.SqlCmd.Parameters["@Account"].Value = HttpContext.Current.Session["Account"].ToString();
            sqlObj.SqlCmd.Parameters["@XOLTP"].Value   = 5;
            try
            {
                sqlObj.SqlConn.Open();
                SqlDataAdapter da = new SqlDataAdapter(sqlObj.SqlCmd);
                da.Fill(dataTable);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                sqlObj.SqlConn.Close();
            }
            BootstrapGridView.DataSource = dataTable; //告訴GridView資料來源為誰
            BootstrapGridView.DataBind();             //綁定
        }
コード例 #2
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();
        }
コード例 #3
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();
        }
コード例 #4
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();
            }
        }
コード例 #5
0
        protected void gv_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            BootstrapGridView gv = (BootstrapGridView)sender;

            MasterDataModel.MasterDataKendaraan item = new MasterDataModel.MasterDataKendaraan();
            item.Vehicle_ID = (int)e.Keys[0];
            item.UpdateBy   = UserProfile.Username;

            string res = MasterDataEntity.DeleteMasterDataVehicle(item);

            gv.JSProperties["cpRes"] = res;

            e.Cancel = true;
            gv.DataBind();
        }
コード例 #6
0
        protected void gv_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            BootstrapGridView gv = (BootstrapGridView)sender;

            MasterDataModel.MasterDataTBBM item = new MasterDataModel.MasterDataTBBM();
            item.TBBM_ID_PK = Convert.ToInt32(e.Keys[0].ToString());
            item.UpdateBy   = UserProfile.Username;

            string res = MasterDataEntity.DeleteMasterDataTBBM(item);

            gv.JSProperties["cpRes"] = res;

            e.Cancel = true;

            gv.DataBind();
        }
コード例 #7
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();
            }
        }
コード例 #8
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();
            }
        }
コード例 #9
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();
        }
コード例 #10
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();
        }
コード例 #11
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();
            }
        }
コード例 #12
0
        protected void gvMasterDataUser_HtmlEditFormCreated(object sender, DevExpress.Web.ASPxGridViewEditFormEventArgs e)
        {
            string param = Request.Params.Get("__CALLBACKPARAM");

            if (!String.IsNullOrEmpty(param))
            {
                if (!param.Contains("CANCELEDIT"))
                {
                    BootstrapGridView     gv                      = (BootstrapGridView)sender;
                    BootstrapTextBox      txtusername             = (BootstrapTextBox)gv.FindEditFormTemplateControl("txtUserName");
                    BootstrapTextBox      txtpassword             = (BootstrapTextBox)gv.FindEditFormTemplateControl("txtPassword");
                    BootstrapTextBox      txtpasswordconfirmation = (BootstrapTextBox)gv.FindEditFormTemplateControl("txtPasswordConfirmation");
                    BootstrapTextBox      txtemail                = (BootstrapTextBox)gv.FindEditFormTemplateControl("txtEmail");
                    BootstrapTextBox      txttelephone            = (BootstrapTextBox)gv.FindEditFormTemplateControl("txtTelephone");
                    BootstrapCheckBoxList chkrole                 = (BootstrapCheckBoxList)gv.FindEditFormTemplateControl("chkRole");
                    BootstrapGridView     gridAuth                = (BootstrapGridView)gv.FindEditFormTemplateControl("gvAuthParameter");


                    string username  = gv.GetRowValues(gv.EditingRowVisibleIndex, "Username") == null ? string.Empty : gv.GetRowValues(gv.EditingRowVisibleIndex, "Username").ToString();
                    string password  = gv.GetRowValues(gv.EditingRowVisibleIndex, "Password") == null ? string.Empty : gv.GetRowValues(gv.EditingRowVisibleIndex, "Password").ToString();
                    string email     = gv.GetRowValues(gv.EditingRowVisibleIndex, "Email") == null ? string.Empty : gv.GetRowValues(gv.EditingRowVisibleIndex, "Email").ToString();
                    string telephone = gv.GetRowValues(gv.EditingRowVisibleIndex, "Telephone") == null ? string.Empty : gv.GetRowValues(gv.EditingRowVisibleIndex, "Telephone").ToString();
                    string roles     = gv.GetRowValues(gv.EditingRowVisibleIndex, "RoleName") == null ? string.Empty : gv.GetRowValues(gv.EditingRowVisibleIndex, "RoleName").ToString();

                    //set textbox username
                    if (!String.IsNullOrWhiteSpace(username))
                    {
                        txtusername.Text = username;
                    }
                    txtusername.ValidationSettings.RequiredField.IsRequired = true;
                    txtusername.ValidationSettings.RequiredField.ErrorText  = "Field is Required";

                    //set textbox password
                    if (!string.IsNullOrEmpty(password))
                    {
                        txtpassword.Text             = Encryption.Decrypt(password);
                        txtpasswordconfirmation.Text = Encryption.Decrypt(password);
                    }
                    txtpassword.ValidationSettings.RequiredField.IsRequired             = true;
                    txtpassword.ValidationSettings.RequiredField.ErrorText              = "Field is Required";
                    txtpasswordconfirmation.ValidationSettings.RequiredField.IsRequired = true;
                    txtpasswordconfirmation.ValidationSettings.RequiredField.ErrorText  = "Field is Required";

                    //set textbox email
                    if (!String.IsNullOrWhiteSpace(email))
                    {
                        txtemail.Text = email;
                    }
                    txtemail.ValidationSettings.RequiredField.IsRequired = true;
                    txtemail.ValidationSettings.RequiredField.ErrorText  = "Field is Required";
                    txtemail.ValidationSettings.RegularExpression.ValidationExpression = @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
                    txtemail.ValidationSettings.RegularExpression.ErrorText            = "Invalid Email Format";

                    //set textbox telephone
                    if (!String.IsNullOrWhiteSpace(telephone))
                    {
                        txttelephone.Text = telephone;
                    }
                    //txttelephone.ValidationSettings.RequiredField.IsRequired = true;
                    //txttelephone.ValidationSettings.RequiredField.ErrorText = "Field is Required";
                    txttelephone.MaskSettings.Mask = "99999999999999";

                    //set checkbox list role
                    //chkrole.DataSource = ListRole();
                    //chkrole.DataBind();
                    //chkrole.ValueField = "RoleID";
                    //chkrole.TextField = "RoleName";
                    chkrole.ValidationSettings.RequiredField.IsRequired = true;
                    chkrole.ValidationSettings.RequiredField.ErrorText  = "Field is Required";
                    if (!string.IsNullOrEmpty(roles))
                    {
                        string[] rolesid = roles.Split(';');
                        foreach (string item in rolesid)
                        {
                            foreach (BootstrapListEditItem i in chkrole.Items)
                            {
                                if (i.Value.ToString() == item.ToString())
                                {
                                    i.Selected = true;
                                }
                            }
                        }
                    }

                    // set grid auth parameter
                    if (ListAuthParameter(username).Count > 0)
                    {
                        gridAuth.DataBind();
                    }
                }
            }
        }