Beispiel #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            double it;
            List<string> lstErrors = new List<string>();

            if (!double.TryParse(txtbAmount.Text, out it))
                lstErrors.Add("[Cantidad]");

            if (txtbName.Text == string.Empty)
                lstErrors.Add(" [Nombre] ");

            if (lstErrors.Count > 0)
            {
                string error = "Verificar la informacion en: ";
                foreach (string err in lstErrors)
                {
                    error += err;
                }
                MessageBox.Show(error);
                return;
            }

            infoConcept updatedConcept = new infoConcept();

            updatedConcept = _selectedConcept;

            if (txtbName.Text != _selectedConcept.Name)
                updatedConcept.Name = txtbName.Text;

            if (float.Parse(txtbAmount.Text) != _selectedConcept.Amount)
                updatedConcept.Amount = float.Parse(txtbAmount.Text);

            if (dateDueDate.Value.Date != _selectedConcept.LimitDate.Date)
                updatedConcept.LimitDate = dateDueDate.Value.Date;

            try
            {
                if (updatedConcept != _selectedConcept)
                {
                    DAL.UpdateConcept(updatedConcept);
                    MessageBox.Show("Entrada actualizada");
                }
                else
                {
                    MessageBox.Show("No cambios registrados, regresando a busqueda");
                }
                this.Close();
            }
            catch
            {
                MessageBox.Show("Error - tratar de nuevo");
            }
        }
Beispiel #2
0
        public static void UpdateConcept(infoConcept updatedConcept)
        {
            SqlCeConnection sqlConnection = new SqlCeConnection(connectionString);
            sqlConnection.Open();

            //AccNum, fName, lastname, lastname2, grade, discount
            SqlCeCommand updateCommand = new SqlCeCommand("UPDATE Conceptos SET Title = @conTitle, Base_Amount= @conAmount, Limit_Date = @conDate " +
                "WHERE ID = @conID", sqlConnection);

            updateCommand.Parameters.AddWithValue("@conTitle", updatedConcept.Name);
            updateCommand.Parameters.AddWithValue("@conAmount", updatedConcept.Amount);
            updateCommand.Parameters.AddWithValue("@conDate", updatedConcept.LimitDate.ToShortDateString());
            updateCommand.Parameters.AddWithValue("@conID", updatedConcept.Value);

            updateCommand.CommandType = System.Data.CommandType.Text;

            try
            {
                updateCommand.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                sqlConnection.Close();
                sqlConnection.Dispose();
            }
        }
Beispiel #3
0
        /// <summary>
        /// Retreive a list of available concepts for the selected account
        /// </summary>
        /// <param name="stdGroup">Group of student</param>
        /// <param name="stdLevel">Level of student</param>
        /// <returns>List with objects representign the different concepts</returns>
        public static List<infoConcept> getExpiredSchoolConcepts(int stdGroup, int stdLevel, Int32 studentID)
        {
            //Create list to hold concepts
            List<infoConcept> lstConcept = new List<infoConcept>();
            List<infoConcept> lstExpiredConcepts = new List<infoConcept>();
            string accountType = getStudentDetails(studentID).paymentType;

            //Create connection, command and open connection.
            SqlCeConnection sqlConnection = new SqlCeConnection(connectionString);
            SqlCeCommand sqlCommand = sqlConnection.CreateCommand();
            sqlConnection.Open();

            //Gets concepts that have expired that are avaible to the student depending on group and level
            sqlCommand.CommandText = "SELECT Rel_GL_Concept.FK_Concept_ID, Conceptos.ID, Conceptos.Title, Conceptos.Base_Amount," +
                " Conceptos.Concept_Type, Conceptos.Limit_Date FROM Rel_GL_Concept INNER JOIN Conceptos " +
                " ON Rel_GL_Concept.FK_Concept_ID = Conceptos.ID WHERE (Rel_GL_Concept.FK_Group_ID = " + stdGroup +") AND" +
                " (Conceptos.Limit_Date < CONVERT(DATETIME, '" + DateTime.Now.ToShortDateString() + "', 102)) OR" +
                " (Rel_GL_Concept.FK_Level_ID = " + stdLevel +") AND (Conceptos.Limit_Date < CONVERT(DATETIME, '" + DateTime.Now.ToShortDateString() +"', 102))";

            SqlCeDataReader sqlReader = sqlCommand.ExecuteReader();

            //Create objects for each concept and fill List<>
            while (sqlReader.Read())
            {
                infoConcept gObject = new infoConcept();
                gObject.Name = sqlReader["Title"].ToString(); ;
                gObject.Amount = float.Parse(sqlReader["Base_Amount"].ToString());
                gObject.Value = sqlReader["FK_Concept_ID"].ToString();
                gObject.LimitDate = DateTime.Parse(sqlReader["Limit_Date"].ToString());
                gObject.Type = sqlReader["Concept_Type"].ToString();

                if (gObject.Name.Contains("Vacaci") && accountType == "Diferido")
                    continue;

                lstConcept.Add(gObject);
            }

            //Expired concepts for student: lstConcept;

            //Get payments made by student
            List<int> payedConcepts = getPayedConceptList(studentID);
            bool payed = false;

            foreach (infoConcept aConcept in lstConcept)
            {
                foreach (int pIDConcept in payedConcepts)
                {
                    if (pIDConcept == int.Parse(aConcept.Value))
                    {
                        payed = true;
                    }
                }

                if (!payed)
                    lstExpiredConcepts.Add(aConcept);
            }

            return lstExpiredConcepts;
        }
