Exemplo n.º 1
0
        public AjaxResult GetDataPagination(int pageNumber, int pageSize, [FromBody] List <Filter> filters)
        {
            var ajaxResult = new AjaxResult();

            try
            {
                string where = string.Empty;
                if (filters != null && filters.Count > 0)
                {
                    where = Filter.BuildWhereFilterCondition(filters);
                }
                using (DocumentBL _documentBL = new DocumentBL())
                {
                    var ajax = _documentBL.GetDataPagination(pageNumber, pageSize, where);
                    ajaxResult.Data       = ajax.Data;
                    ajaxResult.TotalCount = ajax.TotalCount;
                    ajaxResult.Success    = true;
                }
            }
            catch (Exception)
            {
                ajaxResult.Success   = false;
                ajaxResult.Messenger = "Có lỗi xảy ra khi lấy dữ liệu chứng từ. Xin vui lòng liên hệ MISA để giải quyết";
            }
            return(ajaxResult);
        }
Exemplo n.º 2
0
        public JsonResult Delete(string formName, string catName)
        {
            DocumentBL documentBl     = new DocumentBL();
            int        recordaffected = documentBl.DeleteForm(formName);

            #region for Form Archive
            if (recordaffected == 1)
            {
                string archivedFolder  = "~/ArchivedForms/" + catName + "/";
                string uploadedFolder  = "~/Uploads/" + catName + "/";
                string sourcePath      = Server.MapPath(uploadedFolder);
                string destinationPath = Server.MapPath(archivedFolder);
                string uploadedFile    = Path.Combine(sourcePath, formName);
                string archiveFile     = Path.Combine(destinationPath, formName);
                if (System.IO.File.Exists(uploadedFile))
                {
                    if (!Directory.Exists(destinationPath))
                    {
                        Directory.CreateDirectory(destinationPath);
                    }
                    System.IO.File.Move(uploadedFile, archiveFile);
                }
            }
            #endregion
            return(Json(recordaffected, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public static string LoadDocument(int intSchoolID, int intTrustMID, int intStudentMID, int intEmployeeMID)
        {
            try
            {
                #region Bind Section
                DataTable  dtStudent     = new DataTable();
                DocumentBL objDocumentBL = new DocumentBL();
                DocumentBO objDocumentBO = new DocumentBO();

                ApplicationResult objResultSection = new ApplicationResult();
                objResultSection = objDocumentBL.Document_SelectAll_ForDropDown(intSchoolID, intTrustMID, intStudentMID, intEmployeeMID);
                if (objResultSection != null)
                {
                    dtStudent = objResultSection.resultDT;
                    if (dtStudent.Rows.Count > 0)
                    {
                        for (int i = 0; i < dtStudent.Rows.Count; i++)
                        {
                        }
                    }
                }
                string res = "";
                res = DataSetToJSON(dtStudent);
                return(res);

                #endregion
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 4
0
        public void bindSchool()
        {
            try
            {
                #region Bind School

                SchoolBL          objSchoolBL   = new SchoolBL();
                SchoolBO          objSchoolBO   = new SchoolBO();
                DocumentBL        objDocumentBl = new DocumentBL();
                Controls          objControls   = new Controls();
                ApplicationResult objResults    = new ApplicationResult();

                objResults = objSchoolBL.School_SelectAll_All();
                if (objResults != null)
                {
                    if (objResults.resultDT.Rows.Count > 0)
                    {
                        objControls.BindDropDown_ListBox(objResults.resultDT, ddlSchoolID, "SchoolNameEng", "SchoolMID");
                    }
                    ddlSchoolID.Items.Insert(0, new ListItem("-Select-", "-1"));
                }
                #endregion
            }
            catch (Exception ex)
            {
                logger.Error("Error", ex);
                ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Oops! There is some technical issue. Please Contact to your administrator.');</script>");
            }
        }
Exemplo n.º 5
0
        public JsonResult GetFormsByCategoryForDropdown(string categoryId)
        {
            int          catId      = Convert.ToInt32(categoryId);
            DocumentBL   documentBl = new DocumentBL();
            List <Forms> formsList  = new List <Forms>();

            formsList = documentBl.GetFormsByCategoryForDropdown(catId);


            var data = formsList;

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 6
0
        public JsonResult LoadData(string catId)
        {
            int categoryId = Convert.ToInt32(catId);
            int draw, start, length;

            //int pageIndex = 0;

            if (null != Request.Form.GetValues("draw"))
            {
                draw   = int.Parse(Request.Form.GetValues("draw").FirstOrDefault().ToString());
                start  = int.Parse(Request.Form.GetValues("start").FirstOrDefault().ToString());
                length = int.Parse(Request.Form.GetValues("length").FirstOrDefault().ToString());
            }
            else
            {
                draw   = 1;
                start  = 0;
                length = 500;
            }

            //if (start == 0)
            //{
            //    pageIndex = 1;
            //}
            //else
            //{
            //    pageIndex = (start / length) + 1;
            //}

            DocumentBL bL = new DocumentBL(); ///////////////////////////////////////////////////////////////////////////
            //int totalrecords = 0;

            List <Forms> formsList = new List <Forms>();

            formsList = bL.GetFormsListCategoryWise(categoryId);
            List <Forms> formList = new List <Forms>();

            foreach (Forms frm in formsList)
            {
                Forms form = new Forms();
                form.ID        = frm.ID;
                form.RowNumber = frm.RowNumber;
                form.FormName  = frm.FormName;

                formList.Add(form);
            }

            var data = formList;

            return(Json(new { draw = draw, data = data }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 7
0
        public ActionResult UpdateForm()
        {
            DocumentBL           uploadBl     = new DocumentBL();
            List <FormsCategory> catrgoryList = new List <FormsCategory>();

            catrgoryList          = uploadBl.GetCategoryList();
            ViewBag.FormsCategory = catrgoryList.Select(c =>
                                                        new SelectListItem()
            {
                Text  = c.CatecoryName,
                Value = c.ID.ToString()
            }).ToList();
            return(View());
        }
Exemplo n.º 8
0
        public AjaxResult DeleteDocument(Guid DocumentID)
        {
            var ajaxResult = new AjaxResult();

            try
            {
                using (DocumentBL _documentBL = new DocumentBL()) {
                    _documentBL.DeleteDocument(DocumentID);
                    ajaxResult.Success = true;
                }
            }
            catch (Exception)
            {
                ajaxResult.Success   = false;
                ajaxResult.Messenger = "Có lỗi xảy ra khi xóa chứng từ. Xin vui lòng liên hệ MISA để giải quyết";
            }
            return(ajaxResult);
        }
Exemplo n.º 9
0
        public AjaxResult GetDataPagination(int pageNumber, int pageSize)
        {
            var ajaxResult = new AjaxResult();

            try
            {
                using (DocumentBL _documentBL = new DocumentBL())
                {
                    ajaxResult.Data    = _documentBL.GetDocuments(pageNumber, pageSize);
                    ajaxResult.Success = true;
                }
            }
            catch (Exception)
            {
                ajaxResult.Success   = false;
                ajaxResult.Messenger = "Có lỗi xảy ra khi lấy dữ liệu chứng từ. Xin vui lòng liên hệ MISA để giải quyết";
            }
            return(ajaxResult);
        }
Exemplo n.º 10
0
    private int InsertDocument()
    {
        DocumentBL _objDocBL = new DocumentBL();
        int        res       = 0;

        if (fuDocument.HasFile)
        {
            List <HttpPostedFile> lst = fuDocument.PostedFiles.ToList();
            for (int i = 0; i < lst.Count; i++)
            {
                //HttpPostedFile uploadfile = lst[i];
                string inFilename = fuDocument.PostedFiles[i].FileName;
                string strfile    = Path.GetExtension(inFilename);
                string date       = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                var    folder     = Server.MapPath("~/AdminDocuments/" + ObjEn.Decrypt(Request.QueryString["x"].ToString()) + "/" + "AdminRequest");
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }
                string fileName = date + strfile;
                fuDocument.SaveAs(Path.Combine(folder, fileName));
                AdminDocumentEntity AdminDocumentEntity = new AdminDocumentEntity
                {
                    DocId        = Convert.ToInt32(hfDocID.Value),
                    SAID         = txtSaId.Text.ToString(),
                    Document     = fileName,
                    DocumentName = inFilename,
                    DocType      = Convert.ToInt32(ddlDocumentType.SelectedValue),
                    AdvisorID    = Convert.ToInt32(Session["AdvisorID"].ToString()),
                    Status       = 1,
                };
                if (btnSubmit.Text == "Update")
                {
                    res = _ObjClientDcoumentAdvisorBL.AdminDocumentManager(AdminDocumentEntity, 'u');
                }
                else
                {
                    res = _ObjClientDcoumentAdvisorBL.AdminDocumentManager(AdminDocumentEntity, 'i');
                }
            }
        }
        return(res);
    }
Exemplo n.º 11
0
        public AjaxResult GetAutoRenderDocumentPayCode()
        {
            var ajaxResult = new AjaxResult();

            try
            {
                using (DocumentBL documentBL = new DocumentBL())
                {
                    ajaxResult.Data    = documentBL.GetAutoRenderDocumentPayCode();
                    ajaxResult.Success = true;
                }
            }
            catch (Exception)
            {
                ajaxResult.Success   = false;
                ajaxResult.Messenger = "Có lỗi xảy ra khi lấy dữ liệu mã phiếu chi. Xin vui lòng liên hệ MISA để giải quyết";
            }
            return(ajaxResult);
        }
Exemplo n.º 12
0
        public AjaxResult GetDocumentsByDate(DocumentDto documentDto)
        {
            var ajaxResult = new AjaxResult();

            try
            {
                using (DocumentBL _documentBL = new DocumentBL())
                {
                    ajaxResult.Data    = _documentBL.GetDocumentsByDate(documentDto);
                    ajaxResult.Success = true;
                }
            }
            catch (Exception)
            {
                ajaxResult.Success   = false;
                ajaxResult.Messenger = "Có lỗi xảy ra khi lọc dữ liệu. Xin vui lòng liên hệ MISA để giải quyết";
            }
            return(ajaxResult);
        }
Exemplo n.º 13
0
        public AjaxResult GetDocumentByDocumentCode(string documentCode)
        {
            var ajaxResult = new AjaxResult();

            try
            {
                using (DocumentBL documentBL = new DocumentBL())
                {
                    ajaxResult.Data    = documentBL.GetDocumentByDocumentCode(documentCode);
                    ajaxResult.Success = true;
                }
            }
            catch (Exception)
            {
                ajaxResult.Success   = false;
                ajaxResult.Messenger = "Có lỗi xảy ra khi lấy dữ liệu chứng từ theo mã chứng từ. Xin vui lòng liên hệ MISA để giải quyết";
            }
            return(ajaxResult);
        }
Exemplo n.º 14
0
        public AjaxResult GetTotalDocuments()
        {
            var ajaxResult = new AjaxResult();

            try
            {
                using (DocumentBL documentBL = new DocumentBL())
                {
                    ajaxResult.Data    = documentBL.GetTotalDocuments();
                    ajaxResult.Success = true;
                }
            }
            catch (Exception)
            {
                ajaxResult.Success   = false;
                ajaxResult.Messenger = "Có lỗi xảy ra khi lấy dữ liệu tổng số chứng từ. Xin vui lòng liên hệ MISA để giải quyết";
            }
            return(ajaxResult);
        }
Exemplo n.º 15
0
        public AjaxResult GetDocumentsByPersonID(Guid id)
        {
            var ajaxResult = new AjaxResult();

            try
            {
                using (DocumentBL _documentBL = new DocumentBL())
                {
                    var documentVms = _documentBL.GetDocumentsByPerson(id);
                    ajaxResult.Data    = documentVms.Where(x => x.IsPaid == false);
                    ajaxResult.Success = true;
                }
            }
            catch (Exception)
            {
                ajaxResult.Success   = false;
                ajaxResult.Messenger = "Có lỗi xảy ra khi lấy dữ liệu chứng từ theo đối tượng. Xin vui lòng liên hệ MISA để giải quyết";
            }
            return(ajaxResult);
        }
Exemplo n.º 16
0
        public AjaxResult EditDocument(DocumentViewModel documentViewModel)
        {
            var ajaxResult = new AjaxResult();

            try
            {
                using (DocumentBL _documentBL = new DocumentBL()) {
                    var document = _documentBL.MapDocumentViewModelToDocument(documentViewModel);
                    document.DocumentID = documentViewModel.DocumentID;
                    _documentBL.UpdateDocument(document);
                    ajaxResult.Success = true;
                }
            }
            catch (Exception)
            {
                ajaxResult.Success   = false;
                ajaxResult.Messenger = "Có lỗi xảy ra khi sửa chứng từ. Xin vui lòng liên hệ MISA để giải quyết";
            }
            return(ajaxResult);
        }
Exemplo n.º 17
0
        public ActionResult Upload()
        {
            DocumentBL           uploadBl     = new DocumentBL();
            List <FormsCategory> catrgoryList = new List <FormsCategory>();

            catrgoryList = uploadBl.GetCategoryList();
            //List<SelectListItem> catList = new List<SelectListItem>();
            //catList = catrgoryList.Select(c =>
            //                                            new SelectListItem()
            //                                            {
            //                                                Text = c.CatecoryName,
            //                                                Value = c.ID.ToString()
            //                                            }).ToList();

            //ViewBag.FormsCategory = catList.Insert(0,new SelectListItem { Value="0",Text="Select",Selected=true});
            ViewBag.FormsCategory = catrgoryList.Select(c =>
                                                        new SelectListItem()
            {
                Text  = c.CatecoryName,
                Value = c.ID.ToString()
            }).ToList();

            return(View());
        }
Exemplo n.º 18
0
    private void InsertDocument()
    {
        DocumentBL _objDocBL = new DocumentBL();

        if (fuServiceDocument.HasFile)
        {
            List <HttpPostedFile> lst = fuServiceDocument.PostedFiles.ToList();
            for (int i = 0; i < lst.Count; i++)
            {
                //HttpPostedFile uploadfile = lst[i];
                string inFilename = fuServiceDocument.PostedFiles[i].FileName;
                string strfile    = Path.GetExtension(inFilename);
                string date       = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                var    folder     = Server.MapPath("~/ClientDocuments/" + Session["SAID"].ToString() + "/" + "ServiceRequest");
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }
                string fileName = date + strfile;
                fuServiceDocument.SaveAs(Path.Combine(folder, fileName));
                DocumentBO DocumentEntity = new DocumentBO
                {
                    DocId         = 0,
                    ReferenceSAID = Session["SAID"].ToString(),
                    SAID          = Session["SAID"].ToString(),
                    UIC           = "0",
                    Document      = fileName,
                    DocumentName  = inFilename,
                    DocType       = 0,
                    AdvisorID     = 0,
                    Status        = 1,
                };
                int res = _objDocBL.DocumentManager(DocumentEntity, 'i');
            }
        }
    }
Exemplo n.º 19
0
        public ActionResult UploadFiles(FormsCategory category, string categoryId, string categoryName, List <HttpPostedFileBase> fileData)
        {
            List <Forms> formList = new List <Forms>();
            DocumentBL   uploadBL = new DocumentBL();

            if (Request.Files.Count > 0)
            {
                try
                {
                    string relativePath = "~/Uploads/" + categoryName;
                    string path         = Server.MapPath("~/Uploads/");
                    string fileFath     = Path.Combine(path, categoryName);
                    if (!Directory.Exists(fileFath))
                    {
                        Directory.CreateDirectory(fileFath);
                    }
                    //  Get all files from Request object
                    HttpFileCollectionBase files = Request.Files;
                    for (int i = 0; i < files.Count; i++)
                    {
                        Forms form = new Forms();


                        //string path = AppDomain.CurrentDomain.BaseDirectory + "Uploads/";
                        //string filename = Path.GetFileName(Request.Files[i].FileName);

                        HttpPostedFileBase file = files[i];
                        string             fname;

                        // Checking for Internet Explorer
                        if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER")
                        {
                            string[] testfiles = file.FileName.Split(new char[] { '\\' });
                            fname = testfiles[testfiles.Length - 1];
                        }
                        else
                        {
                            fname = file.FileName;
                        }

                        // Get the complete folder path and store the file inside it.
                        string fnameWithPath = Path.Combine(fileFath, fname);
                        file.SaveAs(fnameWithPath);

                        form.FormName   = fname;
                        form.FilePath   = fileFath;
                        form.CategoryId = Convert.ToInt32(categoryId);
                        form.CreateedBy = 1;

                        formList.Add(form);
                    }

                    int count = uploadBL.SaveUploadedForms(formList);
                    // Returns message that successfully uploaded
                    return(Json("File Uploaded Successfully!"));
                }
                catch (Exception ex)
                {
                    return(Json("Error occurred. Error details: " + ex.Message));
                }
            }
            else
            {
                return(Json("No files selected."));
            }
        }
Exemplo n.º 20
0
    private int InsertDocument()
    {
        DocumentBL _objDocBL = new DocumentBL();
        int        res       = 0;

        if (fuDoc.HasFile)
        {
            HttpPostedFile file     = fuDoc.PostedFile;
            int            filesize = file.ContentLength;
            //if (filesize <= 1048576)
            //{
            List <HttpPostedFile> lst = fuDoc.PostedFiles.ToList();
            for (int i = 0; i < lst.Count; i++)
            {
                string inFilename = lst[i].FileName;
                string strfile    = Path.GetExtension(inFilename);
                string date       = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                var    folder     = Server.MapPath("~/ClientDocuments/" + Session["SAID"].ToString() + "/" + ViewState["FoldertName"].ToString() + "/" + txtSAID.Text.Trim());
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }
                string fileName = date + strfile;
                fuDoc.SaveAs(Path.Combine(folder, fileName));

                if (File.Exists(Path.Combine(folder, hfDocumentName.Value.ToString())))
                {
                    //delete file in folder
                    File.Delete(Path.Combine(folder, hfDocumentName.Value.ToString()));
                }
                int DocID = 0;
                if (Convert.ToInt32(hfID.Value) == 0)
                {
                    DocID = _objDocBL.InsertDocType(txtDocumentType.Text);
                }
                else
                {
                    DocID = Convert.ToInt32(hfID.Value);
                }
                DocumentBO DocumentEntity = new DocumentBO
                {
                    DocId         = Convert.ToInt32(hfDocID.Value),
                    ReferenceSAID = Session["SAID"].ToString(),
                    SAID          = hfSAID.Value.ToString(),
                    UIC           = hfUIC.Value.ToString(),
                    Document      = fileName,
                    DocumentName  = inFilename,
                    //DocType = Convert.ToInt32(ddlDocType.SelectedValue),
                    DocType    = DocID,
                    ClientType = Request.QueryString["t"] != null?Convert.ToInt32(ObjDec.Decrypt(Request.QueryString["t"])) : 0,
                                     AdvisorID = 0,
                                     Status    = 1,
                };

                if (btnSubmit.Text == "Update")
                {
                    res = _objDocBL.DocumentManager(DocumentEntity, 'u');
                }
                else
                {
                    res = _objDocBL.DocumentManager(DocumentEntity, 'i');
                }
            }
            lblSizeError.Text = "";
            //}
            //else
            //{
            //    lblSizeError.ForeColor = System.Drawing.Color.Red;
            //    lblSizeError.Text = "Sorry,the document size should be less than 1MB";
            //}
        }
        return(res);
    }
        public ActionResult Delete()
        {
            var vm = DocumentBL.GetDocuments();

            return(View(vm));
        }
Exemplo n.º 22
0
        public JsonResult UploadAndUpdateForm(string categoryId, string categoryName, string formName, string formVersion, string modifiedSection)
        {
            List <Forms> formList = new List <Forms>();
            DocumentBL   uploadBL = new DocumentBL();

            if (Request.Files.Count == 1)
            {
                try
                {
                    string tempFolder   = "~/UploadForUpdate/";
                    string relativePath = "~/Forms/" + categoryName;  // deep
                    string path         = Server.MapPath("~/Forms/"); // deep
                    //string tempath = Server.MapPath(tempFolder);
                    string fileFath = Path.Combine(path, categoryName);
                    //if (!Directory.Exists(tempath))
                    //{
                    //    Directory.CreateDirectory(fileFath);
                    //}
                    //  Get all files from Request object

                    #region form to Archive
                    string archivedFolder  = "~/ArchivedForms/" + categoryName + "/";
                    string uploadedFolder  = "~/Forms/" + categoryName + "/";               // deep
                    string sourcePath      = Server.MapPath(uploadedFolder);
                    string destinationPath = Server.MapPath(archivedFolder);
                    string uploadedFile    = Path.Combine(sourcePath, formName);
                    string archiveFile     = Path.Combine(destinationPath, formName);
                    if (System.IO.File.Exists(uploadedFile))
                    {
                        if (!Directory.Exists(destinationPath))
                        {
                            Directory.CreateDirectory(destinationPath);
                        }
                        //System.IO.File.Move(uploadedFile, archiveFile);
                        System.IO.File.Copy(uploadedFile, archiveFile, true);
                    }
                    #endregion

                    HttpFileCollectionBase files = Request.Files;
                    for (int i = 0; i < files.Count; i++)
                    {
                        Forms form = new Forms();


                        HttpPostedFileBase file = files[i];
                        string             fname;

                        // Checking for Internet Explorer
                        if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER")
                        {
                            string[] testfiles = file.FileName.Split(new char[] { '\\' });
                            fname = testfiles[testfiles.Length - 1];
                        }
                        else
                        {
                            fname = file.FileName;
                        }

                        // Get the complete folder path and store the file inside it.
                        string fnameWithPath = Path.Combine(fileFath, fname);
                        file.SaveAs(fnameWithPath);

                        //form.FormName   = fname;
                        form.FormName   = formName;
                        form.FilePath   = fileFath;
                        form.CategoryId = Convert.ToInt32(categoryId);
                        form.Version    = formVersion;
                        form.CreateedBy = 1;

                        form.ModifiedSection = modifiedSection; // deep

                        formList.Add(form);
                    }

                    int count = uploadBL.SaveUploadedForms(formList);
                    // Returns message that successfully uploaded
                    return(Json("File Updated Successfully!"));
                }
                catch (Exception ex)
                {
                    return(Json("Error occurred. Error details: " + ex.Message));
                }
            }
            else
            {
                return(Json("No files selected."));
            }
        }