Beispiel #1
0
        protected void gridListInvoice_DetailRowExpandedChanged(object sender, ASPxGridViewDetailRowEventArgs e)
        {
            //initialize control
            BootstrapGridView grid             = (BootstrapGridView)sender;
            BootstrapTextBox  txtInvoiceNumber = (BootstrapTextBox)grid.FindDetailRowTemplateControl(e.VisibleIndex, "txtInvoiceNumber");
            BootstrapTextBox  txtApproveBy     = (BootstrapTextBox)grid.FindDetailRowTemplateControl(e.VisibleIndex, "txtApproveBy");
            BootstrapDateEdit dateInvoice      = (BootstrapDateEdit)grid.FindDetailRowTemplateControl(e.VisibleIndex, "dateInvoice");
            BootstrapMemo     txtNote          = (BootstrapMemo)grid.FindDetailRowTemplateControl(e.VisibleIndex, "txtNote");

            //bind control
            if (txtInvoiceNumber == null)
            {
                return;
            }

            txtInvoiceNumber.Text = grid.GetRowValues(e.VisibleIndex, "InvoiceNumber").ToString();
            txtApproveBy.Text     = grid.GetRowValues(e.VisibleIndex, "ApproveBy") != null?grid.GetRowValues(e.VisibleIndex, "ApproveBy").ToString() : string.Empty;

            txtNote.Text = grid.GetRowValues(e.VisibleIndex, "Note") != null?grid.GetRowValues(e.VisibleIndex, "Note").ToString() : string.Empty;

            DateTime InvoiceDate = Convert.ToDateTime(grid.GetRowValues(e.VisibleIndex, "InvoiceDate"));

            if (InvoiceDate != DateTime.Parse("1/1/1900"))
            {
                dateInvoice.Value = InvoiceDate;
            }
            else
            {
                dateInvoice.Value = null;
            }
        }
Beispiel #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();
        }
Beispiel #3
0
        protected MasterDataModel.MasterDataKendaraan GetGvValue(BootstrapGridView gv, int key = 0)
        {
            BootstrapComboBox cmbTransportir      = gv.FindEditFormTemplateControl("cmbTransportir") as BootstrapComboBox;
            BootstrapTextBox  txtNumber           = gv.FindEditFormTemplateControl("txtNumber") as BootstrapTextBox;
            BootstrapTextBox  txtCode             = gv.FindEditFormTemplateControl("txtCode") as BootstrapTextBox;
            BootstrapTextBox  txtMerk             = gv.FindEditFormTemplateControl("txtMerk") as BootstrapTextBox;
            BootstrapSpinEdit spinYearManufacture = gv.FindEditFormTemplateControl("spinYearManufacture") as BootstrapSpinEdit;
            BootstrapComboBox cmbVehicleType      = gv.FindEditFormTemplateControl("cmbVehicleType") as BootstrapComboBox;
            BootstrapComboBox cmbVehicleCategory  = gv.FindEditFormTemplateControl("cmbVehicleCategory") as BootstrapComboBox;
            BootstrapSpinEdit spinCapacity        = gv.FindEditFormTemplateControl("spinCapacity") as BootstrapSpinEdit;
            BootstrapComboBox cmbUnitCapacity     = gv.FindEditFormTemplateControl("cmbUnitCapacity") as BootstrapComboBox;

            MasterDataModel.MasterDataKendaraan item = new MasterDataModel.MasterDataKendaraan();
            item.Vehicle_ID         = key;
            item.Transporter_ID     = Convert.ToInt32(cmbTransportir.Value);
            item.Number             = txtNumber.Text;
            item.Code               = txtCode.Text;
            item.Merk               = txtMerk.Text;
            item.YearManufacture    = Convert.ToInt32(spinYearManufacture.Value);
            item.Type_ID            = Convert.ToInt16(cmbVehicleType.Value);
            item.VehicleCategory_ID = Convert.ToInt16(cmbVehicleCategory.Value);
            item.Capacity           = Convert.ToInt32(spinCapacity.Value);
            item.UnitCapacity_ID    = Convert.ToInt32(cmbUnitCapacity.Value);
            item.CreationBy         = UserProfile.Username;
            item.UpdateBy           = UserProfile.Username;

            return(item);
        }
Beispiel #4
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();
        }
