Beispiel #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            OleDbConnection Connection = new OleDbConnection(Con.ConnectionString());

            OleDbCommand DEL = new OleDbCommand("DELETE FROM Catagory WHERE CatName=@CatName", Connection);

            DEL.Parameters.AddWithValue("@CatName", CatName.Text.ToString());
            try
            {
                Connection.Open();
                int a = DEL.ExecuteNonQuery();
                Connection.Close();
                if (a == 1)
                {
                    toolStripStatusLabel1.Text = "Successfully Deleted";
                    CatName.Text = "";
                    Des.Text     = "";
                    Sup1.Text    = "";
                    Sup2.Text    = "";
                    Sup3.Text    = "";
                    CatName.Focus();
                }
                else
                {
                    toolStripStatusLabel1.Text = "Error Catagory Not Deleted";
                }
            }
            catch
            {
            }
        }
Beispiel #2
0
 private void button2_Click(object sender, EventArgs e)
 {
     CatName.Text               = "";
     Des.Text                   = "";
     Sup1.SelectedIndex         = -1;
     Sup2.SelectedIndex         = -1;
     Sup3.SelectedIndex         = -1;
     toolStripStatusLabel1.Text = "Cleared";
     CatName.Focus();
 }
Beispiel #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            CatName.Focus();
            if (!String.IsNullOrEmpty(Request["ID"]))
            {
                using (SqlConnection conn = new DB().GetConnection())
                {
                    SqlCommand cmd = conn.CreateCommand();
                    string     sql = "select * from cats order by valid desc,Orders desc;select * from Cats where ID = @ID";
                    cmd.CommandText = sql;
                    cmd.Parameters.AddWithValue("@ID", Convert.ToInt16(Request["ID"]));
                    conn.Open();
                    SqlDataReader rd = cmd.ExecuteReader();

                    rd.NextResult();
                    if (rd.Read())
                    {
                        CatName.Text     = rd["CatName"].ToString();
                        Description.Text = rd["Description"].ToString();


                        Description.Text = rd["Description"].ToString();
                        int i = Convert.ToInt16(rd["Valid"]);
                    }
                    rd.Close();
                    conn.Close();
                }
            }
            else
            {
                MyDataBind();
            }
        }
    }
 private void NewButton_Click(object sender, RoutedEventArgs e)
 {
     ViewModel.ResetSelected();
     CatName.Focus();
 }
Beispiel #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["RoleID"] == null || Session["UserID"] == null)
            {
                Util.ShowMessage("用户登录超时,请重新登录!", "Login2.aspx");
            }
            else
            {
                int RoleID = Convert.ToInt16(Session["RoleID"].ToString());
                if (RoleID > 1)
                {
                    Util.ShowMessage("对不起,你无权访问该页面!", "User_Center.aspx");
                }
                else
                {
                    LabelUserID.Text = Request.QueryString["ID"];
                    CatName.Focus();
                    if (!String.IsNullOrEmpty(Request["ID"]))
                    {
                        using (SqlConnection conn = new DB().GetConnection())
                        {
                            SqlCommand cmd = conn.CreateCommand();
                            string     sql = "select * from cats order by valid desc,Orders desc;select * from Cats where ID = @ID";
                            cmd.CommandText = sql;
                            cmd.Parameters.AddWithValue("@ID", Convert.ToInt16(Request["ID"]));
                            conn.Open();
                            SqlDataReader rd = cmd.ExecuteReader();
                            rd.NextResult();

                            if (rd.Read())
                            {
                                CatName.Text     = rd["CatName"].ToString();
                                Description.Text = rd["Description"].ToString();

                                //读取单选框所选择的信息
                                int valid = Convert.ToInt32(rd["Valid"]);
                                if (valid == 1)
                                {
                                    true1.Checked = true;
                                }
                                else
                                {
                                    false1.Checked = true;
                                }
                                int IsShow = Convert.ToInt32(rd["IsShow"]);
                                if (IsShow == 1)
                                {
                                    true2.Checked = true;
                                }
                                else
                                {
                                    false2.Checked = true;
                                }
                            }
                            rd.Close();
                            conn.Close();
                        }
                    }
                    else
                    {
                        MyDataBind();
                    }
                    //using (sqlconnection conn = new db().getconnection())
                    //{
                    //    string sql = "select * from Cats order by ID desc";
                    //    SqlCommand cmd = new SqlCommand(sql, conn);
                    //    conn.Open();
                    //    SqlDataReader rd = cmd.ExecuteReader();
                    //    cmd.Parameters.AddWithValue("@ID", Label1.Text);
                    //    rd = cmd.ExecuteReader();
                    //    if (rd.Read())
                    //    {
                    //        int valid = Convert.ToInt32(rd["Valid"]);
                    //        if (valid == 1)
                    //        {
                    //            true1.Checked = true;
                    //        }
                    //        else
                    //        {
                    //            false1.Checked = true;
                    //        }
                }
            }
        }
    }
