Ejemplo n.º 1
0
    /// <summary>
    /// 删除一条记录
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void gvCars_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "del")
        {
            string Id = e.CommandArgument.ToString();
            try
            {
                Car_Cars cars = CarsManager.GetAllCarsById(Convert.ToInt32(Id));

                if (cars.State == "已出车" || cars.State == "维修中")
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('此车不是未出车状态不可删除!');", true);
                }
                else
                {
                    int num = CarsManager.DcseteCars(Id);

                    if (num > 0)
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('删除成功!');", true);
                    }
                    gvCars.DataSourceID = null;
                    gvCars.DataSource   = odsCars;
                    gvCars.DataBind();
                }
            }
            catch
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('删除失败!');", true);
                return;
            }
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 删除一条记录
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void gvCars_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        //string cmd = e.CommandName;//获取命令名称
        //int Id = Convert.ToInt32(e.CommandArgument);//获取命令参数
        if (e.CommandName == "del")
        {
            string Id = e.CommandArgument.ToString();
            try
            {
                Car_Cars cars = CarsManager.GetAllCarsById(Convert.ToInt32(Id));

                if (cars.State == "已出车" || cars.State == "维修")
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('此车不是未出车状态不可删除!');", true);
                }
                else
                {
                    int num = CarsManager.DcseteCars(Id);

                    if (num > 0)
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('删除成功!');", true);
                    }

                    ucpage.PageIndex = 0;
                    ucpage_onPageIndexChanging(ucpage.PageIndex);
                    //gvCars.DataSourceID = null;
                    //gvCars.DataSource = odsCars;
                    //gvCars.DataBind();
                }
            }
            catch
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('删除失败!');", true);
                return;
            }
        }
        else if (e.CommandName == "weixiou")
        {
            try
            {
                string   Id   = e.CommandArgument.ToString();
                Car_Cars cars = CarsManager.GetAllCarsById(Convert.ToInt32(Id));

                int num = CarsManager.UpadteCarsByIdSate(Convert.ToInt32(Id));
                if (num > 0)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('修改成功!');", true);
                }
                ucpage.PageIndex = 0;
                ucpage_onPageIndexChanging(ucpage.PageIndex);
            }
            catch
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('维修失败!');", true);
            }
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// 删除车辆
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnDelete_Click1(object sender, EventArgs e)
    {
        CheckBox   chckbx      = null;
        LinkButton lkbtnDelete = null;
        string     Id          = "";

        for (int i = 0; i < this.gvCars.Rows.Count; i++)
        {
            chckbx      = this.gvCars.Rows[i].FindControl("chSelect") as CheckBox;
            lkbtnDelete = this.gvCars.Rows[i].FindControl("lnkdel") as LinkButton;
            if (chckbx.Checked)
            {
                string Id1 = lkbtnDelete.CommandArgument.ToString();
                Id += Id1 + ",";
            }
        }
        if (Id != "")
        {
            try
            {
                Id = Id.Substring(0, Id.Length - 1);
                Car_Cars cars = CarsManager.GetAllCarsById(Convert.ToInt32(Id));

                if (cars.State == "已出车" || cars.State == "维修中")
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('此车不是未出车状态不可删除!');", true);
                }
                else
                {
                    CarsManager.DcseteCars(Id);
                    gvCars.DataSourceID = null;
                    gvCars.DataSource   = CarsManager.SelectCarsDark(txtDept.Text, drlCarType.SelectedValue, drlCarStae.SelectedValue);
                    gvCars.DataBind();
                }
            }
            catch
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('删除失败!');", true);
                return;
            }
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('请选择要删除的项!');", true);
        }
    }