Inheritance: System.Web.UI.Page
Ejemplo n.º 1
0
        public void PublicConfidentialTest()
        {
            WebForm1 client  = new WebForm1();
            string   message = "This is confidential information and only available over TCP behind the company FireWall";
            string   result  = client.GetConfidentialServiceClient();

            Assert.AreEqual(message, result, "Pełna zgodność.");
        }
Ejemplo n.º 2
0
        public void Prueba_nuevo_Cliente()
        {
            WebForm1 a = new WebForm1();

            a.coneccion = new Coneccion();

            a.coneccion.SetCadena("data source = HILBERTPC; initial catalog = Taller; integrated security = True;");

            Assert.IsTrue(a.AgregarCliente("Juan", "Pedro", "Casas", "Casas", "2222222"));
        }
Ejemplo n.º 3
0
        public void Test_ComputemothlyPayment()
        {
            var webform = new WebForm1();

            double monthlyPayment = webform.ComputeMonthlyPayment(1000, 3, 2.5);

            monthlyPayment = Math.Round(monthlyPayment, 2);

            Assert.AreEqual(monthlyPayment, 28.86);
        }
    public AnotherClass(WebForm1 wf)
    {
        Button btnConfirm = new Button();

        btnConfirm.Text        = "Confirm";
        btnConfirm.CommandName = "Variable1,Variable2,Variable3";
        wf.Form.Controls.Add(btnConfirm);

        btnConfirm.Click += new EventHandler(wf.btnConfirmBook_Click);
    }
Ejemplo n.º 5
0
        public void Prueba_ObtenerCLientes()
        {
            WebForm1 a = new WebForm1();

            a.coneccion = new Coneccion();

            a.coneccion.SetCadena("data source = HILBERTPC; initial catalog = Taller; integrated security = True;");


            Assert.IsNotNull(a.getClientes());
        }
Ejemplo n.º 6
0
        public void PublicServiceTest()
        {
            // Arrange
            WebForm1 client  = new WebForm1();
            string   message = "This is public information and available over HTTP to all general public outside the FireWall";
            // Act
            string result = client.GetPublicServiceClient();

            // Assert
            Assert.AreEqual(message, result, "Pełna zgodność.");
        }
Ejemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Session.Clear();
            Session["answers"]              = new Dictionary <int, Answer>();
            Session["answeredQuestion"]     = false;
            Session["gaveImportanceFactor"] = false;
            Session["ActiveViewIndex"]      = 0;
            Session["allMarkedButtons"]     = new List <String>();
            WebForm1 wf = new WebForm1();

            wf.Page_Load(null, EventArgs.Empty);
        }
Ejemplo n.º 8
0
        public bool error(string row_str, int row, string file_name)
        {
            WebForm1 Edit_Html  = new WebForm1();
            bool     error_bool = false;

            string error_message = "";
            int    Col_count     = row_str.Split(',').Length;
            string header        = "No error \n";

            string[] cells = row_str.Split(',');

            SqlConnection conn = WebForm1.conn;

            try
            {
                if (row == 0)
                {
                    header       = row_str;
                    header_count = Col_count;
                }
                //Below is the list of errors the program is searching for

                //number of Columns and headers dont' match up in the local file

                if (header_count != Col_count && row != 0)
                {
                    error_bool    = true;
                    error_message = "Either there is a header with no data, or a Column with no header. Please make sure each column has just one header, and double check the headers are correct.\n";
                    header_count  = Col_count;
                }

                //If on Database side, if database does not allow null then check to verify local file has same number of rows.
                string ifnullStr = "select COLUMN_NAME , IS_NULLABLE, DATA_TYPE from INFORMATION_SCHEMA.COLUMNS where (TABLE_SCHEMA + '.' + TABLE_NAME) = '" + WebForm1.selected_table + "'";

                SqlCommand    ifnull  = new SqlCommand(ifnullStr, conn);
                SqlDataReader reader_ = ifnull.ExecuteReader();

                int Col_Num = 0;
                while (reader_.Read() && row == 0)//Get if it's null or not and put it into a list
                {
                    isnull.Add(reader_["IS_NULLABLE"].ToString());
                    header_name.Add(reader_["COLUMN_NAME"].ToString());
                    datatype.Add(reader_["DATA_TYPE"].ToString());
                    Col_Num++;
                }
                reader_.Close();
                if (row == 0 && Col_count == Col_Num)//Checks to see if the Column name on the local file (Header) is the same on the database
                {
                    for (int i = 0; i < Col_Num; i++)
                    {
                        if (cells[i] != header_name[i])//If header on file is not the same as the Database header, give error
                        {
                            error_bool    = true;
                            error_message = "Error with Column \"" + cells[i] + "\". The name needs to be the same name as the column in the database. Make sure that there are no extra spaces at the end.\n";
                        }
                    }
                }
                else if (row == 0)
                {
                    error_bool    = true;
                    error_message = "Wrong Nuber of Columns in the file. The error's below are stating the indivudal rows.\n";
                }



                error_message = error_message + " \n Row number : " + row;
            }
            catch (Exception ex)
            {
                error_message = ex.Message.ToString();
                error_bool    = true;
            }



            Logs log_error = new Logs();

            if (error_bool == true)
            {
                log_error.failed_uploads(row_str, file_name, error_message);
            }


            Edit_Html.SendToForm(error_message, error_bool);
            error_message = "";

            return(error_bool);
        }
