Пример #1
0
        protected void GridView_InitNewRow(object sender, DevExpress.Web.Data.ASPxDataInitNewRowEventArgs e)
        {
            EquTypeVM CloneItem = new EquTypeVM();

            if (bool.Parse(HttpContext.Current.Session["isCloneRow_Com"].ToString()) == true && GridView.FocusedRowIndex >= 0)
            {
                //List<int> selectedIds = GridView.GetSelectedFieldValues("Id").ConvertAll(id => (int)id);
                //CloneItem = EquTypeProvider.GetSingleById(selectedIds.Last());

                CloneItem = Mapper.Map <EquTypeVM>(EquTypeProvider.GetSingleById(GridView.GetRowValues(GridView.FocusedRowIndex, "Id").ToString()));


                HttpContext.Current.Session["isCloneRow_Com"] = false;

                PropertyInfo myFieldInfo;
                foreach (var myProperty in typeof(EquTypeVM).GetProperties())
                {
                    myFieldInfo = typeof(EquTypeVM).GetProperty(myProperty.Name);
                    if (myFieldInfo == null)
                    {
                        continue;
                    }
                    var ttt = myFieldInfo.GetValue(CloneItem);

                    e.NewValues[myProperty.Name] = myFieldInfo.GetValue(CloneItem);
                }
            }
        }
Пример #2
0
        private void UpdateNavBarName()
        {
            List <bool> ActivedList = new List <bool>();
            List <bool> BlockedList = new List <bool>();

            for (int i = 0; i < GridView.VisibleRowCount; i++)
            {
                ActivedList.Add((bool)GridView.GetRowValues(i, "Actived"));
                BlockedList.Add((bool)GridView.GetRowValues(i, "Blocked"));
            }
            GridView.JSProperties["cpActived"] = ActivedList;
            GridView.JSProperties["cpBlocked"] = BlockedList;


            HttpContext.Current.Session["isActBloChanged_Com"] = false;

            GridView.JSProperties["cpAllCount"] = EquTypeProvider.Count(x => true);
            GridView.JSProperties["cpInActivedUnBlockedCount"] = EquTypeProvider.Count(x => x.Actived == false && x.Blocked == false);
            GridView.JSProperties["cpActivedBlockedCount"]     = EquTypeProvider.Count(x => x.Actived == true && x.Blocked == true);
            GridView.JSProperties["cpInactivedBlockedCount"]   = EquTypeProvider.Count(x => x.Actived == false && x.Blocked == true);
            GridView.JSProperties["cpActivedUnBlockedCount"]   = EquTypeProvider.Count(x => x.Actived == true && x.Blocked == false);
            GridView.JSProperties["cpUpdatedByCount"]          = EquTypeProvider.Count(x => x.CreatedBy == User.Identity.Name || x.UpdatedBy == User.Identity.Name);
        }
Пример #3
0
        protected void GridView_CustomCallback(object sender, DevExpress.Web.ASPxGridViewCustomCallbackEventArgs e)
        {
            switch (e.Parameters)
            {
            case "CloneRow":
                HttpContext.Current.Session["isCloneRow_Com"] = true;
                GridView.JSProperties["cpMessage"]            = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString());
                break;

            case "DetailRow":
                HttpContext.Current.Session["isDetailRow_Com"] = true;
                GridView.JSProperties["cpMessage"]             = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString());
                break;

            case "Actived":
                if (GridView.FocusedRowIndex >= 0)
                {
                    var itemID = GridView.GetRowValues(GridView.FocusedRowIndex, "Id").ToString();
                    EquTypeProvider.SetActived(itemID, true);
                    GridView.DataBind();
                    UpdateNavBarName();
                }
                GridView.JSProperties["cpMessage"] = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString());
                break;

            case "InActived":
                if (GridView.FocusedRowIndex >= 0)
                {
                    var itemID = GridView.GetRowValues(GridView.FocusedRowIndex, "Id").ToString();
                    EquTypeProvider.SetActived(itemID, false);
                    GridView.DataBind();
                    UpdateNavBarName();
                }
                GridView.JSProperties["cpMessage"] = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString());
                break;

            case "Blocked":
                if (GridView.FocusedRowIndex >= 0)
                {
                    var itemID = GridView.GetRowValues(GridView.FocusedRowIndex, "Id").ToString();
                    EquTypeProvider.SetBlocked(itemID, true, User.Identity.Name);
                    GridView.DataBind();
                    UpdateNavBarName();
                }
                GridView.JSProperties["cpMessage"] = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString());
                break;

            case "UnBlocked":
                if (GridView.FocusedRowIndex >= 0)
                {
                    var itemID = GridView.GetRowValues(GridView.FocusedRowIndex, "Id").ToString();
                    EquTypeProvider.SetBlocked(itemID, false, User.Identity.Name);
                    GridView.DataBind();
                    UpdateNavBarName();
                }
                GridView.JSProperties["cpMessage"] = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString());
                break;

            case "InActivedBlocked":
                if (GridView.FocusedRowIndex >= 0)
                {
                    var itemID = GridView.GetRowValues(GridView.FocusedRowIndex, "Id").ToString();
                    EquTypeProvider.SetActivedBlocked(itemID, false, true, User.Identity.Name);
                    GridView.DataBind();
                    UpdateNavBarName();
                }
                GridView.JSProperties["cpMessage"] = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString());
                break;

            case "ActivedUnBlocked":
                if (GridView.FocusedRowIndex >= 0)
                {
                    var itemID = GridView.GetRowValues(GridView.FocusedRowIndex, "Id").ToString();
                    EquTypeProvider.SetActivedBlocked(itemID, true, false, User.Identity.Name);
                    GridView.DataBind();
                    UpdateNavBarName();
                }
                GridView.JSProperties["cpMessage"] = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString());
                break;

            case "Delete":
                if (GridView.FocusedRowIndex >= 0)
                {
                    var itemID = GridView.GetRowValues(GridView.FocusedRowIndex, "Id").ToString();
                    EquTypeProvider.Delete(itemID);
                    //EquTypeProvider.Delete(itemID);
                    GridView.DataBind();
                    UpdateNavBarName();
                }
                GridView.JSProperties["cpMessage"] = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString());
                break;

                //case "Delete":
                //List<int> selectedIds = GridView.GetSelectedFieldValues("Id").ConvertAll(id => (int)id);
                //foreach (var item in selectedIds)
                //{
                //    EquTypeProvider.DeleteSuit(item, false);
                //    HttpContext.Current.Session["isActBloChanged_Com"] = true;
                //}
                //GridView.DataBind();
                //GridView.JSProperties["cpMessage"] = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString());
                //break;
            }
            //if ( e.Parameters.Substring(0,7) == CommonConstants.Tokens_Callback)
            //{
            //    string Standards = e.Parameters.Substring(7);
            //    long SumPrice = StandardProvider.SumPrice(Standards);
            //    GridView.JSProperties["cpParameters"] = CommonConstants.Tokens_Callback + SumPrice;
            //    return;
            //}
            GridView.JSProperties["cpParameters"] = e.Parameters;
        }