Пример #1
0
        public ActionResult GetStates(JqGridSettings gridSettings)
        {
            var states    = DatabaseDAL.GetAllStates();
            var stateList = new List <State>();

            foreach (var state in states)
            {
                stateList.Add(state);
            }

            int totalPages;
            int totalRecords;
            var allStates = stateList.AsQueryable();

            var          results = jqGridDataManager.GetGridData <State>(gridSettings, allStates, out totalPages, out totalRecords);
            JqGridResult result  = new JqGridResult()
            {
                Page    = gridSettings.PageIndex,
                Records = totalRecords,
                Total   = totalPages,
                Rows    = results.ToList()
            };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public void ParceRequest()
        {
            HttpRequest r       = _context.Request;
            string      type    = r["type"];
            string      jdata   = r["jdata"];
            string      rResult = String.Empty;


            if (!String.IsNullOrWhiteSpace(type))
            {
                switch (type)
                {
                case "getpage":
                    int departmentId = Convert.ToInt32(r["departmentID"]);

                    PageSettings gridSettings = JqGridSettings.GetPageSettings(_context);

                    MembershipUserCollection users = Membership.GetAllUsers();

                    //users[0]

                    //DataTable dtPage = WorkerDocumets.GetPage(gridSettings, UserId, departmentId);
                    //JqGridResults jqGridResults = DocTemplate.BuildJqGridResults(dtPage, gridSettings);

                    //rResult = new JavaScriptSerializer().Serialize(jqGridResults);
                    break;
                }
                if (!String.IsNullOrWhiteSpace(rResult))
                {
                    _context.Response.Write(rResult);
                }
            }
        }
Пример #3
0
        public ActionResult GetCustomers(JqGridSettings gridSettings)
        {
            int totalPages;
            int totalRecords;
            var allProducts = DatabaseDAL.GetAllProductModels();

            var results =
                jqGridDataManager.GetGridData <ProductModel>(gridSettings,
                                                             allProducts,
                                                             out totalPages,
                                                             out totalRecords);
            JqGridResult result = new JqGridResult()
            {
                Page    = gridSettings.PageIndex,
                Records = totalRecords,
                Total   = totalPages,
                Rows    = results.ToList()
            };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Пример #4
0
        public void ParceRequest()
        {
            HttpRequest  r       = _context.Request;
            HttpResponse res     = _context.Response;
            string       type    = r["type"];
            string       jdata   = r["jdata"];
            string       rResult = String.Empty;


            if (!String.IsNullOrWhiteSpace(type))
            {
                switch (type)
                {
                case "getpage":
                    int departmentId = Convert.ToInt32(r["departmentID"]);

                    PageSettings gridSettings = JqGridSettings.GetPageSettings(_context);

                    DataTable     dtPage        = AdminDocumets.GetPage(gridSettings, UserId, departmentId);
                    JqGridResults jqGridResults = AdminDocumets.BuildJqGridResults(dtPage, gridSettings);

                    rResult = new JavaScriptSerializer().Serialize(jqGridResults);
                    break;

                case "getreplaypage":
                    rResult = GetReplayPage(r);
                    break;

                case "getpagedoc":
                    int depId = Convert.ToInt32(r["dep"]);
                    GetPageRtf(depId);
                    break;
                }
                if (!String.IsNullOrWhiteSpace(rResult))
                {
                    res.Write(rResult);
                }
            }
        }
Пример #5
0
        private string GetReplayPage(HttpRequest r)
        {
            int documentId = Convert.ToInt32(r["documentId"]);

            PageSettings gridSettings = JqGridSettings.GetPageSettings(_context);

            DataTable dtPage = AdminDocumets.GetReplayPage(gridSettings, UserId, documentId);

            JqGridResults    result = new JqGridResults();
            List <JqGridRow> rows   = new List <JqGridRow>();

            if (dtPage != null)
            {
                foreach (DataRow dr in dtPage.Rows)
                {
                    JqGridRow row = new JqGridRow();
                    row.id   = (int)dr["DocTemplateID"];
                    row.cell = new string[20];

                    row.cell[0] = dr["DocTemplateID"].ToString();
                    row.cell[1] = dr["DocumentID"].ToString();

                    row.cell[2] = ((DateTime)dr["CreationDate"]).ToString("dd.MM.yyyy", CultureInfo.CurrentCulture);

                    row.cell[3] = (string)dr["Number"];
                    row.cell[4] = dr["ExternalNumber"].ToString();

                    row.cell[5]  = (string)dr["Content"];
                    row.cell[6]  = (string)dr["Changes"];
                    row.cell[7]  = (string)dr["Notes"];
                    row.cell[8]  = dr["IsControlled"].ToString();
                    row.cell[9]  = dr["IsSpeciallyControlled"].ToString();
                    row.cell[10] = dr["IsIncreasedControlled"].ToString();
                    row.cell[11] = dr["IsInput"].ToString();
                    row.cell[12] = dr["DocTypeID"].ToString();
                    row.cell[13] = (string)dr["DocTypeName"];
                    row.cell[14] = dr["DocStatusID"].ToString();
                    row.cell[15] = (string)dr["DocStatusName"];
                    row.cell[16] = dr["DocumentCodeID"].ToString();
                    row.cell[17] = dr["QuestionTypeID"].ToString();
                    row.cell[18] = (string)dr["QuestionTypeName"];

                    string destination = String.Empty;

                    if (DBNull.Value != dr["OrganizationID"] && (int)dr["OrganizationID"] > 0)
                    {
                        destination = (string)dr["OrganizationName"];
                    }
                    if (DBNull.Value != dr["DepartmentID"] && (int)dr["DepartmentID"] > 0)
                    {
                        destination = destination == String.Empty ? destination : ", ";
                        destination = destination + (string)dr["DepartmentName"];
                    }
                    if (DBNull.Value != dr["WorkerID"] && (int)dr["WorkerID"] > 0)
                    {
                        destination = destination == String.Empty ? destination : ", ";
                        destination = destination + FormatHelper.FormatToLastNameAndInitials((string)dr["WorkerLastName"],
                                                                                             (string)dr["WorkerFirstName"],
                                                                                             (string)dr["WorkerMiddleName"]);
                    }

                    row.cell[19] = destination;

                    rows.Add(row);
                }
            }
            result.rows = rows.ToArray();
            result.page = gridSettings.PageIndex;
            if (gridSettings.TotalRecords % gridSettings.PageSize == 0)
            {
                result.total = gridSettings.TotalRecords / gridSettings.PageSize;
            }
            else
            {
                result.total = gridSettings.TotalRecords / gridSettings.PageSize + 1;
            }
            result.records = gridSettings.TotalRecords;

            return(new JavaScriptSerializer().Serialize(result));
        }
Пример #6
0
        private string GetStatementsPage(HttpRequest r)
        {
            int documentId = Convert.ToInt32(r["documentId"]);

            PageSettings pageSettings = JqGridSettings.GetPageSettings(_context);

            DataTable dataTable = WorkerDocumets.GetStatementsPage(pageSettings, UserId, Worker.DepartmentID);

            JqGridResults    result = new JqGridResults();
            List <JqGridRow> rows   = new List <JqGridRow>();

            if (dataTable != null)
            {
                foreach (DataRow dr in dataTable.Rows)
                {
                    JqGridRow row = new JqGridRow();
                    row.id   = (int)dr["DocStatementID"];
                    row.cell = new string[20];

                    row.cell[0] = dr["DocStatementID"].ToString();
                    row.cell[1] = dr["DocumentID"].ToString();

                    row.cell[2] = ((DateTime)dr["CreationDate"]).ToString("yyyy-MM-dd");

                    row.cell[3] = FormatHelper.FormatToLastNameAndInitials((string)dr["CitizenLastName"],
                                                                           (string)dr["CitizenFirstName"],
                                                                           (string)dr["CitizenMiddleName"]);

                    row.cell[4] = String.Format("{0} {1} {2}", dr["CitizenLastName"], dr["CitizenFirstName"],
                                                dr["CitizenMiddleName"]);

                    if ((string)dr["CityObjectTypeShortName"] == "н")
                    {
                        row.cell[5] = (string)dr["Address"];
                    }
                    else
                    {
                        row.cell[5] = FormatHelper.FormatAddress((string)dr["Address"],
                                                                 (string)dr["CityObjectTypeShortName"],
                                                                 (string)dr["CityObjectName"],
                                                                 (string)dr["HouseNumber"], (string)dr["Corps"],
                                                                 (string)dr["ApartmentNumber"]);
                    }

                    row.cell[6] = FormatHelper.FormatToLastNameAndInitials((string)dr["HeadLastName"],
                                                                           (string)dr["HeadFirstName"],
                                                                           (string)dr["HeadMiddleName"]);

                    row.cell[7] = (string)dr["Number"];
                    row.cell[8] = dr["ExternalNumber"].ToString();

                    row.cell[9]  = (string)dr["Content"];
                    row.cell[10] = dr["DeliveryTypeID"].ToString();
                    row.cell[11] = dr["InputDocTypeID"].ToString();
                    row.cell[12] = dr["InputMethodID"].ToString();
                    row.cell[13] = dr["InputSignID"].ToString();
                    row.cell[14] = dr["InputSubjectTypeID"].ToString();

                    row.cell[15] = dr["ControlCardID"].ToString();
                    row.cell[16] = dr["OpenWorker"].ToString();
                    row.cell[17] = dr["HasSubCards"].ToString();
                    row.cell[18] = dr["IsControlled"].ToString();
                    if (DBNull.Value == dr["ControlEndDate"])
                    {
                        row.cell[19] = String.Empty;
                    }
                    else
                    {
                        row.cell[19] = ((DateTime)dr["ControlEndDate"]).ToString("yyyy-MM-dd");
                    }

                    rows.Add(row);
                }
            }
            result.rows = rows.ToArray();
            result.page = pageSettings.PageIndex;
            if (pageSettings.TotalRecords % pageSettings.PageSize == 0)
            {
                result.total = pageSettings.TotalRecords / pageSettings.PageSize;
            }
            else
            {
                result.total = pageSettings.TotalRecords / pageSettings.PageSize + 1;
            }
            result.records = pageSettings.TotalRecords;

            return(new JavaScriptSerializer().Serialize(result));
        }
Пример #7
0
        public void ParceRequest()
        {
            HttpRequest  r       = _context.Request;
            HttpResponse res     = _context.Response;
            string       type    = r["type"];
            string       jdata   = r["jdata"];
            string       rResult = String.Empty;


            if (!String.IsNullOrWhiteSpace(type))
            {
                switch (type)
                {
                case "getblank":
                    if (!String.IsNullOrWhiteSpace(jdata))
                    {
                        int id;
                        if (int.TryParse(jdata, out id))
                        {
                            rResult = GetDocTemplateBlank(id);
                        }
                        else
                        {
                            throw new ArgumentException("Inuput id is not valid", "jdata");
                        }
                    }
                    else
                    {
                        throw new ArgumentNullException("jdata", "Inuput id is not valid");
                    }
                    break;

                case "getpage":
                    int departmentId = Convert.ToInt32(r["departmentID"]);

                    PageSettings gridSettings = JqGridSettings.GetPageSettings(_context);

                    DataTable     dtPage        = WorkerDocumets.GetPage(gridSettings, UserId, Worker.DepartmentID);
                    JqGridResults jqGridResults = WorkerDocumets.BuildPageResults(dtPage, gridSettings);

                    rResult = new JavaScriptSerializer().Serialize(jqGridResults);
                    break;

                case "getoutputpage":
                    rResult = GetOutputPage(r);
                    break;

                case "getdraftpage":
                    rResult = GetDraftPage(r);
                    break;

                case "getreplaypage":
                    rResult = GetReplayPage(r);
                    break;

                case "draft":
                    if (!String.IsNullOrWhiteSpace(jdata))
                    {
                        DocTemplate docTemplate = null;
                        try
                        {
                            docTemplate = JsonConvert.DeserializeObject <DocTemplate>(jdata, new DateTimeConvertorSql());
                        }
                        catch (Exception)
                        {
                            throw new CustomException.CustomException("Not valid json object");
                        }

                        if (docTemplate.ID == 0)
                        {
                            ProcessingResult pr = InsertDocTemplate(docTemplate);
                            rResult = new JavaScriptSerializer().Serialize(pr);
                        }
                        else
                        {
                            ProcessingResult pr = UpdateDocTemplate(docTemplate);
                            rResult = new JavaScriptSerializer().Serialize(pr);
                        }
                    }
                    else
                    {
                        throw new ArgumentNullException("jdata", "Inuput id is not valid");
                    }
                    break;

                case "del":
                    if (!String.IsNullOrWhiteSpace(jdata))
                    {
                        int id;
                        if (int.TryParse(jdata, out id))
                        {
                            ProcessingResult pr = DeleteDocTemplate(id);
                            rResult = new JavaScriptSerializer().Serialize(pr);
                        }
                        else
                        {
                            throw new ArgumentException("Inuput id is not valid", "jdata");
                        }
                    }
                    else
                    {
                        throw new ArgumentNullException("jdata", "Inuput id is not valid");
                    }
                    break;

                case "getstpage":
                    rResult = GetStatementsPage(r);
                    break;

                case "getstblank":
                    if (!String.IsNullOrWhiteSpace(jdata))
                    {
                        int id;
                        if (int.TryParse(jdata, out id))
                        {
                            rResult = GetDocStatementBlank(id);
                        }
                        else
                        {
                            throw new ArgumentException("Inuput id is not valid", "jdata");
                        }
                    }
                    else
                    {
                        throw new ArgumentNullException("jdata", "Inuput id is not valid");
                    }
                    break;

                case "getstcount":
                    int departmentId2 = Convert.ToInt32(r["dep"]);
                    rResult = WorkerDocumets.GetCountNotOpenByDocStatement(UserId, departmentId2).ToString();
                    break;

                case "getdtcount":
                    int departmentId3 = Convert.ToInt32(r["dep"]);
                    rResult = WorkerDocumets.GetCountNotOpenByDocTemplate(UserId, departmentId3).ToString();
                    break;

                case "getstconcount":
                    int departmentId4 = Convert.ToInt32(r["dep"]);
                    rResult = WorkerDocumets.GetCountControlledByDocStatement(UserId, departmentId4).ToString();
                    break;

                case "getdtconcount":
                    int departmentId5 = Convert.ToInt32(r["dep"]);
                    rResult = WorkerDocumets.GetCountControlledByDocTemplate(UserId, departmentId5).ToString();
                    break;

                case "openworker":
                    int controlCardId = 0;
                    int documentId    = 0;
                    if (String.IsNullOrWhiteSpace(r["DocumentID"]))
                    {
                        throw new ArgumentNullException("DocumentID", "Inuput controlCardId is not valid");
                    }
                    else
                    {
                        documentId = Convert.ToInt32(r["DocumentID"]);
                    }
                    if (!String.IsNullOrWhiteSpace(r["ControlCardID"]))
                    {
                        controlCardId = Convert.ToInt32(r["ControlCardID"]);
                    }

                    if (documentId > 0)
                    {
                        rResult = SetOpenWorker(documentId, controlCardId).ToString();
                    }
                    else
                    {
                        throw new ArgumentException("Inuput DocumentID is not valid", "DocumentID");
                    }
                    break;
                }
                if (!String.IsNullOrWhiteSpace(rResult))
                {
                    res.Write(rResult);
                }
            }
        }