Exemple #1
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);
        }
Exemple #2
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);
        }
Exemple #3
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());
            }
        }
Exemple #4
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.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);
        }
        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);
        }
Exemple #7
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();
                }
            }
        }
Exemple #8
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();
                    }
                }
            }
        }