Beispiel #5
0
        protected void gridInvoiceItem_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            try
            {
                int key = Convert.ToInt16(e.Keys[0]);
                BootstrapPopupControl popup = popupAddLO;
                BootstrapGridView     grid  = (BootstrapGridView)popup.FindControl("gridAddLO");

                //execute data to database
                ResponseQuery = DbTransaction.DbToString("dbo.sp_DeleteInvoice_Item", new
                {
                    InvoiceNumber = txtInvoiceNumber.Text,
                    LO_ID         = key,
                    userlogin     = UserProfile.Username
                }, true);

                //set gridview invoice item
                e.Cancel = true;
                gridInvoiceItem.DataBind();

                //show notification
                gridInvoiceItem.JSProperties["cpRes"] = ResponseQuery;
            }
            catch (Exception ex)
            {
                gridInvoiceItem.JSProperties["cpRes"] = ex.Message;
            }
        }
        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();
            }
        }
        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();             //綁定
        }
        protected void gvFee_BeforePerformDataSelect(object sender, EventArgs e)
        {
            BootstrapGridView gvFee = (BootstrapGridView)sender;

            int transporter_ID = Convert.ToInt32(gvFee.GetMasterRowKeyValue());

            gvFee.DataSource = MasterDataEntity.GetMasterDataTransporterFee(transporter_ID, CommonDataModel.ActiveType.Active);
        }
        protected void gridSPPBItems_DataBinding(object sender, EventArgs e)
        {
            int SPP_ID = Convert.ToInt32(Session["SPPItem_ID"] ?? 0);

            BootstrapGridView gv = (BootstrapGridView)sender;

            gv.DataSource = GetDataSPPBItem(SPP_ID);
        }
Beispiel #10
0
        protected void gridInvoiceItem_DataBinding(object sender, EventArgs e)
        {
            //initialize parameter
            BootstrapGridView grid = (BootstrapGridView)sender;
            List <InvoiceModel.InvoiceItem> ListInvoiceItem = new List <InvoiceModel.InvoiceItem>();
            string InvoiceNumber = Session["InvoiceNumber"].ToString() ?? string.Empty;

            //set datagrid detail
            ListInvoiceItem = DbTransaction.DbToList <InvoiceModel.InvoiceItem>("dbo.sp_GetInvoice_Items", new { InvoiceNumber = InvoiceNumber }, true);
            grid.DataSource = ListInvoiceItem;
        }
Beispiel #11
0
        protected void gvAuthParameter_DataBinding(object sender, EventArgs e)
        {
            //initialize control
            BootstrapGridView gv          = (BootstrapGridView)gvMasterDataUser;
            BootstrapTextBox  txtusername = (BootstrapTextBox)gv.FindEditFormTemplateControl("txtUserName");
            BootstrapGridView gridAuth    = (BootstrapGridView)gv.FindEditFormTemplateControl("gvAuthParameter");

            string username = gv.GetRowValues(gv.EditingRowVisibleIndex, "Username") == null ? string.Empty : gv.GetRowValues(gv.EditingRowVisibleIndex, "Username").ToString();

            gridAuth.DataSource = ListAuthParameter(username);
        }
Beispiel #12
0
        protected void UsersGridView_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e)
        {
            BootstrapGridView grid = sender as BootstrapGridView;

            if (e.NewValues["Email"] == null)
            {
                e.Errors[grid.Columns["Email"]] = "Обязательное поле для заполнения!";
            }

            if (e.Errors.Count > 0)
            {
                e.RowError = "Пожалуйста, исправьте все ошибки!";
            }
        }
Beispiel #13
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();
        }
Beispiel #14
0
        protected void gridSPPB_SelectionChanged(object sender, EventArgs e)
        {
            BootstrapGridView grid = sender as BootstrapGridView;

            for (int i = 0; i < grid.VisibleRowCount; i++) // Loop through selected rows
            {
                if (grid.Selection.IsRowSelected(i))       // do whatever you need to do with selected row values
                {
                    // now use pre-initialized List<object> selectedList to save
                    string key    = grid.GetRowValues(i, "SPP_ID_PK").ToString();
                    string status = grid.GetRowValues(i, "StatusDesc").ToString();
                    ASPxWebControl.RedirectOnCallback(string.Format("~/Pages/InputSPPB.aspx?SPP_ID={0}&StatusDesc={1}", key, status));
                }
            }
        }
Beispiel #15
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();
        }
Beispiel #16
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();
            }
        }
Beispiel #17
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();
        }
Beispiel #18
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();
            }
        }
Beispiel #19
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();
        }
Beispiel #20
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());
            }
        }
