コード例 #1
0
        public void Export(ClinicsMySQLContext mySqlContext)
        {
            DataTable procedures = this.ReadFromSQLite();
            DataTable joined = this.JoinData(mySqlContext, procedures, "Procedure", "Name");

            this.SaveDataToExcel(joined);
        }
コード例 #2
0
        public void Export(ClinicsMySQLContext mySqlContext, int year, int month, string specialistName, string procedureName, int procedureCount, decimal totalPrice)
        {
            var specialistsStatistics = mySqlContext.Specialiststatistics
                .Where(ss => ss.Specialist.Equals(specialistName) && ss.Procedure.Equals(procedureName) && ss.Month.Equals(month) && ss.Year == year)
                .FirstOrDefault();

            if (specialistsStatistics == null)
            {
                Specialiststatistic newSpecialistStatistics = new Specialiststatistic
                {
                    Specialist = specialistName,
                    Procedure = procedureName,
                    ProcedureCount = procedureCount,
                    TotalPrice = totalPrice.ToString(),
                    Month = month,
                    Year = year
                };

                mySqlContext.Add(newSpecialistStatistics);
                mySqlContext.SaveChanges();
            }
        }
コード例 #3
0
        private DataTable JoinData(ClinicsMySQLContext mySqlContext, DataTable procedures, string joinProp, string joinCol)
        {
            DataTable result = this.GenerateExcelColumns(procedures, joinCol);

            // For each item in the collection fill a row in the excel table
            foreach (var row in mySqlContext.Specialiststatistics)
            {
                DataRow insertRow = result.NewRow();

                // Fill the properties of the object
                foreach (var prop in typeof(Specialiststatistic).GetProperties())
                {
                    insertRow[prop.Name] = row.GetType().GetProperty(prop.Name).GetValue(row, null);
                }

                // Find the matching row from the table
                string procName = row.GetType().GetProperty(joinProp).GetValue(row, null).ToString();
                foreach (DataRow proc in procedures.Rows)
                {
                    if ((string)proc[joinCol] == procName)
                    {
                        foreach (DataColumn procCol in procedures.Columns)
                        {
                            if (procCol.ColumnName != joinCol)
                            {
                                insertRow[procCol.ColumnName] = proc[procCol.ColumnName];
                            }
                        }

                        break;
                    }
                }

                result.Rows.Add(insertRow);
            }

            return result;
        }