Пример #1
0
        public async Task <ModelResponseMessageLogin> LogOut(EntityLogSystem entity_model)
        {
            ModelResponseMessageLogin resp = new ModelResponseMessageLogin();

            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                conn.Open();
                using (SqlCommand cmd = new SqlCommand("sp_logout_system", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@RegisterId", SqlDbType.VarChar, 50).Value = entity_model.register_id;
                    cmd.Parameters.Add("@UserId", SqlDbType.VarChar, 50).Value     = entity_model.userid;
                    cmd.Parameters.Add("@LogEvent", SqlDbType.VarChar, 200).Value  = ParseDataHelper.ConvertDBNull(entity_model.log_event);
                    cmd.Parameters.Add("@LogDate", SqlDbType.DateTime).Value       = entity_model.log_date;

                    SqlParameter rStatus = cmd.Parameters.Add("@rStatus", SqlDbType.Int);
                    rStatus.Direction = ParameterDirection.Output;
                    SqlParameter rMessage = cmd.Parameters.Add("@rMessage", SqlDbType.NVarChar, 500);
                    rMessage.Direction = ParameterDirection.Output;

                    await cmd.ExecuteNonQueryAsync();

                    if ((int)cmd.Parameters["@rStatus"].Value > 0)
                    {
                        resp.Status = true;
                    }
                    else
                    {
                        resp.Message = (string)cmd.Parameters["@rMessage"].Value;
                    }
                }
                conn.Close();
            }
            return(resp);
        }
Пример #2
0
        public async Task <ModelResponseA6Message> AddDocMenuA6Async(ModelMenuA6 model)
        {
            var cultureInfo = new CultureInfo("en-GB");

            CultureInfo.DefaultThreadCurrentCulture   = cultureInfo;
            CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;

            ModelResponseA6Message resp = new ModelResponseA6Message();

            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                conn.Open();
                using (SqlCommand cmd = new SqlCommand("sp_doc_menu_a6", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add("@doc_date", SqlDbType.DateTime).Value               = model.docdate.ToString("yyyy-MM-dd");
                    cmd.Parameters.Add("@project_number", SqlDbType.VarChar, 20).Value      = ParseDataHelper.ConvertDBNull(model.projectnumber);
                    cmd.Parameters.Add("@project_head_name", SqlDbType.VarChar, 200).Value  = ParseDataHelper.ConvertDBNull(model.projectheadname);
                    cmd.Parameters.Add("@position_name_thai", SqlDbType.VarChar, 200).Value = ParseDataHelper.ConvertDBNull(model.positionnamethai);
                    cmd.Parameters.Add("@faculty_name", SqlDbType.VarChar, 200).Value       = ParseDataHelper.ConvertDBNull(model.facultyname);
                    cmd.Parameters.Add("@project_name_thai", SqlDbType.VarChar, 200).Value  = ParseDataHelper.ConvertDBNull(model.projectnamethai);
                    cmd.Parameters.Add("@project_name_eng", SqlDbType.VarChar, 200).Value   = ParseDataHelper.ConvertDBNull(model.projectnameeng);
                    cmd.Parameters.Add("@accept_type_name", SqlDbType.VarChar, 200).Value   = ParseDataHelper.ConvertDBNull(model.accepttypenamethai);
                    cmd.Parameters.Add("@conclusion_date", SqlDbType.DateTime).Value        = Convert.ToDateTime(model.conclusiondate);
                    cmd.Parameters.Add("@renew_round", SqlDbType.Int).Value        = model.renewround;
                    cmd.Parameters.Add("@file1name", SqlDbType.VarChar, 200).Value = ParseDataHelper.ConvertDBNull(model.file1name);

                    cmd.Parameters.Add("@create_by", SqlDbType.VarChar, 50).Value = Encoding.UTF8.GetString(Convert.FromBase64String(model.createby));

                    SqlParameter rStatus = cmd.Parameters.Add("@rStatus", SqlDbType.Int);
                    rStatus.Direction = ParameterDirection.Output;
                    SqlParameter rMessage = cmd.Parameters.Add("@rMessage", SqlDbType.NVarChar, 500);
                    rMessage.Direction = ParameterDirection.Output;
                    SqlParameter rDocId = cmd.Parameters.Add("@rDocId", SqlDbType.Int);
                    rDocId.Direction = ParameterDirection.Output;

                    await cmd.ExecuteNonQueryAsync();

                    if ((int)cmd.Parameters["@rStatus"].Value > 0)
                    {
                        resp.Status = true;

                        model_rpt_7_file rpt = await _IDocMenuReportRepository.GetReportR7Async((int)cmd.Parameters["@rDocId"].Value);

                        resp.filename   = rpt.filename;
                        resp.filebase64 = rpt.filebase64;
                    }
                    else
                    {
                        resp.Message = (string)cmd.Parameters["@rMessage"].Value;
                    }
                }
                conn.Close();
            }
            return(resp);
        }
Пример #3
0
        public async Task <ModelResponseD2Message> AddDocMenuD2Async(ModelMenuD2 model)
        {
            var cultureInfo = new CultureInfo("en-GB");

            CultureInfo.DefaultThreadCurrentCulture   = cultureInfo;
            CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;

            ModelResponseD2Message resp = new ModelResponseD2Message();

            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                conn.Open();
                using (SqlCommand cmd = new SqlCommand("sp_doc_menu_d2", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add("@project_number", SqlDbType.VarChar, 20).Value      = ParseDataHelper.ConvertDBNull(model.projectnumber);
                    cmd.Parameters.Add("@project_head_name", SqlDbType.VarChar, 200).Value  = ParseDataHelper.ConvertDBNull(model.projectheadname);
                    cmd.Parameters.Add("@project_name_thai", SqlDbType.VarChar, 200).Value  = ParseDataHelper.ConvertDBNull(model.projectnamethai);
                    cmd.Parameters.Add("@project_name_eng", SqlDbType.VarChar, 200).Value   = ParseDataHelper.ConvertDBNull(model.projectnameeng);
                    cmd.Parameters.Add("@file_download_name", SqlDbType.VarChar, 200).Value = ParseDataHelper.ConvertDBNull(model.filedownloadname);
                    cmd.Parameters.Add("@agenda_number", SqlDbType.Int).Value              = model.agendanumber;
                    cmd.Parameters.Add("@year_of_meeting", SqlDbType.Int).Value            = model.yearofmeeting;
                    cmd.Parameters.Add("@agenda_meeting_date", SqlDbType.DateTime).Value   = Convert.ToDateTime(model.agendameetingdate);
                    cmd.Parameters.Add("@suggestion", SqlDbType.VarChar, 200).Value        = ParseDataHelper.ConvertDBNull(model.acceptTypeNameThai);
                    cmd.Parameters.Add("@remark_suggestion", SqlDbType.VarChar, 200).Value = ParseDataHelper.ConvertDBNull(model.remarkApproval);
                    cmd.Parameters.Add("@conclusion_date", SqlDbType.DateTime).Value       = Convert.ToDateTime(model.conclusiondate);

                    cmd.Parameters.Add("@create_by", SqlDbType.VarChar, 50).Value = Encoding.UTF8.GetString(Convert.FromBase64String(model.createby));

                    SqlParameter rStatus = cmd.Parameters.Add("@rStatus", SqlDbType.Int);
                    rStatus.Direction = ParameterDirection.Output;
                    SqlParameter rMessage = cmd.Parameters.Add("@rMessage", SqlDbType.NVarChar, 500);
                    rMessage.Direction = ParameterDirection.Output;
                    SqlParameter rDocId = cmd.Parameters.Add("@rDocId", SqlDbType.Int);
                    rDocId.Direction = ParameterDirection.Output;

                    await cmd.ExecuteNonQueryAsync();

                    if ((int)cmd.Parameters["@rStatus"].Value > 0)
                    {
                        resp.Status = true;
                    }
                    else
                    {
                        resp.Message = (string)cmd.Parameters["@rMessage"].Value;
                    }
                }
                conn.Close();
            }
            return(resp);
        }
