protected void gvMain_StartRowEditing(object sender, DevExpress.Web.Data.ASPxStartRowEditingEventArgs e)
        {
            ASPxGridView gv = sender as ASPxGridView;

            gv.SettingsText.PopupEditFormCaption = "Edit Form - Ticket # " + e.EditingKeyValue.ToString();
            SetMandatory();
            Session["Init"] = "0";

            //If user is manager, it can edit all records, otherwise only your own ticket
            string sql             = "SELECT IsManager from aspnet_Users WHERE UserName = @UserName";
            List <SqlParameter> sp = new List <SqlParameter>()
            {
                new SqlParameter()
                {
                    ParameterName = "UserName", SqlDbType = SqlDbType.NVarChar, Value = User.Identity.Name
                }
            };
            bool IsManager = bool.Parse(DataBase.GetDT(sp, sql, "ApplicationServices").Rows[0][0].ToString());
            bool IsOwner   = false;

            if (User.Identity.Name == gv.GetRowValuesByKeyValue(e.EditingKeyValue, "UserName").ToString())
            {
                IsOwner = true;
            }

            if (!IsManager && !IsOwner)
            {
                gvMain.JSProperties["cpMessage"] = "You may only edit tickets that you have created. Managers can edit any ticket -- if you feel you need to be assigned as Manager, please send a request to your administrator.";
                e.Cancel = true;
                gvMain.CancelEdit();
            }
        }
Example #2
0
 protected override void PrepareControlHierarchy()
 {
     base.PrepareControlHierarchy();
     if (!Page.IsCallback)
     {
         gdvDataList.DataBind();
         object obj = null;
         if (SelectedValueID > 0)
         {
             obj = gdvDataList.GetRowValuesByKeyValue(SelectedValueID, "Code", "Name");
         }
         if (obj != null)
         {
             object[] objs = (object[])obj;
             hddData.Set(HKEY_ID, SelectedValueID);
             bteTextInput.Text = objs[0].ToString();
             hddData.Set(HKEY_TXTINPUT, bteTextInput.Text);
             lblName.Text = objs[1].ToString();
         }
         else
         {
             hddData.Set(HKEY_ID, 0);
             hddData.Set(HKEY_TXTINPUT, string.Empty);
             bteTextInput.Text = string.Empty;
             lblName.Text      = string.Empty;
         }
     }
 }
 protected override void PrepareControlHierarchy()
 {
     base.PrepareControlHierarchy();
     if (!IsCallback)
     {
         gdvMFCustomers.DataBind();
         object obj = null;
         if (SelectedMFCustomerID > 0)
         {
             obj = gdvMFCustomers.GetRowValuesByKeyValue(SelectedMFCustomerID, "CustomerNO", "CustomerName");
         }
         if (obj != null)
         {
             object[] objs = (object[])obj;
             hddMFCustomers.Set(HKEY_ID, SelectedMFCustomerID);
             bteMFCustomers.Text = objs[0].ToString();
             hddMFCustomers.Set(HKEY_NO, bteMFCustomers.Text);
             lblCustomerName.Text = objs[1].ToString();
         }
         else
         {
             hddMFCustomers.Set(HKEY_ID, 0);
             hddMFCustomers.Set(HKEY_NO, string.Empty);
             bteMFCustomers.Text  = string.Empty;
             lblCustomerName.Text = string.Empty;
         }
     }
 }
Example #4
0
        protected void ASPxGridView1_RowUpdating(object sender, ASPxDataUpdatingEventArgs e)
        {
            ASPxGridView grid = (ASPxGridView)sender;

            DataType dataType = (DataType)grid.GetRowValuesByKeyValue(e.Keys[0], "Type");

            string editorID = string.Empty;

            switch (dataType)
            {
            case DataType.Text:
                editorID = "txt";
                break;

            case DataType.DateTime:
                editorID = "date";
                break;

            case DataType.Dictionary1:
                editorID = "dict";
                break;

            case DataType.Dictionary2:
                editorID = "dict";
                break;
            }

            ASPxEdit editor = (ASPxEdit)grid.FindEditFormTemplateControl(editorID);

            e.NewValues["DataValue"] = editor.Value.ToString();
        }