Beispiel #21
0
        protected MasterDataModel.MasterDataTBBM GetGvValue(BootstrapGridView gv, int key = 0)
        {
            BootstrapTextBox  txtName    = gv.FindEditFormTemplateControl("txtName") as BootstrapTextBox;
            BootstrapComboBox cmbRegion  = gv.FindEditFormTemplateControl("cmbRegion") as BootstrapComboBox;
            BootstrapMemo     txtAddress = gv.FindEditFormTemplateControl("txtAddress") as BootstrapMemo;
            BootstrapTextBox  txtTelp    = gv.FindEditFormTemplateControl("txtTelp") as BootstrapTextBox;
            BootstrapTextBox  txtEmail   = gv.FindEditFormTemplateControl("txtEmail") as BootstrapTextBox;

            MasterDataModel.MasterDataTBBM item = new MasterDataModel.MasterDataTBBM();
            item.TBBM_ID_PK   = key;
            item.Region_ID_FK = Convert.ToByte(cmbRegion.Value);
            item.Name         = txtName.Text;
            item.Address      = txtAddress.Text;
            item.Telp         = txtTelp.Text;
            item.Email        = txtEmail.Text;
            item.CreationBy   = UserProfile.Username;
            item.UpdateBy     = UserProfile.Username;

            return(item);
        }
        protected MasterDataModel.MasterDataTransporter GetGvValue(BootstrapGridView gv, int key = 0)
        {
            BootstrapTextBox txtName     = gv.FindEditFormTemplateControl("txtName") as BootstrapTextBox;
            BootstrapMemo    txtAddress  = gv.FindEditFormTemplateControl("txtAddress") as BootstrapMemo;
            BootstrapTextBox txtEmail    = gv.FindEditFormTemplateControl("txtEmail") as BootstrapTextBox;
            BootstrapTextBox txtPhone    = gv.FindEditFormTemplateControl("txtPhone") as BootstrapTextBox;
            BootstrapTextBox txtContact1 = gv.FindEditFormTemplateControl("txtContact1") as BootstrapTextBox;
            BootstrapTextBox txtContact2 = gv.FindEditFormTemplateControl("txtContact2") as BootstrapTextBox;

            MasterDataModel.MasterDataTransporter item = new MasterDataModel.MasterDataTransporter();
            item.Transporter_ID  = key;
            item.TransporterName = txtName.Text;
            item.Address         = txtAddress.Text;
            item.Email           = txtEmail.Text;
            item.Phone           = txtPhone.Text;
            item.Contact1        = txtContact1.Text;
            item.Contact2        = txtContact2.Text;
            item.CreationBy      = UserProfile.Username;
            item.UpdateBy        = UserProfile.Username;

            return(item);
        }
        protected MasterDataModel.MasterDataDriver GetGvValue(BootstrapGridView gv, int key = 0)
        {
            BootstrapTextBox  txtName        = gv.FindEditFormTemplateControl("txtName") as BootstrapTextBox;
            BootstrapComboBox cmbTransportir = gv.FindEditFormTemplateControl("cmbTransportir") as BootstrapComboBox;
            BootstrapDateEdit deBirthday     = gv.FindEditFormTemplateControl("deBirthday") as BootstrapDateEdit;
            BootstrapMemo     txtAddress     = gv.FindEditFormTemplateControl("txtAddress") as BootstrapMemo;
            BootstrapTextBox  txtEmail       = gv.FindEditFormTemplateControl("txtEmail") as BootstrapTextBox;
            BootstrapTextBox  txtPhone1      = gv.FindEditFormTemplateControl("txtPhone1") as BootstrapTextBox;
            BootstrapTextBox  txtPhone2      = gv.FindEditFormTemplateControl("txtPhone2") as BootstrapTextBox;

            MasterDataModel.MasterDataDriver item = new MasterDataModel.MasterDataDriver();
            item.Driver_ID      = key;
            item.Name           = txtName.Text;
            item.Transporter_ID = Convert.ToInt32(cmbTransportir.Value);
            if (deBirthday.Value != null)
            {
                item.Birthday = deBirthday.Date;
            }
            else
            {
                item.Birthday = null;
            }
            item.Address    = txtAddress.Text;
            item.Email      = txtEmail.Text;
            item.Phone1     = txtPhone1.Text;
            item.Phone2     = txtPhone2.Text;
            item.CreationBy = UserProfile.Username;
            item.UpdateBy   = UserProfile.Username;
            if (Session["DriverPhotoImageName"] != null && Session["DriverPhotoImageBytes"] != null)
            {
                item.ImageName  = Convert.ToString(Session["DriverPhotoImageName"]);
                item.ImageBytes = (byte[])Session["DriverPhotoImageBytes"];
                Session["DriverPhotoImageName"]  = null;
                Session["DriverPhotoImageBytes"] = null;
            }

            return(item);
        }
Beispiel #24
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();
            }
        }
Beispiel #25
0
        protected void gvMasterDataUser_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            string response = string.Empty;

            try
            {
                //initialize control
                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");

                //validation input
                if (txtusername.IsValid == false ||
                    txtpassword.IsValid == false ||
                    txtpasswordconfirmation.IsValid == false ||
                    txtemail.IsValid == false ||
                    chkrole.IsValid == false)
                {
                    return;
                }

                if (txtpassword.Text != txtpasswordconfirmation.Text)
                {
                    response = "Password Confirmation is not valid";
                    return;
                }

                //set roles
                string roles = string.Empty;
                if (chkrole.SelectedValues.Count > 0)
                {
                    foreach (string item in chkrole.SelectedValues)
                    {
                        roles = roles + ";" + item;
                    }
                    roles = roles.Substring(1);
                }

                //execute query
                response = DbTransaction.DbToString("dbo.sp_AddMasterDataUser", new
                {
                    username  = txtusername.Text,
                    password  = Encryption.Encrypt(txtpassword.Text),
                    email     = txtemail.Text,
                    telephone = txttelephone.Text,
                    roles     = roles,
                    userlogin = UserProfile.Username
                }, true);
            }
            catch (Exception ex)
            {
                response = ex.Message;
            }
            finally
            {
                gvMasterDataUser.JSProperties["cpRes"] = response;
                e.Cancel = true;
                if (response.Contains("Success"))
                {
                    gvMasterDataUser.CancelEdit();
                }
            }
        }
Beispiel #26
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();
                    }
                }
            }
        }