Пример #4
0
        public async Task <ModelResponseD1Message> UpdateDocMenuD1EditAsync(ModelMenuD1 model)
        {
            var cultureInfo = new CultureInfo("en-GB");

            CultureInfo.DefaultThreadCurrentCulture   = cultureInfo;
            CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;

            ModelResponseD1Message resp = new ModelResponseD1Message();

            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                conn.Open();
                using (SqlCommand cmd = new SqlCommand("sp_doc_menu_d1_edit", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add("@doc_id", SqlDbType.Int).Value                     = model.docid;
                    cmd.Parameters.Add("@doc_date", SqlDbType.DateTime).Value              = model.docdate.ToString("yyyy-MM-dd");
                    cmd.Parameters.Add("@project_number", SqlDbType.VarChar, 20).Value     = ParseDataHelper.ConvertDBNull(model.projectnumber);
                    cmd.Parameters.Add("@project_head_name", SqlDbType.VarChar, 200).Value = ParseDataHelper.ConvertDBNull(model.projectheadname);
                    cmd.Parameters.Add("@faculty_name", SqlDbType.VarChar, 200).Value      = ParseDataHelper.ConvertDBNull(model.facultyname);
                    cmd.Parameters.Add("@project_name_thai", SqlDbType.VarChar, 200).Value = ParseDataHelper.ConvertDBNull(model.projectnamethai);
                    cmd.Parameters.Add("@project_name_eng", SqlDbType.VarChar, 200).Value  = ParseDataHelper.ConvertDBNull(model.projectnameeng);
                    cmd.Parameters.Add("@accept_type_name", SqlDbType.VarChar, 200).Value  = ParseDataHelper.ConvertDBNull(model.accepttypenamethai);
                    cmd.Parameters.Add("@advisorsNameThai", SqlDbType.VarChar, 200).Value  = ParseDataHelper.ConvertDBNull(model.advisorsnamethai);
                    cmd.Parameters.Add("@acceptProjectNo", SqlDbType.VarChar, 50).Value    = ParseDataHelper.ConvertDBNull(model.acceptprojectno);
                    cmd.Parameters.Add("@acceptResult", SqlDbType.Int).Value               = model.acceptresult;
                    cmd.Parameters.Add("@acceptCondition", SqlDbType.Int).Value            = model.acceptcondition;

                    cmd.Parameters.Add("@create_by", SqlDbType.VarChar, 50).Value = Encoding.UTF8.GetString(Convert.FromBase64String(model.createby));

                    // จริงๆไม่ต้องใช้แล้ว ------------------------------------------------------------------------------
                    cmd.Parameters.Add("@acceptDate", SqlDbType.DateTime).Value = Convert.ToDateTime(DateTime.Now);
                    cmd.Parameters.Add("@expireDate", SqlDbType.DateTime).Value = Convert.ToDateTime(DateTime.Now);
                    //---------------------------------------------------------------------------------------------

                    SqlParameter rStatus = cmd.Parameters.Add("@rStatus", SqlDbType.Int);
                    rStatus.Direction = ParameterDirection.Output;
                    SqlParameter rMessage = cmd.Parameters.Add("@rMessage", SqlDbType.NVarChar, 500);
                    rMessage.Direction = ParameterDirection.Output;

                    await cmd.ExecuteNonQueryAsync();

                    if ((int)cmd.Parameters["@rStatus"].Value > 0)
                    {
                        resp.Status = true;

                        model_rpt_9_file rpt = await _IDocMenuReportRepository.GetReportR9Async(Convert.ToInt32(model.docid));

                        resp.filename   = rpt.filename;
                        resp.filebase64 = rpt.filebase64;
                    }
                    else
                    {
                        resp.Message = (string)cmd.Parameters["@rMessage"].Value;
                    }
                }
                conn.Close();
            }
            return(resp);
        }
Пример #5
0
        public async Task <ModelResponseMessageUpdateUserRegister> UpdateUserAccountAsync(ModelUpdateAccountUser model)
        {
            ModelResponseMessageUpdateUserRegister resp = new ModelResponseMessageUpdateUserRegister();

            string userid = Encoding.UTF8.GetString(Convert.FromBase64String(model.registerid));

            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                conn.Open();
                using (SqlCommand cmd = new SqlCommand("sp_update_user_account", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add("@RegisterId", SqlDbType.VarChar, 100).Value = userid;
                    cmd.Parameters.Add("@Email", SqlDbType.VarChar, 200).Value      = ParseDataHelper.ConvertDBNull(model.email);
                    cmd.Parameters.Add("@FirstName1", SqlDbType.VarChar, 50).Value  = ParseDataHelper.ConvertDBNull(model.firstname1);
                    cmd.Parameters.Add("@FirstName2", SqlDbType.VarChar, 50).Value  = ParseDataHelper.ConvertDBNull(model.firstname2);
                    cmd.Parameters.Add("@FirstName", SqlDbType.VarChar, 50).Value   = ParseDataHelper.ConvertDBNull(model.firstname);
                    cmd.Parameters.Add("@FullName", SqlDbType.VarChar, 200).Value   = ParseDataHelper.ConvertDBNull(model.fullname);
                    cmd.Parameters.Add("@WorkPhone", SqlDbType.VarChar, 50).Value   = ParseDataHelper.ConvertDBNull(model.workphone);
                    cmd.Parameters.Add("@Mobile", SqlDbType.VarChar, 20).Value      = ParseDataHelper.ConvertDBNull(model.mobile);
                    cmd.Parameters.Add("@Fax", SqlDbType.VarChar, 20).Value         = ParseDataHelper.ConvertDBNull(model.fax);
                    cmd.Parameters.Add("@Position", SqlDbType.VarChar, 2).Value     = model.position;
                    cmd.Parameters.Add("@Faculty", SqlDbType.VarChar, 2).Value      = model.faculty;
                    cmd.Parameters.Add("@Education", SqlDbType.VarChar, 2).Value    = model.education;
                    cmd.Parameters.Add("@Note1", SqlDbType.NVarChar).Value          = ParseDataHelper.ConvertDBNull(model.note1);
                    cmd.Parameters.Add("@Note2", SqlDbType.NVarChar).Value          = ParseDataHelper.ConvertDBNull(model.note2);
                    cmd.Parameters.Add("@Note3", SqlDbType.NVarChar).Value          = ParseDataHelper.ConvertDBNull(model.note3);

                    SqlParameter rStatus = cmd.Parameters.Add("@rStatus", SqlDbType.Int);
                    rStatus.Direction = ParameterDirection.Output;
                    SqlParameter rMessage = cmd.Parameters.Add("@rMessage", SqlDbType.NVarChar, 500);
                    rMessage.Direction = ParameterDirection.Output;

                    await cmd.ExecuteNonQueryAsync();

                    if ((int)cmd.Parameters["@rStatus"].Value > 0)
                    {
                        resp.Status = true;
                    }
                    else
                    {
                        resp.Message = (string)cmd.Parameters["@rMessage"].Value;
                    }
                }
                conn.Close();
            }
            return(resp);
        }
