示例#1
0
        public JsonResult ValidateEntryForUpdate(string username, string equipment, int ID)
        {
            int count = 0;

            //get the result
            count = UserEquipmentModels.CheckEntryForUpdate(username, equipment, ID);

            return(Json(count, JsonRequestBehavior.AllowGet));
        }
        public JsonResult ValidateEntryWithHost(string username, string equipment, string host)
        {
            int count = 0;

            //get the result
            count = UserEquipmentModels.CheckEntryWithHost(username, equipment, host);

            return(Json(count, JsonRequestBehavior.AllowGet));
        }
示例#3
0
        public JsonResult DeleteEquipment(string equipmentID)
        {
            var result = HttpHandler.DeleteEquipment(equipmentID);

            if (result == "True")
            {
                var temp_result = UserEquipmentModels.DeleteUserEquipmentByBatch(equipmentID);
                result = temp_result.ToString();
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public JsonResult DeleteEquipmentType(string ID)
        {
            var result = EquipTypeModels.DeleteEquipmentType(ID);

            DataTable dt = new DataTable();

            if (result == true)
            {
                dt = EquipmentModels.GetEquipmentByType(ID);

                int count = 0;
                try
                {
                    count = dt.Rows.Count;
                }
                catch
                {
                    count = 0;
                }

                if (count > 0)
                {
                    result = EquipmentModels.DeleteEquipmentByType(ID);
                }

                bool temp = result;
                if (result == true)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        int EquipID = Convert.ToInt32(dr["ID"].ToString());
                        result = UserEquipmentModels.DeleteUserEquipmentByBatch(EquipID.ToString());
                        if (result == true)
                        {
                            temp = true;
                        }
                    }
                }

                result = temp;
            }

            return(Json(result.ToString(), JsonRequestBehavior.AllowGet));
        }
示例#5
0
        public JsonResult GetUserEquipmentList()
        {
            //create a dictionary that will contain the column + datafied config for the grid
            Dictionary <string, object> result_config = new Dictionary <string, object>();

            //get columns
            Dictionary <string, string> columns = UserEquipmentModels.GetCols();

            //check for filters
            string where = "";
            Dictionary <string, string> filters = new Dictionary <string, string>();

            if (Request["filterscount"] != null && Int32.Parse(Request["filterscount"]) > 0)
            {
                for (int i = 0; i < Int32.Parse(Request["filterscount"]); i++)
                {
                    filters.Add("filtervalue" + i, Request["filtervalue" + i]);
                    filters.Add("filtercondition" + i, Request["filtercondition" + i]);
                    filters.Add("filterdatafield" + i, Request["filterdatafield" + i]);
                    filters.Add("filteroperator" + i, Request["filteroperator" + i]);
                }
                where = custom_helper.FormatFilterConditions(filters, Int32.Parse(Request["filterscount"]), columns);
            }

            //check for sorting ops
            string sorting = "";

            if (Request["sortdatafield"] != null)
            {
                sorting = Request["sortdatafield"].ToString() + " " + Request["sortorder"].ToString().ToUpper();
            }

            //determine if cols_only
            if (Request["cols_only"] != null && bool.Parse(Request["cols_only"]) == true)
            {
                //get total row count
                int totalRows = UserEquipmentModels.GetCount(where, ((Request["searchStr"] == null) ? "" : Request["searchStr"].ToString()));

                //prepare column config
                var cols = new List <string>();
                foreach (var item in columns)
                {
                    cols.Add(item.Value);
                }

                Dictionary <string, object> cols_arr = custom_helper.PrepareStaticColumns(cols);
                result_config.Add("column_config", custom_helper.PrepareColumns(cols_arr));
                result_config.Add("TotalRows", totalRows);
            }
            else
            {
                //pagination initialization
                int pagenum  = Request["pagenum"] == null ? 0 : Int32.Parse(Request["pagenum"].ToString());
                int pagesize = Request["pagesize"] == null ? 0 : Int32.Parse(Request["pagesize"].ToString());
                int start    = pagenum * pagesize;

                //get data
                DataTable transactions = new DataTable();
                if (Request["showAll"] != null && bool.Parse(Request["showAll"]) == true)
                {
                    transactions = UserEquipmentModels.GetData(0, 0, where, sorting, ((Request["searchStr"] == null) ? "" : Request["searchStr"].ToString()));
                }
                else
                {
                    transactions = UserEquipmentModels.GetData(start, pagesize, where, sorting, ((Request["searchStr"] == null) ? "" : Request["searchStr"].ToString()));
                }

                //convert data into json object
                var data = custom_helper.DataTableToJson(transactions);

                result_config.Add("data", data);

                //prepare column config
                var cols = new List <string>();
                foreach (DataColumn column in transactions.Columns)
                {
                    cols.Add(column.ColumnName);
                }
                Dictionary <string, object> cols_arr = custom_helper.PrepareStaticColumns(cols);
                result_config.Add("column_config", custom_helper.PrepareColumns(cols_arr));
                result_config.Add("TotalRows", UserEquipmentModels.GetCount(where, ((Request["searchStr"] == null) ? "" : Request["searchStr"].ToString())));
            }
            string temp = Request["searchStr"];

            response.Add("success", true);
            response.Add("error", false);
            response.Add("message", result_config);

            return(Json(response, JsonRequestBehavior.AllowGet));
        }