Esempio n. 1
0
        protected void Button1_Click1(object sender, EventArgs e)
        {
            Literal1.Text = "{ <br />";
            foreach (GridViewRow row in GridViewPontaj.Rows)
            {
                if (row.RowType == DataControlRowType.DataRow)
                {
                    SqlConnection sqlConnection = new SqlConnection();
                    sqlConnection.ConnectionString = ConfigurationManager.ConnectionStrings["CrisTimeConnection"].ConnectionString;
                    SqlCommand sqlCommand = new SqlCommand();
                    sqlCommand.Connection  = sqlConnection;
                    sqlCommand.CommandType = CommandType.StoredProcedure;
                    sqlCommand.CommandText = "[dbo].[CorectezPontaj]";
                    sqlCommand.Parameters.Add(new SqlParameter("@marca", row.Cells[0].Text));
                    sqlCommand.Parameters.Add(new SqlParameter("@an", row.Cells[3].Text));
                    sqlCommand.Parameters.Add(new SqlParameter("@luna", row.Cells[2].Text));

                    Literal1.Text = Literal1.Text + "-->" + row.Cells[0].Text + " " + row.Cells[1].Text + " " + row.Cells[2].Text + " " + row.Cells[3].Text + " ";
                    for (int z = 1; z <= 31; z++)
                    {
                        string textore = ((TextBox)row.FindControl("TextBox" + z.ToString().Trim())).Text.ToString();
                        int    ore;
                        if (textore.Trim().Length > 0)
                        {
                            ore = Convert.ToInt16(textore.ToString());
                            if (((TextBox)row.FindControl("TextBox" + z.ToString().Trim())).Text.ToString() != ((TextBox)row.FindControl("TextBox" + z.ToString().Trim())).ToolTip.ToString())
                            {
                                sqlCommand.Parameters.Add(new SqlParameter("@z" + z, ore.ToString()));
                            }

                            Literal1.Text = Literal1.Text + ore.ToString() + " ";
                        }
                        else
                        {
                            ore           = -10;
                            Literal1.Text = Literal1.Text + " " + " ";
                        }
                    }
                    sqlCommand.Connection.Open();
                    sqlCommand.ExecuteNonQuery();
                    sqlCommand.Connection.Close();

                    Literal1.Text = Literal1.Text + "  <br />";
                    GridViewPontaj.DataBind();
                }
            }
            Literal1.Text = Literal1.Text + "<br /> }";
        }
Esempio n. 2
0
        protected void Button2_Command(object sender, CommandEventArgs e)
        {
            int an = 0, luna = 0, first = 0;

            DataTable  zile;
            DataColumn tcolumn;
            DataRow    trow;

            init_zile(out zile, out tcolumn);


            foreach (GridViewRow row in GridViewPontaj.Rows)
            {
                if (row.RowType == DataControlRowType.DataRow)
                {
                    if (an != Convert.ToInt32(row.Cells[3].Text) || luna != Convert.ToInt32(row.Cells[2].Text))
                    {
                        if (first == 0)
                        {
                            first = 1;
                        }
                        else
                        {
                            //insert into sql server

                            insSqlZile(an, luna, zile);
                        }
                        init_zile(out zile, out tcolumn);
                        luna = Convert.ToInt32(row.Cells[2].Text);
                        an   = Convert.ToInt32(row.Cells[3].Text);
                    }
                    for (int z = 1; z <= 31; z++)
                    {
                        string textore = ((TextBox)row.FindControl("TextBox" + z.ToString().Trim())).Text.ToString();
                        int    ore;
                        if (textore.Trim().Length > 0)
                        {
                            try
                            {
                                ore = Convert.ToInt16(textore.ToString());
                            }
                            catch
                            {
                                switch (textore.ToUpper().Trim())
                                {
                                case "CO":
                                    ore = -1;
                                    break;

                                case "CFS":
                                    ore = -2;
                                    break;

                                case "CM":
                                    ore = -3;
                                    break;

                                case "EV":
                                    ore = -4;
                                    break;

                                case "N":
                                    ore = -5;
                                    break;

                                default:
                                    textore = ((TextBox)row.FindControl("TextBox" + z.ToString().Trim())).ToolTip.ToString();
                                    ((TextBox)row.FindControl("TextBox" + z.ToString().Trim())).Text = textore;
                                    ore = Convert.ToInt16(textore.ToString());
                                    ore = 0;
                                    break;
                                }
                            }
                            if (((TextBox)row.FindControl("TextBox" + z.ToString().Trim())).Text.ToString() != ((TextBox)row.FindControl("TextBox" + z.ToString().Trim())).ToolTip.ToString())
                            {
                                trow          = zile.NewRow();
                                trow["marca"] = Convert.ToInt32(row.Cells[0].Text);
                                trow["zi"]    = z;
                                trow["val"]   = ore;
                                zile.Rows.Add(trow);

                                //sqlCommand.Parameters.Add(new SqlParameter("@z" + z, ore.ToString()));
                            }
                        }
                        else
                        {
                            ore = -10;
                        }
                    }
                }
            }
            insSqlZile(an, luna, zile);
            Literal1.Text = "salvat";
            GridViewPontaj.DataBind();

            ButtonCalc_Click(sender, e);
        }