Ejemplo n.º 1
0
    protected void btnNew_Click(object sender, EventArgs e)
    {
        if (btnNew.Text.Equals("Save New"))
        {
            try
            {
                string theID    = txtID.Text;
                string newName  = txtName.Text;
                double newPrice = double.Parse(txtPrice.Text.Replace("$", ""));
                string newDesc  = txtDescription.Text;
                SQLDataClass.InsertProduct(theID, newName, newPrice, newDesc);
                txtMessage.Text = "Record updated.";
                SQLDataClass.getAllProducts();
            }
            catch (Exception ex)
            {
                txtMessage.Text = "Product Not Inserted: " + ex.Message;
            }
        }
        else if (btnNew.Text.Equals("New"))
        {
            txtDescription.Text = "";
            txtID.Text          = "";
            txtName.Text        = "";
            txtPrice.Text       = "";

            btnUpdate.Enabled   = false;
            btnFirst.Enabled    = false;
            btnLast.Enabled     = false;
            btnNext.Enabled     = false;
            btnPrevious.Enabled = false;
        }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     SQLDataClass.getAllProducts();
     TextArea1.InnerText = "";
     if (!IsPostBack)
     {
         DisplayRow((int)Session["Prog3_Index"]);
     }
 }
Ejemplo n.º 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     SQLDataClass.getAllLogin();
     Label5.Visible = false;
     if (CheckBox1.Checked)
     {
         Response.Redirect("Default.aspx");
     }
 }
Ejemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         SQLDataClass.DeleteShopping();
     }
     catch (Exception ex)
     {
         //Response.Write(ex.Message);
     }
 }
Ejemplo n.º 5
0
 protected void btnUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         string theID    = txtID.Text;
         string newName  = txtName.Text;
         double newPrice = double.Parse(txtPrice.Text.Replace("$", ""));
         string newDesc  = txtDescription.Text;
         SQLDataClass.UpdateProduct(theID, newName, newPrice, newDesc);
         txtMessage.Text = "Record updated.";
         SQLDataClass.getAllProducts();
     }
     catch (Exception ex)
     {
         txtMessage.Text = "Product Not Updated: " + ex.Message;
     }
 }
Ejemplo n.º 6
0
        protected void Button3_Click(object sender, EventArgs e)
        {
            try
            {
                for (int i = 0; i < SQLDataClass.tblCart.Rows.Count; i++)
                {
                    if (SQLDataClass.tblCart.Rows[i][0].ToString().Equals(TextBox1.Text.ToString()))
                    {
                        try
                        {
                            string theID    = TextBox1.Text;
                            string newName  = TextBox2.Text;
                            double newPrice = double.Parse(TextBox3.Text.Replace("$", ""));
                            int    newQty   = int.Parse(TextBox4.Text);
                            double newTotal = double.Parse(TextBox7.Text.Replace("$", ""));


                            SQLDataClass.UpdateCart(theID, newName, newQty, newPrice, newTotal);
                            SQLDataClass.getAllCart();
                        }
                        catch (Exception ex)
                        {
                            TextArea1.InnerText = "Product Not Updated:" + ex.Message;
                        }
                    }
                }
                Guid          newGuid = Guid.NewGuid();
                SqlConnection conn    = new SqlConnection(ConfigurationManager.ConnectionStrings["UWPCS3870ConnectionString"].ConnectionString);
                conn.Open();
                String     insertQuery = "Insert into Cart(CartProdID, CartProdName, CartProdQty, CartProdUnitPrice, CartProdCost) values(@CID, @CName, @CQty, @CUnitPrice, @CTotal)";
                SqlCommand comm        = new SqlCommand(insertQuery, conn);
                comm.Parameters.AddWithValue("@CID", TextBox1.Text);
                comm.Parameters.AddWithValue("@CName", TextBox2.Text);
                comm.Parameters.AddWithValue("@CQty", TextBox4.Text);
                comm.Parameters.AddWithValue("@CUnitPrice", TextBox3.Text);
                comm.Parameters.AddWithValue("@CTotal", TextBox7.Text);
                comm.ExecuteNonQuery();
                conn.Close();
                Response.Redirect("Login.aspx");
            }
            catch (Exception ex)
            {
                Response.Write("Error:" + ex.ToString());
            }
        }
        protected void Button5_Click(object sender, EventArgs e)
        {
            try
            {
                string theID    = TextBox1.Text;
                string newName  = TextBox2.Text;
                double newPrice = double.Parse(TextBox3.Text.Replace("$", ""));
                string newDesc  = TextBox4.Text;

                SQLDataClass.UpdateProduct(theID, newName, newPrice, newDesc);
                TextArea1.InnerText = "Record Updated";
                SQLDataClass.getAllProducts();
            }
            catch (Exception ex)
            {
                TextArea1.InnerText = "Product Not Updated:" + ex.Message;
            }
        }
