Esempio n. 1
0
        public IEnumerable getReportHeader(int sample_id)
        {
            using (ALSIEntities ctx = new ALSIEntities())
            {
                var result = from i in ctx.job_info
                             join s in ctx.job_sample on i.ID equals s.job_id
                             join c in ctx.m_customer on i.customer_id equals c.ID
                             where s.ID == sample_id
                             orderby s.job_number ascending
                             select new
                {
                    cusRefNo            = s.sample_po,
                    alsRefNo            = s.job_number,
                    cur_date            = i.date_of_receive,
                    addr1               = c.company_name,
                    addr2               = c.address,
                    dateOfDampleRecieve = i.date_of_receive,
                    dateOfAnalyze       = i.date_of_request,
                    dateOfTestComplete  = s.due_date,
                    description         = s.description,
                    model               = s.model,
                    surface_areas       = s.surface_area,
                    remark              = s.remarks
                };


                return(result.ToList());
            }
        }
        private void bindingData()
        {
            using (var ctx = new ALSIEntities())
            {
                job_sample_logs jsl    = new job_sample_logs();
                var             result = from l in ctx.job_sample_logs
                                         join j in ctx.job_sample on l.job_sample_id equals j.ID
                                         orderby l.date descending
                                         select new
                {
                    l.ID,
                    j.step1owner,
                    j.step2owner,
                    j.step3owner,
                    j.step4owner,
                    j.step5owner,
                    j.step6owner,
                    j.step7owner,
                    l.log_title,
                    l.job_remark,
                    l.date,
                    j.job_status,
                    j.job_number
                };

                RoleEnum roleEnum = (RoleEnum)Enum.Parse(typeof(RoleEnum), userLogin.role_id.ToString());
                switch (roleEnum)
                {
                case RoleEnum.LOGIN:
                    result = result.Where(x => x.step1owner == userLogin.id || x.step2owner == userLogin.id);
                    result = result.Where(x => x.job_status == 11);    // Convert.ToInt16(StatusEnum.LOGIN_SELECT_SPEC));
                    break;

                case RoleEnum.CHEMIST:
                    result = result.Where(x => x.step3owner == userLogin.id);
                    result = result.Where(x => x.job_status == 12);    // Convert.ToInt16(StatusEnum.CHEMIST_TESTING));
                    break;

                case RoleEnum.SR_CHEMIST:
                    result = result.Where(x => x.step4owner == userLogin.id);
                    result = result.Where(x => x.job_status == 4);    // Convert.ToInt16(StatusEnum.SR_CHEMIST_CHECKING));
                    break;

                case RoleEnum.ADMIN:
                    result = result.Where(x => x.step6owner == userLogin.id || x.step7owner == userLogin.id);
                    //result = result.Where(x => x.job_status == Convert.ToInt16(StatusEnum.ADMIN_CONVERT_PDF)||x.job_status == Convert.ToInt16(StatusEnum.ADMIN_CONVERT_WORD));
                    break;

                case RoleEnum.LABMANAGER:
                    result = result.Where(x => x.step5owner == userLogin.id);
                    result = result.Where(x => x.job_status == 9);    // Convert.ToInt16(StatusEnum.LABMANAGER_CHECKING));
                    break;
                }

                DataTable dt = result.ToDataTable();
                foreach (DataRow dr in dt.Rows)
                {
                    int             id   = Convert.ToInt32(dr["ID"].ToString());
                    job_sample_logs _jsl = jsl.SelectByID(id);
                    if (_jsl != null)
                    {
                        _jsl.is_active = "1";
                        _jsl.Update();
                    }

                    Console.WriteLine();
                }
                searchResult        = result.ToList();
                gvResult.DataSource = searchResult;
                gvResult.DataBind();
                //Commit
                GeneralManager.Commit();

                //if (gvResult.Rows.Count > 0)
                //{
                //    lbTotalRecords.Text = String.Format(Constants.TOTAL_RECORDS, gvResult.Rows.Count);
                //}
                //else
                //{
                //    lbTotalRecords.Text = string.Empty;
                //}
            }
        }