public string A_2_GreenPart(Global global, DASHBOARD_PERIOD currentPeriod, List <backoffice.dim_dim_value_value> yearMonthList) { StringBuilder sb = new StringBuilder(); DASHBOARD_MONTH dashBoardMonth = new DASHBOARD_MONTH(currentPeriod); // Denne skal dersom parameter er shippet ta periodetype inn long dInPeriod = 0; long dInPrevPeriod = 0; foreach (backoffice.dim_dim_value_value yearMonth in yearMonthList) { if (yearMonth.sDim_1 == dashBoardMonth.iThisMonthYear.ToString() && yearMonth.sDim_2 == dashBoardMonth.iThisMonth.ToString()) { dInPeriod = (long)(yearMonth.dValue_2); } else if (yearMonth.sDim_1 == dashBoardMonth.iPrevMonthYear.ToString() && yearMonth.sDim_2 == dashBoardMonth.iPrevMonth.ToString()) { dInPrevPeriod = (long)(yearMonth.dValue_2); } } string sPercentChange = get_percent_increase_from_to(dInPrevPeriod, dInPeriod, true); sb.Append(A_1_GreenPart("frame_1", 0, 10, 300, 220, 170, "OMSETNING " + new DASHBOARD_MONTH(currentPeriod).sThisMonth, "FORRIGE MND.", "ENDRING I %", dInPeriod.ToString("# ##0") + " kr", dInPrevPeriod.ToString("# ##0") + " kr", global.getSvgUpDownArrow(" " + sPercentChange + " %", false))); return(sb.ToString()); }
public string A_1_GetGreenPart(Global global, DASHBOARD_PERIOD currentPeriod, List <backoffice.dim_dim_value> yearMonthList, List <backoffice.dim_value_value> shopList) { StringBuilder sb = new StringBuilder(); DASHBOARD_MONTH dashBoardMonth = new DASHBOARD_MONTH(currentPeriod); // Denne skal dersom parameter er shippet ta periodetype inn int iInPeriod = 0; int iFromAncientTimeToLastDateBeforePeriod = 0; foreach (backoffice.dim_dim_value yearMonth in yearMonthList) { if (yearMonth.sDim_1 == dashBoardMonth.iThisMonthYear.ToString() && yearMonth.sDim_2 == dashBoardMonth.iThisMonth.ToString()) { iInPeriod = Convert.ToInt32(yearMonth.sValue); // 14 okt = 68 } else if (yearMonth.sDim_1 == dashBoardMonth.iThisMonthYear.ToString()) { if (Convert.ToInt32(yearMonth.sDim_2) <= dashBoardMonth.iThisMonth) { iFromAncientTimeToLastDateBeforePeriod += Convert.ToInt32(yearMonth.sValue); } } else if (Convert.ToInt32(yearMonth.sDim_1) <= dashBoardMonth.iThisMonthYear) { iFromAncientTimeToLastDateBeforePeriod += Convert.ToInt32(yearMonth.sValue); } } int iTotalMembers = 0; foreach (backoffice.dim_value_value shop in shopList) { iTotalMembers += Convert.ToInt32(shop.sValue_1); } // iInPrevPeriod = antall medlemmer inntil den den flrste i iInPeriod. string sIncreasePercent = "+ " + get_percent_of(iFromAncientTimeToLastDateBeforePeriod, iInPeriod, false); // 14 okt = 68 sb.Append(XXX_getCenteredGreenFrame(0, 10, 300, 220, 170, "MEDLEMSBASE", "TOTALT ANTALL MEDLEMMER", "I PERIODEN", "ENDRING I %", iTotalMembers.ToString(), global.getSvgUpDownArrow(" " + iInPeriod.ToString(), true), global.getSvgUpDownArrow(" " + sIncreasePercent + " %", true))); return(sb.ToString()); }
public string GET_TOP_MENU(DASHBOARD_PERIOD currentDashboardPeriod) { StringBuilder sb = new StringBuilder(); DASHBOARD_MONTH dbMonth = new DASHBOARD_MONTH(DASHBOARD_PERIOD.DONT_CARE); sb.Append("<td valign=top align=center>"); sb.Append("<div>"); // ******START: TOP GREEN HORISONTAL *************************************************************** sb.Append(" <table width=100% cellpadding=0 cellspacing=0 align=center>"); sb.Append(" <tr>"); sb.Append(" <td valign=top style='padding:20px;background-color:rgb(247,247,247);' colspan=1>"); sb.Append(" <div style='float:left;margin-top:12px;'>"); sb.Append(" <div class=bember_burger_line></div>"); sb.Append(" <div class=bember_burger_line></div>"); sb.Append(" <div class=bember_burger_line></div>"); sb.Append(" </div>"); sb.Append(" <div class=bember_your_memberclub style='float:left;'>Din Kundeklubb</div>"); sb.Append(" <div id=bember_working style='float:left;'>Ready ...</div>"); sb.Append(" <div onclick=level_2_report_4('" + ((int)DASHBOARD_PERIOD.THIS_MONTH).ToString() + "') " + getButtonClass(DASHBOARD_PERIOD.THIS_MONTH, currentDashboardPeriod) + " style='float:right;'>Inneværende periode</div>"); sb.Append(" <div onclick=level_2_report_4('" + ((int)DASHBOARD_PERIOD.PREV_MONTH).ToString() + "') " + getButtonClass(DASHBOARD_PERIOD.PREV_MONTH, currentDashboardPeriod) + " style='float:right;'>" + dbMonth.sPrevMonth + " " + dbMonth.iPrevMonthYear.ToString() + "</div>"); sb.Append(" <div onclick=level_2_report_4('" + ((int)DASHBOARD_PERIOD.PREV_PREV_MONTH).ToString() + "') " + getButtonClass(DASHBOARD_PERIOD.PREV_PREV_MONTH, currentDashboardPeriod) + " style='float:right;'>" + dbMonth.sPrevPrevMonth + " " + dbMonth.iPrevPrevMonthYear.ToString() + "</div>"); sb.Append(" </td>"); sb.Append(" </tr>"); sb.Append(" </table>"); sb.Append("</div>"); sb.Append("</td>"); return sb.ToString(); }
public string GET_TOP_MENU(DASHBOARD_PERIOD currentDashboardPeriod) { StringBuilder sb = new StringBuilder(); DASHBOARD_MONTH dbMonth = new DASHBOARD_MONTH(DASHBOARD_PERIOD.DONT_CARE); sb.Append("<td valign=top align=center>"); sb.Append("<div>"); // ******START: TOP GREEN HORISONTAL *************************************************************** sb.Append(" <table width=100% cellpadding=0 cellspacing=0 align=center>"); sb.Append(" <tr>"); sb.Append(" <td valign=top style='padding:20px;background-color:rgb(247,247,247);' colspan=5>"); sb.Append(" <div style='float:left;margin-top:12px;'>"); sb.Append(" <div class=bember_burger_line></div>"); sb.Append(" <div class=bember_burger_line></div>"); sb.Append(" <div class=bember_burger_line></div>"); sb.Append(" </div>"); sb.Append(" <div class=bember_your_memberclub style='float:left;'>Din Kundeklubb</div>"); sb.Append(" <div onclick=level_2_report_4('" + ((int)DASHBOARD_PERIOD.THIS_MONTH).ToString() + "') " + getButtonClass(DASHBOARD_PERIOD.THIS_MONTH, currentDashboardPeriod) + " style='float:right;'>Inneværende periode</div>"); sb.Append(" <div onclick=level_2_report_4('" + ((int)DASHBOARD_PERIOD.PREV_MONTH).ToString() + "') " + getButtonClass(DASHBOARD_PERIOD.PREV_MONTH, currentDashboardPeriod) + " style='float:right;'>" + dbMonth.sPrevMonth + " " + dbMonth.iPrevMonthYear.ToString() + "</div>"); sb.Append(" <div onclick=level_2_report_4('" + ((int)DASHBOARD_PERIOD.PREV_PREV_MONTH).ToString() + "') " + getButtonClass(DASHBOARD_PERIOD.PREV_PREV_MONTH, currentDashboardPeriod) + " style='float:right;'>" + dbMonth.sPrevPrevMonth + " " + dbMonth.iPrevPrevMonthYear.ToString() + "</div>"); sb.Append(" </td>"); sb.Append(" </tr>"); sb.Append(" </table>"); sb.Append("</div>"); sb.Append("</td>"); return(sb.ToString()); }
public List<shop_top_bottom> get_conversion_data_in_shoplist(DASHBOARD_PERIOD yearMonthPeriod, string sChainId) { List<shop_top_bottom> shopList = new List<shop_top_bottom>(); DASHBOARD_MONTH yearMonth = new DASHBOARD_MONTH(yearMonthPeriod); string sFromMonthDate = ""; string sBeforeMonthDate = ""; sFromMonthDate = yearMonth.getThisDbYearMonthDay1String(0); sBeforeMonthDate = yearMonth.getThisDbYearNextMonthDay1String(); // Mountain Conversion rate Dashboard 02 string sSql = "select s.name," + "case when sub_action like 'ecr_new%' then 'yes' when sub_action like 'ecr_ref%' then 'no' when sub_action like 'ecr_already%' then 'already_member' end got_mobile," + "case when c.pincode_verified = 'yes' then 'yes' when c.pincode_verified = 'no' then 'no_not_yet' else 'no_phone' end approved_sms," + "count(*) nof_events " + "from user_action ua left JOIN shop s ON (s.shop_external_id = substring(ua.parameters for position(';' in ua.parameters)-position('baxid=' in ua.parameters)-6 from position('baxid=' in parameters)+6) and s.parent_shop=" + sChainId + ")" + "left JOIN consumer c ON (c.phone = split_part(ua.parameters, ';', 2)) " + "where " + "(sub_action like 'ecr_refused_enrollment' or sub_action like 'ecr_new_enrollment') and " + "ua.id > 4785 and ua.timestamp >= '" + sFromMonthDate + "' and ua.timestamp < '" + sBeforeMonthDate + "' " + "and s.shop_external_id = substring(ua.parameters for position(';' in ua.parameters)-position('baxid=' in ua.parameters)-6 from position('baxid=' in parameters)+6) " + "group by s.name, ua.sub_action, c.pincode_verified " + "order by s.name, ua.sub_action, c.pincode_verified"; GLOBAL_SQL_CONN conn = new GLOBAL_SQL_CONN(this); try { GLOBAL_SQL_COMMAND command = new GLOBAL_SQL_COMMAND(sSql, conn); GLOBAL_SQL_READER reader = new GLOBAL_SQL_READER(command); shop_top_bottom shop = null; // Shop, got_mobile, approved_sms, number_of_events string sPrevShopName = ""; int iii = 0; while (reader.Read()) { ++iii; try { if (iii == 18) { iii = iii; } string sShopName = reader.c("name").ToString(); if (sShopName != sPrevShopName) { if (shop != null) { decimal decimal_1 = DASHBOARD_GREEN.get_percent_of_to_decimal(shop.iNoPhone + shop.iYesPhoneApproved + shop.iYesPhoneNotApproved, shop.iYesPhoneApproved + shop.iYesPhoneNotApproved, false); shop.dLeftMobilePercent = decimal_1; decimal decimal_2 = DASHBOARD_GREEN.get_percent_of_to_decimal(shop.iNoPhone + shop.iYesPhoneApproved + shop.iYesPhoneNotApproved, shop.iYesPhoneApproved, false); shop.dConvertedFromTotalPercent = Convert.ToDecimal(decimal_2); shopList.Add(shop); } shop = new shop_top_bottom(); } shop.sName = sShopName; string sGotMobile = reader.c("got_mobile").ToString(); string sApprovedSms = reader.c("approved_sms").ToString(); /* 1 */ if (sGotMobile == "yes" && sApprovedSms == "yes") shop.iYesPhoneApproved = Convert.ToInt64(reader.c("nof_events").ToString()); /* 2 */ else if (sGotMobile == "yes" && sApprovedSms == "no_not_yet") shop.iYesPhoneNotApproved = Convert.ToInt64(reader.c("nof_events").ToString()); /* 3 */ else if (sGotMobile == "no") shop.iNoPhone = Convert.ToInt64(reader.c("nof_events").ToString()); sPrevShopName = sShopName; } catch (Exception) { int t = 0; } } if (shop != null) { shop.dLeftMobilePercent = DASHBOARD_GREEN.get_percent_of_to_decimal(shop.iNoPhone + shop.iYesPhoneApproved + shop.iYesPhoneNotApproved, shop.iYesPhoneApproved + shop.iYesPhoneNotApproved, false); shop.dConvertedFromTotalPercent = DASHBOARD_GREEN.get_percent_of_to_decimal(shop.iNoPhone + shop.iYesPhoneApproved + shop.iYesPhoneNotApproved, shop.iYesPhoneApproved, false); shopList.Add(shop); } } catch (Exception e) { shopList = null; } finally { conn.Close(); } return shopList; }
public List<name_value_value_value_value> get_conversion_data(DASHBOARD_PERIOD yearMonthPeriod, string sChainId, bool bHalfYear) { List<name_value_value_value_value> monthList = new List<name_value_value_value_value>(); DASHBOARD_MONTH yearMonth = new DASHBOARD_MONTH(yearMonthPeriod); string sFromMonthDate = ""; string sBeforeMonthDate = ""; if (yearMonthPeriod == DASHBOARD_PERIOD.THIS_MONTH || yearMonthPeriod == DASHBOARD_PERIOD.PREV_MONTH || yearMonthPeriod == DASHBOARD_PERIOD.PREV_PREV_MONTH) { if (bHalfYear) sFromMonthDate = yearMonth.getThisDbYearMonthDay1String(-5); else sFromMonthDate = yearMonth.getThisDbYearMonthDay1String(0); sBeforeMonthDate = yearMonth.getThisDbYearNextMonthDay1String(); } /* else if (yearMonthPeriod == DASHBOARD_PERIOD.HALF_YEAR) { sFromMonthDate = yearMonth.getThisDbYearMonthDay1String(-5); sBeforeMonthDate = yearMonth.getThisDbYearNextMonthDay1String(); } */ //Mountain Dashboard 001 // Conversion data string sSql = "select " + "EXTRACT(YEAR FROM ua.timestamp) x_year, " + "EXTRACT(MONTH FROM ua.timestamp) x_month, " + "case " + "when sub_action like 'ecr_new%' then 'yes' " + "when sub_action like 'ecr_ref%' then 'no' " + "when sub_action like 'ecr_already%' then 'already_member' " + "end got_mobile, " + "case " + "when c.pincode_verified = 'yes' then 'yes' " + "when c.pincode_verified = 'no' then 'no_not_yet' " + "else 'no_phone' " + "end approved_sms, " + "count(*) nof_events " + "from user_action ua " + "left JOIN shop s ON (s.shop_external_id = substring(ua.parameters for position(';' in ua.parameters)-position('baxid=' in ua.parameters)-6 from position('baxid=' in parameters)+6) and " + // "(s.id <> 20 and s.id <> 25) and " + "s.parent_shop=" + sChainId + ") " + // "s.parent_shop=" + sChainId + ") " + "left JOIN consumer c ON (c.phone = split_part(ua.parameters, ';', 2)) " + "where (sub_action like 'ecr_refused_enrollment' or sub_action like 'ecr_new_enrollment' or sub_action like 'ecr_already%') " + "and ua.id > 4785 " + "and ua.timestamp >= '" + sFromMonthDate + "' " + "and " + "ua.timestamp < '" + sBeforeMonthDate + "' " + "and s.shop_external_id = substring(ua.parameters for position(';' in ua.parameters)-position('baxid=' in ua.parameters)-6 from position('baxid=' in parameters)+6) " + "group by x_month,x_year, ua.sub_action, c.pincode_verified " + "order by x_year,x_month, ua.sub_action, c.pincode_verified"; // "order by x_month,x_year, ua.sub_action, c.pincode_verified"; GLOBAL_SQL_CONN conn = new GLOBAL_SQL_CONN(this); try { GLOBAL_SQL_COMMAND command = new GLOBAL_SQL_COMMAND(sSql, conn); GLOBAL_SQL_READER reader = new GLOBAL_SQL_READER(command); string sLastYearMonth = ""; string sValue_1 = ""; // value_1 : Searching for yes - yes string sValue_2 = ""; // value_2 : Searching for yes - no_not_yet string sValue_3 = ""; // value_3 : Searching for no - whatever string sValue_4 = ""; // value_3 : Searching for no - already_member name_value_value_value_value month = null; while (reader.Read()) { string sMonth = reader.c("x_month").ToString(); string sThisYearMonth = reader.c("x_year").ToString() + "_" + sMonth; if (sThisYearMonth != sLastYearMonth) { month = new name_value_value_value_value(); sValue_1 = ""; sValue_2 = ""; sValue_3 = ""; sValue_4 = ""; } string sGotMobile = reader.c("got_mobile").ToString(); string sApprovedSms = reader.c("approved_sms").ToString(); if (sGotMobile == "yes" && sApprovedSms == "yes") sValue_1 = reader.c("nof_events").ToString(); else if (sGotMobile == "yes" && sApprovedSms == "no_not_yet") sValue_2 = reader.c("nof_events").ToString(); else if (sGotMobile == "no") sValue_3 = reader.c("nof_events").ToString(); else if (sGotMobile == "already_member") sValue_4 = reader.c("nof_events").ToString(); if (sValue_1 != "" && sValue_2 != "" && sValue_3 != "" && sValue_4 != "") { // Test if value_4 already member has values. These must be subtracted ... month.sName = DASHBOARD_MONTH.month_text(Convert.ToInt32(sMonth)); // month.sName = sThisYearMonth; month.sValue1 = sValue_1; month.sValue2 = sValue_2; month.sValue3 = sValue_3; month.sValue4 = sValue_4; monthList.Add(month); } sLastYearMonth = sThisYearMonth; } } catch (Exception e) { monthList = null; } finally { conn.Close(); } return monthList; }
public List<dim_value_value> dash_get_members_by_chain_shop(string sParentShopId, DASHBOARD_PERIOD currentPeriod) { DASHBOARD_MONTH yearMonth = new DASHBOARD_MONTH(currentPeriod); string sPeriodFilter = ""; if (currentPeriod != DASHBOARD_PERIOD.DONT_CARE) { string sFromMonthDate = yearMonth.getThisDbYearMonthDay1String(0); string sBeforeMonthDate = yearMonth.getThisDbYearNextMonthDay1String(); sPeriodFilter = " and " + // lunch "c.created_at >= '" + sFromMonthDate + "' " + "and " + "c.created_at < '" + sBeforeMonthDate + "' "; } /* if (yearMonthPeriod == DASHBOARD_PERIOD.THIS_MONTH || yearMonthPeriod == DASHBOARD_PERIOD.PREV_MONTH || yearMonthPeriod == DASHBOARD_PERIOD.PREV_PREV_MONTH) { sFromMonthDate = yearMonth.getThisDbYearMonthDay1String(0); sBeforeMonthDate = yearMonth.getThisDbYearNextMonthDay1String(); } */ // Mountain Dashboard 003 Antall medlemmer med godkjent/ikke godkjent avtale string sSql = "select s.id shop_id, s.name,c.pincode_verified membership_status,count(*) consumer_count " + "from consumer c, shop s " + "where " + "s.id = c.enrolled_by_shop_id " + sPeriodFilter + "and " + "s.parent_shop=" + sParentShopId + " " + // "and " + // "and (s.id <> 20 and s.id <> 25) " + "group by " + "enrolled_by_shop_id, s.name,s.id, c.pincode_verified " + "order by s.name, c.pincode_verified"; List<dim_value_value> shopList = new List<dim_value_value>(); GLOBAL_SQL_CONN conn = new GLOBAL_SQL_CONN(this); try { GLOBAL_SQL_COMMAND command = new GLOBAL_SQL_COMMAND(sSql, conn); GLOBAL_SQL_READER reader = new GLOBAL_SQL_READER(command); string sOldShopId = ""; dim_value_value currentShop = null; while (reader.Read()) { string sShopId = reader.c("shop_id").ToString(); if (sShopId != sOldShopId) { currentShop = new dim_value_value(); currentShop.sDim = reader.c("name").ToString(); shopList.Add(currentShop); } string sMembershipStatus = reader.c("membership_status").ToString(); string sConsumerCount = reader.c("consumer_count").ToString(); if (sMembershipStatus == "yes") currentShop.sValue_1 = sConsumerCount; // Has approved SMS // 14 okt = 65 else if (sMembershipStatus == "no") currentShop.sValue_2 = sConsumerCount; // Not approved SMS sOldShopId = sShopId; } } catch (Exception e) { shopList = null; } finally { conn.Close(); } return shopList; }
public List<dim_value> get_consumer_sex_list(string sChainId, DASHBOARD_PERIOD currentPeriod) { List<dim_value> sexList = new List<dim_value>(); DASHBOARD_MONTH yearMonth = new DASHBOARD_MONTH(currentPeriod); string sPeriodFilter = " "; if (currentPeriod != DASHBOARD_PERIOD.DONT_CARE) { string sFromMonthDate = yearMonth.getThisDbYearMonthDay1String(0); string sBeforeMonthDate = yearMonth.getThisDbYearNextMonthDay1String(); sPeriodFilter = " and " + // lunch "c.accepted_membership_at >= '" + sFromMonthDate + "' " + "and " + "c.accepted_membership_at < '" + sBeforeMonthDate + "' "; } // Mountain dashboard 006 Antall medlemmer etter kjønn string sSql = "select c.sex, count(*) nof_sex " + "from consumer c, shop s " + "where c.enrolled_by_shop_id=s.id and s.parent_shop=" + sChainId + " " + sPeriodFilter + "and c.pincode_verified='yes' " + "and " + "(sex = 'female' or sex = 'male') " + "group by c.sex "; GLOBAL_SQL_CONN conn = new GLOBAL_SQL_CONN(this); try { GLOBAL_SQL_COMMAND command = new GLOBAL_SQL_COMMAND(sSql, conn); GLOBAL_SQL_READER reader = new GLOBAL_SQL_READER(command); while (reader.Read()) { dim_value sex = new dim_value(); sex.sDim = reader.c("sex").ToString(); sex.sValue = reader.c("nof_sex").ToString(); sexList.Add(sex); } } catch (Exception e) { sexList = null; } finally { conn.Close(); } return sexList; }
public string get_average_member_age(string sChainId, DASHBOARD_PERIOD currentPeriod) { string sRetVal = "0.0"; string s10_Years_ago = DateTime.Now.AddYears(-10).Year.ToString(); string s110_Years_ago = DateTime.Now.AddYears(-110).Year.ToString(); // Only accepting age beetween 11 and 109 DASHBOARD_MONTH yearMonth = new DASHBOARD_MONTH(currentPeriod); string sPeriodFilter = " "; if (currentPeriod != DASHBOARD_PERIOD.DONT_CARE) { string sFromMonthDate = yearMonth.getThisDbYearMonthDay1String(0); string sBeforeMonthDate = yearMonth.getThisDbYearNextMonthDay1String(); sPeriodFilter = " and " + // lunch "c.accepted_membership_at >= '" + sFromMonthDate + "' " + "and " + "c.accepted_membership_at < '" + sBeforeMonthDate + "' "; } // Mountain dashboard 007 gjennomsnittsalder string sSql = "select avg(age(c.date_of_birth)) average_day_string " + "from consumer c, shop s " + "where " + "EXTRACT(YEAR FROM c.date_of_birth) > " + s110_Years_ago + " " + "and " + "EXTRACT(YEAR FROM c.date_of_birth) < " + s10_Years_ago + " " + sPeriodFilter + "and " + "c.pincode_verified = 'yes' and s.id = c.enrolled_by_shop_id and s.parent_shop=" + sChainId; // 30 sept GLOBAL_SQL_CONN conn = new GLOBAL_SQL_CONN(this); try { GLOBAL_SQL_COMMAND command = new GLOBAL_SQL_COMMAND(sSql, conn); GLOBAL_SQL_READER reader = new GLOBAL_SQL_READER(command); if (reader.Read()) { sRetVal = reader.c("average_day_string").ToString(); if (sRetVal != null && sRetVal.Length > 0) { string[] sTab = sRetVal.Split(".".ToCharArray()); if (sTab.Length > 0) sRetVal = sTab[0]; decimal dDays = Convert.ToDecimal(sRetVal); decimal dYears = decimal.Divide(dDays, (decimal)365.25); sRetVal = dYears.ToString("#.#"); if (sRetVal.StartsWith(",") || sRetVal.StartsWith(".")) sRetVal = "0" + sRetVal; } } } catch (Exception e) { sRetVal = "0.0"; } finally { conn.Close(); } if (sRetVal == "") sRetVal = "0.0"; return sRetVal; }
public string A_3_GreenPart(Global global, DASHBOARD_PERIOD currentPeriod, List<backoffice.dim_dim_value_value> yearMonthList) { StringBuilder sb = new StringBuilder(); DASHBOARD_MONTH dashBoardMonth = new DASHBOARD_MONTH(currentPeriod); // Denne skal dersom parameter er shippet ta periodetype inn long dInPeriod = 0; long dInPrevPeriod = 0; foreach (backoffice.dim_dim_value_value yearMonth in yearMonthList) { if (yearMonth.sDim_1 == dashBoardMonth.iThisMonthYear.ToString() && yearMonth.sDim_2 == dashBoardMonth.iThisMonth.ToString()) { if (yearMonth.dValue_1 > 0) dInPeriod = (long)(yearMonth.dValue_2 / yearMonth.dValue_1); else dInPeriod = 0; } else if (yearMonth.sDim_1 == dashBoardMonth.iPrevMonthYear.ToString() && yearMonth.sDim_2 == dashBoardMonth.iPrevMonth.ToString()) { if (yearMonth.dValue_1 > 0) dInPrevPeriod = (long)(yearMonth.dValue_2 / yearMonth.dValue_1); else dInPrevPeriod = 0; } } string sPercentChange = get_percent_increase_from_to(dInPrevPeriod, dInPeriod, true); sb.Append(A_1_GreenPart("frame_2", 0, 10, 300, 220, 170, "GJENNOMSNITTSKJØP " + new DASHBOARD_MONTH(currentPeriod).sThisMonth, "FORRIGE MND.", "ENDRING I %", dInPeriod.ToString() + " kr", dInPrevPeriod.ToString() + " kr", global.getSvgUpDownArrow(" " + sPercentChange + " %",false))); return sb.ToString(); }
public string A_1_GetGreenPart(Global global,DASHBOARD_PERIOD currentPeriod, List<backoffice.dim_dim_value> yearMonthList, List<backoffice.dim_value_value> shopList) { StringBuilder sb = new StringBuilder(); DASHBOARD_MONTH dashBoardMonth = new DASHBOARD_MONTH(currentPeriod); // Denne skal dersom parameter er shippet ta periodetype inn int iInPeriod = 0; int iFromAncientTimeToLastDateBeforePeriod = 0; foreach (backoffice.dim_dim_value yearMonth in yearMonthList) { if (yearMonth.sDim_1 == dashBoardMonth.iThisMonthYear.ToString() && yearMonth.sDim_2 == dashBoardMonth.iThisMonth.ToString()) { iInPeriod = Convert.ToInt32(yearMonth.sValue); // 14 okt = 68 } else if (yearMonth.sDim_1 == dashBoardMonth.iThisMonthYear.ToString()) { if (Convert.ToInt32(yearMonth.sDim_2) <= dashBoardMonth.iThisMonth) { iFromAncientTimeToLastDateBeforePeriod += Convert.ToInt32(yearMonth.sValue); } } else if (Convert.ToInt32(yearMonth.sDim_1) <= dashBoardMonth.iThisMonthYear) { iFromAncientTimeToLastDateBeforePeriod += Convert.ToInt32(yearMonth.sValue); } } int iTotalMembers = 0; foreach (backoffice.dim_value_value shop in shopList) { iTotalMembers += Convert.ToInt32(shop.sValue_1); } // iInPrevPeriod = antall medlemmer inntil den den flrste i iInPeriod. string sIncreasePercent = "+ " + get_percent_of(iFromAncientTimeToLastDateBeforePeriod, iInPeriod, false); // 14 okt = 68 sb.Append(XXX_getCenteredGreenFrame(0, 10, 300, 220, 170, "MEDLEMSBASE", "TOTALT ANTALL MEDLEMMER", "I PERIODEN", "ENDRING I %", iTotalMembers.ToString(), global.getSvgUpDownArrow(" " + iInPeriod.ToString(), true), global.getSvgUpDownArrow(" " + sIncreasePercent + " %",true))); return sb.ToString(); }