Ejemplo n.º 8
0
 protected void txtChange(object sender, EventArgs e)
 {
     if (SQLDataClass.checkID(txtID.Text))
     {
         for (int i = 0; i < SQLDataClass.tblProduct.Rows.Count; i++)
         {
             System.Data.DataRow row = SQLDataClass.tblProduct.Rows[i];
             String temp1            = row[0].ToString();
             String temp2            = row[1].ToString();
             String temp3            = row[2].ToString();
             if (txtID.Text.Trim().Equals(row[0].ToString().Trim()))
             {
                 txtID.Text    = row[0].ToString();
                 txtName.Text  = row[1].ToString();
                 txtPrice.Text = row[2].ToString();
             }
         }
     }
 }
        protected void Button6_Click(object sender, EventArgs e)
        {
            if (Button6.Text.Equals("Cancel"))
            {
                ResetButtons();
                TextArea1.InnerText = "Insertion was canceled";
            }
            else
            {
                try
                {
                    string theID = TextBox1.Text;

                    SQLDataClass.DeleteProdcut(theID);
                    TextArea1.InnerText = "Record Deleted";
                }
                catch (Exception ex)
                {
                    TextArea1.InnerText = "Product Not Deleted" + ex.Message;
                }
            }
        }
        protected void Button7_Click(object sender, EventArgs e)
        {
            if (Button7.Text.Equals("Save New"))
            {
                try
                {
                    string theID    = TextBox1.Text;
                    string newName  = TextBox2.Text;
                    double newPrice = double.Parse(TextBox3.Text.Replace("$", ""));
                    string newDesc  = TextBox4.Text;

                    SQLDataClass.AddProduct(theID, newName, newPrice, newDesc);
                    TextArea1.InnerText = "Record Added";
                    SQLDataClass.getAllProducts();
                    ResetButtons();
                }
                catch (Exception ex)
                {
                    TextArea1.InnerText = "Product Not added:" + ex.Message;
                }
            }
            else
            {
                TextBox1.Text = "";
                TextBox2.Text = "";
                TextBox3.Text = "";
                TextBox4.Text = "";

                Button1.Enabled = false;
                Button2.Enabled = false;
                Button3.Enabled = false;
                Button4.Enabled = false;
                Button5.Enabled = false;

                Button6.Text = "Cancel";
                Button7.Text = "Save New";
            }
        }
Ejemplo n.º 11
0
 protected void Application_Start(object sender, EventArgs e)
 {
     SQLDataClass.setupProdAdapter();
 }
Ejemplo n.º 12
0
 protected void Page_Load(object sender, EventArgs e)
 {
     SQLDataClass.getAllProducts();
     //dtlProduct.DataSource = SQLDataClass.tblProduct;
     //dtlProduct.DataBind();
 }
Ejemplo n.º 13
0
 protected void Page_Load(object sender, EventArgs e)
 {
     SQLDataClass.getAllProducts();
     DisableText();
 }
