Ejemplo n.º 1
0
        public JobFileClass GetJobFileAttachments(Guid id)
        {
            JobFileClass obj = new JobFileClass();

            try
            {
                obj.Joblist = new List <JobFileClass>();
                var temp = from x in db.JobFile
                           where x.JobKey == id && x.IsDelete == false

                           select new JobFileClass
                {
                    FileKey          = x.FileKey,
                    JobKey           = x.JobKey,
                    JobName          = x.Job.JobName,
                    DocumentTypeKey  = x.DocumentTypeKey,
                    AddedBy          = x.AddedBy,
                    AddedOn          = x.AddedOn,
                    Comment          = x.Comment,
                    Title            = x.Title,
                    Remarks          = x.Remarks,
                    IsDelete         = x.IsDelete,
                    DocumentTypeName = x.DocumentType.TName
                };
                obj.Joblist = temp.OrderByDescending(m => m.AddedOn).ToList();
            }
            catch (Exception ex)
            {
                string fall = ex.ToString();
            }
            return(obj);
        }
Ejemplo n.º 2
0
        public DataReturn SaveAttachmentInJobFile(JobFileClass model)
        {
            DataReturn obj = new DataReturn();

            try
            {
                JobFile fj = db.JobFile.SingleOrDefault(m => m.JobKey == model.JobKey && m.DocumentTypeKey == model.DocumentTypeKey);
                if (fj == null)
                {
                }
                else
                {
                    db.JobFile.Remove(fj);
                    db.SaveChanges();
                    db = new RCSdbEntities();
                }
                JobFile invoice = new JobFile();
                Job     job     = db.Job.Find(model.JobKey);
                invoice.FileKey         = Guid.NewGuid();
                invoice.JobKey          = (Guid)model.JobKey;
                invoice.DocumentTypeKey = model.DocumentTypeKey;
                //invoice.AddedBy = GlobalClass.LoginUser.PersonnelKey;
                invoice.AddedOn = System.DateTime.Now;
                if (string.IsNullOrEmpty(model.Comment))
                {
                    invoice.Comment = "--";
                }
                else
                {
                    invoice.Comment = model.Comment;
                }
                invoice.Title   = model.Title;
                invoice.Remarks = db.DocumentType.Find(model.DocumentTypeKey).TName + " is Added by " + GlobalClass.LoginUser.Cname;

                invoice.FileContent = model.FileContent;
                invoice.FileType    = model.FileType;
                invoice.IsDelete    = false;
                invoice.IsFileNew   = true;
                db.JobFile.Add(invoice);
                db.SaveChanges();

                obj.flag = 1;
                obj.mess = "Data has been updated successfully.";
            }
            catch (Exception ex)
            {
                obj.mess = ex.ToString();
                obj.flag = 0;
            }
            obj.key = model.JobKey;
            return(obj);
        }
Ejemplo n.º 3
0
        public ActionResult FilesandAttachments(HttpPostedFileBase file, JobFileClass model)
        {
            if (GlobalClass.SystemSession)
            {
                ViewBag.mess = "";
                Job job = db.Job.Find(model.JobKey);
                if (ModelState.IsValid)
                {
                    if (file != null)
                    {
                        byte[] data = null;
                        using (Stream inputStream = file.InputStream)
                        {
                            MemoryStream memoryStream = inputStream as MemoryStream;
                            if (memoryStream == null)
                            {
                                memoryStream = new MemoryStream();
                                inputStream.CopyTo(memoryStream);
                            }
                            data = memoryStream.ToArray();
                        }
                        model.FileType    = file.ContentType;
                        model.Title       = file.FileName;
                        model.FileContent = data;
                        DataReturn dt = manage.SaveAttachmentInJobFile(model);
                        ViewBag.mess = dt.mess;
                    }
                }


                model         = new JobFileClass();
                model         = manage.GetJobFileAttachments((Guid)job.JobKey);
                model.JobKey  = job.JobKey;
                model.JobName = job.JobName;

                ViewBag.DocumentTypeKey = new SelectList(db.DocumentType.Where(m => m.DocumentForID == 6 && m.IsDelete == false && m.CompanyKey == GlobalClass.Company.CompanyKey).OrderBy(m => m.TName), "ID", "TName");

                return(View(model));
            }
            else
            {
                Exception e = new Exception("Sorry, your Session has Expired");
                return(View("Error", new HandleErrorInfo(e, "Home", "Logout")));
            }
        }
Ejemplo n.º 4
0
        public ActionResult FilesandAttachments(Guid id)
        {
            if (GlobalClass.SystemSession)
            {
                JobFileClass model = new JobFileClass();
                Job          job   = db.Job.Find(id);

                model         = manage.GetJobFileAttachments(id);
                model.JobKey  = id;
                model.JobName = job.JobName;
                ViewBag.mess  = " ";

                ViewBag.DocumentTypeKey = new SelectList(db.DocumentType.Where(m => m.DocumentForID == 6 && m.IsDelete == false && m.CompanyKey == GlobalClass.Company.CompanyKey).OrderBy(m => m.TName), "ID", "TName");

                return(View(model));
            }
            else
            {
                Exception e = new Exception("Sorry, your Session has Expired");
                return(View("Error", new HandleErrorInfo(e, "Home", "Logout")));
            }
        }