Пример #6
0
        public async Task <ModelResponseMessage> AddDocMenuE1Async(ModelMenuE1 model)
        {
            ModelResponseMessage resp = new ModelResponseMessage();

            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                conn.Open();
                using (SqlCommand cmd = new SqlCommand("sp_doc_menu_e1", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add("@section_name", SqlDbType.VarChar, 200).Value = ParseDataHelper.ConvertDBNull(model.sectionName);
                    cmd.Parameters.Add("@faculty", SqlDbType.Int).Value = model.faculty;
                    cmd.Parameters.Add("@department_name", SqlDbType.VarChar, 200).Value  = ParseDataHelper.ConvertDBNull(model.departmentName);
                    cmd.Parameters.Add("@phone", SqlDbType.VarChar, 200).Value            = ParseDataHelper.ConvertDBNull(model.phone);
                    cmd.Parameters.Add("@fax", SqlDbType.VarChar, 200).Value              = ParseDataHelper.ConvertDBNull(model.fax);
                    cmd.Parameters.Add("@email", SqlDbType.VarChar, 200).Value            = ParseDataHelper.ConvertDBNull(model.email);
                    cmd.Parameters.Add("@group_1_genus", SqlDbType.VarChar, 200).Value    = ParseDataHelper.ConvertDBNull(model.group1genus);
                    cmd.Parameters.Add("@group_1_species", SqlDbType.VarChar, 200).Value  = ParseDataHelper.ConvertDBNull(model.group1species);
                    cmd.Parameters.Add("@group_1_risk_human", SqlDbType.Int).Value        = model.group1riskHuman;
                    cmd.Parameters.Add("@group_1_risk_animal", SqlDbType.Int).Value       = model.group1riskAnimal;
                    cmd.Parameters.Add("@group_1_pathogens", SqlDbType.Int).Value         = model.group1pathogens;
                    cmd.Parameters.Add("@group_1_virus", SqlDbType.VarChar, 200).Value    = ParseDataHelper.ConvertDBNull(model.group1virus);
                    cmd.Parameters.Add("@group_1_bacteria", SqlDbType.VarChar, 200).Value = ParseDataHelper.ConvertDBNull(model.group1bacteria);
                    cmd.Parameters.Add("@group_1_parasit", SqlDbType.VarChar, 200).Value  = ParseDataHelper.ConvertDBNull(model.group1paraSit);
                    cmd.Parameters.Add("@group_1_mold", SqlDbType.VarChar, 200).Value     = ParseDataHelper.ConvertDBNull(model.group1mold);
                    cmd.Parameters.Add("@group_1_protein", SqlDbType.VarChar, 200).Value  = ParseDataHelper.ConvertDBNull(model.group1protein);
                    cmd.Parameters.Add("@group_2_genus", SqlDbType.VarChar, 200).Value    = ParseDataHelper.ConvertDBNull(model.group2genus);
                    cmd.Parameters.Add("@group_2_species", SqlDbType.VarChar, 200).Value  = ParseDataHelper.ConvertDBNull(model.group2species);
                    cmd.Parameters.Add("@group_2_risk_human", SqlDbType.Int).Value        = model.group2riskHuman;
                    cmd.Parameters.Add("@group_2_risk_animal", SqlDbType.Int).Value       = model.group2riskAnimal;
                    cmd.Parameters.Add("@group_2_pathogens", SqlDbType.Int).Value         = model.group2pathogens;
                    cmd.Parameters.Add("@group_2_virus", SqlDbType.VarChar, 200).Value    = ParseDataHelper.ConvertDBNull(model.group2virus);
                    cmd.Parameters.Add("@group_2_bacteria", SqlDbType.VarChar, 200).Value = ParseDataHelper.ConvertDBNull(model.group2bacteria);
                    cmd.Parameters.Add("@group_2_parasit", SqlDbType.VarChar, 200).Value  = ParseDataHelper.ConvertDBNull(model.group2paraSit);
                    cmd.Parameters.Add("@group_2_mold", SqlDbType.VarChar, 200).Value     = ParseDataHelper.ConvertDBNull(model.group2mold);
                    cmd.Parameters.Add("@group_2_protein", SqlDbType.VarChar, 200).Value  = ParseDataHelper.ConvertDBNull(model.group2protein);

                    SqlParameter rStatus = cmd.Parameters.Add("@rStatus", SqlDbType.Int);
                    rStatus.Direction = ParameterDirection.Output;
                    SqlParameter rMessage = cmd.Parameters.Add("@rMessage", SqlDbType.NVarChar, 500);
                    rMessage.Direction = ParameterDirection.Output;

                    await cmd.ExecuteNonQueryAsync();

                    if ((int)cmd.Parameters["@rStatus"].Value > 0)
                    {
                        resp.Status = true;
                    }
                    else
                    {
                        resp.Message = (string)cmd.Parameters["@rMessage"].Value;
                    }
                }
                conn.Close();
            }
            return(resp);
        }
