Exemple #1
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);
        }
Exemple #2
0
        public async Task <IActionResult> UpdateDocMenuA6Edit([FromBody] ModelMenuA6 model)
        {
            ModelResponseA6Message e = await _IDocMenuAService.UpdateDocMenuA6EditAsync(model);

            if (e.Status)
            {
                return(Ok(e));
            }
            else
            {
                return(BadRequest());
            }
        }