Exemple #1
0
        public async Task <IActionResult> Edit(int id, [Bind("FeeNameId,FeeCaption,FeeDuration,FeeType,FeeOrder,ShowIt")] Fcaption fcaption)
        {
            if (id != fcaption.FeeNameId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(fcaption);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FcaptionExists(fcaption.FeeNameId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(fcaption));
        }
Exemple #2
0
 public async Task <IActionResult> PostFcaption([FromBody] Fcaption fcaption)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     try
     {
         var conn = _context.Database.GetDbConnection();
         if (conn.State == ConnectionState.Closed)
         {
             await conn.OpenAsync();
         }
         using (var command = conn.CreateCommand())
         {
             MySql = " INSERT INTO FCaption(FeeNameId, FeeCaption, FeeDuration, FeeType, FeeOrder, ShowIt,";
             MySql = MySql + " Dormant, LoginName, ModTime, cTerminal, dBID) Values (0, '";
             MySql = MySql + fcaption.FeeCaption + "','" + fcaption.FeeDuration + "','"
                     + fcaption.FeeType + "'," + fcaption.FeeOrder + "," + CBI(fcaption.ShowIt);
             MySql = MySql + ",0,'" + fcaption.LoginName + "'," + GenFunc.GloFunc.ToOADate(DateTime.Now);
             MySql = MySql + ",'" + fcaption.CTerminal + "'," + fcaption.DBid + ")";
             command.CommandType = CommandType.Text;
             command.CommandText = MySql;
             command.ExecuteNonQuery();
         }
     }
     catch (DbUpdateConcurrencyException)
     {
         throw;
     }
     return(CreatedAtAction("GetFcaption", new { id = fcaption.FeeNameId }, fcaption));
 }
Exemple #3
0
        public IEnumerable <Fcaption> GetFcaption(string dSess, int mDbId)
        {
            List <Fcaption> stdfCapList = new List <Fcaption>();
            var             conn        = _context.Database.GetDbConnection();

            if (conn.State == ConnectionState.Closed)
            {
                conn.Open();
            }
            using (var command = conn.CreateCommand())
            {
                MySql = "SELECT  FeeNameId, FeeCaption, FeeDuration, FeeType, FeeOrder, ShowIt";
                MySql = MySql + " FROM FCaption WITH (NOLOCK) ";
                MySql = MySql + " WHERE Dormant =0 ";
                MySql = MySql + " AND DBID =  " + mDbId;
                MySql = MySql + " ORDER BY FeeCaption";
                command.CommandType = System.Data.CommandType.Text;
                command.CommandText = MySql;
                DbDataReader kMyReader = command.ExecuteReader();
                if (kMyReader.HasRows)
                {
                    while (kMyReader.Read())
                    {
                        Fcaption fCaps = new Fcaption();
                        if (!kMyReader.IsDBNull(0))
                        {
                            fCaps.FeeNameId = kMyReader.GetInt32(0);
                        }
                        if (!kMyReader.IsDBNull(1))
                        {
                            fCaps.FeeCaption = kMyReader.GetString(1);
                        }
                        if (!kMyReader.IsDBNull(2))
                        {
                            fCaps.FeeDuration = kMyReader.GetString(2);
                        }
                        if (!kMyReader.IsDBNull(3))
                        {
                            fCaps.FeeType = kMyReader.GetString(3);
                        }
                        if (!kMyReader.IsDBNull(4))
                        {
                            fCaps.FeeOrder = kMyReader.GetInt32(4);
                        }
                        if (!kMyReader.IsDBNull(5))
                        {
                            fCaps.ShowIt = CIB(kMyReader.GetInt32(5));
                        }
                        stdfCapList.Add(fCaps);
                    }
                }
                kMyReader.Close();
            }
            return(stdfCapList);
            //return _context.Fcaption;
        }
Exemple #4
0
        public async Task <IActionResult> PutFcaption([FromRoute] int id, [FromBody] Fcaption fcaption)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                var conn = _context.Database.GetDbConnection();
                if (conn.State == ConnectionState.Closed)
                {
                    await conn.OpenAsync();
                }
                using (var command = conn.CreateCommand())
                {
                    MySql = " UPDATE FCaption SET ";
                    MySql = MySql + " FeeCaption = '" + fcaption.FeeCaption + "',";
                    MySql = MySql + " FeeDuration = '" + fcaption.FeeDuration + "',";
                    MySql = MySql + " FeeType = '" + fcaption.FeeType + "',";
                    MySql = MySql + " ShowIt = " + CBI(fcaption.ShowIt) + ",";
                    MySql = MySql + " FeeOrder = " + fcaption.FeeOrder + "";
                    MySql = MySql + " WHERE FeeNameId = " + fcaption.FeeNameId;
                    MySql = MySql + " AND Dormant = 0";
                    MySql = MySql + " AND dBID = " + fcaption.DBid;

                    command.CommandType = CommandType.Text;
                    command.CommandText = MySql;
                    command.ExecuteNonQuery();
                }
                //await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FcaptionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(NoContent());
        }
Exemple #5
0
 public async Task <IActionResult> Create([Bind("FeeNameId,FeeCaption,FeeDuration,FeeType,FeeOrder, ShowIt")] Fcaption fcaption)
 {
     if (ModelState.IsValid)
     {
         if (!FcaptionExists(fcaption.FeeCaption))
         {
             using (HttpClient client = new HttpClient())
             {
                 client.BaseAddress = new Uri(GloVar.iBaseURI);
                 MediaTypeWithQualityHeaderValue contentType = new MediaTypeWithQualityHeaderValue("application/json");
                 client.DefaultRequestHeaders.Accept.Add(contentType);
                 string stringData            = JsonConvert.SerializeObject(fcaption);
                 var    contentData           = new StringContent(stringData, System.Text.Encoding.UTF8, "application/json");
                 HttpResponseMessage response = client.PostAsync("/api/fcaptions?mDbid=" + mdBId, contentData).Result;
                 ViewBag.Message = response.Content.ReadAsStringAsync().Result;
                 if (response.IsSuccessStatusCode)
                 {
                     ViewBag.Remark = "Creation of Class '" + fcaption.FeeCaption + "' Successful";
                     return(View());
                 }
                 else
                 {
                     ViewBag.Remark = "Creation of Class '" + fcaption.FeeCaption + "' Failed!. Please Try Again";
                     return(View(fcaption));
                 }
             }
         }
         else
         {
             ViewBag.Remark = "Failed Class '" + fcaption.FeeCaption + "' Already Exists.";
             return(View(fcaption));
         }
     }
     else
     {
         ViewBag.Remark = "Failed! Class '" + fcaption.FeeCaption + "' Unable To create. PleaseTry Again.";
         return(View(fcaption));
     }
 }