Пример #7
0
        public async Task <ModelResponseMessageAddDocB1> UpdateDocMenuB1Async(ModelMenuB1Edit model)
        {
            ModelResponseMessageAddDocB1 resp = new ModelResponseMessageAddDocB1();

            try
            {
                var cultureInfo = new CultureInfo("en-GB");
                CultureInfo.DefaultThreadCurrentCulture   = cultureInfo;
                CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;

                using (SqlConnection conn = new SqlConnection(ConnectionString))
                {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand("sp_doc_menu_b1_edit", conn))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;

                        string project_head = Encoding.UTF8.GetString(Convert.FromBase64String(model.projecthead));

                        cmd.Parameters.Add("@doc_id", SqlDbType.Int).Value                            = model.docid;
                        cmd.Parameters.Add("@doc_date", SqlDbType.DateTime).Value                     = model.docdate.ToString("yyyy-MM-dd");
                        cmd.Parameters.Add("@accept_type", SqlDbType.VarChar, 2).Value                = ParseDataHelper.ConvertDBNull(model.accepttype);
                        cmd.Parameters.Add("@project_head", SqlDbType.VarChar, 50).Value              = ParseDataHelper.ConvertDBNull(project_head);
                        cmd.Parameters.Add("@project_id", SqlDbType.Int).Value                        = ParseDataHelper.ConvertDBNull(model.projectid);
                        cmd.Parameters.Add("@project_name_thai", SqlDbType.NVarChar).Value            = ParseDataHelper.ConvertDBNull(model.projectnamethai);
                        cmd.Parameters.Add("@project_name_eng", SqlDbType.VarChar, 200).Value         = ParseDataHelper.ConvertDBNull(model.projectnameeng);
                        cmd.Parameters.Add("@acronyms", SqlDbType.VarChar, 3).Value                   = ParseDataHelper.ConvertDBNull(model.acronyms);
                        cmd.Parameters.Add("@initial_result", SqlDbType.VarChar, 50).Value            = ParseDataHelper.ConvertDBNull(model.initialresult);
                        cmd.Parameters.Add("@file_download_name_title", SqlDbType.VarChar, 500).Value = ParseDataHelper.ConvertDBNull(model.filedownloadnametitle);
                        cmd.Parameters.Add("@file_download_name", SqlDbType.VarChar, 200).Value       = ParseDataHelper.ConvertDBNull(model.filedownloadname);
                        cmd.Parameters.Add("@project_key_number", SqlDbType.VarChar, 20).Value        = ParseDataHelper.ConvertDBNull(model.projectkeynumber);
                        cmd.Parameters.Add("@notes", SqlDbType.NVarChar).Value                        = ParseDataHelper.ConvertDBNull(model.notes);
                        cmd.Parameters.Add("@round_of_meeting", SqlDbType.Int).Value                  = model.roundofmeeting;
                        cmd.Parameters.Add("@year_of_meeting", SqlDbType.Int).Value                   = model.yearofmeeting;
                        cmd.Parameters.Add("@year_of_running", SqlDbType.Int).Value                   = model.defaultyear;
                        cmd.Parameters.Add("@meeting_date", SqlDbType.DateTime).Value                 = Convert.ToDateTime(model.meetingdate);

                        cmd.Parameters.Add("@create_by", SqlDbType.VarChar, 50).Value = Encoding.UTF8.GetString(Convert.FromBase64String(model.createby));

                        SqlParameter rStatus = cmd.Parameters.Add("@rStatus", SqlDbType.Int);
                        rStatus.Direction = ParameterDirection.Output;
                        SqlParameter rMessage = cmd.Parameters.Add("@rMessage", SqlDbType.NVarChar, 500);
                        rMessage.Direction = ParameterDirection.Output;

                        await cmd.ExecuteNonQueryAsync();

                        if ((int)cmd.Parameters["@rStatus"].Value > 0)
                        {
                            resp.Status    = true;
                            resp.DocNumber = (string)cmd.Parameters["@rMessage"].Value;

                            model_rpt_8_file rpt = await _IDocMenuReportRepository.GetReportR8Async(Convert.ToInt32(model.docid));

                            resp.filename   = rpt.filename;
                            resp.filebase64 = rpt.filebase64;
                        }
                        else
                        {
                            resp.Message = (string)cmd.Parameters["@rMessage"].Value;
                        }
                    }
                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(resp);
        }
Пример #8
0
        public async Task <ModelResponseC12Message> AddDocMenuC12Async(ModelMenuC12 model)
        {
            var cultureInfo = new CultureInfo("en-GB");

            CultureInfo.DefaultThreadCurrentCulture   = cultureInfo;
            CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;

            ModelResponseC12Message resp = new ModelResponseC12Message();

            try
            {
                using (SqlConnection conn = new SqlConnection(ConnectionString))
                {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand("sp_doc_menu_c1_2", conn))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;

                        string assigner_code = Encoding.UTF8.GetString(Convert.FromBase64String(model.assignercode));

                        cmd.Parameters.Add("@assigner_code", SqlDbType.VarChar, 50).Value      = ParseDataHelper.ConvertDBNull(assigner_code);
                        cmd.Parameters.Add("@position_name", SqlDbType.VarChar, 200).Value     = ParseDataHelper.ConvertDBNull(model.positionname);
                        cmd.Parameters.Add("@accept_type", SqlDbType.VarChar, 200).Value       = ParseDataHelper.ConvertDBNull(model.accepttype);
                        cmd.Parameters.Add("@project_number", SqlDbType.VarChar, 20).Value     = ParseDataHelper.ConvertDBNull(model.projectnumber);
                        cmd.Parameters.Add("@lab_type_name", SqlDbType.VarChar, 200).Value     = ParseDataHelper.ConvertDBNull(model.labtypename);
                        cmd.Parameters.Add("@faculty_name", SqlDbType.VarChar, 200).Value      = ParseDataHelper.ConvertDBNull(model.facultyname);
                        cmd.Parameters.Add("@board_code_array", SqlDbType.VarChar).Value       = JsonConvert.SerializeObject(model.boardcodearray);
                        cmd.Parameters.Add("@speciallist_code_array", SqlDbType.VarChar).Value = JsonConvert.SerializeObject(model.speciallistcodearray);
                        cmd.Parameters.Add("@round_of_meeting", SqlDbType.Int).Value           = model.roundofmeeting;
                        cmd.Parameters.Add("@year_of_meeting", SqlDbType.Int).Value            = model.yearofmeeting;
                        cmd.Parameters.Add("@meeting_date", SqlDbType.DateTime).Value          = Convert.ToDateTime(model.meetingdate);

                        SqlParameter rStatus = cmd.Parameters.Add("@rStatus", SqlDbType.Int);
                        rStatus.Direction = ParameterDirection.Output;
                        SqlParameter rMessage = cmd.Parameters.Add("@rMessage", SqlDbType.NVarChar, 500);
                        rMessage.Direction = ParameterDirection.Output;

                        await cmd.ExecuteNonQueryAsync();

                        if ((int)cmd.Parameters["@rStatus"].Value > 0)
                        {
                            resp.Status = true;

                            resp.EmailArray = await GetEmailUserC12Async(model);
                        }
                        else
                        {
                            resp.Message = (string)cmd.Parameters["@rMessage"].Value;
                        }
                    }
                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(resp);
        }
