Пример #1
0
        public ActionResult DataSource(string clss, DateTime stDate, [FromBody] DataManagerRequest dm)
        {
            double fStDate = GloFunc.ToOADate(stDate);

            using (HttpClient client = new HttpClient())
            {
                client.BaseAddress = new Uri(iBaseURI);
                MediaTypeWithQualityHeaderValue contentType = new MediaTypeWithQualityHeaderValue("application/json");
                client.DefaultRequestHeaders.Accept.Add(contentType);
                HttpResponseMessage response = client.GetAsync("/api/Conveyances?clss=" + clss + "&stDate=" + fStDate + "&dSess=" + dSess + "&mdBID=" + mdBId).Result;
                var stringData              = response.Content.ReadAsStringAsync().Result;
                List <Conveyance> subjects  = JsonConvert.DeserializeObject <List <Conveyance> >(stringData);
                DataOperations    operation = new DataOperations();
                IEnumerable       data      = subjects;
                var count = data.AsQueryable().Count();
                if (dm.Skip > 0)
                {
                    data = operation.PerformSkip(data, dm.Skip);
                }
                if (dm.Take > 0)
                {
                    data = operation.PerformTake(data, dm.Take);
                }
                return(Json(new { result = data, count = count }));
            }
        }
        public async Task <IActionResult> PutTransActivity([FromRoute] int id, [FromBody] TransActivity transActivity)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                transActivity.ActivityId = GetActivityID(_context, transActivity.Activity, transActivity.ActGroupID, transActivity.DBid);
                var conn = _context.Database.GetDbConnection();
                if (conn.State == ConnectionState.Closed)
                {
                    await conn.OpenAsync();
                }
                using (var command = conn.CreateCommand())
                {
                    if (transActivity.Activity == "None")
                    {
                        if (transActivity.TransActId != 0)
                        {
                            MySql = " UPDATE TransActivity SET ";
                            MySql = MySql + " Dormant = 1 ";
                            MySql = MySql + " WHERE TransActID = " + transActivity.TransActId;
                            MySql = MySql + " AND RegNumber = " + transActivity.RegNumber;
                            command.CommandType = CommandType.Text;
                            command.CommandText = MySql;
                            command.ExecuteNonQuery();
                        }
                    }
                    else
                    {
                        MySql = " INSERT INTO TransActivity (TransActID, TransActName, ActivityID, RegNumber, TransActValue, "
                                + "TransActDate, TransActObserver, TeachID, TransActRemarks, UniReg, Score, ";
                        MySql = MySql + " Dormant, LoginName, ModTime, cTerminal, dBID) Values (0, '";
                        MySql = MySql + transActivity.Activity + "'," + transActivity.ActivityId + "," + transActivity.RegNumber + ","
                                + transActivity.TransActValue + "," + GloFunc.ToOADate(transActivity.TransActDate) + ",'"
                                + transActivity.TransActObserver + "',0,'" + transActivity.TransActRemarks + "'," + transActivity.UniReg + ",0,";
                        MySql = MySql + "0,'" + transActivity.LoginName + "'," + GenFunc.GloFunc.ToOADate(DateTime.Now);
                        MySql = MySql + ",'" + transActivity.CTerminal + "'," + transActivity.DBid + ")";

                        command.CommandType = CommandType.Text;
                        command.CommandText = MySql;
                        command.ExecuteNonQuery();
                    }
                }
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TransActivityExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(NoContent());
        }
