protected void Button1_Click(object sender, EventArgs e)
        {
            string carNum = Label3.Text;
            string id = Label4.Text;
            string cost = textCost.Text;
            int month = int.Parse(DropDownList1.SelectedValue);

            string recordID = (string)Session["recordID"];

            string insert = "insert cost values ('" + carNum + "','" + id + "','" + cost + "','" + "','" + month + "')";
            DataTable ds = new DataTable();
            ConnectCarData cd = new ConnectCarData();
            SqlConnection scon = cd.getConnect();
            SqlCommand scmd = new SqlCommand(insert, scon);
            bool flag = (scmd.ExecuteNonQuery() == 1);
            if (flag)
            {
                string delete = "delete from record where recordID='" + recordID + "'";
                string update = "update car set isSend='false' where carID='" + Session["carID"] + "'";
                new SqlCommand(delete, scon).ExecuteNonQuery();
                new SqlCommand(update, scon).ExecuteNonQuery();
            }
            scon.Close();
            Server.Transfer(Request.Url.LocalPath);
        }
 public static bool hasEmployee(string id)
 {
     string query = "select * from employee where employeeID='" + id + "'";
     DataTable dt = new DataTable();
     ConnectCarData cd = new ConnectCarData();
     SqlConnection scon = cd.getConnect();
     SqlDataAdapter sda = new SqlDataAdapter(query, scon);
     sda.Fill(dt);
     scon.Close();
     return dt.Rows.Count == 1;
 }
 protected void Button2_Click(object sender, EventArgs e)
 {
     int month = int.Parse(this.DropDownList2.SelectedValue);
     DataTable dt = new DataTable();
     ConnectCarData cd = new ConnectCarData();
     SqlConnection scon = cd.getConnect();
     SqlDataAdapter sda = new SqlDataAdapter("select SUM(cost) from cost where month='" + month + "'", scon);
     scon.Close();
     sda.Fill(dt);
     decimal cost = (decimal)dt.Rows[0][0];
     this.Label7.Text = cost.ToString();
 }
Beispiel #4
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string delete = "delete from record where recordID='";
            List<string> c = new List<string>();
            for (int i = 2; i <= 15; ++i)
            {
                string t = Request["GridView1$ctl" + i.ToString("D2") + "$CheckBox1"];
                if (t != null && t.Equals("on"))
                    //checkBox的位置与carID的位置不一样,要减2,checkBox的位置从2开始计算
                    c.Add(GridView1.Rows[i - 2].Cells[11].Text);
            }

            ConnectCarData cd = new ConnectCarData();
            SqlConnection scon = cd.getConnect();
            for (int i = 0; i < c.Count; ++i)
            {
                new SqlCommand(delete + c[i] + "'", scon).ExecuteNonQuery();
            }
            scon.Close();
            Server.Transfer(Request.Url.LocalPath);
        }