示例#1
0
        public IEnumerable <sp_schedule_course_search_Result> search(scheduleCourseModel value)
        {
            StandardCanEntities context = new StandardCanEntities();
            IEnumerable <sp_schedule_course_search_Result> result = context.sp_schedule_course_search(value.year_from, value.year_to, value.prj_from, value.prj_to, value.course_name, value.start_date, value.stop_date).AsEnumerable();

            return(result);
        }
示例#2
0
        public projectFormulaMasterModel master(projectFormularModel value)
        {
            projectFormulaMasterModel result = new projectFormulaMasterModel();

            try
            {
                using (var context = new StandardCanEntities())
                {
                    if (String.IsNullOrEmpty(value.user_id))
                    {
                        throw new Exception("Unauthorized Access");
                    }
                    var userId = JwtHelper.GetUserIdFromToken(value.user_id);
                    if (String.IsNullOrEmpty(userId))
                    {
                        throw new Exception("Unauthorized Access");
                    }

                    string sql = "select convert(nvarchar(4), MFT_ID) code, MFT_NAME [text] ";
                    sql        += " from MAS_FORMULA_TYPE ";
                    sql        += " order by    MFT_NAME ";
                    result.type = context.Database.SqlQuery <dropdown>(sql).ToList();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(result);
        }
示例#3
0
        public UserRoleDDL getDDLData()
        {
            UserRoleDDL result = new UserRoleDDL();

            using (var context = new StandardCanEntities())
            {
                result.UserGroupList = new List <DDLViewModel>();
                var programList = context.MAS_PROGRAM.ToList();
                result.UserGroupList = context.USER_GROUP.Select(a => new DDLViewModel
                {
                    id       = a.Group_ID.ToString(),
                    name     = a.Group_Name,
                    detail   = a.Group_Name,
                    active   = a.Active == true ? "True" : "False",
                    roleList = context.USER_ROLE.Where(x => x.Group_ID == a.Group_ID.ToString()).Select(r => new UserRoleProgramViewModel
                    {
                        program_id = r.Program_ID,
                        // program_name = programList.SingleOrDefault(x => x.Program_ID.ToString() == r.Program_ID) != null ? programList.SingleOrDefault(x => x.Program_ID.ToString() == r.Program_ID).Program_Name : ""
                    }).ToList()
                }).ToList();
                result.ProgramList = new List <DDLViewModel>();
                result.ProgramList = context.MAS_PROGRAM.Where(a => a.Active).Select(a => new DDLViewModel
                {
                    id     = a.Program_ID.ToString(),
                    name   = a.Program_Name,
                    detail = a.Url_Path,
                    order  = a.Order_Item
                }).OrderBy(a => a.order.Value).ToList();
            }

            return(result);
        }
示例#4
0
        public messageModel update(projectModel value)
        {
            messageModel result = new messageModel();

            try
            {
                using (var context = new StandardCanEntities())
                {
                    if (String.IsNullOrEmpty(value.user_id))
                    {
                        throw new Exception("Unauthorized Access");
                    }
                    var userId = JwtHelper.GetUserIdFromToken(value.user_id);
                    if (String.IsNullOrEmpty(userId))
                    {
                        throw new Exception("Unauthorized Access");
                    }

                    int ret = context.sp_project_update_v2(value.prj_id, value.prj_name, value.start_date, value.stop_date, value.prj_detail, value.prj_status, userId);
                }

                result.status  = "S";
                result.message = "";
            }
            catch (Exception ex)
            {
                result.status  = "E";
                result.message = ex.Message.ToString();
            }

            return(result);
        }
示例#5
0
        public List <UserRoleViewModel> searchUserGroup()
        {
            List <UserRoleViewModel> result = new List <UserRoleViewModel>();

            using (var context = new StandardCanEntities())
            {
                //result = context.USER_GROUP.Where().Select(a => new UserRoleViewModel
                //{
                //    roleId = a.role,
                //    Name = a.OfficeName
                //}).ToList();
                //var data = new List<USER_ROLE>();
                //if (String.IsNullOrEmpty(role.usergroup))
                //{
                //    data = context.USER_ROLE.ToList();
                //}
                //else
                //{
                //    data = context.USER_ROLE.Where(a => a.Group_ID.Equals(role.group_id)).ToList();
                //}
                //foreach (var item in data)
                //{
                //    UserRoleViewModel model = new UserRoleViewModel();
                //    model.roleId = item.Role_ID.ToString();
                //    model.userGroupId = item.Group_ID;
                //    model.userGroup = context.USER_GROUP.SingleOrDefault(a => a.Group_Name == item.Group_ID).Group_Detail;
                //    model.programId = item.Program_ID;
                //    model.programName = item.Program_Name;
                //    model.active = item.Active ? "True" : null;
                //    result.Add(model);
                //}
            }

            return(result);
        }
示例#6
0
        public List <sp_calendar_dashboard_Result> searchCalendar_v2(dashBoardModel value)
        {
            try
            {
                using (StandardCanEntities context = new StandardCanEntities())
                {
                    if (String.IsNullOrEmpty(value.user_id))
                    {
                        throw new Exception("Unauthorized Access");
                    }
                    var userId = JwtHelper.GetUserIdFromToken(value.user_id);
                    if (String.IsNullOrEmpty(userId))
                    {
                        throw new Exception("Unauthorized Access");
                    }
                    JavaScriptSerializer js = new JavaScriptSerializer();
                    string json             = js.Serialize(value);
                    context.interface_log.Add(new interface_log
                    {
                        data_log    = json,
                        module      = "dashBoard",
                        update_date = DateTime.Now
                    });
                    context.SaveChanges();

                    List <sp_calendar_dashboard_Result> result = context.sp_calendar_dashboard(userId).ToList();
                    return(result);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
示例#7
0
        public empTabNoteModel tab_note_search(employeeModel value)
        {
            empTabNoteModel result = new empTabNoteModel();

            try
            {
                using (var context = new StandardCanEntities())
                {
                    if (String.IsNullOrEmpty(value.user_id))
                    {
                        throw new Exception("Unauthorized Access");
                    }
                    var userId = JwtHelper.GetUserIdFromToken(value.user_id);
                    if (String.IsNullOrEmpty(userId))
                    {
                        throw new Exception("Unauthorized Access");
                    }

                    var note = context.sp_emp_profile_tabnote_search(value.emp_code).FirstOrDefault();
                    result.note = note ?? "";
                }
            }
            catch (Exception ex)
            {
                //result.status = "E";
                //result.message = ex.Message.ToString();
                throw new Exception(ex.Message);
            }

            return(result);
        }
示例#8
0
        public empMasterModel master(employeeModel value)
        {
            empMasterModel result = new empMasterModel();

            try
            {
                using (var context = new StandardCanEntities())
                {
                    if (String.IsNullOrEmpty(value.user_id))
                    {
                        throw new Exception("Unauthorized Access");
                    }
                    var userId = JwtHelper.GetUserIdFromToken(value.user_id);
                    if (String.IsNullOrEmpty(userId))
                    {
                        throw new Exception("Unauthorized Access");
                    }

                    result.sh         = context.sp_sh_search().ToList();
                    result.depart     = context.sp_depart_search().ToList();
                    result.emp_status = context.sp_emp_status_search().ToList();
                }
            }
            catch (Exception ex)
            {
                //result.status = "E";
                //result.message = ex.Message.ToString();
                throw new Exception(ex.Message);
            }

            return(result);
        }
示例#9
0
        public empTab3Model tab3_search(employeeModel value)
        {
            empTab3Model result = new empTab3Model();

            try
            {
                using (var context = new StandardCanEntities())
                {
                    if (String.IsNullOrEmpty(value.user_id))
                    {
                        throw new Exception("Unauthorized Access");
                    }
                    var userId = JwtHelper.GetUserIdFromToken(value.user_id);
                    if (String.IsNullOrEmpty(userId))
                    {
                        throw new Exception("Unauthorized Access");
                    }
                    result.quota = context.sp_emp_profile_tab3_quota(value.emp_code).ToList();
                    result.data  = context.sp_emp_profile_tab3(value.emp_code, value.start_date, value.stop_date).ToList();
                }
            }
            catch (Exception ex)
            {
                //result.status = "E";
                //result.message = ex.Message.ToString();
                throw new Exception(ex.Message);
            }

            return(result);
        }
示例#10
0
        public IEnumerable <sp_car_search_v3_Result> search(carModel value)
        {
            StandardCanEntities context = new StandardCanEntities();
            IEnumerable <sp_car_search_v3_Result> result = context.sp_car_search_v3(value.car_type_from, value.car_type_to, value.car_from, value.car_to).AsEnumerable();

            return(result);
        }
示例#11
0
        public projectMasterModel master(scheduleCourseModel value)
        {
            projectMasterModel result = new projectMasterModel();

            try
            {
                using (var context = new StandardCanEntities())
                {
                    string sql = "select convert(nvarchar(4), MPJ_YEAR) code, convert(nvarchar(4), MPJ_YEAR) [text] ";
                    sql        += " from MAS_PROJECT ";
                    sql        += " where MPJ_YEAR is not null ";
                    sql        += " group by    MPJ_YEAR ";
                    result.year = context.Database.SqlQuery <dropdown>(sql).ToList();

                    sql            = "select		convert(nvarchar(5), MPJ_ID) code ";
                    sql           += " , MPJ_NAME [text] ";
                    sql           += " from MAS_PROJECT ";
                    sql           += " where MPJ_STATUS = 1 ";
                    sql           += " order by MPJ_NAME ";
                    result.project = context.Database.SqlQuery <dropdown>(sql).ToList();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(result);
        }
示例#12
0
        public IEnumerable <sp_emp_temporary_search_v2_Result> search_Temporary(empCheckInModel value)
        {
            try
            {
                JavaScriptSerializer js     = new JavaScriptSerializer();
                string json                 = js.Serialize(value);
                StandardCanEntities context = new StandardCanEntities();
                if (String.IsNullOrEmpty(value.user_id))
                {
                    throw new Exception("Unauthorized Access");
                }
                var userId = JwtHelper.GetUserIdFromToken(value.user_id);
                if (String.IsNullOrEmpty(userId))
                {
                    throw new Exception("Unauthorized Access");
                }

                context.interface_log.Add(new interface_log
                {
                    ID          = 1,
                    data_log    = json,
                    module      = "search_Temporary",
                    update_date = DateTime.Now
                });

                context.SaveChanges();

                IEnumerable <sp_emp_temporary_search_v2_Result> result = context.sp_emp_temporary_search_v2(userId, value.start_date, value.stop_date, value.emp_code_from, value.emp_code_to, value.depart_from, value.depart_to, value.fname, value.lname).AsEnumerable();
                return(result);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
示例#13
0
        public holidayMasterModel master(holidayModel value)
        {
            holidayMasterModel result = new holidayMasterModel();

            try
            {
                using (var context = new StandardCanEntities())
                {
                    if (String.IsNullOrEmpty(value.user_id))
                    {
                        throw new Exception("Unauthorized Access");
                    }
                    var userId = JwtHelper.GetUserIdFromToken(value.user_id);
                    if (String.IsNullOrEmpty(userId))
                    {
                        throw new Exception("Unauthorized Access");
                    }

                    string sql = "select		convert(nvarchar(4), year(mhd_date)) code ";
                    sql        += " , convert(nvarchar(4), year(mhd_date)) [text] ";
                    sql        += " from MAS_HOLIDAY ";
                    sql        += " group by    year(mhd_date) ";
                    sql        += " order by    year(mhd_date) ";
                    result.year = context.Database.SqlQuery <dropdown>(sql).ToList();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(result);
        }
示例#14
0
        public IEnumerable <sp_emp_profile_search_v2_Result> search(employeeModel value)
        {
            try
            {
                if (String.IsNullOrEmpty(value.user_id))
                {
                    throw new Exception("Unauthorized Access");
                }
                var userId = JwtHelper.GetUserIdFromToken(value.user_id);
                if (String.IsNullOrEmpty(userId))
                {
                    throw new Exception("Unauthorized Access");
                }

                StandardCanEntities context = new StandardCanEntities();
                IEnumerable <sp_emp_profile_search_v2_Result> result = context.sp_emp_profile_search_v2(value.emp_code_start, value.emp_code_stop,
                                                                                                        value.sh_start, value.sh_stop, value.depart_start, value.depart_stop, value.emp_status_start, value.emp_status_stop,
                                                                                                        value.emp_fname, value.emp_lname, value.head_fname, value.head_lname).AsEnumerable();
                return(result);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
示例#15
0
        public timeAttRealtimeMasterModel master(empCheckInModel value)
        {
            timeAttRealtimeMasterModel result = new timeAttRealtimeMasterModel();

            try
            {
                using (var context = new StandardCanEntities())
                {
                    if (String.IsNullOrEmpty(value.user_id))
                    {
                        throw new Exception("Unauthorized Access");
                    }
                    var userId = JwtHelper.GetUserIdFromToken(value.user_id);
                    if (String.IsNullOrEmpty(userId))
                    {
                        throw new Exception("Unauthorized Access");
                    }

                    string sql = "select		convert(nvarchar(5), MD_ID) code ";
                    sql += " , md_name [text] ";
                    sql += " from MAS_DEPARTMENT ";
                    sql += " where md_status = 1 ";
                    sql += " order by md_name ";
                    result.department = context.Database.SqlQuery <dropdown>(sql).ToList();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(result);
        }
示例#16
0
        public IEnumerable <sp_trainning_search_Result> searchTraining(projectTrainingScheduleModel value)
        {
            try
            {
                //if (String.IsNullOrEmpty(value.user_id))
                //{
                //    throw new Exception("Unauthorized Access");
                //}
                //var userId = JwtHelper.GetUserIdFromToken(value.user_id);
                //if (String.IsNullOrEmpty(userId))
                //{
                //    throw new Exception("Unauthorized Access");
                //}
                StandardCanEntities  context = new StandardCanEntities();
                JavaScriptSerializer js      = new JavaScriptSerializer();
                string json = js.Serialize(value);
                context.interface_log.Add(new interface_log
                {
                    data_log    = json,
                    module      = "searchTraining",
                    update_date = DateTime.Now
                });
                context.SaveChanges();

                IEnumerable <sp_trainning_search_Result> result = context.sp_trainning_search(value.project_year, value.project_id, value.date_form, value.date_to, value.training_name, "", value.status_id).AsEnumerable();
                return(result);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
示例#17
0
        public messageModel delete(carModel value)
        {
            messageModel result = new messageModel();

            try
            {
                using (var context = new StandardCanEntities())
                {
                    if (String.IsNullOrEmpty(value.user_id))
                    {
                        throw new Exception("Unauthorized Access");
                    }
                    var userId = JwtHelper.GetUserIdFromToken(value.user_id);
                    if (String.IsNullOrEmpty(userId))
                    {
                        throw new Exception("Unauthorized Access");
                    }

                    int ret = context.sp_car_delete(value.id, userId);
                }

                result.status  = "S";
                result.message = "";
            }
            catch (Exception ex)
            {
                result.status  = "E";
                result.message = ex.Message.ToString();
            }

            return(result);
        }
示例#18
0
        public projectTrainingMasterModel master(projectTrainingScheduleModel value)
        {
            projectTrainingMasterModel result = new projectTrainingMasterModel();

            try
            {
                using (var context = new StandardCanEntities())
                {
                    //if (String.IsNullOrEmpty(value.user_id))
                    //{
                    //    throw new Exception("Unauthorized Access");
                    //}
                    //var userId = JwtHelper.GetUserIdFromToken(value.user_id);
                    //if (String.IsNullOrEmpty(userId))
                    //{
                    //    throw new Exception("Unauthorized Access");
                    //}

                    JavaScriptSerializer js = new JavaScriptSerializer();
                    string json             = js.Serialize(value);
                    context.interface_log.Add(new interface_log
                    {
                        data_log    = json,
                        module      = "Training_master",
                        update_date = DateTime.Now
                    });
                    context.SaveChanges();

                    string sql = "select convert(nvarchar(4), MPJ_YEAR) code, convert(nvarchar(4), MPJ_YEAR) [text] ";
                    sql += " from MAS_PROJECT ";
                    sql += " where MPJ_YEAR is not null ";
                    sql += " group by    MPJ_YEAR ";
                    result.project_year = context.Database.SqlQuery <dropdown>(sql).ToList();

                    sql  = "select convert(nvarchar(5), MPJ_ID) code ";
                    sql += " , MPJ_NAME [text] ";
                    sql += " from MAS_PROJECT ";
                    sql += " where MPJ_STATUS = 1 ";
                    sql += " order by MPJ_NAME ";
                    result.project_name = context.Database.SqlQuery <dropdown>(sql).ToList();

                    var expenseData = context.MAS_EXPENSE.ToList();
                    foreach (var item in expenseData)
                    {
                        projectTrainingExpenseModel expenseModel = new projectTrainingExpenseModel();
                        expenseModel.id           = item.MEXP_ID.ToString();
                        expenseModel.expense_name = item.MEXP_NAME;
                        result.project_expense.Add(expenseModel);
                    }
                    result.depart = context.sp_depart_search().ToList();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(result);
        }
示例#19
0
        public benefitsDataResultModel search(benefitsModel value)
        {
            benefitsDataResultModel result = new benefitsDataResultModel();

            result.message = new messageModel();
            try
            {
                using (StandardCanEntities context = new StandardCanEntities())
                {
                    var           _Gapi    = context.MAS_GLOBAL_CONFIG.SingleOrDefault(x => x.GGC_KEY == "API_PATH");
                    var           _Gpath   = context.MAS_GLOBAL_CONFIG.SingleOrDefault(x => x.GGC_KEY == "FILE_PATH");
                    JsonPathModel jsonPath = new JsonPathModel();
                    if (_Gpath != null)
                    {
                        jsonPath = (JsonPathModel)Newtonsoft.Json.JsonConvert.DeserializeObject(_Gpath.GGC_VAL, typeof(JsonPathModel));
                    }

                    if (String.IsNullOrEmpty(value.user_id))
                    {
                        throw new Exception("Unauthorized Access");
                    }
                    var userId = JwtHelper.GetUserIdFromToken(value.user_id);
                    if (String.IsNullOrEmpty(userId))
                    {
                        throw new Exception("Unauthorized Access");
                    }
                    JavaScriptSerializer js = new JavaScriptSerializer();
                    string json             = js.Serialize(value);
                    context.interface_log.Add(new interface_log
                    {
                        data_log    = json,
                        module      = "Benefits_search",
                        update_date = DateTime.Now
                    });
                    context.SaveChanges();

                    var data = context.MAS_BENEFITS.Where(a => a.mb_title.Contains(value.title)).ToList();
                    result.benefitData = new List <benefitsModel>();
                    foreach (var item in data)
                    {
                        benefitsModel news = new benefitsModel();
                        news.id     = item.MB_ID.ToString();
                        news.title  = item.mb_title;
                        news.detail = item.mb_detail;
                        news.url    = !String.IsNullOrEmpty(item.mb_link_url) ? _Gapi.GGC_VAL + jsonPath.benefits + item.mb_link_url : null;
                        result.benefitData.Add(news);
                    }

                    result.message.status  = "S";
                    result.message.message = "Success";
                }
            }
            catch (Exception ex)
            {
                result.message.status  = "E";
                result.message.message = ex.Message.ToString();
            }
            return(result);
        }
示例#20
0
        public dashBoardModel search(dashBoardModel value)
        {
            dashBoardModel result = new dashBoardModel();

            result.message = new messageModel();
            try
            {
                using (StandardCanEntities context = new StandardCanEntities())
                {
                    var           _Gapi    = context.MAS_GLOBAL_CONFIG.SingleOrDefault(x => x.GGC_KEY == "API_PATH");
                    var           _Gpath   = context.MAS_GLOBAL_CONFIG.SingleOrDefault(x => x.GGC_KEY == "FILE_PATH");
                    JsonPathModel jsonPath = new JsonPathModel();
                    if (_Gpath != null)
                    {
                        jsonPath = (JsonPathModel)Newtonsoft.Json.JsonConvert.DeserializeObject(_Gpath.GGC_VAL, typeof(JsonPathModel));
                    }
                    if (String.IsNullOrEmpty(value.user_id))
                    {
                        throw new Exception("Unauthorized Access");
                    }
                    var userId = JwtHelper.GetUserIdFromToken(value.user_id);
                    if (String.IsNullOrEmpty(userId))
                    {
                        throw new Exception("Unauthorized Access");
                    }
                    JavaScriptSerializer js = new JavaScriptSerializer();
                    string json             = js.Serialize(value);
                    context.interface_log.Add(new interface_log
                    {
                        data_log    = json,
                        module      = "dashBoard",
                        update_date = DateTime.Now
                    });
                    context.SaveChanges();

                    var data = context.IMAGE_SLIDE.Where(a => a.is_status == 1).ToList().OrderBy(a => a.is_order_by).ToList();
                    result.imgList = new List <dashBoardImg>();
                    foreach (var item in data)
                    {
                        dashBoardImg news = new dashBoardImg();
                        string       path = Path.Combine(HostingEnvironment.MapPath("~" + jsonPath.imageSlide),
                                                         Path.GetFileName(item.is_url_image));
                        byte[] bytes = File.ReadAllBytes(path);
                        news.base64 = Convert.ToBase64String(bytes);
                        result.imgList.Add(news);
                    }

                    result.message.status  = "S";
                    result.message.message = "Success";
                }
            }
            catch (Exception ex)
            {
                result.message.status  = "E";
                result.message.message = ex.Message.ToString();
            }
            return(result);
        }
示例#21
0
        public FileContentResult exportFileWeb(timeAttRealModel value)
        {
            try
            {
                if (String.IsNullOrEmpty(value.user_id))
                {
                    throw new Exception("Unauthorized Access");
                }
                var userId = JwtHelper.GetUserIdFromToken(value.user_id);
                if (String.IsNullOrEmpty(userId))
                {
                    throw new Exception("Unauthorized Access");
                }
                using (var context = new StandardCanEntities())
                {
                    var           _Gapi    = context.MAS_GLOBAL_CONFIG.SingleOrDefault(x => x.GGC_KEY == "API_PATH");
                    var           _Gpath   = context.MAS_GLOBAL_CONFIG.SingleOrDefault(x => x.GGC_KEY == "FILE_PATH");
                    JsonPathModel jsonPath = new JsonPathModel();
                    if (_Gpath != null)
                    {
                        jsonPath = (JsonPathModel)Newtonsoft.Json.JsonConvert.DeserializeObject(_Gpath.GGC_VAL, typeof(JsonPathModel));
                    }

                    string out_put_dir = System.AppDomain.CurrentDomain.BaseDirectory + jsonPath.timeAttRealtime;
                    Directory.CreateDirectory(out_put_dir);
                    string filePath = out_put_dir + value.fileName;
                    var    microsoftDateFormatSettings = new JsonSerializerSettings
                    {
                        DateParseHandling  = DateParseHandling.None,
                        DateFormatHandling = DateFormatHandling.IsoDateFormat,
                        Formatting         = Formatting.Indented,
                    };
                    using (StreamWriter writer = new StreamWriter(filePath, true))
                    {
                        var v_date_from = String.IsNullOrEmpty(value.start_date) ? "" : DateTime.ParseExact(value.start_date, "yyyy-MM-dd", CultureInfo.InvariantCulture).ToString("dd/MM/yyyy");
                        var v_date_to   = String.IsNullOrEmpty(value.stop_date) ? "" : DateTime.ParseExact(value.stop_date, "yyyy-MM-dd", CultureInfo.InvariantCulture).ToString("dd/MM/yyyy");

                        IEnumerable <sp_report_timeatt_v2_Result> dataList = context.sp_report_timeatt_v2(value.start_date, value.stop_date, value.emp_code_from, value.emp_code_to, value.depart_from, value.depart_to, value.fname, value.lname, value.node_from, value.node_to, userId).ToList();
                        foreach (var item in dataList)
                        {
                            writer.WriteLine(item.emp_code + "  " + item.type1 + " " + item.tar_date + " " + item.tar_time + " " + item.type2);
                        }
                    }

                    var               file      = System.IO.Path.Combine(out_put_dir, value.fileName);
                    byte[]            fileBytes = System.IO.File.ReadAllBytes(file);
                    FileContentResult result    = new FileContentResult(fileBytes, "application/octet-stream");
                    result.FileDownloadName = value.fileName;
                    return(result);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
示例#22
0
        public projectCourseDetailModel detail2(projectCourseModel value)
        {
            projectCourseDetailModel result = new projectCourseDetailModel();

            try
            {
                using (var context = new StandardCanEntities())
                {
                    if (String.IsNullOrEmpty(value.user_id))
                    {
                        throw new Exception("Unauthorized Access");
                    }
                    var userId = JwtHelper.GetUserIdFromToken(value.user_id);
                    if (String.IsNullOrEmpty(userId))
                    {
                        throw new Exception("Unauthorized Access");
                    }

                    result.data = context.sp_project_course_detail_v4(value.id).ToList();

                    string sql = "";
                    sql            = "select		convert(nvarchar(5), MPJ_ID) code ";
                    sql           += " , MPJ_NAME [text] ";
                    sql           += " from MAS_PROJECT ";
                    sql           += " where MPJ_STATUS = 1 ";
                    sql           += " order by MPJ_NAME ";
                    result.project = context.Database.SqlQuery <dropdown>(sql).ToList();

                    sql           = "select		convert(nvarchar(5), MEP_ID) code ";
                    sql          += " , MEP_NAME [text] ";
                    sql          += " from MAS_EXPERT ";
                    sql          += " where MEP_STATUS = 1 ";
                    sql          += " order by MEP_NAME ";
                    result.expert = context.Database.SqlQuery <dropdown>(sql).ToList();

                    sql             = "select		convert(nvarchar(5), MTD_ID) code ";
                    sql            += " , MTD_NAME [text] ";
                    sql            += " from MAS_TRAIN_DESTINATION ";
                    sql            += " where MTD_STATUS = 1 ";
                    sql            += " order by MTD_NAME ";
                    result.location = context.Database.SqlQuery <dropdown>(sql).ToList();

                    sql            = "select		convert(nvarchar(5), MFL_ID) code ";
                    sql           += " , MFL_NAME [text] ";
                    sql           += " from MAS_FORMULA ";
                    sql           += " where MFL_STATUS = 1 ";
                    sql           += " order by MFL_NAME ";
                    result.formula = context.Database.SqlQuery <dropdown>(sql).ToList();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(result);
        }
示例#23
0
        public messageModel insert(projectFormularModel value)
        {
            messageModel result = new messageModel();

            try
            {
                if (String.IsNullOrEmpty(value.user_id))
                {
                    throw new Exception("Unauthorized Access");
                }
                var userId = JwtHelper.GetUserIdFromToken(value.user_id);
                if (String.IsNullOrEmpty(userId))
                {
                    throw new Exception("Unauthorized Access");
                }

                System.Data.Entity.Core.Objects.ObjectParameter myOutputParamInt = new System.Data.Entity.Core.Objects.ObjectParameter("r_id", typeof(Int32));
                using (var context = new StandardCanEntities())
                {
                    int ret        = context.sp_formular_insert(value.fml_name, value.fml_type, value.fml_input_type, value.user_id, myOutputParamInt);
                    int countRange = value.formularRange.Count();
                    for (int i = 0; i < countRange; i++)
                    {
                        int ret2 = context.sp_formularrange_insert(ret.ToString(), value.formularRange[i].fml_range_no, value.formularRange[i].fml_range_score, value.formularRange[i].fml_range_display, value.user_id, myOutputParamInt);
                    }

                    int countvalue = value.formularValue.Count();
                    for (int i = 0; i < countvalue; i++)
                    {
                        int ret2 = context.sp_formularvalue_insert(ret.ToString(), value.formularValue[i].fmlv_orderby, value.formularValue[i].fmlv_value, value.formularValue[i].fmlv_text, value.user_id, myOutputParamInt);
                    }
                }


                if (myOutputParamInt.Value != null)
                {
                    int r_id = Convert.ToInt32(myOutputParamInt.Value);
                    result.status  = "S";
                    result.message = "";
                    result.value   = r_id.ToString();
                }
                else
                {
                    result.status  = "E";
                    result.message = "";
                }
            }
            catch (Exception ex)
            {
                result.status  = "E";
                result.message = ex.Message.ToString();
            }

            return(result);
        }
示例#24
0
        public FileContentResult exportFileQRCode(qrCodeViewModel value)
        {
            try
            {
                if (String.IsNullOrEmpty(value.user_id))
                {
                    throw new Exception("Unauthorized Access");
                }
                var userId = JwtHelper.GetUserIdFromToken(value.user_id);
                if (String.IsNullOrEmpty(userId))
                {
                    throw new Exception("Unauthorized Access");
                }
                using (var context = new StandardCanEntities())
                {
                    var             fileName    = "QRCode";
                    var             qrCodeData  = String.Format("{0},{1},{2},{3}", value.id, value.req_date, value.start_date, value.stop_date);
                    QRCodeGenerator _qrCode     = new QRCodeGenerator();
                    QRCodeData      _qrCodeData = _qrCode.CreateQrCode(qrCodeData, QRCodeGenerator.ECCLevel.Q);
                    QRCode          qrCode      = new QRCode(_qrCodeData);
                    Bitmap          qrCodeImage = qrCode.GetGraphic(20);

                    var microsoftDateFormatSettings = new JsonSerializerSettings
                    {
                        DateParseHandling  = DateParseHandling.None,
                        DateFormatHandling = DateFormatHandling.IsoDateFormat,
                        Formatting         = Formatting.Indented,
                    };
                    Bitmap newBitmap;
                    PointF roomLocation  = new PointF(70, 30);
                    PointF dateLocation  = new PointF(70, 660);
                    PointF topicLocation = new PointF(70, 700);
                    using (Graphics graphics = Graphics.FromImage(qrCodeImage))
                    {
                        using (Font arialFont = new Font("Arial", 22, FontStyle.Bold))
                        {
                            graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
                            graphics.DrawString(value.room_name, arialFont, Brushes.Blue, roomLocation);
                            graphics.DrawString(value.req_date + " " + value.start_date + "-" + value.stop_date, arialFont, Brushes.Blue, dateLocation);
                            graphics.DrawString(value.topic, arialFont, Brushes.Blue, topicLocation);
                        }
                    }
                    newBitmap = new Bitmap(qrCodeImage);
                    byte[]            fileBytes = BitmapToBytesCode(newBitmap);
                    FileContentResult result    = new FileContentResult(fileBytes, "application/octet-stream");
                    result.FileDownloadName = fileName;
                    return(result);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
示例#25
0
        public messageModel save_Regular(empCheckInModel value)
        {
            messageModel result = new messageModel();

            try
            {
                JavaScriptSerializer js = new JavaScriptSerializer();
                string json             = js.Serialize(value);


                using (var context = new StandardCanEntities())
                {
                    if (String.IsNullOrEmpty(value.user_id))
                    {
                        throw new Exception("Unauthorized Access");
                    }
                    var userId = JwtHelper.GetUserIdFromToken(value.user_id);
                    if (String.IsNullOrEmpty(userId))
                    {
                        throw new Exception("Unauthorized Access");
                    }

                    context.interface_log.Add(new interface_log
                    {
                        ID          = 1,
                        data_log    = json,
                        module      = "save_Regular",
                        update_date = DateTime.Now
                    });
                    context.SaveChanges();

                    int ret = context.sp_emp_regular_delete(userId);

                    if (value.data != null)
                    {
                        foreach (var item in value.data)
                        {
                            context.sp_emp_regular_insert(userId, item.emp_code);
                        }
                    }
                }

                result.status  = "S";
                result.message = "";
            }
            catch (Exception ex)
            {
                result.status  = "E";
                result.message = ex.Message.ToString();
            }

            return(result);
        }
示例#26
0
        public carMasterModel master(carModel value)
        {
            carMasterModel result = new carMasterModel();

            try
            {
                using (var context = new StandardCanEntities())
                {
                    if (String.IsNullOrEmpty(value.user_id))
                    {
                        throw new Exception("Unauthorized Access");
                    }
                    var userId = JwtHelper.GetUserIdFromToken(value.user_id);
                    if (String.IsNullOrEmpty(userId))
                    {
                        throw new Exception("Unauthorized Access");
                    }

                    string sql = "select		convert(nvarchar(5), MCT_ID) code ";
                    sql            += " , MCT_NAME [text] ";
                    sql            += " from MAS_CAR_TYPE ";
                    sql            += " where MCT_STATUS = 1 ";
                    sql            += " order by MCT_NAME ";
                    result.car_type = context.Database.SqlQuery <dropdown>(sql).ToList();

                    sql  = "select		convert(nvarchar(5), MCA_ID) code ";
                    sql += " , MCA_NAME [text] ";
                    sql += " from MAS_CAR ";
                    sql += " where MCT_ID = " + (value.carTypes ?? "0") + "AND MCA_STATUS = 1 ";
                    sql += " order by MCA_NAME ";
                    result.car_license = context.Database.SqlQuery <dropdown>(sql).ToList();

                    sql  = "select		convert(nvarchar(5), MCR_ID) code ";
                    sql += " , MCR_NAME[text] ";
                    sql += " from MAS_CAR_REASON ";
                    sql += " where MCR_STATUS = 1 ";
                    sql += " order by    MCR_NAME ";
                    result.car_reason = context.Database.SqlQuery <dropdown>(sql).ToList();

                    sql  = " select convert(nvarchar(5), MAS_ID) code, mas_name [text] ";
                    sql += " from MAS_APPROVE_STATUS ";
                    sql += " where MAS_ID != 0 ";
                    sql += " order by mas_orderby ";
                    result.car_status = context.Database.SqlQuery <dropdown>(sql).ToList();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(result);
        }
示例#27
0
 public IEnumerable <sp_emp_profile_tabcard_search_Result> tab_card_search(employeeModel value)
 {
     try
     {
         StandardCanEntities context = new StandardCanEntities();
         IEnumerable <sp_emp_profile_tabcard_search_Result> result = context.sp_emp_profile_tabcard_search(value.emp_code).AsEnumerable();
         return(result);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
示例#28
0
        public bookRoomMasterModel master(bookRoomModel value)
        {
            bookRoomMasterModel result = new bookRoomMasterModel();

            try
            {
                using (var context = new StandardCanEntities())
                {
                    if (String.IsNullOrEmpty(value.user_id))
                    {
                        throw new Exception("Unauthorized Access");
                    }
                    var userId = JwtHelper.GetUserIdFromToken(value.user_id);
                    if (String.IsNullOrEmpty(userId))
                    {
                        throw new Exception("Unauthorized Access");
                    }

                    string sql = "select		convert(nvarchar(5), MRM_ID) code ";
                    sql        += " , MRM_CODE [text] ";
                    sql        += " from MAS_ROOM ";
                    sql        += " order by MRM_CODE ";
                    result.room = context.Database.SqlQuery <dropdown>(sql).ToList();

                    sql           = " select convert(nvarchar(5), MAS_ID) code, mas_name [text] ";
                    sql          += " from MAS_APPROVE_STATUS ";
                    sql          += " where MAS_ID != 0 ";
                    sql          += " order by mas_orderby ";
                    result.status = context.Database.SqlQuery <dropdown>(sql).ToList();
                }

                //if (myOutputParamInt.Value != null)
                //{
                //    int r_id = Convert.ToInt32(myOutputParamInt.Value);
                //    result.status = "S";
                //    result.message = "";
                //    result.value = r_id.ToString();
                //}
                //else
                //{
                //    result.status = "E";
                //    result.message = "";
                //}
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(result);
        }
示例#29
0
        public messageAuthenticationModel LoginToken(string token)
        {
            messageAuthenticationModel result = new messageAuthenticationModel();

            try
            {
                using (var context = new StandardCanEntities())
                {
                    result.message = new messageModel();
                    var userId = JwtHelper.GetUserIdFromToken(token);
                    //var passEncrypt = Cipher.Encrypt(password, secrectKey);
                    var userGroupList = context.USER_GROUP.ToList();
                    var empDetail     = context.EMP_PROFILE.SingleOrDefault(a => a.EMP_ID.ToString() == userId);
                    if (empDetail != null)
                    {
                        var countBoss = context.EMP_PROFILE.Where(a => a.emp_boss_id == empDetail.EMP_ID).ToList().Count();
                        result.message.status  = "1";
                        result.message.message = "";
                        var groupName = userGroupList.SingleOrDefault(a => a.Group_ID == empDetail.emp_group);
                        if (countBoss > 0)
                        {
                            result.permission = "2";
                        }
                        else if (groupName.Group_Name == "EMP")
                        {
                            result.permission = "1";
                        }
                        else if (groupName.Group_Name == "ADMIN")
                        {
                            result.permission = "3";
                        }
                        else if (groupName.Group_Name == "ACC")
                        {
                            result.permission = "4";
                        }
                        result.token_login = CreateToken(empDetail.EMP_ID.ToString(), result.permission, groupName.Group_Name);
                    }
                    else
                    {
                        throw new Exception("The username or password is incorrect");
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("The username or password is incorrect");
            }

            return(result);
        }
示例#30
0
        public projectFomularResult searchFomulay(projectTrainingScheduleModel value)
        {
            projectFomularResult result = new projectFomularResult();

            result.message = new messageModel();
            try
            {
                using (StandardCanEntities context = new StandardCanEntities())
                {
                    //if (String.IsNullOrEmpty(value.user_id))
                    //{
                    //    throw new Exception("Unauthorized Access");
                    //}
                    //var userId = JwtHelper.GetUserIdFromToken(value.user_id);
                    //if (String.IsNullOrEmpty(userId))
                    //{
                    //    throw new Exception("Unauthorized Access");
                    //}
                    JavaScriptSerializer js = new JavaScriptSerializer();
                    string json             = js.Serialize(value);
                    context.interface_log.Add(new interface_log
                    {
                        data_log    = json,
                        module      = "searchFomulay",
                        update_date = DateTime.Now
                    });
                    context.SaveChanges();

                    string sql = "";
                    sql        += "select		convert(int, b.MFV_ORDER_BY) order_by, MFV_VALUE value, MFV_TEXT text ";
                    sql        += " from MAS_COURSE a inner ";
                    sql        += " join MAS_FORMULA_VALUE b on a.MFL_ID = b.MFL_ID ";
                    sql        += " where a.MCS_ID = " + value.course_id + " and MFV_STATUS = 1 ";
                    sql        += " order by    b.MFV_ORDER_BY ";
                    result.data = context.Database.SqlQuery <fomularField>(sql).ToList();



                    result.message.status  = "S";
                    result.message.message = "Success";
                }
            }
            catch (Exception ex)
            {
                result.message.status  = "E";
                result.message.message = ex.Message.ToString();
            }
            return(result);
        }