Beispiel #4
0
        public static infoConcept getConceptInfo(int conceptID)
        {
            //Create list to hold concepts
            infoConcept gObject = new infoConcept();

            //Create connection, command and open connection.
            SqlCeConnection sqlConnection = new SqlCeConnection(connectionString);
            SqlCeCommand sqlCommand = sqlConnection.CreateCommand();
            sqlConnection.Open();

            //Gets concepts that are available depending on group and level of student
            sqlCommand.CommandText = "SELECT ID, Title, Base_Amount, Limit_Date FROM Conceptos WHERE " +
                "ID = @cID";

            sqlCommand.Parameters.AddWithValue("@cID", conceptID);

            SqlCeDataReader sqlReader = sqlCommand.ExecuteReader();

            //Create objects for each concept and fill List<>
            while (sqlReader.Read())
            {
                gObject.Name = sqlReader["Title"].ToString(); ;
                gObject.Amount = float.Parse(sqlReader["Base_Amount"].ToString());
                gObject.Value = sqlReader["ID"].ToString();
                string coco = sqlReader["Limit_Date"].ToString();
                gObject.LimitDate = DateTime.Parse(sqlReader["Limit_Date"].ToString());
            }

            return gObject;
        }
Beispiel #5
0
        /// <summary>
        /// Retreive a list<> of available concepts for the selected account
        /// </summary>
        /// <param name="stdGroup">Group of student</param>
        /// <param name="stdLevel">Level of student</param>
        /// <returns>List with objects representign the different concepts</returns>
        public static List<infoConcept> getAvailableConcepts(int stdGroup, int stdLevel)
        {
            //Create list to hold concepts
            List<infoConcept> lstConcept = new List<infoConcept>();

            //Create connection, command and open connection.
            SqlCeConnection sqlConnection = new SqlCeConnection(connectionString);
            SqlCeCommand sqlCommand = sqlConnection.CreateCommand();
            sqlConnection.Open();

            //Gets concepts that are available depending on group and level of student
            sqlCommand.CommandText = "SELECT Rel_GL_Concept.FK_Concept_ID, Conceptos.* " +
                "FROM Rel_GL_Concept INNER JOIN " +
                "Conceptos ON Rel_GL_Concept.FK_Concept_ID = Conceptos.ID " +
                "WHERE (REL_GL_Concept.FK_Group_ID = " + stdGroup.ToString() +
                " ) OR (Rel_GL_Concept.FK_Level_ID = " + stdLevel.ToString() + " )";

            SqlCeDataReader sqlReader = sqlCommand.ExecuteReader();

            //Create objects for each concept and fill List<>
            while (sqlReader.Read())
            {
                infoConcept gObject = new infoConcept();
                gObject.Name = sqlReader["Title"].ToString(); ;
                gObject.Amount = float.Parse(sqlReader["Base_Amount"].ToString());
                gObject.Value = sqlReader["FK_Concept_ID"].ToString();

                lstConcept.Add(gObject);
            }

            return lstConcept;
        }
Beispiel #6
0
 private void getInfo(int selected)
 {
     _selectedConcept = DAL.getConceptInfo(selected);
 }