예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind(" ClsName,ClassTeacher,StdStrength,ClssNum")] Clss clss)
        {
            if (id != clss.AutoId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(clss);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClssExists(clss.AutoId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(clss));
        }
        public static int PumpAllClass(string Company)
        {
            Console.WriteLine("Classes for Company " + Company);
            string         sql      = "SELECT * FROM Class";
            List <QBClass> clsItems = new ODBCReaderToModel <QBClass>().CreateList(sql, Company);

            using (clsDataGetter dg = new clsDataGetter(CommonProcs.WCompanyConnStr))
            {
                dg.RunCommand("DELETE FROM Clss WHERE QBFile='" + Company + "'");
            }
            if (clsItems.Count > 0)
            {
                foreach (var QBclass in clsItems)
                {
                    if (QBclass.Name.Contains("00") || QBclass.Name.Contains("01") || QBclass.Name.Contains("02"))
                    {
                        Clss clss = QBclass.ConvertTo <Clss>();
                        Console.WriteLine("Class " + clss.Name);
                        clss.QBFile = Company;
                        clss.Branch = clss.Name.Substring(0, 2);
                        new ModelToSQL <Clss>().WriteInsertSQL("Clss", clss, "ClassID", CommonProcs.WCompanyConnStr);
                    }
                }
            }
            return(clsItems.Count);
        }
예제 #3
0
        public int PumpClass(string Company)
        {
            string sql = "SELECT * FROM Class WHERE TimeModified > " + CommonProcs.TimeStampString(DateTime.Now.AddDays(-1));

            UpdateStatusBar("Opening Quickbooks", 10);
            List <QBClass> clsItems = new ODBCReaderToModel <QBClass>().CreateList(sql, Company);

            if (clsItems.Count > 0)
            {
                foreach (var QBclass in clsItems)
                {
                    if (QBclass.Name.Contains("00") || QBclass.Name.Contains("01") || QBclass.Name.Contains("02"))
                    {
                        UpdateStatusBar("Adding " + QBclass.Name, 1);
                        Clss clss = QBclass.ConvertTo <Clss>();
                        clss.QBFile = Company;
                        clss.Branch = clss.Name.Substring(0, 2);
                        using (clsDataGetter dg = new clsDataGetter(CommonProcs.WCompanyConnStr))
                        {
                            clss.ClassID = dg.GetScalarInteger("SELECT ClassID FROM Clss WHERE ListID='" + clss.ListID + "' AND QBFile='" + Company + "'");
                        }
                        new ModelToSQL <Clss>().WriteUpdateToSQL("Clss", clss, "ClassID", CommonProcs.WCompanyConnStr);
                    }
                }
            }
            UpdateStatusBar("Done", progBar.Maximum);
            return(clsItems.Count);
        }
예제 #4
0
        public IEnumerable <Clss> Get(string sess, int mdBId)
        {
            List <Clss> clssList = new List <Clss>();
            var         conn     = _context.Database.GetDbConnection();

            if (conn.State == ConnectionState.Closed)
            {
                conn.Open();
            }
            using (var command = conn.CreateCommand())
            {
                MySql = " SELECT ClsId, ClsName, ClassTeacher, ClssNum FROM Clss WITH (NOLOCK)";
                MySql = MySql + " WHERE  Dormant = 0";
                MySql = MySql + " AND dBID = " + mdBId;
                if (sess != "All")
                {
                    MySql = MySql + " AND AcaSession = '" + sess + "'";
                }

                command.CommandType = CommandType.Text;
                command.CommandText = MySql;
                DbDataReader kMyReader = command.ExecuteReader();
                if (kMyReader.HasRows)
                {
                    while (kMyReader.Read())
                    {
                        Clss clss = new Clss();
                        if (!kMyReader.IsDBNull(0))
                        {
                            clss.ClsId = kMyReader.GetInt32(0);
                        }
                        if (!kMyReader.IsDBNull(1))
                        {
                            clss.ClsName = kMyReader.GetString(1);
                        }
                        if (!kMyReader.IsDBNull(2))
                        {
                            clss.ClassTeacher = kMyReader.GetString(2);
                        }
                        if (!kMyReader.IsDBNull(3))
                        {
                            clss.ClssNum = kMyReader.GetDouble(3);
                        }
                        clssList.Add(clss);
                    }
                }
            }
            return(clssList);
        }
예제 #5
0
 public IActionResult Create([Bind("ClsName,ClassTeacher,ClssNum")] Clss clss)
 {
     if (ModelState.IsValid)
     {
         if (!ClssExists(clss.ClsName))
         {
             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(clss);
                 var    contentData           = new StringContent(stringData, System.Text.Encoding.UTF8, "application/json");
                 HttpResponseMessage response = client.PostAsync("/api/Clsses", contentData).Result;
                 ViewBag.Message = response.Content.ReadAsStringAsync().Result;
                 if (response.IsSuccessStatusCode)
                 {
                     ViewBag.Remark = "Creation of Class '" + clss.ClsName + "' Successful";
                     AcaFunctions.GetSchTeachers(_context, true);
                     ViewBag.dropdownTeacher = new SelectList(SchTeachLst, "Value", "Text", null);
                     return(View());
                 }
                 else
                 {
                     ViewBag.Remark = "Creation of Class '" + clss.ClsName + "' Failed!. Please Try Again";
                     AcaFunctions.GetSchTeachers(_context, true);
                     ViewBag.dropdownTeacher = new SelectList(SchTeachLst, "Value", "Text", null);
                     return(View(clss));
                 }
             }
         }
         else
         {
             ViewBag.Remark = "Failed Class '" + clss.ClsName + "' Already Exists.";
             AcaFunctions.GetSchTeachers(_context, true);
             ViewBag.dropdownTeacher = new SelectList(SchTeachLst, "Value", "Text", null);
             return(View(clss));
         }
     }
     else
     {
         ViewBag.Remark = "Failed! Class '" + clss.ClsName + "' Unable To create. PleaseTry Again.";
         AcaFunctions.GetSchTeachers(_context, true);
         ViewBag.dropdownTeacher = new SelectList(SchTeachLst, "Value", "Text", null);
         return(View(clss));
     }
 }
