protected void Page_Load(object sender, EventArgs e) { string action = string.Empty; string answer = "ocurrio un error"; action = Request["action"]; if (action == "list") { BrBonus brBonus = new BrBonus(); MyFunctions mf = new MyFunctions(); MyConstants mc = new MyConstants(); var data = brBonus.GetFullPeriod(); if (data != "") { var arrayData = data.Split('¬'); var tableHtml = ""; tableHtml = "<table class='table table-hovered'>"; tableHtml += "<tr>"; tableHtml += "<th>#</th>"; tableHtml += "<th>Fecha de Inicio</th>"; tableHtml += "<th>Fecha de Fin</th>"; tableHtml += "<th>Fecha de Pago</th>"; tableHtml += "<th>Estado</th>"; tableHtml += "<th></th>"; tableHtml += "<th></th>"; tableHtml += "</tr>"; for (int i = 0; i < arrayData.Length; i++) { var row = arrayData[i].Split('|'); if (row.Length > 1) { var button = $"Activate({row[0]})"; var display = "Activar"; var classbutton = "primary"; if (int.Parse(row[3]) == 1) { button = $"Defuce({row[0]})"; display = "Desactivar"; classbutton = "danger"; } tableHtml += "<tr>"; tableHtml += $"<td>{(i + 1).ToString()}</td>"; tableHtml += $"<td>{mf.DateFormatClient(row[1])}</td>"; tableHtml += $"<td>{mf.DateFormatClient(row[2])}</td>"; tableHtml += $"<td>{mf.DateFormatClient(row[4])}</td>"; tableHtml += $"<td>{mf.GeneralStatus(row[3])}</td>"; tableHtml += $"<td><input type='button' class='btn-{classbutton}' onclick={button} value='{display}' /></td>"; if (DateTime.Parse(row[4]) >= DateTime.Now && row[3] == "1") { tableHtml += $"<td><input type='button' class='btn-info' onclick=PayBonus({row[0]}) value='Pagar Bonus' /> | "; tableHtml += $"<input type='button' class='btn-success' onclick=HistoryRange({row[0]}) value='Calcular Rangos Compuestos' /> | "; tableHtml += $"<input type='button' class='btn-warning' onclick=HistoryRangeResidual({row[0]}) value='Calcular Rangos Residual' /></td>"; } else { tableHtml += "<td></td>"; } tableHtml += "</tr>"; } } tableHtml += "</table>"; answer = tableHtml; } } if (action == "status") { BrBonus brBonus = new BrBonus(); var option = int.Parse(Request["option"]); var id = int.Parse(Request["id"]); var anwdata = false; if (option == 0) { anwdata = brBonus.ChangeStatus(id, 0); } if (option == 1) { anwdata = brBonus.ChangeStatus(id, 1); } if (anwdata) { answer = "La operacion se realizo con exito."; } brBonus = null; } if (action == "new") { MyFunctions mf = new MyFunctions(); var _from = Request["from"]; var _until = Request["until"]; var _payDate = Request["paydate"]; _from = mf.DateFormatBd(_from); _until = mf.DateFormatBd(_until); _payDate = mf.DateFormatBd(_payDate); BrBonus brBonus = new BrBonus(); var dataresp = brBonus.PutPeriod(_from, _until, _payDate); if (dataresp) { answer = "La operacion se realizo con exito."; } brBonus = null; } if (action == "paybonus") { var id = int.Parse(Request["id"]); BrBonus brBonus = new BrBonus(); var dataresp = brBonus.PayBonus(id); if (dataresp) { var listEmail = brBonus.GetEmailPayWallet(id).Split('¬'); for (int i = 0; i < listEmail.Length; i++) { var row = listEmail[i].Split('|'); var amount = decimal.Parse(row[2]); var transfid = new Random().Next(100000).ToString(); var walletId = int.Parse(row[4]).ToString("00000000"); var arrdescrip = row[3].Split(':'); var descripti = arrdescrip[0] + " : <span>" + arrdescrip[1] + "</span>"; MyConstants mc = new MyConstants(); var sendee = SendPayWallet(row[0], row[1], amount, descripti, transfid, walletId); sendee = SendPayWallet(mc.EmailEmpresaBonus, row[1], amount, descripti, transfid, walletId); } answer = "La operacion se realizo con exito."; } } if (action == "historyrange") { var id = int.Parse(Request["id"]); BrHistoryRange brHistoryRange = new BrHistoryRange(); var dataresp = brHistoryRange.PutHistoryRangePeriod(id); answer = ""; if (dataresp) { answer = "La operacion se realizo con exito."; } } if (action == "historyrangeresidual") { var id = int.Parse(Request["id"]); BrHistoryRange brHistoryRange = new BrHistoryRange(); var dataresp = brHistoryRange.PutHistoryRangeResidualPeriod(id); answer = ""; if (dataresp) { answer = "La operacion se realizo con exito."; } } Response.Write(answer); }