Пример #9
0
        public async Task <ModelResponseC1Message> AddDocMenuC1Async(ModelMenuC1 model)
        {
            var cultureInfo = new CultureInfo("en-GB");

            CultureInfo.DefaultThreadCurrentCulture   = cultureInfo;
            CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;

            ModelResponseC1Message resp = new ModelResponseC1Message();

            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                conn.Open();
                using (SqlCommand cmd = new SqlCommand("sp_doc_menu_c1", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    string assigner_code = Encoding.UTF8.GetString(Convert.FromBase64String(model.assignercode));

                    cmd.Parameters.Add("@assigner_code", SqlDbType.VarChar, 50).Value      = ParseDataHelper.ConvertDBNull(assigner_code);
                    cmd.Parameters.Add("@position_name", SqlDbType.VarChar, 200).Value     = ParseDataHelper.ConvertDBNull(model.positionname);
                    cmd.Parameters.Add("@accept_type", SqlDbType.VarChar, 200).Value       = ParseDataHelper.ConvertDBNull(model.accepttype);
                    cmd.Parameters.Add("@project_number", SqlDbType.VarChar, 20).Value     = ParseDataHelper.ConvertDBNull(model.projectnumber);
                    cmd.Parameters.Add("@project_head_name", SqlDbType.VarChar, 200).Value = ParseDataHelper.ConvertDBNull(model.projectheadname);
                    cmd.Parameters.Add("@faculty_name", SqlDbType.VarChar, 200).Value      = ParseDataHelper.ConvertDBNull(model.facultyname);
                    cmd.Parameters.Add("@project_name_thai", SqlDbType.VarChar, 200).Value = ParseDataHelper.ConvertDBNull(model.projectnamethai);
                    cmd.Parameters.Add("@project_name_eng", SqlDbType.VarChar, 200).Value  = ParseDataHelper.ConvertDBNull(model.projectnameeng);
                    cmd.Parameters.Add("@board_code_array", SqlDbType.VarChar).Value       = JsonConvert.SerializeObject(model.boardcodearray);
                    cmd.Parameters.Add("@speciallist_code_array", SqlDbType.VarChar).Value = JsonConvert.SerializeObject(model.speciallistcodearray);
                    cmd.Parameters.Add("@round_of_meeting", SqlDbType.Int).Value           = model.roundofmeeting;
                    cmd.Parameters.Add("@year_of_meeting", SqlDbType.Int).Value            = model.yearofmeeting;
                    cmd.Parameters.Add("@meeting_date", SqlDbType.DateTime).Value          = Convert.ToDateTime(model.meetingdate);

                    cmd.Parameters.Add("@create_by", SqlDbType.VarChar, 50).Value = Encoding.UTF8.GetString(Convert.FromBase64String(model.createby));

                    int           seq = 1;
                    StringBuilder list_committee_code_array = new StringBuilder();
                    StringBuilder list_committee_name_array = new StringBuilder();
                    if (model.boardcodearray != null && model.boardcodearray.Count > 0)
                    {
                        foreach (var item in model.boardcodearray)
                        {
                            list_committee_code_array.AppendLine(Encoding.UTF8.GetString(Convert.FromBase64String(item.value.Trim())) + ", ");
                            list_committee_name_array.AppendLine(seq.ToString() + ". " + item.label.Trim());
                            seq++;
                        }
                    }
                    cmd.Parameters.Add("@committee_code_array", SqlDbType.NVarChar).Value = list_committee_code_array.ToString();
                    cmd.Parameters.Add("@committee_name_array", SqlDbType.NVarChar).Value = list_committee_name_array.ToString();

                    SqlParameter rStatus = cmd.Parameters.Add("@rStatus", SqlDbType.Int);
                    rStatus.Direction = ParameterDirection.Output;
                    SqlParameter rMessage = cmd.Parameters.Add("@rMessage", SqlDbType.NVarChar, 500);
                    rMessage.Direction = ParameterDirection.Output;
                    SqlParameter rDocId = cmd.Parameters.Add("@rDocId", SqlDbType.Int);
                    rDocId.Direction = ParameterDirection.Output;

                    await cmd.ExecuteNonQueryAsync();

                    if ((int)cmd.Parameters["@rStatus"].Value > 0)
                    {
                        resp.Status = true;

                        resp.EmailArray = await GetEmailUserAsync(model);

                        model_rpt_11_file rpt = await _IDocMenuReportRepository.GetReportR11Async((int)cmd.Parameters["@rDocId"].Value);

                        resp.filename   = rpt.filename;
                        resp.filebase64 = rpt.filebase64;
                    }
                    else
                    {
                        resp.Message = (string)cmd.Parameters["@rMessage"].Value;
                    }
                }
                conn.Close();
            }

            return(resp);
        }
Пример #10
0
        public async Task <ModelResponseMessageAddDocB2> AddDocMenuB2Async(ModelMenuB2 model)
        {
            var cultureInfo = new CultureInfo("en-GB");

            CultureInfo.DefaultThreadCurrentCulture   = cultureInfo;
            CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;

            ModelResponseMessageAddDocB2 resp = new ModelResponseMessageAddDocB2();

            try
            {
                using (SqlConnection conn = new SqlConnection(ConnectionString))
                {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand("sp_doc_menu_b2", conn))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;

                        cmd.Parameters.Add("@doc_date", SqlDbType.DateTime).Value      = model.docdate.ToString("yyyy-MM-dd");
                        cmd.Parameters.Add("@accept_type", SqlDbType.VarChar, 2).Value = ParseDataHelper.ConvertDBNull(model.accepttype);
                        cmd.Parameters.Add("@project_id", SqlDbType.Int).Value         = model.projectid;

                        char[]   spearator  = { ':' };
                        string[] lab_number = model.labNumber.Split(spearator, System.StringSplitOptions.RemoveEmptyEntries);

                        cmd.Parameters.Add("@lab_number", SqlDbType.VarChar, 50).Value          = ParseDataHelper.ConvertDBNull(lab_number[0].ToString().Trim());
                        cmd.Parameters.Add("@lab_type_name", SqlDbType.VarChar, 200).Value      = ParseDataHelper.ConvertDBNull(model.labTypeName);
                        cmd.Parameters.Add("@faculty_name", SqlDbType.VarChar, 200).Value       = ParseDataHelper.ConvertDBNull(model.facultyName);
                        cmd.Parameters.Add("@initial_result", SqlDbType.VarChar, 50).Value      = ParseDataHelper.ConvertDBNull(model.initialresult);
                        cmd.Parameters.Add("@file_download_name", SqlDbType.VarChar, 200).Value = ParseDataHelper.ConvertDBNull(model.filedownloadname);
                        cmd.Parameters.Add("@project_key_number", SqlDbType.VarChar, 20).Value  = ParseDataHelper.ConvertDBNull(model.projectkeynumber);
                        cmd.Parameters.Add("@notes", SqlDbType.NVarChar).Value        = ParseDataHelper.ConvertDBNull(model.notes);
                        cmd.Parameters.Add("@acronyms", SqlDbType.NVarChar).Value     = ParseDataHelper.ConvertDBNull(model.acronyms);
                        cmd.Parameters.Add("@round_of_meeting", SqlDbType.Int).Value  = model.roundofmeeting;
                        cmd.Parameters.Add("@year_of_meeting", SqlDbType.Int).Value   = model.yearofmeeting;
                        cmd.Parameters.Add("@year_of_running", SqlDbType.Int).Value   = model.defaultyear;
                        cmd.Parameters.Add("@meeting_date", SqlDbType.DateTime).Value = Convert.ToDateTime(model.meetingdate);

                        SqlParameter rStatus = cmd.Parameters.Add("@rStatus", SqlDbType.Int);
                        rStatus.Direction = ParameterDirection.Output;
                        SqlParameter rMessage = cmd.Parameters.Add("@rMessage", SqlDbType.NVarChar, 500);
                        rMessage.Direction = ParameterDirection.Output;
                        SqlParameter rDocId = cmd.Parameters.Add("@rDocId", SqlDbType.Int);
                        rDocId.Direction = ParameterDirection.Output;

                        await cmd.ExecuteNonQueryAsync();

                        if ((int)cmd.Parameters["@rStatus"].Value > 0)
                        {
                            resp.Status    = true;
                            resp.DocNumber = (string)cmd.Parameters["@rMessage"].Value;
                        }
                        else
                        {
                            resp.Message = (string)cmd.Parameters["@rMessage"].Value;
                        }
                    }
                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(resp);
        }