Пример #3
0
        public async Task <IActionResult> PutDynaFee([FromRoute] int id, [FromBody] DynaFee dynaFee)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Entry(dynaFee).State = EntityState.Modified;
            try
            {
                var conn = _context.Database.GetDbConnection();
                if (conn.State == ConnectionState.Closed)
                {
                    await conn.OpenAsync();
                }
                using (var command = conn.CreateCommand())
                {
                    if (dynaFee.ClsFeeId != 0)
                    {
                        MySql = " DELETE FROM DynaFee"
                                + " WHERE Dormant = 0  "
                                + " AND ClsFeeId = " + dynaFee.ClsFeeId
                                + " AND ForClass = '" + dynaFee.ForClass + "'"
                                + " AND StdCategory = '" + dynaFee.StdCategory + "'"
                                + " AND SessionName = '" + dynaFee.SessionName + "'"
                                + " AND FeeCaption = '" + dynaFee.FeeCaption + "'"
                                + " AND Caption = '" + dynaFee.Caption + "'";
                        command.CommandType = CommandType.Text;
                        command.CommandText = MySql;
                        command.ExecuteNonQuery();
                    }
                    MySql = " INSERT INTO DynaFee ( ClsFeeId, FeeNo, Caption, ForMonth, Amount, FeeCaption, PayByDate, ForClass, " +
                            "StdCategory,   SessionName, DueOn,"
                            + " Dormant, LoginName, ModTime, cTerminal, dBID) Values ("
                            + dynaFee.ClsFeeId + "," + dynaFee.FeeNo + ",'" + dynaFee.Caption + "'," + GloFunc.ToOADate(dynaFee.ForMonth) + ","
                            + dynaFee.Amount + ",'" + dynaFee.FeeCaption + "'," + GloFunc.ToOADate(dynaFee.PayByDate) + ",'" + dynaFee.ForClass + "','"
                            + dynaFee.StdCategory + "','" + dynaFee.SessionName + "'," + GloFunc.ToOADate(dynaFee.DueOn)
                            + ", 0,'" + dynaFee.LoginName + "'," + DateTime.Now.Date.ToOADate()
                            + ",'" + dynaFee.CTerminal + "'," + dynaFee.DBid + ")";

                    command.CommandType = CommandType.Text;
                    command.CommandText = MySql;
                    command.ExecuteNonQuery();
                }
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
            return(NoContent());
        }