Ejemplo n.º 9
0
        public void upload(int new_row, int row, string row_str, string file_name)
        {
            string username  = Environment.UserName;                                    //Microsfot user account name
            var    path      = System.Web.HttpContext.Current.Server.MapPath("/temp/"); //Path for temp file
            string temp_file = (path + file_name + username + ".csv");

            File.AppendAllText(temp_file, "");//inits file
            Error_detect   error           = new Error_detect();
            SqlConnection  conn            = WebForm1.conn;
            string         table_name      = WebForm1.selected_table;
            bool           error_result    = error.error(row_str, row, file_name);
            SqlDataAdapter updateSQLcmd    = new SqlDataAdapter();
            DataSet        ds              = new DataSet();
            string         sql_row         = "";
            bool           resume_old_file = File.ReadAllText(temp_file).Contains(row_str)? true : false;
            string         temp_row        = "";
            Logs           log             = new Logs();

            if (resume_old_file == false)
            {
                if (error_result == false && new_row != 0)
                {
                    try
                    {
                        sql_row = row_str.Insert(0, "'") + "'";
                        sql_row = sql_row.Replace(",", "','");
                        string     insert_sql     = "INSERT INTO " + table_name + " VALUES(" + sql_row + ")";
                        SqlCommand insert_sql_cmd = new SqlCommand(insert_sql, conn);
                        updateSQLcmd.SelectCommand = insert_sql_cmd;
                        updateSQLcmd.Fill(ds);

                        log.successful_upload(row_str, file_name);

                        ////Sends row to temp file
                        File.AppendAllText(path + file_name + username + ".csv", row_str + "\n");
                    }
                    catch (SqlException ex)
                    {
                        //This is dealing with Errors on Database/SQL side.
                        WebForm1 issue = new WebForm1();
                        Logs     log_advaced_errors = new Logs();

                        string message;
                        if (ex.Number == 2627)
                        {
                            message = "You have a duplicate unique ID. Please make sure all rows have a unique ID.  More info is below. \n" + ex.Message + "\n Row number : " + row + "\n Error number : " + ex.Number;
                        }
                        else if (ex.Number == 245)
                        {
                            message = "You are trying to put a word into a number column, or a number into a word column. Please make sure numbers go in number columns and word's go into word columns. More info is below : \n" + ex.Message + "\nRow number : " + row;
                        }
                        else if (ex.Number == 241)
                        {
                            message = "You can only put a date in a date column. See more details below. \n" + ex.Message + "\n Row number : " + row + "\n Error number : " + ex.Number + "\n" + row_str;
                        }
                        else
                        {
                            message = "There was an error in processing the data. More details are below. Please contact your administrator for questions.\n" + ex.Message + "\n Row number : " + row + "\n Error number : " + ex.Number;
                        }

                        issue.SendToForm(message, true);
                        log_advaced_errors.failed_uploads(row_str, file_name, message);
                    }
                }
                else
                {
                    //If no Error's then Upload data
                }
            }
        }