示例#1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string name = "0";

        name = Request.QueryString["DR_name"];
        DisobeyRecord dr = new DisobeyRecord();

        dr.DR_Id = Convert.ToInt32(Request.QueryString["DR_Id"]);

        string FileName = System.IO.Path.GetFileName(fuBillPhoto.PostedFile.FileName).ToLower();

        if (!string.IsNullOrEmpty(FileName))
        {
            fuBillPhoto.PostedFile.SaveAs(Server.MapPath("~/images/UpLoad/" + FileName));
            dr.BillPhoto = "~/images/UpLoad/" + FileName;
        }
        else
        {
            dr.BillPhoto = "";
        }


        dr.CarMark       = ddlCarMark.SelectedItem.Text;
        dr.Dr_CarType    = rblDR_CarType.SelectedValue;
        dr.DR_Circs      = txtDR_Circs.Text;
        dr.DR_Date       = Convert.ToDateTime(txtDR_Date.Value);
        dr.DR_Department = ddlDR_Department.SelectedItem.Text;
        dr.DR_Expense    = Convert.ToDouble(txtDR_Expense.Text);
        dr.DR_Explain    = txtDR_Explain.Value;
        dr.DR_Locus      = txtDR_Locus.Text;
        dr.DR_People     = ddlDR_People.SelectedItem.Text;
        dr.DR_Sum        = Convert.ToDouble(txtDR_Sum.Text);
        dr.DR_Type       = ddlDR_Type.SelectedValue;
        dr.FactCost      = Convert.ToDouble(txtFactCost.Text);
        dr.Remark        = txtRemark.Value;
        image.ImageUrl   = dr.BillPhoto;

        if (name == "Up")
        {
            int result = DisobeyRecordManager.updateDisobeyRecord(dr);
            if (result != 0)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('更新成功!');window.location.href='DisobeyRecordlist.aspx'", true);
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('更新失败!');", true);

                return;
            }
        }
        else
        {
            int result = DisobeyRecordManager.addDisobeyRecord(dr);
            if (result != 0)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('添加成功!');window.location.href='DisobeyRecordlist.aspx'", true);
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('添加失败!');", true);

                return;
            }
        }
    }
示例#2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            string name = "0";
            name = Request.QueryString["DR_name"];
            DisobeyRecord dr = new DisobeyRecord();
            dr.DR_Id = Convert.ToInt32(Request.QueryString["DR_Id"]);


            if (ddlCarMark.SelectedItem.Text == "请选择")
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('温馨提示:请选择正确的车牌号!')", true);
                return;
            }
            else
            {
                dr.CarMark = ddlCarMark.SelectedItem.Text;
            }
            dr.Dr_CarType = rblDR_CarType.SelectedValue;

            dr.DR_Date = Convert.ToDateTime(txtDR_Date.Value);
            if (ddlDR_Department.SelectedItem.Text == "请选择")
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('温馨提示:请选择正确的部门!')", true);
                return;
            }
            else
            {
                dr.DR_Department = ddlDR_Department.SelectedItem.Text;
            }

            dr.DR_Explain = Server.HtmlDecode(txtDR_Explain.Value.Trim());
            dr.DR_Locus   = txtDR_Locus.Text.Trim();
            if (ddlDR_People.SelectedItem.Text == "")
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('温馨提示:该部门没人,请选择其它部门!')", true);
                return;
            }
            else
            {
                dr.DR_People = ddlDR_People.SelectedItem.Text;
            }

            dr.DR_Type    = ddlDR_Type.SelectedValue;                  //类型(违章,事故)
            dr.DR_Expense = Convert.ToDouble(txtDR_Expense.Text);      //经  济  损  失
            dr.DR_Sum     = Convert.ToDouble(txtDR_Sum.Text.Trim());   //罚 款 金额
            dr.FactCost   = Convert.ToDouble(txtFactCost.Text.Trim()); //实际赔偿费

            dr.DR_Circs = txtDR_Circs.Text.Trim();
            dr.Remark   = Server.HtmlDecode(txtRemark.Value.Trim());


            //图片上传判断
            string FileName = "";
            if (fuBillPhoto.PostedFile != null)
            {
                FileName = System.IO.Path.GetFileName(fuBillPhoto.PostedFile.FileName).ToLower();
                if (FileName == "")
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('清单照片不能为空!');", true);
                    return;
                }
                fuBillPhoto.PostedFile.SaveAs(Server.MapPath("~/images/UpLoad/" + FileName));
                dr.BillPhoto = "~/images/UpLoad/" + FileName;
            }
            else
            {
                dr.BillPhoto = image.ImageUrl;
            }
            image.ImageUrl = dr.BillPhoto;

            if (name == "Up")
            {
                int result = DisobeyRecordManager.updateDisobeyRecord(dr);
                if (result != 0)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('更新成功!');window.location.href='DisobeyRecordlist.aspx'", true);
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('更新失败!');", true);

                    return;
                }
            }
            else
            {
                int result = DisobeyRecordManager.addDisobeyRecord(dr);
                if (result != 0)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('添加成功!');window.location.href='DisobeyRecordlist.aspx'", true);
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('添加失败!');", true);

                    return;
                }
            }
        }
        catch (Exception ex)
        {
            throw new Exception(ex.ToString());
            return;
        }
    }