Пример #4
0
        public ActionResult Update(string clss, DateTime stDate, [FromBody] ConveyanceEdit ConveyancesVal)
        {
            double fStDate = GloFunc.ToOADate(stDate);

            if (ConveyancesVal.Value.Commit)
            {
                ConveyancesVal.Value.Clss     = clss;
                ConveyancesVal.Value.DateFrom = stDate;
                ConveyancesVal.Value.DBid     = mdBId;
                try
                {
                    using (HttpClient client = new HttpClient())
                    {
                        client.BaseAddress = new Uri(iBaseURI);
                        MediaTypeWithQualityHeaderValue contentType = new MediaTypeWithQualityHeaderValue("application/json");
                        client.DefaultRequestHeaders.Accept.Add(contentType);
                        string stringData            = JsonConvert.SerializeObject(ConveyancesVal.Value);
                        var    contentData           = new StringContent(stringData, System.Text.Encoding.UTF8, "application/json");
                        HttpResponseMessage response = client.PutAsync("/api/Conveyances/" + ConveyancesVal.Key + mdBId, contentData).Result;
                        ViewBag.Message = response.Content.ReadAsStringAsync().Result;
                    }

                    //_context.Update(acaSession);
                    //await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ConveyanceExists(ConveyancesVal.Value.ConId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            //AcaSession acsess = JsonConvert.DeserializeObject<AcaSession>(value);
            return(Json(ConveyancesVal.Value));
        }
Пример #5
0
        public async Task <IActionResult> PutMarks([FromRoute] int id, [FromBody] Marks marks)
        {
            string MySql = "";

            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 Marks SET ";
                    MySql = MySql + " Dormant = 1 ";
                    MySql = MySql + " WHERE SubName ='" + repSplChr(marks.SubName) + "'";
                    MySql = MySql + " AND ExamName ='" + repSplChr(marks.ExamName) + "'";
                    MySql = MySql + " AND MClss = '" + repSplChr(marks.MClss) + "'";
                    MySql = MySql + " AND MSession ='" + repSplChr(marks.MSession) + "'";
                    MySql = MySql + " AND DBID =  " + marks.dBID;
                    MySql = MySql + " AND UniReg =" + marks.UniReg;

                    command.CommandType = CommandType.Text;
                    command.CommandText = MySql;
                    command.ExecuteNonQuery();

                    MySql = "INSERT INTO Marks (";
                    MySql = MySql + " MkID, MClss, SubName, ExamName, TotalMarks, ThMarks, PracMarks, OrMarks, AsgnMarks,";
                    MySql = MySql + " RegNum, MSession, TotalMarksCalc, Grades, StdGrades, LoginName, ModTime, Dormant, cTerminal, dBID, UniReg) VALUES ( ";
                    MySql = MySql + marks.MkID + " ,'";
                    MySql = MySql + repSplChr(marks.MClss) + "','";
                    MySql = MySql + repSplChr(marks.SubName) + "','";
                    MySql = MySql + repSplChr(marks.ExamName) + "',";
                    switch (marks.TotalMarks)
                    {
                    case null:
                        MySql = MySql + " -1 ,";
                        break;

                    case "":
                        MySql = MySql + " -1 ,";
                        break;

                    case "ab":
                    case "Ab":
                    case "AB":
                    case "aB":
                        MySql = MySql + " -2 ,";
                        break;

                    case "na":
                    case "Na":
                    case "NA":
                    case "nA":
                        MySql = MySql + " -5 ,";
                        break;

                    default: MySql = MySql + Convert.ToDouble(marks.TotalMarks) + ",";
                        break;
                    }

                    switch (marks.ThMarks)
                    {
                    case null:
                        MySql = MySql + " -1 ,";
                        break;

                    case "":
                        MySql = MySql + " -1 ,";
                        break;

                    case "ab":
                    case "Ab":
                    case "AB":
                    case "aB":
                        MySql = MySql + " -2 ,";
                        break;

                    case "na":
                    case "Na":
                    case "NA":
                    case "nA":
                        MySql = MySql + " -5 ,";
                        break;

                    default:
                        MySql = MySql + Convert.ToDouble(marks.ThMarks) + ",";
                        break;
                    }
                    switch (marks.PracMarks)
                    {
                    case null:
                        MySql = MySql + " -1 ,";
                        break;

                    case "":
                        MySql = MySql + " -1 ,";
                        break;

                    case "ab":
                    case "Ab":
                    case "AB":
                    case "aB":
                        MySql = MySql + " -2 ,";
                        break;

                    case "na":
                    case "Na":
                    case "NA":
                    case "nA":
                        MySql = MySql + " -5 ,";
                        break;

                    default:
                        MySql = MySql + Convert.ToDouble(marks.PracMarks) + ",";
                        break;
                    }

                    switch (marks.OrMarks)
                    {
                    case null:
                        MySql = MySql + " -1 ,";
                        break;

                    case "":
                        MySql = MySql + " -1 ,";
                        break;

                    case "ab":
                    case "Ab":
                    case "AB":
                    case "aB":
                        MySql = MySql + " -2 ,";
                        break;

                    case "na":
                    case "Na":
                    case "NA":
                    case "nA":
                        MySql = MySql + " -5 ,";
                        break;

                    default:
                        MySql = MySql + Convert.ToDouble(marks.OrMarks) + ",";
                        break;
                    }


                    switch (marks.AsgnMarks)
                    {
                    case null:
                        MySql = MySql + " -1 ,";
                        break;

                    case "":
                        MySql = MySql + " -1 ,";
                        break;

                    case "ab":
                    case "Ab":
                    case "AB":
                    case "aB":
                        MySql = MySql + " -2 ,";
                        break;

                    case "na":
                    case "Na":
                    case "NA":
                    case "nA":
                        MySql = MySql + " -5 ,";
                        break;

                    default:
                        MySql = MySql + Convert.ToDouble(marks.AsgnMarks) + ",";
                        break;
                    }
                    MySql = MySql + marks.RegNum + ",'";
                    MySql = MySql + repSplChr(marks.MSession) + "',";
                    switch (marks.TotalMarksCalc)
                    {
                    case null:
                        MySql = MySql + " -1 ,";
                        break;

                    case "":
                        MySql = MySql + " -1 ,";
                        break;

                    case "ab":
                    case "Ab":
                    case "AB":
                    case "aB":
                        MySql = MySql + " -2 ,";
                        break;

                    case "na":
                    case "Na":
                    case "NA":
                    case "nA":
                        MySql = MySql + " -5 ,";
                        break;

                    default:
                        MySql = MySql + Convert.ToDouble(marks.TotalMarksCalc) + ",";
                        break;
                    }

                    MySql = MySql + "'" + marks.Grades + "','";
                    MySql = MySql + repSplChr(marks.StdGrades) + "','";
                    MySql = MySql + repSplChr(strLoginName) + "'," + GloFunc.ToOADate(DateTime.Now) + ",0,'" + repSplChr(strComputerName) + "'," + marks.dBID + "," + marks.UniReg + ")";


                    command.CommandType = CommandType.Text;
                    command.CommandText = MySql;
                    command.ExecuteNonQuery();
                }
                //await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MarksExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }