Пример #1
0
// <snippet3>
        public bool Delete()
        {
            if (ID.Equals(DBNull.Value))
            {
                // The Employee object is not persisted.
                return(true);
            }
            else
            {
                // The Employee object is persisted.
                // Use the SqlDataSource control as a convenient wrapper for
                // the ADO.NET code needed to delete a record from the database.
                ConnectionStringSettings cts = ConfigurationManager.ConnectionStrings["NorthwindConnection"];
                SqlDataSource            sds = new SqlDataSource();

                try {
                    sds.ConnectionString = cts.ConnectionString;
                    sds.DeleteParameters.Add(new Parameter("empID", TypeCode.Int32, this.ID.ToString()));
                    sds.DeleteCommand = "DELETE FROM [Order Details] " +
                                        "WHERE OrderID IN (SELECT OrderID FROM Orders WHERE EmployeeID=@empID)";
                    sds.Delete();
                    sds.DeleteCommand = "DELETE FROM Orders WHERE EmployeeID=@empID";
                    sds.Delete();
                    sds.DeleteCommand = "DELETE FROM EmployeeTerritories WHERE EmployeeID=@empID";
                    sds.Delete();
                    sds.DeleteCommand = "DELETE FROM Employees WHERE EmployeeID=@empID";
                    sds.Delete();
                    return(true);
                }
                finally {
                    // Clean up resources.
                    sds.Dispose();
                }
            }
        }
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlDataSource sqldatasource2 = new SqlDataSource();
            sqldatasource2.ConnectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString.ToString();
            sqldatasource2.UpdateParameters.Add("Order_date", TextBox1.Text);
            sqldatasource2.UpdateParameters.Add("Assign_numbers", TextBox2.Text);
            sqldatasource2.UpdateParameters.Add("Account_numbers", DropDownList1.Text);
            sqldatasource2.UpdateParameters.Add("Account_abstract", TextBox3.Text);
            sqldatasource2.UpdateParameters.Add("Income", TextBox4.Text);
            sqldatasource2.UpdateParameters.Add("Spend", TextBox5.Text);
            sqldatasource2.UpdateCommand = "Update [Account_Order_M] set Order_date=@Order_date, Account_numbers=@Account_numbers, Assign_numbers=@Assign_numbers, Account_abstract=@Account_abstract, Income=@Income, Spend=@Spend where Id="+Request["Id"];

            int affraw_update = sqldatasource2.Update();

            if (affraw_update == 0)
            {
                Label1.Text = "error";
            }
            else
            {
                Label1.Text = "ok";
                Button1.Visible = false;
            }
            sqldatasource2.Dispose();
    }
Пример #3
0
        // Returns a collection of NorthwindEmployee objects.
        public static ICollection GetAllEmployees()
        {
            ArrayList al = new ArrayList();

            // Use the SqlDataSource class to wrap the
            // ADO.NET code required to query the database.
            ConnectionStringSettings cts = ConfigurationManager.ConnectionStrings["NorthwindConnection"];

            SqlDataSource sds
                = new SqlDataSource(cts.ConnectionString,
                                    "SELECT EmployeeID FROM Employees");

            try {
                IEnumerable IDs = sds.Select(DataSourceSelectArguments.Empty);

                // Iterate through the Enumeration and create a
                // NorthwindEmployee object for each ID.
                IEnumerator enumerator = IDs.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    // The IEnumerable contains DataRowView objects.
                    DataRowView       row = enumerator.Current as DataRowView;
                    int               id  = (int)row["EmployeeID"];
                    NorthwindEmployee nwe = new NorthwindEmployee(id);
                    // Add the NorthwindEmployee object to the collection.
                    al.Add(nwe);
                }
            }
            finally {
                // If anything strange happens, clean up.
                sds.Dispose();
            }

            return(al);
        }
Пример #4
0
// <snippet3>
        public bool Delete()
        {
            if (ID.Equals(DBNull.Value))
            {
                // The Employee object is not persisted.
                return(true);
            }
            else
            {
                // The Employee object is persisted.
                // Use the SqlDataSource control as a convenient wrapper for
                // the ADO.NET code needed to delete a record from the database.
                ConnectionStringSettings cts = ConfigurationManager.ConnectionStrings["NorthwindConnection"];
                SqlDataSource            sds = new SqlDataSource();
                try {
                    sds.ConnectionString = cts.ConnectionString;
                    sds.DeleteCommand    = "DELETE FROM Employees WHERE EmployeeID=@empID;";
                    sds.DeleteParameters.Add(new Parameter("empID", TypeCode.Int32, this.ID.ToString()));

                    /* To make this sample fully functional, uncomment these lines
                     * int retval = sds.Delete();
                     * if (retval == 1) { return true; }
                     * return false; */

                    return(true);
                }
                finally {
                    sds.Dispose();
                }
            }
        }
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlDataSource SqlDataSource2 = new SqlDataSource();
        SqlDataSource2.ConnectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        try
        {
            SqlDataSource2.DeleteCommand = "delete [Account_Order_M] where id=" + Request["Id"];

            int affraw = SqlDataSource2.Delete();
            if (affraw == 0)
            {
                Label8.Text = "error";
                Button1.Visible = false;
            }
            else
            {
                Label8.Text = "ok";
                Button1.Visible = false;
            }
        }
        catch (Exception ex2)
        {
            Response.Write(ex2.ToString());
        }
        finally
        {
            SqlDataSource2.Dispose();
        }
    }
Пример #6
0
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            if (Session["AdminName"] == null && Session["AId"] == null)
            {
                Response.Redirect("~/admin/default.aspx");
            }

            string admin_id = Session["AId"].ToString();

            if (string.IsNullOrEmpty(admin_id))
            {
                Response.Redirect("~/admin/default.aspx");
            }

            SqlDataSource SqlDataSource1 = new SqlDataSource();

            SqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

            SqlDataSource1.UpdateCommand = @"UPDATE [Admin] SET [admin_name] = @admin_name, [admin_email] = @admin_email, [admin_pass] = @admin_pass WHERE [admin_id] = @admin_id";

            SqlDataSource1.UpdateParameters.Add("admin_name", aname_ip.Text.Trim().ToString());
            SqlDataSource1.UpdateParameters.Add("admin_email", email_ip.Text.Trim().ToString());
            SqlDataSource1.UpdateParameters.Add("admin_pass", pass_ip.Text.Trim().ToString());

            SqlDataSource1.UpdateParameters.Add("admin_id", Session["AId"].ToString());

            SqlDataSource1.Update();
            SqlDataSource1.Dispose();

            //Label1.Text = "Update Successful....!!!";



            html1.InnerHtml += "<div class=alertBox alertBox--success>";
            html1.InnerHtml += "<div class=alertBox-column alertBox-icon>";

            html1.InnerHtml += "<icon glyph=ic-success class=icon aria-hidden=true>";

            html1.InnerHtml += "<svg xmlns=http://www.w3.org/2000/svg width=24 height=24 viewBox=0 0 24 24>";

            html1.InnerHtml += "<path d=M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z>";

            html1.InnerHtml += "</path>";

            html1.InnerHtml += "</svg>";

            html1.InnerHtml += "</icon>";
            html1.InnerHtml += "</div>";


            html1.InnerHtml += "<p class=alertBox-column alertBox-message>";

            html1.InnerHtml += "<span>";
            html1.InnerHtml += "Your account details have been updated.";
            html1.InnerHtml += "</span>";
            html1.InnerHtml += "</p>";
            html1.InnerHtml += "</div>";
        }
Пример #7
0
        public SqlDataSource bindGrid(string query, string dsID)
        {
            SqlDataSource sql = new SqlDataSource(System.Configuration.ConfigurationManager.ConnectionStrings["SQLConnstr"].ConnectionString, query);

            sql.ID = dsID;
            sql.DataBind();
            sql.Dispose();
            return(sql);
        }
        protected void ButtonOpasnost_Click(object sender, EventArgs e)
        {
            // ID ИСПДн
            string IspdnID = DetailsViewISPDnOpasn.Rows[0].Cells[1].Text;

            string        conn = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
            SqlDataSource sdsDelMnogieOpasn = new SqlDataSource();

            sdsDelMnogieOpasn.ConnectionString = conn;
            sdsDelMnogieOpasn.DeleteCommand    = "DELETE FROM MnogieOpasnUgrozIS WHERE (ISPDnOperatorID = @ParamISPDnID)";
            sdsDelMnogieOpasn.DeleteParameters.Add(new Parameter("ParamISPDnID", TypeCode.Int32, IspdnID));
            sdsDelMnogieOpasn.Delete();

            sdsDelMnogieOpasn.InsertCommand = "INSERT INTO MnogieOpasnUgrozIS (NazvanieUgrozID, ISPDnOperatorID, OpasnostUgrozID) VALUES (@ParamUgrozaID,@ParamISPDnID,@ParamOpasnID)";
            sdsDelMnogieOpasn.InsertParameters.Add(new Parameter("ParamUgrozaID", TypeCode.Int32));
            sdsDelMnogieOpasn.InsertParameters.Add(new Parameter("ParamISPDnID", TypeCode.Int32));
            sdsDelMnogieOpasn.InsertParameters.Add(new Parameter("ParamOpasnID", TypeCode.Int32));

            // незабыть диспозе для дата сорсе
            int ugroza;

            //ugroza = 0;

            for (int i = 0; i < GridViewUgrozaOpasn.Rows.Count - 1; i++)
            {
                RadioButton radioVer1 = (RadioButton)GridViewUgrozaOpasn.Rows[i].FindControl("RadioButton1");
                RadioButton radioVer2 = (RadioButton)GridViewUgrozaOpasn.Rows[i].FindControl("RadioButton2");
                RadioButton radioVer3 = (RadioButton)GridViewUgrozaOpasn.Rows[i].FindControl("RadioButton3");

                // если первая радио кнопка отмечена то маловероятная угроза
                if (radioVer1.Checked == true)
                {
                    ugroza = 1;
                    sdsDelMnogieOpasn.InsertParameters["ParamUgrozaID"].DefaultValue = (i + 1).ToString();
                    sdsDelMnogieOpasn.InsertParameters["ParamISPDnID"].DefaultValue  = IspdnID;
                    sdsDelMnogieOpasn.InsertParameters["ParamOpasnID"].DefaultValue  = ugroza.ToString();
                    sdsDelMnogieOpasn.Insert();
                }
                else if (radioVer2.Checked == true)
                {
                    ugroza = 2;
                    sdsDelMnogieOpasn.InsertParameters["ParamUgrozaID"].DefaultValue = (i + 1).ToString();
                    sdsDelMnogieOpasn.InsertParameters["ParamISPDnID"].DefaultValue  = IspdnID;
                    sdsDelMnogieOpasn.InsertParameters["ParamOpasnID"].DefaultValue  = ugroza.ToString();
                    sdsDelMnogieOpasn.Insert();
                }
                else if (radioVer3.Checked == true)
                {
                    ugroza = 3;
                    sdsDelMnogieOpasn.InsertParameters["ParamUgrozaID"].DefaultValue = (i + 1).ToString();
                    sdsDelMnogieOpasn.InsertParameters["ParamISPDnID"].DefaultValue  = IspdnID;
                    sdsDelMnogieOpasn.InsertParameters["ParamOpasnID"].DefaultValue  = ugroza.ToString();
                    sdsDelMnogieOpasn.Insert();
                }
            }
            sdsDelMnogieOpasn.Dispose();
        }
Пример #9
0
    public void refreshdata()
    {
        SqlDataSource da1 = new SqlDataSource();

        da1.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
        da1.SelectCommand    = @"SELECT Batch.batch_id,Batch.batch_sdate,Batch.batch_edate,Course.course_name FROM  Course INNER JOIN Batch ON Batch.course_id = Course.course_id";
        da1.DataBind();
        Batch.DataSource = da1;
        Batch.DataBind();
        da1.Dispose();
    }
Пример #10
0
    public void refreshdata()
    {
        SqlDataSource da1 = new SqlDataSource();

        da1.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
        da1.SelectCommand    = @"SELECT Product.product_id,Product.product_name,Product.product_cdate,Category.category_name FROM  Category INNER JOIN Product ON Category.category_id = Product.category_id";
        da1.DataBind();
        Products.DataSource = da1;
        Products.DataBind();
        da1.Dispose();
    }
Пример #11
0
        private void GVBind(int page)
        {
            using (SqlDataSource Conn = new SqlDataSource())
            {
                Conn.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["EIPAConnectionString"].ConnectionString;

                StringBuilder sb = new StringBuilder();

                string user = this.UserName.Text;
                string dept = this.Dept.SelectedValue.Trim();


                sb.Append(" select u.id,d.dept_nm ,u.name ,u.email,u.logonid from eipa.dbo.dguser u ");
                sb.Append(" left join eipa.dbo.lea_hm1emp10 e on e.emp_no = u.empid");
                sb.Append(" left join eipa.dbo.lea_hm1dept10 d on d.dept_no = e.dept_no  ");
                sb.Append(" left join eipa.dbo.dglevel l on u.levid = l.lnid  ");
                sb.Append(" where ustatus='57DADAB8-44CF-4BAA-A40C-324F9F4533A9'");
                sb.Append("  and comid='MAT' and d.dept_no is not null  ");

                if (_group.ToUpper() == "MAIL")
                {
                    sb.Append("  and u.email is not null  ");
                }

                sb.AppendFormat("  and  u.logonid not in (select logonid from eipe.dbo.IPQC_Mail where u_group='{0}' ) ", _group);

                if (!string.IsNullOrEmpty(user))
                {
                    sb.Append(string.Format(" and u.name like '%{0}%' ", user));
                }

                if (!string.IsNullOrEmpty(dept))
                {
                    sb.Append(string.Format(" and d.dept_no='{0}' ", dept));
                }

                sb.Append(" order by d.dept_no ,l.lshort desc ");


                Conn.SelectCommand = sb.ToString();

                Conn.DataSourceMode = SqlDataSourceMode.DataSet;

                DataSourceSelectArguments args = new DataSourceSelectArguments();

                DataView dv = (DataView)Conn.Select(args);

                GridView1.PageIndex  = page;
                GridView1.DataSource = dv;
                GridView1.DataBind();
                Session["Page"] = page;
                Conn.Dispose();
            }
        }
Пример #12
0
    public void getdata()
    {
        SqlDataSource da1 = new SqlDataSource();

        da1.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
        da1.SelectCommand    = @"SELECT Student.stud_code,Student.stud_name,Student.batch_id,Course.course_name FROM  Course INNER JOIN Student ON Student.course_id = Course.course_id";
        da1.DataBind();
        Student.DataSource = da1;
        Student.DataBind();
        da1.Dispose();
    }
        protected void Page_Init(object sender, EventArgs e)
        {
            if (Session["Id"] == null)
            {
                Response.Redirect("login.aspx");
            }

            string user_id = Session["Id"].ToString();

            if (string.IsNullOrEmpty(user_id))
            {
                Response.Redirect("login.aspx");
            }


            SqlDataSource SqlDataSource1 = new SqlDataSource();

            SqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

            SqlDataSource1.SelectCommand = @"SELECT [user_fname], [user_lname], [user_email], [user_ph_num], [user_addr1], [user_addr2], [user_city], [user_state], [user_country], [user_zip] FROM [UserInfo] WHERE [user_id] = @user_id";

            SqlDataSource1.SelectParameters.Add("user_id", user_id);

            DataSourceSelectArguments args = new DataSourceSelectArguments();
            DataView dv = SqlDataSource1.Select(args) as DataView;

            fname_ip.Text    = dv.Table.Rows[0]["user_fname"].ToString();
            lname_ip.Text    = dv.Table.Rows[0]["user_lname"].ToString();
            email_ip.Text    = dv.Table.Rows[0]["user_email"].ToString();
            phnum_ip.Text    = dv.Table.Rows[0]["user_ph_num"].ToString();
            addr1_ip.Text    = dv.Table.Rows[0]["user_addr1"].ToString();
            addr2_ip.Text    = dv.Table.Rows[0]["user_addr2"].ToString();
            city_ip.Text     = dv.Table.Rows[0]["user_city"].ToString();
            state_ip.Text    = dv.Table.Rows[0]["user_state"].ToString();
            countrylist.Text = dv.Table.Rows[0]["user_country"].ToString();
            zip_ip.Text      = dv.Table.Rows[0]["user_zip"].ToString();



            /*fname_ip.Text = dv.Table.Rows[0][1].ToString();
             * lname_ip.Text = dv.Table.Rows[0][2].ToString();
             * email_ip.Text = dv.Table.Rows[0][3].ToString();
             * phnum_ip.Text = dv.Table.Rows[0][5].ToString();
             * addr1_ip.Text = dv.Table.Rows[0][6].ToString();
             * addr2_ip.Text = dv.Table.Rows[0][7].ToString();
             * city_ip.Text = dv.Table.Rows[0][10].ToString();
             * state_ip.Text = dv.Table.Rows[0][9].ToString();
             * countrylist.Text = dv.Table.Rows[0][8].ToString();
             * zip_ip.Text = dv.Table.Rows[0][11].ToString();
             */

            SqlDataSource1.Dispose();
        }
Пример #14
0
    public void getdata()
    {
        SqlDataSource da1 = new SqlDataSource();

        da1.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
        da1.SelectCommand    = @"SELECT Category.category_id, Category.category_name, Product.product_name, Product.product_desc, Product.product_video, Product.product_image, Product.category_id AS cat_id, Product.product_id FROM Product INNER JOIN Category ON Product.product_id = @product_id";
        da1.SelectParameters.Add("product_id", pro_id);
        da1.DataBind();
        formview1.DataSource = da1;
        formview1.DataBind();
        da1.Dispose();
    }
Пример #15
0
        /// <summary>
        /// Executes the query reader.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="execType">Type of the execute.</param>
        /// <param name="command">The command.</param>
        /// <returns></returns>
        public System.Data.SqlClient.SqlDataReader executeQueryReader(string query, byte execType = 0, System.Data.SqlClient.SqlCommand command = null)
        {
            query = query ?? queryOverride;
            if (string.IsNullOrEmpty(query) && string.IsNullOrEmpty(queryOverride))
            {
                return(null);
            }
            if (Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["check4"] ?? "0") == 3)
            {
                setLogAppEntry(query);
            }
            Consultas asd            = new Consultas();
            var       sqlInstruction = query;

            sqlInstruction = string.Format(sqlInstruction);
            sqlInstruction = indeedFormatted != 0? commandFormat(sqlInstruction):sqlInstruction;
            SqlDataSource sqlDs = new SqlDataSource()
            {
                ConnectionString  = System.Configuration.ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString,
                SelectCommand     = execType == 0 ? sqlInstruction : string.Empty,
                SelectCommandType = command == null ? SqlDataSourceCommandType.Text : SqlDataSourceCommandType.StoredProcedure,
                InsertCommand     = execType == 1 ? sqlInstruction : string.Empty,
                InsertCommandType = command == null ? SqlDataSourceCommandType.Text : SqlDataSourceCommandType.StoredProcedure,
                UpdateCommand     = execType == 2 ? sqlInstruction : string.Empty,
                UpdateCommandType = command == null ? SqlDataSourceCommandType.Text : SqlDataSourceCommandType.StoredProcedure,
                DeleteCommand     = execType == 3?sqlInstruction:string.Empty,
                DeleteCommandType = command == null?SqlDataSourceCommandType.Text:SqlDataSourceCommandType.StoredProcedure,
                DataSourceMode    = execType == 0? SqlDataSourceMode.DataReader: SqlDataSourceMode.DataSet,
                ConflictDetection = System.Web.UI.ConflictOptions.OverwriteChanges
            };
            SqlDataReader reader = null;

            try {
                switch (execType)
                {
                case 0: { reader = ((SqlDataReader)sqlDs.Select(new System.Web.UI.DataSourceSelectArguments())); break; }

                case 1: { rwSnd = sqlDs.Insert(); break; }

                case 2: { rwSnd = sqlDs.Update(); break; }

                case 3: { rwSnd = sqlDs.Delete(); break; }

                default: { break; }
                }
            }
            catch (Exception xcpt) {
                setLogAppEntry(xcpt.Message + '\n' + xcpt.StackTrace + '\n' + xcpt.InnerException != null?xcpt.Source :xcpt.InnerException.Message);
            }
            sqlDs.Dispose();
            return(reader);
        }
Пример #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SqlDataSource SqlDataSource1 = new SqlDataSource();

            SqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
            SqlDataSource1.SelectCommand    = @"SELECT user_id, user_fname, user_lname, user_email, user_ph_num, user_addr1, user_addr2, user_city, user_state, user_country, user_zip FROM UserInfo";

            SqlDataSource1.DataBind();

            GridView1.DataSource = SqlDataSource1;
            GridView1.DataBind();
            SqlDataSource1.Dispose();
        }
Пример #17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SqlDataSource SqlDataSource1 = new SqlDataSource();

            SqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
            SqlDataSource1.SelectCommand    = @"SELECT Product.product_id, Product.product_name, Product.product_desc, Product.product_price, Product.product_stock, Product.product_cdate, Category.category_name FROM  Category INNER JOIN Product ON Category.category_id = Product.category_id";

            SqlDataSource1.DataBind();

            GridView1.DataSource = SqlDataSource1;
            GridView1.DataBind();
            SqlDataSource1.Dispose();
        }
        public void NewCountry(string CountryName)
        {
            SqlDataSource sqlDataSource = new SqlDataSource();

            sqlDataSource.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString();
            Parameter p = new Parameter("@Name", System.Data.DbType.String, CountryName);

            sqlDataSource.InsertParameters.Add(p);
            sqlDataSource.InsertCommandType = SqlDataSourceCommandType.StoredProcedure;
            sqlDataSource.InsertCommand     = "SP_NewCountry";
            sqlDataSource.Insert();
            sqlDataSource.Dispose();
        }
    public void view()
    {
        BatchStudent.Visible = true;
        SqlDataSource da1 = new SqlDataSource();

        da1.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
        da1.SelectCommand    = @"SELECT Student.stud_code,Student.stud_name,Student.batch_id,Course.course_name FROM  Course INNER JOIN Student ON Student.course_id = Course.course_id where Student.batch_id=@batch_id";
        da1.SelectParameters.Add("batch_id", batch);
        da1.DataBind();
        BatchStudent.DataSource = da1;
        BatchStudent.DataBind();
        da1.Dispose();
    }
Пример #20
0
    public void bindGrid(string query, string dsID, GridView g, Page p)
    {
        SqlDataSource sql = new SqlDataSource(System.Configuration.ConfigurationManager.ConnectionStrings["SQLConnstr"].ConnectionString, query);

        sql.ID = dsID;
        sql.DataBind();
        sql.Dispose();
        p.Controls.Add(sql);
        g.DataSourceID = dsID;
        g.AllowPaging  = true;
        g.AllowSorting = true;
        g.DataBind();
    }
Пример #21
0
        private void GetTotalPayment()
        {
            SqlDataSource SqlDataSource1 = new SqlDataSource();

            SqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

            SqlDataSource1.SelectCommand = "SELECT SUM(cart_subTotal) AS TotalPayment FROM Cart WHERE [cart_transid] = @cart_transid";

            SqlDataSource1.SelectParameters.Add("cart_transid", Session["Tid"].ToString());

            FormView1.DataSource = SqlDataSource1;
            FormView1.DataBind();
            SqlDataSource1.Dispose();
        }
Пример #22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SqlDataSource SqlDataSource1 = new SqlDataSource();

            SqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

            SqlDataSource1.SelectCommand = @"SELECT order_id, cart_transid, order_customerName, order_total, order_payment, user_id FROM [Order]";

            //SqlDataSource1.DataBind();

            GridView1.DataSource = SqlDataSource1;
            GridView1.DataBind();
            SqlDataSource1.Dispose();
        }
Пример #23
0
        private void BindGrid()
        {
            SqlDataSource SqlDataSource1 = new SqlDataSource();

            SqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

            SqlDataSource1.SelectCommand = "SELECT [cart_id], [product_id], [cart_quantity], [cart_product_name], [cart_productSubPrice], [cart_subTotal], [cart_cdate], [cart_transid] FROM [Cart] WHERE [cart_transid] = @cart_transid";

            SqlDataSource1.SelectParameters.Add("cart_transid", Session["Tid"].ToString());

            GridView1.DataSource = SqlDataSource1;
            GridView1.DataBind();
            SqlDataSource1.Dispose();
        }
Пример #24
0
        /// <summary>
        /// Crea nueva acta
        /// </summary>
        /// <param name="CodConvocatoria">id convocatoria.</param>
        /// <param name="CodDocumentoFormato">id formato del documento.</param>
        /// <param name="Comentario">comentario.</param>
        /// <param name="Fecha">fecha.</param>
        /// <param name="FechaActa">fecha del acta.</param>
        /// <param name="Icono">icono.</param>
        /// <param name="Id_Acta"> id del acta.</param>
        /// <param name="NomActa">The nom acta.</param>
        /// <param name="NomDocumentoFormato">nombre documento.</param>
        /// <param name="NumActa">numero del acta.</param>
        /// <param name="URL">URL.</param>
        public void NewActa(string CodConvocatoria, string CodDocumentoFormato, string Comentario, string Fecha, string FechaActa, string Icono, string Id_Acta, string NomActa, string NomDocumentoFormato, string NumActa, string URL)
        {
            if (contextProc)
            {
                return;
            }
            var jyf = new Datos.MD_ActasFormatoResult()
            {
                CodConvocatoria     = int.Parse(CodConvocatoria),
                CodDocumentoFormato = byte.Parse(CodDocumentoFormato ?? "0"),
                Comentario          = Comentario,
                Fecha               = DateTime.Parse(Fecha),
                FechaActa           = DateTime.Parse(FechaActa),
                Icono               = Icono ?? "0",
                Id_Acta             = int.Parse(Id_Acta ?? "0"),
                NomActa             = NomActa,
                NomDocumentoFormato = NomDocumentoFormato ?? "0",
                NumActa             = NumActa,
                URL = URL
            };


            Consultas asd = new Consultas();

            asd.Db.MD_ActasFormato(0).ToList().Add(jyf);
            asd.Db.SubmitChanges();
            var IdContacto = HttpContext.Current.Request.ServerVariables["cod"] ?? "0";

            CodDocumentoFormato = HttpContext.Current.Session["Adjuntos"] != null?((HttpPostedFile[])HttpContext.Current.Session["Adjuntos"]).FirstOrDefault().FileName.Split('.')[1].Insert(0, "."):"5";
            var _CodDocumentoFormato =
                (int)asd.Db.DocumentoFormatos.Where(u => u.Extension == CodDocumentoFormato).Select(h => h.Id_DocumentoFormato).FirstOrDefault();

            _CodDocumentoFormato = _CodDocumentoFormato > 0 ? _CodDocumentoFormato : 5;
            CodDocumentoFormato  = _CodDocumentoFormato.ToString();
            var sqlInsert = "INSERT INTO [dbo].[ConvocatoriaActa] ([NumActa] ,[NomActa] ,[FechaActa] ,[Fecha] ,[URL] ,[CodConvocatoria]" +
                            ",[CodDocumentoFormato],[CodContacto],[Comentario],[Borrado]) " +
                            "VALUES ({0} ,ƒ{1}ƒ ,CONVERT(DATETIME, ƒ{2}ƒ, 103) ,CONVERT(DATETIME, ƒ{3}ƒ, 103) ,ƒ{4}ƒ ,{5} ,{6} ,{7} ,ƒ{8}ƒ ,{9})";

            sqlInsert = string.Format(sqlInsert, jyf.NumActa, jyf.NomActa, jyf.FechaActa.ToShortDateString(), jyf.Fecha.ToShortDateString(), jyf.URL, jyf.CodConvocatoria, CodDocumentoFormato, IdContacto, jyf.Comentario, new byte());
            sqlInsert = commandFormat(sqlInsert);
            SqlDataSource sqlDs = new SqlDataSource()
            {
                ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString, InsertCommand = sqlInsert, UpdateCommandType = SqlDataSourceCommandType.Text, DataSourceMode = SqlDataSourceMode.DataReader
            };

            sqlDs.Insert();
            sqlDs.Dispose();
            contextProc = true;
        }
Пример #25
0
        // Кнопка добавления отмеченных ПД
        protected void ButtonChekOtdelPD_Click(object sender, EventArgs e)
        {
            //*** Методы добавления основных персональных данных в связную таблицу МногиеИСПДнПД
            string        conn = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
            SqlDataSource sds  = new SqlDataSource();

            sds.ConnectionString = conn;
            sds.DeleteCommand    = "DELETE FROM MnogieKategoryPdOtdel WHERE (OtdelOrgID = @ParamOtdelID)";
            sds.DeleteParameters.Add(new Parameter("ParamOtdelID", TypeCode.Int32, DetailsViewOtdel.Rows[0].Cells[1].Text));
            sds.Delete();
            sds.InsertCommand = "INSERT INTO MnogieKategoryPdOtdel(OtdelOrgID, KategoryPdID) VALUES (@ParamOtdelID, @ParamPdID)";
            sds.InsertParameters.Add(new Parameter("ParamOtdelID", TypeCode.Int32));
            sds.InsertParameters.Add(new Parameter("ParamPdID", TypeCode.Int32));

            for (int i = 0; i < CheckBoxListOtdelOsnova.Items.Count; i++)
            {
                if (CheckBoxListOtdelOsnova.Items[i].Selected == true)
                {
                    sds.InsertParameters["ParamOtdelID"].DefaultValue = DetailsViewOtdel.Rows[0].Cells[1].Text;
                    sds.InsertParameters["ParamPdID"].DefaultValue    = (i + 1).ToString();
                    sds.Insert();
                }
            }
            sds.Dispose();

            //*** Методы добавления специальных персональных данных в связную таблицу МногиеИСПДнСпецПД
            SqlDataSource sdsspecPD = new SqlDataSource();

            sdsspecPD.ConnectionString = conn;
            sdsspecPD.DeleteCommand    = "DELETE FROM MnogieKategoriSpecOtdel WHERE (OtdelOrgID = @ParamOtdelID)";
            sdsspecPD.DeleteParameters.Add(new Parameter("ParamOtdelID", TypeCode.Int32, DetailsViewOtdel.Rows[0].Cells[1].Text));
            sdsspecPD.Delete();

            sdsspecPD.InsertCommand = "INSERT INTO MnogieKategoriSpecOtdel(OtdelOrgID, KategoryPdSpecID) VALUES (@ParamOtdelID, @ParamPdID)";
            sdsspecPD.InsertParameters.Add(new Parameter("ParamOtdelID", TypeCode.Int32));
            sdsspecPD.InsertParameters.Add(new Parameter("ParamPdID", TypeCode.Int32));


            for (int i = 0; i < CheckBoxListOtdelSpecPD.Items.Count; i++)
            {
                if (CheckBoxListOtdelSpecPD.Items[i].Selected == true)
                {
                    sdsspecPD.InsertParameters["ParamOtdelID"].DefaultValue = DetailsViewOtdel.Rows[0].Cells[1].Text;
                    sdsspecPD.InsertParameters["ParamPdID"].DefaultValue    = (i + 1).ToString();
                    sdsspecPD.Insert();
                }
            }
            sdsspecPD.Dispose();
        }
        protected void SubscribeButton_Click(object sender, EventArgs e)
        {
            SqlDataSource SqlData1 = new SqlDataSource();

            SqlData1.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();

            SqlData1.InsertCommand = "INSERT INTO [Subscriber] ([subscriber_email]) VALUES (@subscriber_email)";

            SqlData1.InsertParameters.Add("subscriber_email", newsletter_email_ip.Text.Trim().ToString());

            SqlData1.Insert();
            SqlData1.Dispose();

            Response.Redirect("subscribe.aspx");
        }
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlDataSource SqlDataSource2 = new SqlDataSource();
        SqlDataSource2.ConnectionString=WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        try
        {
            //update
            //SqlDataSource2.UpdateParameters.Add("Order_date", TextBox1.Text);
            //SqlDataSource2.UpdateParameters.Add("Assign_numbers", TextBox2.Text);
            //SqlDataSource2.UpdateParameters.Add("Account_numbers", DropDownList1.Text);
            //SqlDataSource2.UpdateParameters.Add("Account_abstract", TextBox3.Text);
            //SqlDataSource2.UpdateParameters.Add("Income", TextBox4.Text);
            //SqlDataSource2.UpdateParameters.Add("Spend", TextBox5.Text);
            //SqlDataSource2.UpdateCommand = "Update [Joural_Order_M] set Order_date=@Order_date, Assign_numbers=@Assign_numbers, Account_numbers=@Account_numbers, Account_abstract=@Account_abstract, Income=@Income, Spend=@Spend where Id=" + Request["Id"];
            //update

            SqlDataSource2.DeleteCommand = "delete [Account_Order_M]  where Id=" + Request["Id"];

            //delete table Joural_Order_M content
            //SqlDataSource2.DeleteParameters.Add("Order_date", Label1.Text);
            //SqlDataSource2.DeleteParameters.Add("Assign_numbers", Label2.Text);
            //SqlDataSource2.DeleteParameters.Add("Account_numbers", Label3.Text);
            //SqlDataSource2.DeleteParameters.Add("Account_abstract", TextBox3.Text);
            //SqlDataSource2.DeleteParameters.Add("Income", TextBox4.Text);
            //SqlDataSource2.DeleteParameters.Add("Spend", TextBox5.Text);
            //delete table Joural_Order_M content

            int affraw = SqlDataSource2.Delete();

            if (affraw == 0)
            {
                Label1.Text = "Error";
            }
            else
            {
                Label1.Text = "Delete OK";
                Button1.Visible = false;
            }
        }
        catch (Exception ex2)
        {
            Response.Write("error" + ex2.ToString());
        }
        finally
        {
            SqlDataSource2.Dispose();
        }
    }
Пример #28
0
        protected void Page_Init(object sender, EventArgs e)
        {
            if (Session["AId"] == null)
            {
                Response.Redirect("~/default.aspx");
            }

            pro_id = Request.QueryString.Get("pid").ToString();
            if (pro_id == String.Empty)
            {
                Response.Redirect("products.aspx");
            }

            SqlDataSource SqlDataSource1 = new SqlDataSource();

            SqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

            SqlDataSource1.SelectCommand = @"SELECT [product_id], [product_name], [product_desc], [product_price], [product_stock], [product_cdate], [product_image1], [product_image2], [product_image3], [category_id] FROM [Product] WHERE [product_id] = @product_id";

            SqlDataSource1.SelectParameters.Add("product_id", pro_id);

            DataSourceSelectArguments args = new DataSourceSelectArguments();
            DataView dv     = SqlDataSource1.Select(args) as DataView;
            string   cat_id = dv.Table.Rows[0][9].ToString();

            txtProductName.Text  = dv.Table.Rows[0][1].ToString();
            txtProductDesc.Text  = dv.Table.Rows[0][2].ToString();
            txtProductPrice.Text = dv.Table.Rows[0][3].ToString();
            txtProductQty.Text   = dv.Table.Rows[0][4].ToString();

            dv.Dispose();

            SqlDataSource1.SelectCommand = @"SELECT [category_id],[category_name] FROM Category";

            //SqlDataSource1.SelectParameters.Add("cat_id", cat_id);

            ProductPageList.DataSource     = SqlDataSource1;
            ProductPageList.DataTextField  = "category_name";
            ProductPageList.DataValueField = "category_id";
            ProductPageList.SelectedIndex  = Convert.ToInt32(cat_id) - 1;
            ProductPageList.DataBind();


            SqlDataSource1.Dispose();
        }
Пример #29
0
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string cart_id = GridView1.DataKeys[e.RowIndex].Value.ToString();

            SqlDataSource SqlDataSource1 = new SqlDataSource();

            SqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

            SqlDataSource1.DeleteCommand = "DELETE FROM [Cart] WHERE [cart_id] = @cart_id AND [cart_transid] = @cart_transid ";
            SqlDataSource1.DeleteParameters.Add("cart_id", cart_id);
            SqlDataSource1.DeleteParameters.Add("cart_transid", Session["Tid"].ToString());

            SqlDataSource1.Delete();
            SqlDataSource1.Dispose();
            GridView1.EditIndex = -1;
            BindGrid();
            GetTotalPayment();
        }