예제 #6
0
        public async Task <IActionResult> PutClss([FromRoute] int id, [FromBody] Clss clss)
        {
            var ssid = clss.ClsId;

            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 Clss SET ";
                    MySql = MySql + " ClsName = '" + clss.ClsName + "',";
                    MySql = MySql + " ClassTeacher = '" + clss.ClassTeacher + "',";
                    MySql = MySql + " ClssNum = " + clss.ClssNum;
                    MySql = MySql + " WHERE ClsId = " + clss.ClsId;
                    MySql = MySql + " AND Dormant = 0";
                    MySql = MySql + " AND dBID = " + clss.DBid;
                    MySql = MySql + " AND AcaSession = '" + clss.AcaSession + "'";

                    command.CommandType = CommandType.Text;
                    command.CommandText = MySql;
                    command.ExecuteNonQuery();
                }
                //UpdateAcaSession(acaSession);
                //    await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ClssExists(ssid))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(NoContent());
        }
예제 #7
0
        public async Task <IActionResult> PostClss([FromBody] Clss clss)
        {
            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 Clss (ClsId, ClsName, TeachID, ClassTeacher, StdStrength, ClssNum, AcaSession";
                    MySql = MySql + " Dormant, LoginName, ModTime, cTerminal, dBID) Values (0, '";
                    MySql = MySql + clss.ClsName + "','" + clss.TeachId + "','" + clss.ClassTeacher + "','" + clss.StdStrength
                            + clss.ClssNum + "','" + clss.AcaSession + "'";

                    MySql = MySql + "', 0,'" + clss.LoginName + "'," + GenFunc.GloFunc.ToOADate(DateTime.Now);
                    MySql = MySql + ",'" + clss.CTerminal + "'," + clss.DBid + ")";

                    command.CommandType = CommandType.Text;
                    command.CommandText = MySql;
                    command.ExecuteNonQuery();
                }
                //UpdateAcaSession(acaSession);
                //    await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }

            //_context.Clss.Add(clss);
            //await _context.SaveChangesAsync();

            return(CreatedAtAction("GetClss", new { id = clss.AutoId }, clss));
        }