Пример #11
0
        public async Task <ModelResponseC22Message> AddDocMenuC22Async(ModelMenuC22 model)
        {
            var cultureInfo = new CultureInfo("en-GB");

            CultureInfo.DefaultThreadCurrentCulture   = cultureInfo;
            CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;

            ModelResponseC22Message resp = new ModelResponseC22Message();

            try
            {
                using (SqlConnection conn = new SqlConnection(ConnectionString))
                {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand("sp_doc_menu_c2_2", conn))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;

                        string assigner_code = Encoding.UTF8.GetString(Convert.FromBase64String(model.assignercode));

                        cmd.Parameters.Add("@assigner_code", SqlDbType.VarChar, 50).Value  = ParseDataHelper.ConvertDBNull(assigner_code);
                        cmd.Parameters.Add("@position_name", SqlDbType.VarChar, 200).Value = ParseDataHelper.ConvertDBNull(model.positionname);
                        cmd.Parameters.Add("@assigner_seq", SqlDbType.Int).Value           = ParseDataHelper.ConvertDBNull(model.assignerseq);
                        cmd.Parameters.Add("@project_number", SqlDbType.VarChar, 20).Value = ParseDataHelper.ConvertDBNull(model.projectnumber);
                        cmd.Parameters.Add("@lab_type_name", SqlDbType.VarChar, 200).Value = ParseDataHelper.ConvertDBNull(model.labtypename);
                        cmd.Parameters.Add("@faculty_name", SqlDbType.VarChar, 200).Value  = ParseDataHelper.ConvertDBNull(model.facultyname);
                        cmd.Parameters.Add("@safety_type", SqlDbType.VarChar, 2).Value     = ParseDataHelper.ConvertDBNull(model.safetytype);
                        cmd.Parameters.Add("@approval_type", SqlDbType.VarChar, 2).Value   = ParseDataHelper.ConvertDBNull(model.approvaltype);
                        cmd.Parameters.Add("@comment_consider", SqlDbType.VarChar).Value   = ParseDataHelper.ConvertDBNull(model.commentconsider);

                        SqlParameter rStatus = cmd.Parameters.Add("@rStatus", SqlDbType.Int);
                        rStatus.Direction = ParameterDirection.Output;
                        SqlParameter rMessage = cmd.Parameters.Add("@rMessage", SqlDbType.NVarChar, 500);
                        rMessage.Direction = ParameterDirection.Output;

                        await cmd.ExecuteNonQueryAsync();

                        if ((int)cmd.Parameters["@rStatus"].Value > 0)
                        {
                            resp.Status = true;
                        }
                        else
                        {
                            resp.Message = (string)cmd.Parameters["@rMessage"].Value;
                        }
                    }
                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(resp);
        }
Пример #12
0
        public async Task <ModelResponseC2Message> UpdateDocMenuC2EditAsync(ModelMenuC2 model)
        {
            var cultureInfo = new CultureInfo("en-GB");

            CultureInfo.DefaultThreadCurrentCulture   = cultureInfo;
            CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;

            ModelResponseC2Message resp = new ModelResponseC2Message();

            try
            {
                using (SqlConnection conn = new SqlConnection(ConnectionString))
                {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand("sp_doc_menu_c2_edit", conn))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;

                        string assigner_code = Encoding.UTF8.GetString(Convert.FromBase64String(model.assignercode));

                        cmd.Parameters.Add("@doc_id", SqlDbType.Int).Value = model.docid;
                        cmd.Parameters.Add("@assigner_code", SqlDbType.VarChar, 50).Value      = ParseDataHelper.ConvertDBNull(assigner_code);
                        cmd.Parameters.Add("@position_name", SqlDbType.VarChar, 200).Value     = ParseDataHelper.ConvertDBNull(model.positionname);
                        cmd.Parameters.Add("@assigner_seq", SqlDbType.Int).Value               = ParseDataHelper.ConvertDBNull(model.assignerseq);
                        cmd.Parameters.Add("@project_number", SqlDbType.VarChar, 20).Value     = ParseDataHelper.ConvertDBNull(model.projectnumber);
                        cmd.Parameters.Add("@project_head_name", SqlDbType.VarChar, 200).Value = ParseDataHelper.ConvertDBNull(model.projectheadname);
                        cmd.Parameters.Add("@faculty_name", SqlDbType.VarChar, 200).Value      = ParseDataHelper.ConvertDBNull(model.facultyname);
                        cmd.Parameters.Add("@project_name_thai", SqlDbType.VarChar, 200).Value = ParseDataHelper.ConvertDBNull(model.projectnamethai);
                        cmd.Parameters.Add("@project_name_eng", SqlDbType.VarChar, 200).Value  = ParseDataHelper.ConvertDBNull(model.projectnameeng);
                        cmd.Parameters.Add("@safety_type", SqlDbType.VarChar, 2).Value         = ParseDataHelper.ConvertDBNull(model.safetytype);
                        cmd.Parameters.Add("@approval_type", SqlDbType.VarChar, 2).Value       = ParseDataHelper.ConvertDBNull(model.approvaltype);
                        cmd.Parameters.Add("@comment_consider", SqlDbType.VarChar).Value       = ParseDataHelper.ConvertDBNull(model.commentconsider);
                        cmd.Parameters.Add("@round_of_meeting", SqlDbType.Int).Value           = model.roundofmeeting;
                        cmd.Parameters.Add("@year_of_meeting", SqlDbType.Int).Value            = model.yearofmeeting;
                        cmd.Parameters.Add("@create_by", SqlDbType.VarChar, 50).Value          = Encoding.UTF8.GetString(Convert.FromBase64String(model.createby));

                        SqlParameter rStatus = cmd.Parameters.Add("@rStatus", SqlDbType.Int);
                        rStatus.Direction = ParameterDirection.Output;
                        SqlParameter rMessage = cmd.Parameters.Add("@rMessage", SqlDbType.NVarChar, 500);
                        rMessage.Direction = ParameterDirection.Output;

                        await cmd.ExecuteNonQueryAsync();

                        if ((int)cmd.Parameters["@rStatus"].Value > 0)
                        {
                            resp.Status = true;

                            model_rpt_10_file rpt = await _IDocMenuReportRepository.GetReportR10Async(Convert.ToInt32(model.docid));

                            resp.filename   = rpt.filename;
                            resp.filebase64 = rpt.filebase64;
                        }
                        else
                        {
                            resp.Message = (string)cmd.Parameters["@rMessage"].Value;
                        }
                    }
                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(resp);
        }
