Exemple #1
0
        protected void UserList_DeleteCommand(object source, DataListCommandEventArgs e)
        {
            string id = this.UserList.DataKeys[e.Item.ItemIndex].ToString();

            try
            {
                string mycon = "delete from UserInfo where PhoneNumber='" + id + "'";
                int    k     = DataBase.ExecuteNonQuery(mycon);
                ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('删除成功!');window.location.href= 'BossWeb.aspx'", true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #2
0
        protected void OrderBtu_Click(object sender, EventArgs e)
        {
            EnOrder   en = Session["OrderInfo"] as EnOrder;
            CnOrders  cn = new CnOrders();
            DataTable dt = cn.getDataTable("select * from Orders where OrderNumber='" + en.orderNumber.Trim() + "'");

            dt.Rows[0]["Coment"] = Coments.Text.Trim();
            DataSet   ds       = DataBase.RunDataSet("select * from Doc where 0=1");
            DataTable DocTable = ds.Tables[0];

            try
            {
                dt.Rows[0]["OrderTypeID"]  = int.Parse(SendMothedList.SelectedItem.Value.Trim());
                dt.Rows[0]["AddressRecID"] = int.Parse(AddressList.SelectedItem.Value.Trim());
                dt.Rows[0]["ToalPrice"]    = this.Money.Text;
                int          k        = DataBase.update("Orders", "OrderNumber", dt);
                List <EnDoc> docslist = en.docs;
                foreach (var item in docslist)
                {
                    DataRow dr = DocTable.NewRow();
                    dr["DocID"]       = 0;
                    dr["OrderNumber"] = en.orderNumber.Trim();
                    dr["Comment"]     = Coments.Text.Trim();
                    dr["DocName"]     = item.docName;
                    dr["DocPath"]     = item.docPath;
                    dr["DocTypeID"]   = item.docTypeID;
                    dr["UploadTime"]  = en.placeOrderTime;
                    dr["TotalPages"]  = item.totalPages;
                    dr["PrintTypeID"] = item.printTypeID;
                    DocTable.Rows.Add(dr);
                }
                int j = DataBase.update("Doc", "DocID", DocTable);
                this.Page.RegisterStartupScript("",
                                                "<script>alert('下单成功!');window.location.href= 'UserCenter.aspx'</script>");
            }
            catch (Exception)
            {
                int k =
                    DataBase.ExecuteNonQuery("delete Orders where OrderNumber='" +
                                             en.orderNumber + "'");
                int l = DataBase.ExecuteNonQuery("delete Doc where OrderNumber='" +
                                                 en.orderNumber + "'");

                this.Page.RegisterStartupScript("",
                                                "<script>alert('下单失败!');window.location.href= 'UserCenter.aspx'</script>");
            }
        }
Exemple #3
0
        //增加、删除地址
        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            DataTable dt        = Session["UserTable"] as DataTable;
            int       i         = Convert.ToInt32(dt.Rows[0]["UserRecID"]);
            string    AdressNum = "select AddressName from Address where UserRecID=" + i;
            DataSet   AdressN   = DataBase.RunDataSet(AdressNum);

            if (e.CommandName.Equals("del"))
            {
                if (AdressN.Tables[0].Rows.Count > 1)
                {
                    string mycon = "delete from Address where AddressName='" + e.CommandArgument + "'";
                    int    k     = DataBase.ExecuteNonQuery(mycon);
                    if (k > 0)
                    {
                        MessageTxt.Value = "删除成功!";
                    }
                    Response.Redirect("UserCenter.aspx");
                }
                else
                {
                    MessageTxt.Value = "必须要有一个地址!删除失败!";
                }
            }
            if (e.CommandName == "insert")
            {
                TextBox tbx = (TextBox)e.Item.FindControl("UserAdressAdd");
                if (tbx.Text != "")
                {
                    if (AdressN.Tables[0].Rows.Count < 3)
                    {
                        for (int k = 0; k < AdressN.Tables[0].Rows.Count; k++)
                        {
                            if (tbx.Text != AdressN.Tables[0].Rows[k]["AddressName"].ToString())
                            {
                                string    sql        = "select * from Address where 0=1";
                                DataSet   AdressForm = DataBase.RunDataSet(sql);
                                DataTable AdresTable = new DataTable();
                                AdresTable = AdressForm.Tables[0];
                                DataRow dr = AdresTable.NewRow();
                                dr["AddressRecID"]     = 0;
                                dr["UserRecID"]        = i;
                                dr["AddressName"]      = tbx.Text;
                                dr["IsUsuallyAddress"] = 1;
                                AdresTable.Rows.Add(dr);
                                int p = DataBase.update("Address", "AddressRecID", AdresTable);
                                if (p > 0)
                                {
                                    MessageTxt.Value = "增添成功!";
                                    tbx.Text         = "";
                                }
                                Response.Redirect("UserCenter.aspx");
                            }
                            else
                            {
                                MessageTxt.Value = "此地址已存在!请重新输入!";
                                tbx.Text         = "";
                            }
                        }
                    }
                    else
                    {
                        MessageTxt.Value = "地址不能超过三个!添加失败!";
                        tbx.Text         = "";
                    }
                }
                else
                {
                    MessageTxt.Value = "不能增添地址,请重新输入地址!";
                }
            }
        }