Beispiel #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            OleDbConnection Connection = new OleDbConnection(Con.ConnectionString());

            if (CatName.Text.ToString().Trim(' ') == "")
            {
                toolStripStatusLabel1.Text = "Please Enter Catagory Name";
                CatName.Text = "";
                CatName.Focus();
            }
            else if ((Sup1.SelectedIndex == -1) && (Sup2.SelectedIndex == -1) && (Sup3.SelectedIndex == -1))
            {
                toolStripStatusLabel1.Text = "Please Select atleast One Supplier for this Catagory";
                Sup1.Focus();
            }
            else
            {
                try
                {
                    if (button1.Text.ToString() == "Save")
                    {
                        OleDbCommand INSERT = new OleDbCommand("INSERT INTO Catagory(CatName,Descriptions,Supplier1,Supplier2,Supplier3) VALUES(@CatName,@Descriptions,@Supplier1,@Supplier2,@Supplier3)", Connection);
                        INSERT.Parameters.AddWithValue("@CatName", CatName.Text.ToString());
                        INSERT.Parameters.AddWithValue("@Descriptions", Des.Text.ToString());

                        if (Sup1.SelectedIndex != -1)
                        {
                            INSERT.Parameters.AddWithValue("@Supplier1", Sup1.SelectedItem.ToString());
                        }
                        else
                        {
                            INSERT.Parameters.AddWithValue("@Supplier1", "");
                        }

                        if (Sup2.SelectedIndex != -1)
                        {
                            INSERT.Parameters.AddWithValue("@Supplier2", Sup2.SelectedItem.ToString());
                        }
                        else
                        {
                            INSERT.Parameters.AddWithValue("@Supplier2", "");
                        }

                        if (Sup3.SelectedIndex != -1)
                        {
                            INSERT.Parameters.AddWithValue("@Supplier3", Sup3.SelectedItem.ToString());
                        }
                        else
                        {
                            INSERT.Parameters.AddWithValue("@Supplier3", "");
                        }

                        Connection.Open();
                        int a = INSERT.ExecuteNonQuery();
                        Connection.Close();

                        if (a == 1)
                        {
                            toolStripStatusLabel1.Text = "Successfully Saved";
                            CatName.Text = "";
                            Des.Text     = "";
                            Sup1.Text    = "";
                            Sup2.Text    = "";
                            Sup3.Text    = "";
                            CatName.Focus();
                        }
                        else
                        {
                            toolStripStatusLabel1.Text = "Error Catagory not Saved";
                        }
                    }
                    else
                    {
                        OleDbCommand UPDES = new OleDbCommand("UPDATE Catagory SET Descriptions=@Descriptions WHERE CatName=@CatName", Connection);
                        UPDES.Parameters.AddWithValue("@CatName", CatName.Text.ToString());
                        UPDES.Parameters.AddWithValue("@Descriptions", Des.Text.ToString());

                        OleDbCommand UPSUP1 = new OleDbCommand("UPDATE Catagory SET Supplier1=@Supplier1 WHERE CatName=@CatName", Connection);
                        if (Sup1.SelectedIndex != -1)
                        {
                            UPSUP1.Parameters.AddWithValue("@Supplier1", Sup1.SelectedItem.ToString());
                        }
                        else
                        {
                            UPSUP1.Parameters.AddWithValue("@Supplier1", "");
                        }
                        UPSUP1.Parameters.AddWithValue("@CatName", CatName.Text.ToString());

                        OleDbCommand UPSUP2 = new OleDbCommand("UPDATE Catagory SET Supplier2=@Supplier2 WHERE CatName=@CatName", Connection);
                        if (Sup2.SelectedIndex != -1)
                        {
                            UPSUP2.Parameters.AddWithValue("@Supplier2", Sup2.SelectedItem.ToString());
                        }
                        else
                        {
                            UPSUP2.Parameters.AddWithValue("@Supplier2", "");
                        }
                        UPSUP2.Parameters.AddWithValue("@CatName", CatName.Text.ToString());

                        OleDbCommand UPSUP3 = new OleDbCommand("UPDATE Catagory SET Supplier3=@Supplier3 WHERE CatName=@CatName", Connection);
                        if (Sup3.SelectedIndex != -1)
                        {
                            UPSUP3.Parameters.AddWithValue("@Supplier3", Sup3.SelectedItem.ToString());
                        }
                        else
                        {
                            UPSUP3.Parameters.AddWithValue("@Supplier3", "");
                        }
                        UPSUP3.Parameters.AddWithValue("@CatName", CatName.Text.ToString());

                        int a, b, c, d;

                        Connection.Open();
                        a = UPDES.ExecuteNonQuery();
                        b = UPSUP1.ExecuteNonQuery();
                        c = UPSUP2.ExecuteNonQuery();
                        d = UPSUP3.ExecuteNonQuery();
                        Connection.Close();

                        if ((a == 1) && (b == 1) && (c == 1) && (d == 1))
                        {
                            toolStripStatusLabel1.Text = "Successfully Updated";
                            CatName.Text = "";
                            Des.Text     = "";
                            Sup1.Text    = "";
                            Sup2.Text    = "";
                            Sup3.Text    = "";
                            CatName.Focus();
                        }
                        else
                        {
                            toolStripStatusLabel1.Text = "Error Catagory Not Updated";
                        }
                    }
                }
                catch
                {
                }
            }
        }