Пример #13
0
        public async Task <ModelResponseC2Message> AddDocMenuC2Async(ModelMenuC2 model)
        {
            var cultureInfo = new CultureInfo("en-GB");

            CultureInfo.DefaultThreadCurrentCulture   = cultureInfo;
            CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;

            ModelResponseC2Message resp = new ModelResponseC2Message();

            try
            {
                using (SqlConnection conn = new SqlConnection(ConnectionString))
                {
                    conn.Open();

                    IList <ModelSelectOption> list_assign_seq = new List <ModelSelectOption>();
                    int assig_seq = 0;

                    string sqlA = "SELECT board_code_array FROM Doc_MenuC1 WHERE project_number='" + model.projectnumber + "'";

                    using (SqlCommand cmdA = new SqlCommand(sqlA, conn))
                    {
                        SqlDataReader reader = await cmdA.ExecuteReaderAsync();

                        if (reader.HasRows)
                        {
                            while (await reader.ReadAsync())
                            {
                                list_assign_seq = JsonConvert.DeserializeObject <List <ModelSelectOption> >(reader["board_code_array"].ToString());
                            }
                            if (list_assign_seq != null && list_assign_seq.Count > 0)
                            {
                                int seq = 1;
                                foreach (var item in list_assign_seq)
                                {
                                    if (item.value == model.assignercode)
                                    {
                                        assig_seq = seq;
                                    }
                                    seq++;
                                }
                            }
                        }
                        reader.Close();
                    }



                    StringBuilder array_comment_date = new StringBuilder();

                    string sqlB = "SELECT committee_comment_date FROM Transaction_Document WHERE project_number='" + model.projectnumber + "'";

                    using (SqlCommand cmdB = new SqlCommand(sqlB, conn))
                    {
                        SqlDataReader reader = await cmdB.ExecuteReaderAsync();

                        if (reader.HasRows)
                        {
                            while (await reader.ReadAsync())
                            {
                                array_comment_date.AppendLine(reader["committee_comment_date"].ToString().Trim());

                                array_comment_date.AppendLine("คนที่ " + assig_seq.ToString() + ". " + DateTime.Now.ToString("dd/MM/yyyy"));
                            }
                        }
                        reader.Close();
                    }



                    using (SqlCommand cmd = new SqlCommand("sp_doc_menu_c2", conn))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;

                        string assigner_code = Encoding.UTF8.GetString(Convert.FromBase64String(model.assignercode));

                        cmd.Parameters.Add("@assigner_code", SqlDbType.VarChar, 50).Value           = ParseDataHelper.ConvertDBNull(assigner_code);
                        cmd.Parameters.Add("@position_name", SqlDbType.VarChar, 200).Value          = ParseDataHelper.ConvertDBNull(model.positionname);
                        cmd.Parameters.Add("@assigner_seq", SqlDbType.Int).Value                    = ParseDataHelper.ConvertDBNull(model.assignerseq);
                        cmd.Parameters.Add("@project_number", SqlDbType.VarChar, 20).Value          = ParseDataHelper.ConvertDBNull(model.projectnumber);
                        cmd.Parameters.Add("@project_head_name", SqlDbType.VarChar, 200).Value      = ParseDataHelper.ConvertDBNull(model.projectheadname);
                        cmd.Parameters.Add("@faculty_name", SqlDbType.VarChar, 200).Value           = ParseDataHelper.ConvertDBNull(model.facultyname);
                        cmd.Parameters.Add("@project_name_thai", SqlDbType.VarChar, 200).Value      = ParseDataHelper.ConvertDBNull(model.projectnamethai);
                        cmd.Parameters.Add("@project_name_eng", SqlDbType.VarChar, 200).Value       = ParseDataHelper.ConvertDBNull(model.projectnameeng);
                        cmd.Parameters.Add("@safety_type", SqlDbType.VarChar, 2).Value              = ParseDataHelper.ConvertDBNull(model.safetytype);
                        cmd.Parameters.Add("@approval_type", SqlDbType.VarChar, 2).Value            = ParseDataHelper.ConvertDBNull(model.approvaltype);
                        cmd.Parameters.Add("@comment_consider", SqlDbType.VarChar).Value            = ParseDataHelper.ConvertDBNull(model.commentconsider);
                        cmd.Parameters.Add("@committee_comment_date", SqlDbType.VarChar, 200).Value = ParseDataHelper.ConvertDBNull(array_comment_date.ToString());
                        cmd.Parameters.Add("@round_of_meeting", SqlDbType.Int).Value                = model.roundofmeeting;
                        cmd.Parameters.Add("@year_of_meeting", SqlDbType.Int).Value                 = model.yearofmeeting;
                        cmd.Parameters.Add("@create_by", SqlDbType.VarChar, 50).Value               = Encoding.UTF8.GetString(Convert.FromBase64String(model.createby));

                        SqlParameter rStatus = cmd.Parameters.Add("@rStatus", SqlDbType.Int);
                        rStatus.Direction = ParameterDirection.Output;
                        SqlParameter rMessage = cmd.Parameters.Add("@rMessage", SqlDbType.NVarChar, 500);
                        rMessage.Direction = ParameterDirection.Output;
                        SqlParameter rDocId = cmd.Parameters.Add("@rDocId", SqlDbType.Int);
                        rDocId.Direction = ParameterDirection.Output;

                        await cmd.ExecuteNonQueryAsync();

                        if ((int)cmd.Parameters["@rStatus"].Value > 0)
                        {
                            resp.Status = true;

                            model_rpt_10_file rpt = await _IDocMenuReportRepository.GetReportR10Async((int)cmd.Parameters["@rDocId"].Value);

                            resp.filename   = rpt.filename;
                            resp.filebase64 = rpt.filebase64;
                        }
                        else
                        {
                            resp.Message = (string)cmd.Parameters["@rMessage"].Value;
                        }
                    }
                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(resp);
        }
Пример #14
0
        public async Task <ModelResponseMessageRegisterActive> AddRegisterActiveAsync(EntityRegisterUser model)
        {
            ModelResponseMessageRegisterActive resp = new ModelResponseMessageRegisterActive();

            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                conn.Open();
                using (SqlCommand cmd = new SqlCommand("sp_register_active", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add("@RegisterId", SqlDbType.VarChar, 100).Value = model.register_id;
                    cmd.Parameters.Add("@FirstName1", SqlDbType.VarChar, 50).Value  = ParseDataHelper.ConvertDBNull(model.first_name_1);
                    cmd.Parameters.Add("@FirstName2", SqlDbType.VarChar, 50).Value  = ParseDataHelper.ConvertDBNull(model.first_name_2);
                    cmd.Parameters.Add("@FirstName", SqlDbType.VarChar, 50).Value   = ParseDataHelper.ConvertDBNull(model.first_name);
                    cmd.Parameters.Add("@FullName", SqlDbType.VarChar, 200).Value   = ParseDataHelper.ConvertDBNull(model.full_name);
                    cmd.Parameters.Add("@Position", SqlDbType.VarChar, 2).Value     = ParseDataHelper.ConvertDBNull(model.position);
                    cmd.Parameters.Add("@Faculty", SqlDbType.VarChar, 2).Value      = ParseDataHelper.ConvertDBNull(model.faculty);
                    cmd.Parameters.Add("@WorkPhone", SqlDbType.VarChar, 50).Value   = ParseDataHelper.ConvertDBNull(model.work_phone);
                    cmd.Parameters.Add("@Mobile", SqlDbType.VarChar, 20).Value      = ParseDataHelper.ConvertDBNull(model.mobile);
                    cmd.Parameters.Add("@Fax", SqlDbType.VarChar, 20).Value         = ParseDataHelper.ConvertDBNull(model.fax);
                    cmd.Parameters.Add("@Education", SqlDbType.VarChar, 2).Value    = model.education;
                    cmd.Parameters.Add("@Character", SqlDbType.VarChar, 2).Value    = model.character;
                    cmd.Parameters.Add("@Note1", SqlDbType.NVarChar).Value          = ParseDataHelper.ConvertDBNull(model.note1);
                    cmd.Parameters.Add("@Note2", SqlDbType.NVarChar).Value          = ParseDataHelper.ConvertDBNull(model.note2);
                    cmd.Parameters.Add("@Note3", SqlDbType.NVarChar).Value          = ParseDataHelper.ConvertDBNull(model.note3);
                    cmd.Parameters.Add("@ConfirmDate", SqlDbType.DateTime).Value    = model.confirm_date;
                    cmd.Parameters.Add("@MemberExpire", SqlDbType.DateTime).Value   = model.member_expire;

                    SqlParameter rStatus = cmd.Parameters.Add("@rStatus", SqlDbType.Int);
                    rStatus.Direction = ParameterDirection.Output;
                    SqlParameter rMessage = cmd.Parameters.Add("@rMessage", SqlDbType.NVarChar, 500);
                    rMessage.Direction = ParameterDirection.Output;

                    await cmd.ExecuteNonQueryAsync();

                    if ((int)cmd.Parameters["@rStatus"].Value > 0)
                    {
                        resp.Status = true;
                    }
                    else
                    {
                        resp.Message = (string)cmd.Parameters["@rMessage"].Value;
                    }
                }
                conn.Close();
            }
            return(resp);
        }
Пример #15
0
        public async Task <ModelResponseA2Message> AddDocMenuA2Async(ModelMenuA2 model)
        {
            var cultureInfo = new CultureInfo("en-GB");

            CultureInfo.DefaultThreadCurrentCulture   = cultureInfo;
            CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;

            ModelResponseA2Message resp = new ModelResponseA2Message();

            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                conn.Open();
                using (SqlCommand cmd = new SqlCommand("sp_doc_menu_a2", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add("@DocDate", SqlDbType.DateTime).Value               = model.docdate.ToString("yyyy-MM-dd");
                    cmd.Parameters.Add("@ProjectMethod", SqlDbType.VarChar, 2).Value       = model.projectaccordingtypemethod;
                    cmd.Parameters.Add("@FacultyLaboratory", SqlDbType.VarChar, 200).Value = model.facultylaboratory;
                    cmd.Parameters.Add("@Department", SqlDbType.VarChar, 200).Value        = ParseDataHelper.ConvertDBNull(model.department);
                    cmd.Parameters.Add("@LaboratoryAddress", SqlDbType.VarChar).Value      = ParseDataHelper.ConvertDBNull(model.laboratoryaddress);
                    cmd.Parameters.Add("@Building", SqlDbType.VarChar, 100).Value          = ParseDataHelper.ConvertDBNull(model.building);
                    cmd.Parameters.Add("@Floor", SqlDbType.VarChar, 10).Value              = ParseDataHelper.ConvertDBNull(model.floor);
                    cmd.Parameters.Add("@RoomNumber", SqlDbType.VarChar, 10).Value         = ParseDataHelper.ConvertDBNull(model.roomnumber);
                    cmd.Parameters.Add("@LabOtherName", SqlDbType.VarChar, 10).Value       = ParseDataHelper.ConvertDBNull(model.labothername);
                    cmd.Parameters.Add("@Telephone", SqlDbType.VarChar, 20).Value          = ParseDataHelper.ConvertDBNull(model.telephone);
                    cmd.Parameters.Add("@ReponsiblePerson", SqlDbType.VarChar, 100).Value  = ParseDataHelper.ConvertDBNull(model.responsibleperson);
                    cmd.Parameters.Add("@Workphone", SqlDbType.VarChar, 20).Value          = ParseDataHelper.ConvertDBNull(model.workphone);
                    cmd.Parameters.Add("@Mobile", SqlDbType.VarChar, 20).Value             = ParseDataHelper.ConvertDBNull(model.mobile);
                    cmd.Parameters.Add("@FileName1", SqlDbType.VarChar, 200).Value         = ParseDataHelper.ConvertDBNull(model.filename1);
                    cmd.Parameters.Add("@FileName2", SqlDbType.VarChar, 200).Value         = ParseDataHelper.ConvertDBNull(model.filename2);
                    cmd.Parameters.Add("@create_by", SqlDbType.NVarChar).Value             = Encoding.UTF8.GetString(Convert.FromBase64String(model.createby));

                    cmd.Parameters.Add("@create_by", SqlDbType.VarChar, 50).Value = Encoding.UTF8.GetString(Convert.FromBase64String(model.createby));

                    SqlParameter rStatus = cmd.Parameters.Add("@rStatus", SqlDbType.Int);
                    rStatus.Direction = ParameterDirection.Output;
                    SqlParameter rMessage = cmd.Parameters.Add("@rMessage", SqlDbType.NVarChar, 500);
                    rMessage.Direction = ParameterDirection.Output;
                    SqlParameter rDocId = cmd.Parameters.Add("@rDocId", SqlDbType.Int);
                    rDocId.Direction = ParameterDirection.Output;

                    await cmd.ExecuteNonQueryAsync();

                    if ((int)cmd.Parameters["@rStatus"].Value > 0)
                    {
                        resp.Status = true;

                        model_rpt_17_file rpt = await _IDocMenuReportRepository.GetReportR17_18Async((int)cmd.Parameters["@rDocId"].Value);

                        resp.filename   = rpt.filename;
                        resp.filebase64 = rpt.filebase64;
                    }
                    else
                    {
                        resp.Message = (string)cmd.Parameters["@rMessage"].Value;
                    }
                }
                conn.Close();
            }
            return(resp);
        }