Пример #30
0
        protected void Page_Init(object sender, EventArgs e)
        {
            if (Session["AId"] == null)
            {
                Response.Redirect("~/default.aspx");
            }

            SqlDataSource SqlDataSource1 = new SqlDataSource();

            SqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
            SqlDataSource1.SelectCommand    = "SELECT [category_id], [category_name] FROM [Category]";


            CategoryList.DataSource     = SqlDataSource1;
            CategoryList.DataTextField  = "category_name";
            CategoryList.DataValueField = "category_id";
            CategoryList.DataBind();
            SqlDataSource1.Dispose();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["AId"] == null)
            {
                Response.Redirect("~/default.aspx");
            }

            SqlDataSource SqlDataSource1 = new SqlDataSource();

            SqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

            SqlDataSource1.SelectCommand = "SELECT [cart_id], [product_id], [cart_quantity], [cart_product_name], [cart_productSubPrice], [cart_subTotal], [cart_cdate], [cart_transid], [cart_status], [user_id] FROM [Cart] WHERE [cart_status] = @cart_status";

            SqlDataSource1.SelectParameters.Add("cart_status", "Pending");

            GridView1.DataSource = SqlDataSource1;
            GridView1.DataBind();
            SqlDataSource1.Dispose();
        }
Пример #32
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["AId"] == null)
            {
                Response.Redirect("~/admin/default.aspx");
            }


            SqlDataSource SqlDataSource1 = new SqlDataSource();

            SqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
            SqlDataSource1.SelectCommand    = "SELECT [category_id], [category_name] FROM [Category]";

            SqlDataSource1.DataBind();

            GridView1.DataSource = SqlDataSource1;
            GridView1.DataBind();
            SqlDataSource1.Dispose();
        }
Пример #33
0
        protected void Page_Init(object sender, EventArgs e)
        {
            pro_id = Request.QueryString.Get("pid").ToString();
            if (string.IsNullOrEmpty(pro_id))
            {
                Response.Redirect("Default.aspx");
            }

            SqlDataSource SqlDataSource1 = new SqlDataSource();

            SqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

            SqlDataSource1.SelectCommand = @"SELECT [product_id], [product_name], [product_desc], [product_price], [product_stock], [product_cdate], [product_image1], [product_image2], [product_image3], [category_id] FROM [Product] WHERE [product_id] = @product_id";

            SqlDataSource1.SelectParameters.Add("product_id", pro_id);

            DataSourceSelectArguments args = new DataSourceSelectArguments();
            DataView dv = SqlDataSource1.Select(args) as DataView;

            cat_id         = dv.Table.Rows[0][9].ToString();
            pid            = Convert.ToInt32(pro_id);
            productName    = dv.Table.Rows[0][1].ToString();
            price_per_unit = dv.Table.Rows[0][3].ToString();

            Image1.ImageUrl = dv.Table.Rows[0]["product_image1"].ToString();
            Image2.ImageUrl = dv.Table.Rows[0]["product_image2"].ToString();
            Image3.ImageUrl = dv.Table.Rows[0]["product_image3"].ToString();

            Image4.ImageUrl = dv.Table.Rows[0]["product_image1"].ToString();
            Image5.ImageUrl = dv.Table.Rows[0]["product_image2"].ToString();
            Image6.ImageUrl = dv.Table.Rows[0]["product_image3"].ToString();

            product_nameLabel.Text  = dv.Table.Rows[0]["product_name"].ToString();
            product_priceLabel.Text = dv.Table.Rows[0]["product_price"].ToString();
            product_descLabel.Text  = dv.Table.Rows[0]["product_desc"].ToString();
            dv.Dispose();
            productQ.Text = "1";



            SqlDataSource1.Dispose();
        }
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlDataSource sqldatasource2 = new SqlDataSource();
        sqldatasource2.ConnectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString.ToString();
        sqldatasource2.UpdateParameters.Add("Lottery", DropDownList1.Text);
        sqldatasource2.UpdateCommand = "Update [Account_Order_M] set Lottery=@Lottery where Id=" + Request["Id"];

        int affraw_update = sqldatasource2.Update();

        if (affraw_update == 0)
        {
            Label8.Text = "error";
        }
        else
        {
            Label8.Text = "ok";
            Button1.Visible = false;
        }
        sqldatasource2.Dispose();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlDataSource SqlDataSource1 = new SqlDataSource();
        SqlDataSource1.ConnectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlDataSource1.InsertParameters.Add("Order_date", TextBox1.Text);
        SqlDataSource1.InsertParameters.Add("Assign_numbers", TextBox2.Text);
        SqlDataSource1.InsertParameters.Add("Account_numbers", DropDownList1.Text);
        SqlDataSource1.InsertParameters.Add("Account_abstract", TextBox3.Text);
        SqlDataSource1.InsertParameters.Add("Income", TextBox4.Text);
        SqlDataSource1.InsertParameters.Add("Spend", TextBox5.Text);
        SqlDataSource1.InsertCommand = "Insert into Account_Order_M(Order_date,Assign_numbers,Account_numbers,Account_abstract,Income,Spend) values(@Order_date,@Assign_numbers,@Account_numbers,@Account_abstract,@Income,@Spend)";

        int affraw = SqlDataSource1.Insert();
        if (affraw == 0)
        {
            Label1.Text = "Error";
        }
        else
        {
            Label1.Text = "OK";
            Button1.Visible = false;
        }
        SqlDataSource1.Dispose();
    }