Ejemplo n.º 14
0
        public JsonStringResult Get(double lon, double lat, double Scale, string CalcType, string Adminpwd, string ReportToken, string ProjectName, string CustomerName, string Recipients, bool DelCalcTables = true)
        {
            //this function received the WS parameters
            //and extract the osm data according to it


            // let's avoid low scale calculation and quit the calculation with an alert message
            if (Scale > 0.5)
            {
                return(new JsonStringResult(ExtractOSMMapProdProd.Properties.Resources.BigScale));
            }

            coor = new Coordinates()
            {
                lon = lon, lat = lat, zoomLevel = Scale
            };
            string strContent = string.Empty;

            try
            {
                initLogger();

                // let's extract the osm data and insert it to the PGSQL DB as tables
                ExtractOSMMap OSMData = new ExtractOSMMap();
                tblprefix = OSMData.OsmFileDownload(lon, lat, Scale);

                // let's get set background rank according to the coordinates geocoding (coordinates in a city, suburb, village and etc)
                GeoCodingServices service = new GeoCodingServices();
                int Rank = service.GetCityRank(coor.lon, coor.lat);

                switch (Rank)
                {
                case 1:
                    m_BackgroundInterference = 36;
                    break;

                case 2:
                    m_BackgroundInterference = 20;
                    break;

                case 3:
                    m_BackgroundInterference = 15;
                    break;

                case 4:
                    m_BackgroundInterference = 8;
                    break;

                case 5:
                    m_BackgroundInterference = 4;
                    break;

                default:
                    m_BackgroundInterference = 0;
                    break;
                }

                // convert string to enum
                Types type = ((Types)Enum.Parse(typeof(Types), CalcType, true));

                // let's calculate the attributes Indcies according to the coordinates location and other parameters
                dataClass = new SQLDataClass(Connectionstr);
                List <Results> lstResults = dataClass.CalculateIndcies(tblprefix, coor, m_BackgroundInterference, ProjectName + StringDot + CustomerName, true, type);
                strContent += ParseData(lstResults);

                // let's get the address of teh location as a string and add it to the result JSON
                string Address = GetAddress(coor);
                strContent += StringSeparator + "Address:" + Address;

                // the report is disabled, later on will be added back to the results
                string reportName = StringSeparator + "Report:N.A.";
                strContent += reportName;

                if (DelCalcTables)
                {
                    dataClass.DeleteTables(tblprefix);
                }

                // let's calc the total index value and add it to the list
                Results result = new Results {
                    type = Types.All, category = 6, indexvalue = lstResults.Average(x => x.indexvalue)
                };
                lstResults.Add(result);
                // let's send the shorty report email and update the email send status
                strContent += StringSeparator + "Email:" + GenerateShortReport(coor, Address, CustomerName, Recipients, lstResults);

                // ** report code - disabled at this stage **
                //if (!string.IsNullOrEmpty(ReportToken) && ReportToken == "Report56562")
                //{
                //GenerateReport generateReport = new GenerateReport();
                //GenerateReport.Coordinates coordinates = new GenerateReport.Coordinates { lon = Convert.ToSingle(lon), lat = Convert.ToSingle(lat), zoomlevel = 17 };
                //GenerateReport.Marks marks = new GenerateReport.Marks { AirQuality = AirQualityVal, Ecology = EcologyVal, NoiseInterference = noiseVal, RadiationEG = radiationVal, SoilPollution = soilVal, FinalMark = ((noiseVal + soilVal + radiationVal + AirQualityVal + EcologyVal) / 5) };
                //GenerateReport.ReportExtraInfo ReportExtraInfo = new GenerateReport.ReportExtraInfo { CustomerName = CustomerName, ProjName = ProjectName };
                //string reportName = generateReport.GenerateReportPdf(marks, coordinates, ReportExtraInfo);";
                //strContent += reportName;
                //}
                //else
                //{
                //    strContent += "N.A.";
                //}
            }
            catch (Exception ex)
            {
                strContent = ex.Message;
            }

            return(new JsonStringResult(strContent));
        }