Example #5
0
    /// <summary>
    /// fires when edit row get current value of combobox and populate on combobox databound or we will lose initial text
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void dxgridTitles_StartRowEditing(object sender, DevExpress.Web.Data.ASPxStartRowEditingEventArgs e)
    {
        ASPxGridView _grid = (ASPxGridView)sender;

        string[] _fields = { "Title" };
        string   _title  = _grid.GetRowValuesByKeyValue(e.EditingKeyValue, _fields).ToString();

        Session["Title"] = _title;
    }
 public void DeleteFile(ASPxGridView gv, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
 {
     try{
         string path = gv.GetRowValuesByKeyValue(e.Keys[0], "Path").ToString();
         File.Delete(Server.MapPath(path));
     }
     catch (Exception)
     {
     }
 }
Example #7
0
    protected void grdModifier_RowCommand(object sender, ASPxGridViewRowCommandEventArgs e)
    {
        string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url);

        using (Utils utility = new Utils())
        {
            utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
        try
        {
            if (e.CommandArgs.CommandName == "select")
            {
                ASPxGridView grid = (ASPxGridView)sender;
                object       id_  = e.KeyValue;
                txtModifier.Text           = grid.GetRowValuesByKeyValue(id_, "sz_modifier").ToString();
                txtIDCode.Text             = grid.GetRowValuesByKeyValue(id_, "sz_code").ToString();
                txtModifierDesc.Text       = grid.GetRowValuesByKeyValue(id_, "sz_modifier_desc").ToString();
                txtSelectedModifierID.Text = grid.GetRowValuesByKeyValue(id_, "i_modifier_id").ToString();
                btnAdd.Enabled             = false;
                btnUpdate.Enabled          = true;
            }
        }
        catch (Exception ex)
        {
            Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            using (Utils utility = new Utils())
            {
                utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
            }
            string str2 = "Error Request=" + id + ".Please share with Technical support.";
            base.Response.Redirect("../Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2);
        }

        //Method End
        using (Utils utility = new Utils())
        {
            utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
    }
Example #8
0
        protected void Detail_BatchUpdate(object sender, ASPxDataBatchUpdateEventArgs e)
        {
            DataTable    dt         = new DataTable();
            ASPxGridView EffectGrid = (ASPxGridView)sender;

            foreach (var args in e.UpdateValues)
            {
                string OBID      = args.Keys[0].ToString();// leftrel
                string tag_no    = args.NewValues[3].ToString();
                string right_rel = EffectGrid.GetRowValuesByKeyValue(OBID, "RIGHTREL").ToString();
                string qry       = "  UPDATE TBLSYSTEM_TAGNO SET TAGNO = '" + tag_no + "' ";
                qry = qry + " WHERE LEFTREL = '" + OBID + "' AND RIGHTREL = '" + right_rel + "'  ";
                SqlCommand cmd;
                cmd = new SqlCommand(qry, fgm_moduler.func_Class.conn);
                cmd.ExecuteNonQuery();
            }
        }
Example #9
0
    protected void gvProducts_CustomCallback(object sender, DevExpress.Web.ASPxGridViewCustomCallbackEventArgs e)
    {
        ASPxGridView gridView = sender as ASPxGridView;

        string[] parameters = e.Parameters.Split('|');
        string   command    = parameters[0];

        if (command == "MOVEUP" || command == "MOVEDOWN")
        {
            int focusedRowKey = GetGridViewKeyByVisibleIndex(gridView, gridView.FocusedRowIndex);
            int index         = (int)gridView.GetRowValues(gridView.FocusedRowIndex, "DisplayOrder");
            int newIndex      = index;
            if (command == "MOVEUP")
            {
                newIndex = (index == 0) ? index : index - 1;
            }
            if (command == "MOVEDOWN")
            {
                newIndex = (index == gridView.VisibleRowCount) ? index : index + 1;
            }
            int rowKey = GetKeyIDBySortIndex(gridView, newIndex);
            UpdateSortIndex(focusedRowKey, newIndex);
            UpdateSortIndex(rowKey, index);
            gridView.FocusedRowIndex = gridView.FindVisibleIndexByKeyValue(rowKey);
        }
        if (command == "DRAGROW")
        {
            int draggingIndex     = int.Parse(parameters[1]);
            int targetIndex       = int.Parse(parameters[2]);
            int draggingRowKey    = GetKeyIDBySortIndex(gridView, draggingIndex);
            int targetRowKey      = GetKeyIDBySortIndex(gridView, targetIndex);
            int draggingDirection = (targetIndex < draggingIndex) ? 1 : -1;
            for (int rowIndex = 0; rowIndex < gridView.VisibleRowCount; rowIndex++)
            {
                int rowKey = GetGridViewKeyByVisibleIndex(gridView, rowIndex);
                int index  = (int)gridView.GetRowValuesByKeyValue(rowKey, "DisplayOrder");
                if ((index > Math.Min(targetIndex, draggingIndex)) && (index < Math.Max(targetIndex, draggingIndex)))
                {
                    UpdateSortIndex(rowKey, index + draggingDirection);
                }
            }
            UpdateSortIndex(draggingRowKey, targetIndex);
            UpdateSortIndex(targetRowKey, targetIndex + draggingDirection);
        }
        gridView.DataBind();
    }
Example #10
0
    protected void ASPxGridViewDemo_CellEditorInitialize(object sender, ASPxGridViewEditorEventArgs e)
    {
        if (e.Column != null && e.Column.FieldName == "Type")
        {
            ASPxComboBox comboBox = (ASPxComboBox)e.Editor;
            ASPxGridView gridView = (ASPxGridView)sender;

            IssueType issueType = (IssueType)gridView.GetRowValuesByKeyValue(e.KeyValue, "IssueTypeName");

            /*var filterValues = from issue in Issues
             *                 where issue.Type == issueType
             *                 select issue;*/
            var filterValues = Issues.Where(issue => issue.Type == issueType);

            comboBox.DataSource = filterValues;
            comboBox.DataBindItems();
        }
    }
Example #11
0
        protected void InitializeCombo(ASPxGridViewEditorEventArgs e,
                                       string parentComboName, SqlDataSource source, CallbackEventHandlerBase callBackHandler, ASPxGridView grid)
        {
            string id = string.Empty;

            if (!grid.IsNewRowEditing)
            {
                object val = grid.GetRowValuesByKeyValue(e.KeyValue, parentComboName);
                id = (val == null || val == DBNull.Value) ? null : val.ToString();
            }
            ASPxComboBox combo = e.Editor as ASPxComboBox;

            if (combo != null)
            {
                // unbind combo
                combo.DataSourceID = null;
                FillMenuHijoCombo(combo, id, source);
                combo.Callback += callBackHandler;
            }
            return;
        }
Example #12
0
 protected void grdDetailEntry_HtmlDataCellPrepared(object sender, ASPxGridViewTableDataCellEventArgs e)
 {
     if (e.DataColumn.Name.Equals("AccountId"))
     {
         ASPxGridView grid = sender as ASPxGridView;
         if (grid != null)
         {
             e.Cell.Text = session.GetObjectByKey <NAS.DAL.Accounting.AccountChart.Account>(grid.GetRowValuesByKeyValue(e.KeyValue, "AccountId!Key")).Code;
         }
     }
 }