protected void btnIn_Click(object sender, EventArgs e)
    {
        try
        {
            string fileName1 = this.fileSelect.PostedFile.FileName;
            string name      = this.GetFileName(fileName1);
            string path      = base.Server.MapPath("~/files") + @"\" + name;
            this.fileSelect.SaveAs(path);
            hidpath.Value = path;

            string    sqlstr = "select * from RM_keshiyewufei where Remark1='" + DateTime.Now.Year + "' and Remark=0";
            DataTable dtsql  = DBUnity.AdapterToTab(sqlstr);
            if (dtsql.Rows.Count > 0)
            {
                var s = "if(confirm('点击确定追加金额!点击取消覆盖上一次的金额')){0};else {1};";
                ScriptManager.RegisterStartupScript(this, typeof(cashier_keshiyewufei), "",
                                                    string.Format(s, this.ClientScript.GetPostBackEventReference(this, "是"), this.ClientScript.GetPostBackEventReference(this, "否")),
                                                    true);
            }
            else
            {
                DataTable dt = ImportExcelFile(path);

                string    sqlstr11 = "select * from RM_keshiyewufei where Remark1='" + DateTime.Now.Year + "' and Remark=0";
                DataTable dtOld    = DBUnity.AdapterToTab(sqlstr11);
                DataTable dtNew    = new DataTable();
                dt.Columns.Add("aaaa");

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    RM_keshiyewufei rk = new RM_keshiyewufei();
                    rk.Depname = dt.Rows[i]["部门名"].ToString();
                    rk.SQJE    = ParseUtil.ToDecimal(dt.Rows[i]["上年余额"].ToString(), 0);
                    rk.BQJE    = ParseUtil.ToDecimal(dt.Rows[i]["本期金额"].ToString(), 0);
                    rk.ZJJE    = ParseUtil.ToDecimal(dt.Rows[i]["追加金额"].ToString(), 0);

                    rk.LSJL = rk.ZJJE.ToString() + "#" + DateTime.Now.ToString("yyyy-MM-dd") + "@";

                    string aa = rk.LSJL.ToString();

                    decimal zj = 0;
                    for (int j = 0; j < aa.Trim('@').Split('@').Length; j++)
                    {
                        zj += ParseUtil.ToDecimal(aa.Trim('@').Split('@')[j].Split('#')[0], 0);
                    }

                    rk.KYJE = zj + rk.BQJE + rk.SQJE;

                    rk.Remark  = 0;
                    rk.Remark1 = DateTime.Now.Year.ToString();
                    RM_keshiyewufeiManager.AddRM_keshiyewufei(rk);
                }
                MessageBox.Show(this, "导入成功");

                RpDataBind();
            }
        }
        catch
        {
        }
    }
    public void RaisePostBackEvent(string eventArgument)
    {
        DataTable dt = new DataTable();

        dt = ImportExcelFile(hidpath.Value);

        switch (eventArgument)
        {
        case "是":
            decimal je = 0;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                je += ParseUtil.ToDecimal(dt.Rows[i]["追加金额"].ToString(), 0);
            }
            string    sqlstr11 = "select * from RM_keshiyewufei where Remark1='" + DateTime.Now.Year + "' and Remark=0";
            DataTable dtOld    = DBUnity.AdapterToTab(sqlstr11);
            DataTable dtNew    = new DataTable();
            dt.Columns.Add("aaaa");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string depname = dt.Rows[i]["部门名"].ToString();
                for (int j = 0; j < dtOld.Rows.Count; j++)
                {
                    if (dtOld.Rows[j]["Depname"].ToString() == depname)
                    {
                        string zj = dtOld.Rows[j]["LSJL"].ToString();

                        if (je > 0)
                        {
                            zj += dt.Rows[i]["追加金额"].ToString() + "#" + DateTime.Now.ToString("yyyy-MM-dd") + "@";
                        }


                        dt.Rows[i]["aaaa"] = zj;
                    }
                    else
                    {
                        RM_keshiyewufei rk = new RM_keshiyewufei();
                        rk.Depname = dt.Rows[i]["部门名"].ToString();
                        rk.SQJE    = ParseUtil.ToDecimal(dt.Rows[i]["上年余额"].ToString(), 0);
                        rk.BQJE    = ParseUtil.ToDecimal(dt.Rows[i]["本期金额"].ToString(), 0);
                        rk.ZJJE    = ParseUtil.ToDecimal(dt.Rows[i]["追加金额"].ToString(), 0);

                        string aa = dt.Rows[i]["aaaa"].ToString();

                        rk.LSJL = rk.ZJJE + "#" + DateTime.Now.ToString("yyyy-MM-dd") + "@";


                        rk.KYJE = rk.ZJJE + rk.BQJE + rk.SQJE;

                        rk.Remark  = 0;
                        rk.Remark1 = DateTime.Now.Year.ToString();
                        RM_keshiyewufeiManager.AddRM_keshiyewufei(rk);
                    }
                }
            }
            string strsql = "delete from RM_keshiyewufei where Remark1='" + DateTime.Now.Year + "' and Remark=0";
            DBUnity.ExecuteNonQuery(CommandType.Text, strsql, null);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                RM_keshiyewufei rk = new RM_keshiyewufei();
                rk.Depname = dt.Rows[i]["部门名"].ToString();
                rk.SQJE    = ParseUtil.ToDecimal(dt.Rows[i]["上年余额"].ToString(), 0);
                rk.BQJE    = ParseUtil.ToDecimal(dt.Rows[i]["本期金额"].ToString(), 0);
                rk.ZJJE    = ParseUtil.ToDecimal(dt.Rows[i]["追加金额"].ToString(), 0);

                rk.LSJL = dt.Rows[i]["aaaa"].ToString();

                string aa = dt.Rows[i]["aaaa"].ToString();

                decimal zj = 0;
                for (int j = 0; j < aa.Trim('@').Split('@').Length; j++)
                {
                    zj += ParseUtil.ToDecimal(aa.Trim('@').Split('@')[j].Split('#')[0], 0);
                }

                rk.KYJE = zj + rk.BQJE + rk.SQJE;

                rk.Remark  = 0;
                rk.Remark1 = DateTime.Now.Year.ToString();
                RM_keshiyewufeiManager.AddRM_keshiyewufei(rk);
            }
            MessageBox.Show(this, "导入成功");

            RpDataBind();

            break;

        case "否":

            string    sqlstr = "select * from RM_keshiyewufei where Remark1='" + DateTime.Now.Year + "' and Remark=0";
            DataTable dtUpd  = DBUnity.AdapterToTab(sqlstr);

            dt.Columns.Add("newje");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string depname = dt.Rows[i]["部门名"].ToString();
                for (int j = 0; j < dtUpd.Rows.Count; j++)
                {
                    if (dtUpd.Rows[j]["Depname"].ToString() == depname)
                    {
                        string zj = dtUpd.Rows[j]["LSJL"].ToString().TrimEnd('@');
                        if (zj.Contains("@"))
                        {
                            zj  = zj.Substring(0, zj.LastIndexOf('@'));
                            zj += dt.Rows[i]["追加金额"].ToString() + "#" + DateTime.Now.ToString("yyyy-MM-dd") + "@";
                        }
                        else
                        {
                            zj = dt.Rows[i]["追加金额"].ToString() + "#" + DateTime.Now.ToString("yyyy-MM-dd") + "@";
                        }


                        dt.Rows[i]["newje"] = zj;
                    }
                }
            }

            string strsqlde = "delete from RM_keshiyewufei where Remark1='" + DateTime.Now.Year + "' and Remark=0";
            DBUnity.ExecuteNonQuery(CommandType.Text, strsqlde, null);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                RM_keshiyewufei rk = new RM_keshiyewufei();
                rk.Depname = dt.Rows[i]["部门名"].ToString();
                rk.SQJE    = ParseUtil.ToDecimal(dt.Rows[i]["上年余额"].ToString(), 0);
                rk.BQJE    = ParseUtil.ToDecimal(dt.Rows[i]["本期金额"].ToString(), 0);
                rk.ZJJE    = ParseUtil.ToDecimal(dt.Rows[i]["追加金额"].ToString(), 0);

                rk.LSJL = dt.Rows[i]["newje"].ToString();

                string aa = dt.Rows[i]["newje"].ToString();

                decimal zj = 0;
                for (int j = 0; j < aa.Trim('@').Split('@').Length; j++)
                {
                    zj += ParseUtil.ToDecimal(aa.Trim('@').Split('@')[j].Split('#')[0], 0);
                }

                rk.KYJE = zj + rk.BQJE + rk.SQJE;

                rk.Remark  = 0;
                rk.Remark1 = DateTime.Now.Year.ToString();
                RM_keshiyewufeiManager.AddRM_keshiyewufei(rk);
            }
            MessageBox.Show(this, "导入成功");

            RpDataBind();

            break;
        }
    }