Advertisement
Guest User

Untitled

a guest
Dec 14th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 3.99 KB | None | 0 0
  1.  protected void btn_replicate_Click(object sender, EventArgs e)
  2.         {
  3.             string dataI = start_date.Text;
  4.             string dataF = end_date.Text;
  5.  
  6.             DateTime START = DateTime.ParseExact(dataI, "dd/MM/yyyy HH:mm", System.Globalization.DateTimeFormatInfo.CurrentInfo);
  7.             DateTime END = DateTime.ParseExact(dataF, "dd/MM/yyyy HH:mm", System.Globalization.DateTimeFormatInfo.CurrentInfo);
  8.             INT weekRepeat = CONVERT.ToInt32(tb_replicate.Text);
  9.  
  10.             FOR(INT i = 0;i<weekRepeat;i++)
  11.             {
  12.                 DateTime nextWeekStart = START.AddDays((7*(i+1)));
  13.                 DateTime nextWeekEnd = END.AddDays((7 * (i + 1)));
  14.                 Response.WRITE("Start: " + nextWeekStart + "           " + " end: " + nextWeekEnd);
  15.  
  16.                 TimeSpan diferença = nextWeekEnd.Subtract(nextWeekStart);
  17.                 DOUBLE difDouble = diferença.TotalHours;
  18.  
  19.                 SqlConnection myConn = NEW SqlConnection(ConfigurationManager.ConnectionStrings["projectofinalatestes2ConnectionString"].ConnectionString);
  20.                 SqlCommand myCommand = NEW SqlCommand();
  21.                
  22.  
  23.                 myCommand.Connection = myConn;
  24.                 myCommand.Parameters.AddWithValue("@id", -1);
  25.  
  26.                 DateTime aEnviar  = DateTime.ParseExact(nextWeekStart.ToShortDateString(), "dd/MM/yyyy", System.Globalization.DateTimeFormatInfo.CurrentInfo);
  27.                 Response.WRITE(aEnviar.ToString());
  28.                 //myCommand.Parameters.AddWithValue("@st_date", nextWeekStart);
  29.                 //myCommand.Parameters.AddWithValue("@ed_date", nextWeekEnd);
  30.                 //myCommand.Parameters.AddWithValue("@id_turma", CONVERT.ToInt32(SESSION["id_turma"].ToString()));
  31.                 //myCommand.Parameters.AddWithValue("@id_form", ddl_form.SelectedValue);
  32.                 //myCommand.Parameters.AddWithValue("@id_ufcd", ddl_ufcd.SelectedValue);
  33.                 //myCommand.Parameters.AddWithValue("@horas", difDouble);
  34.                 //myCommand.Parameters.AddWithValue("@text", ddl_ufcd.SelectedItem.ToString() + " - " + ddl_form.SelectedItem.ToString());
  35.  
  36.                 //SqlParameter existe = NEW SqlParameter();
  37.                 //existe.ParameterName = "@flag";
  38.                 //existe.SIZE = 10;
  39.                 //existe.Direction = ParameterDirection.Output;
  40.  
  41.                 //myCommand.Parameters.ADD(existe);
  42.                 //myCommand.CommandType = CommandType.StoredProcedure;
  43.                 //myCommand.CommandText = "insert_update_aulas";
  44.  
  45.                 //myConn.OPEN();
  46.  
  47.                 //myCommand.ExecuteNonQuery();
  48.                 //INT estado = CONVERT.ToInt32(myCommand.Parameters["@flag"].VALUE);
  49.  
  50.                 //IF (estado == 4)
  51.                 //{
  52.                 //    Response.WRITE("formador nao tem disponibilidade no dia " + nextWeekStart.ToShortDateString());
  53.                 //}
  54.  
  55.                 //ELSE IF (estado == 3)
  56.                 //{
  57.                 //    Response.WRITE("formador inserido");
  58.                 //}
  59.  
  60.                 //ELSE IF (estado == 2)
  61.                 //{
  62.                 //    Response.WRITE("forcar horas, foi possiver replicar " + (i + 1) + "semanas");
  63.                 //}
  64.  
  65.                 //ELSE IF (estado == 1)
  66.                 //{
  67.                 //    Response.WRITE("horas requeridas");
  68.                 //}
  69.  
  70.                 //ELSE IF (estado == 6)
  71.                 //{
  72.                 //    Response.WRITE("formador ja alocado");
  73.                 //}
  74.                 //ELSE IF (estado == 5)
  75.                 //{
  76.                 //    Response.WRITE("ja há alocacao");
  77.                 //}
  78.                 //ELSE IF (estado == 7)
  79.                 //{
  80.                 //    Response.WRITE("Ultima semana com horas forçadas, foi possiver replicar " + (i + 1) + "semanas");
  81.                 //    break;
  82.                 //}
  83.  
  84.                 //myConn.Close();
  85.  
  86.                 //ClientScript.RegisterStartupScript(GetType(), "", "lightbox.close();", TRUE);
  87.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement