Пример #1
0
        public void Delete(string RequestID, string Type, string rowIndex)
        {
            string sqldel = "";

            if (Type == "T")
            {
                sqldel += "select * from Eflow where RequestID='" + RequestID + "' and [Type]='T';";
                sqldel += "select * from ETravel where ID='" + RequestID + "';";
                sqldel += "select * from ETraveleDetail where [No]='" + RequestID + "';";
                //sqldel += "delete from Eflow where RequestID='" + RequestID + "' and [Type]='T';";
                //sqldel += "delete from ETravel where ID='" + RequestID + "';";
                //sqldel += "delete from ETraveleDetail where [No]='" + RequestID + "';";
                sqldel += "update ETravel set Void=1 where ID='" + RequestID + "';";
            }
            else if (Type == "G")
            {
                sqldel += "select * from Eflow where RequestID='" + RequestID + "' and [Type]='G';";
                sqldel += "select * from Ecommon where ID='" + RequestID + "';";
                sqldel += "select * from EeommonDetail where [No]='" + RequestID + "';";
                //sqldel += "delete from Eflow where RequestID='" + RequestID + "' and [Type]='G';";
                //sqldel += "delete from Ecommon where ID='" + RequestID + "';";
                //sqldel += "delete from EeommonDetail where [No]='" + RequestID + "';";
                sqldel += "update Ecommon set Void=1 where ID='" + RequestID + "';";
            }
            cs.DBCommand dbc   = new cs.DBCommand();
            string       sqlre = dbc.UpdateData("eReimbursement", sqldel, "Update");
            //X.AddScript("Store1.removeAt(" + rowIndex + ");Store1.load();");
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                if (Request.Cookies.Get("eReimUserID") == null)
                {
                    X.AddScript("loginWindow.show();Panel1.disable();");
                    return;
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "", "$('div.gn_person ul.q-menubox li:eq(0) a').text('" + Request.Cookies.Get("eReimUserName").Value + "');", true);
                    X.AddScript("loginWindow.hide();Panel1.enable();");

                    cs.DBCommand dbc      = new cs.DBCommand();
                    string       sql      = "select MailList as Email from MailSetting where UserID='" + Request.Cookies.Get("eReimUserID").Value + "' and MailList!=''";
                    DataTable    dtdetail = new DataTable();
                    dtdetail = dbc.GetData("eReimbursement", sql);
                    if (dtdetail != null && dtdetail.Rows.Count == 1)
                    {
                        string[]  mc = dtdetail.Rows[0]["Email"].ToString().Split(',');
                        DataTable dt = new DataTable();
                        dt.Columns.Add("Email");
                        for (int i = 0; i < mc.Length; i++)
                        {
                            DataRow dr = dt.NewRow();
                            dr["Email"] = mc[i];
                            dt.Rows.Add(dr);
                        }
                        StoreCCList.DataSource = dt;
                        StoreCCList.DataBind();
                    }
                }
            }
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                if (Request.Cookies.Get("eReimUserID") == null)
                {
                    X.AddScript("loginWindow.show();Panel1.disable();");
                    return;
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "", "$('div.gn_person ul.q-menubox li:eq(0) a').text('" + Request.Cookies.Get("eReimUserName").Value + "');", true); X.AddScript("loginWindow.hide();Panel1.enable();");
                }
                LabelUser.Text = Request.Cookies.Get("eReimUserName").Value.ToString();
                LabelCostCenter.Text = Request.Cookies.Get("eReimCostCenter").Value.ToString() + "(" + DIMERCO.SDK.Utilities.LSDK.GetStationCurrencyByCode(Request.Cookies.Get("eReimCostCenter").Value.ToString()) + ")";

                cs.DBCommand dbc = new cs.DBCommand();

                DataTable dtCur = DIMERCO.SDK.Utilities.ReSM.GetCurrency().Tables[0];
                dtCur.DefaultView.Sort = "CurrencyCode ASC";
                DataTable dtCurNew = dtCur.DefaultView.ToTable();
                StoreCurOri.DataSource = dtCurNew;
                StoreCurOri.DataBind();

                StoreCurTar.DataSource = dtCurNew;
                StoreCurTar.DataBind();

                DataSet ds2 = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(Request.Cookies.Get("eReimUserID").Value.ToString());
                string station = ""; string CostCenterCur = ""; string UserCur = "";
                if (ds2.Tables[0].Rows.Count == 1)
                {
                    DataTable dt1 = ds2.Tables[0];
                    station = dt1.Rows[0]["stationCode"].ToString();
                    CostCenterCur = DIMERCO.SDK.Utilities.LSDK.GetStationCurrencyByCode(station);
                    LabelCur.Text = CostCenterCur;
                    DataTable dttemp = new DataTable();
                    string sqltemp = "select * from ESUSER where Userid='" + Request.Cookies.Get("eReimUserID").Value.ToString() + "'";
                    dttemp = dbc.GetData("eReimbursement", sqltemp);
                    if (dttemp.Rows.Count > 0)
                    {
                        UserCur = dttemp.Rows[0]["Currency"].ToString();
                        LabelCur.Text = UserCur;
                    }
                    cbxOriCur.Text = UserCur;
                    cbxTarCur.Text = CostCenterCur;
                    decimal rate = System.Math.Round(DIMERCO.SDK.Utilities.LSDK.GetBudgetConverRate(cbxTarCur.Text, cbxOriCur.Text, DateTime.Now.Year), 4);
                    LabelRate.Text = rate.ToString();
                    LabelEx.Text = "1000(" + cbxOriCur.Text + ") = " + System.Math.Round(rate * 1000, 2).ToString() + "(" + cbxTarCur.Text + ")";
                }

                
            }
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                if (Request.Cookies.Get("eReimUserID") == null)
                {
                    X.AddScript("loginWindow.show();Panel1.disable();");
                    return;
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "", "$('div.gn_person ul.q-menubox li:eq(0) a').text('" + Request.Cookies.Get("eReimUserName").Value + "');", true); X.AddScript("loginWindow.hide();Panel1.enable();");
                }
                LabelUser.Text       = Request.Cookies.Get("eReimUserName").Value.ToString();
                LabelCostCenter.Text = Request.Cookies.Get("eReimCostCenter").Value.ToString() + "(" + DIMERCO.SDK.Utilities.LSDK.GetStationCurrencyByCode(Request.Cookies.Get("eReimCostCenter").Value.ToString()) + ")";

                cs.DBCommand dbc = new cs.DBCommand();

                DataTable dtCur = DIMERCO.SDK.Utilities.ReSM.GetCurrency().Tables[0];
                dtCur.DefaultView.Sort = "CurrencyCode ASC";
                DataTable dtCurNew = dtCur.DefaultView.ToTable();
                StoreCurOri.DataSource = dtCurNew;
                StoreCurOri.DataBind();

                StoreCurTar.DataSource = dtCurNew;
                StoreCurTar.DataBind();

                DataSet ds2 = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(Request.Cookies.Get("eReimUserID").Value.ToString());
                string  station = ""; string CostCenterCur = ""; string UserCur = "";
                if (ds2.Tables[0].Rows.Count == 1)
                {
                    DataTable dt1 = ds2.Tables[0];
                    station       = dt1.Rows[0]["stationCode"].ToString();
                    CostCenterCur = DIMERCO.SDK.Utilities.LSDK.GetStationCurrencyByCode(station);
                    LabelCur.Text = CostCenterCur;
                    DataTable dttemp  = new DataTable();
                    string    sqltemp = "select * from ESUSER where Userid='" + Request.Cookies.Get("eReimUserID").Value.ToString() + "'";
                    dttemp = dbc.GetData("eReimbursement", sqltemp);
                    if (dttemp.Rows.Count > 0)
                    {
                        UserCur       = dttemp.Rows[0]["Currency"].ToString();
                        LabelCur.Text = UserCur;
                    }
                    cbxOriCur.Text = UserCur;
                    cbxTarCur.Text = CostCenterCur;
                    decimal rate = System.Math.Round(DIMERCO.SDK.Utilities.LSDK.GetBudgetConverRate(cbxTarCur.Text, cbxOriCur.Text, DateTime.Now.Year), 4);
                    LabelRate.Text = rate.ToString();
                    LabelEx.Text   = "1000(" + cbxOriCur.Text + ") = " + System.Math.Round(rate * 1000, 2).ToString() + "(" + cbxTarCur.Text + ")";
                }
            }
        }
Пример #5
0
        private void RefreshList(string StationCode)
        {
            //获取站点文件后缀列表
            cs.DBCommand dbc        = new cs.DBCommand();
            string       getpostfix = "select * from FileRule where StationCode='" + StationCode + "'";
            DataTable    dtPostfix  = dbc.GetData("eReimbursement", getpostfix);

            dtPostfix.Columns.Add("Allow1");
            for (int i = 0; i < dtPostfix.Rows.Count; i++)
            {
                dtPostfix.Rows[i]["Allow1"] = dtPostfix.Rows[i]["Allow"].ToString() == "0" ? "NO" : "YES";
            }
            StoreCCList.DataSource = dtPostfix;
            StoreCCList.DataBind();
        }
Пример #6
0
        protected void Search(object sender, DirectEventArgs e)
        {
            string sql = "";

            cs.DBCommand dbc = new cs.DBCommand();

            //string sql = "select * from V_Eflow_ETravel where [Active]=1 or [Active]=2 ";

            if (!string.IsNullOrEmpty(txtNo.Text))
            {
                string rem = dbc.ConvertString(txtNo.Text).IndexOf('\\') == -1 ? (dbc.ConvertString(txtNo.Text) + "%'") : (dbc.ConvertString(txtNo.Text) + @"%' escape '\'");
                sql += "and ([No] like '%" + rem + ") ";
            }
            if (!string.IsNullOrEmpty(cbxType.Text))
            {
                sql += "and [Type]='" + cbxType.Text + "' ";
            }
            if (!string.IsNullOrEmpty(txtAmount1.Text))
            {
                sql += "and [Tamount]>='" + txtAmount1.Text + "' ";
            }
            if (!string.IsNullOrEmpty(txtAmount2.Text))
            {
                sql += "and [Tamount]<='" + txtAmount2.Text + "' ";
            }
            if (!string.IsNullOrEmpty(txtRemark.Text))
            {
                string rem = dbc.ConvertString(txtRemark.Text).IndexOf('\\') == -1 ? (dbc.ConvertString(txtRemark.Text) + "%'") : (dbc.ConvertString(txtRemark.Text) + @"%' escape '\'");
                sql += "and ([Remark] like '%" + rem + ") ";
            }
            if (!string.IsNullOrEmpty(dfTDate1.RawText))
            {
                sql += "and convert(varchar(10),CreadedDate,111)>='" + dfTDate1.RawText + "' ";
            }
            if (!string.IsNullOrEmpty(dfTDate2.RawText))
            {
                sql += "and convert(varchar(10),CreadedDate,111)<='" + dfTDate2.RawText + "' ";
            }
            if (!string.IsNullOrEmpty(cbxSubType.Text))
            {
                sql += cbxSubType.Text == "0" ? "and [Step]!=0 " : "and [Step]=0 ";
            }
            if (!string.IsNullOrEmpty(cbxPerson.Text))
            {
                sql += "and PersonID='" + cbxPerson.Text + "' ";
            }
            BindData(sql);
        }
Пример #7
0
        public void Add(string address)
        {
            cs.DBCommand  dbc          = new cs.DBCommand();
            string        sConnection  = ConfigurationManager.ConnectionStrings["eReimbursement"].ConnectionString;
            SqlConnection DbConnection = new SqlConnection(sConnection);
            SqlCommand    command      = new SqlCommand("SP_MailSetting", DbConnection);

            command.CommandType = CommandType.StoredProcedure;

            SqlParameter sp = new SqlParameter("@UserID", SqlDbType.VarChar, 50);

            sp.Value = Request.Cookies.Get("eReimUserID").Value;
            command.Parameters.Add(sp);

            //处理抄送人列表
            string CCMailList                = "";
            JavaScriptSerializer serd        = new JavaScriptSerializer();
            List <CCMailList>    CCMailList1 = serd.Deserialize <List <CCMailList> >(address);

            foreach (CCMailList mail in CCMailList1)
            {
                CCMailList += mail.Email + ",";
            }
            CCMailList = CCMailList.Length > 0 ? CCMailList.Substring(0, CCMailList.Length - 1) : "";

            sp       = new SqlParameter("@MailList", SqlDbType.VarChar, 2000);
            sp.Value = CCMailList;
            command.Parameters.Add(sp);

            sp           = new SqlParameter("@Return", SqlDbType.Int);
            sp.Direction = ParameterDirection.Output;
            command.Parameters.Add(sp);

            DbConnection.Open();
            int rowsAffected = command.ExecuteNonQuery();
            //int result = (int)command.Parameters["Returnvalue"].Value;
            //string rw = command.Parameters["@Return"].Value.ToString();
            int newID = (int)command.Parameters["@Return"].Value;

            DbConnection.Close();
        }
Пример #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                if (Request.Cookies.Get("eReimUserID") == null)
                {
                    X.AddScript("loginWindow.show();Panel1.disable();");
                    return;
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "", "$('div.gn_person ul.q-menubox li:eq(0) a').text('" + Request.Cookies.Get("eReimUserName").Value + "');", true);
                    X.AddScript("loginWindow.hide();Panel1.enable();");

                    cs.DBCommand dbc = new cs.DBCommand();
                    string sql = "select MailList as Email from MailSetting where UserID='" + Request.Cookies.Get("eReimUserID").Value + "' and MailList!=''";
                    DataTable dtdetail = new DataTable();
                    dtdetail = dbc.GetData("eReimbursement", sql);
                    if (dtdetail!=null && dtdetail.Rows.Count==1)
                    {
                        string[] mc = dtdetail.Rows[0]["Email"].ToString().Split(',');
                        DataTable dt = new DataTable();
                        dt.Columns.Add("Email");
                        for (int i = 0; i < mc.Length; i++)
                        {
                            DataRow dr = dt.NewRow();
                            dr["Email"] = mc[i];
                            dt.Rows.Add(dr);
                        }
                        StoreCCList.DataSource = dt;
                        StoreCCList.DataBind();
                    }
                    
                }
            }
        }
Пример #9
0
        protected void UploadScanFileClick(object sender, DirectEventArgs e)
        {
            //if (this.FileUploadField1.HasFile)
            //{
            //    string lstrFileName = null;     //上传文件路径
            //    string lstrFileFolder = null;   //存放文件路径
            //    string lstrFileNamePath = null; //上传目录及文件名

            //    //获得上传到服务器的目录名称,如果上传目录为空,就使用"D:\"作为缺省上传目录 
            //    //if (dir.Value != "") lstrFileFolder = dir.Value; else lstrFileFolder = "D:\\";
            //    lstrFileFolder = System.Web.HttpContext.Current.Request.MapPath("Upload/");

            //    //lstrFileName = FileUploadField1.PostedFile.FileName;  //获得文件名称
            //    //注:FileUploadField1.PostedFile.FileName 返回的是通过文件对话框选择的文件名,这之中包含了文件的目录信息

            //    lstrFileName = System.IO.Path.GetFileName(FileUploadField1.PostedFile.FileName);  //去掉目录信息,返回文件名称

            //    //判断上传目录是否存在,不存在就建立 
            //    if (!System.IO.Directory.Exists(lstrFileFolder)) System.IO.Directory.CreateDirectory(lstrFileFolder);
            //    string dtime = DateTime.Now.ToString("yyyyMMddHHmmss");
            //    lstrFileNamePath = lstrFileFolder + "SF" + dtime + System.IO.Path.GetExtension(lstrFileName); //得到上传目录及文件名称  
            //    FileUploadField1.PostedFile.SaveAs(lstrFileNamePath);       //上传文件到服务器
            //    string filename = "SF" + dtime + System.IO.Path.GetExtension(lstrFileName);
            //    HLAttachFile.Text = filename; hdScanFile.Value = filename;
            //    HLAttachFile.NavigateUrl = "./Upload/" + filename;
            //    string tpl = "Uploaded file: {0}<br/>Size: {1} bytes";
            //    //更新数据
            //    if (hdDetailID.Value.ToString() != "")
            //    {
            //        string updatesql = "update EeommonDetail set Attach='" + filename + "' where ID=" + hdDetailID.Value.ToString();
            //        cs.DBCommand dbc = new cs.DBCommand();
            //        string update = dbc.UpdateData("eReimbursement", updatesql, "Update");
            //    }
            //    X.Msg.Show(new MessageBoxConfig
            //    {
            //        Buttons = MessageBox.Button.OK,
            //        Icon = MessageBox.Icon.INFO,
            //        Title = "Success",
            //        Message = string.Format(tpl, this.FileUploadField1.PostedFile.FileName, this.FileUploadField1.PostedFile.ContentLength)
            //    });
            //}
            if (this.FileUploadField1.HasFile)
            {
                string lstrFileName = null;     //上传文件路径
                string lstrFileFolder = null;   //存放文件路径
                string lstrFileNamePath = null; //上传目录及文件名
                cs.DBCommand dbc = new cs.DBCommand();
                //获得上传到服务器的目录名称,如果上传目录为空,就使用"D:\"作为缺省上传目录 
                //if (dir.Value != "") lstrFileFolder = dir.Value; else lstrFileFolder = "D:\\";
                lstrFileFolder = System.Web.HttpContext.Current.Request.MapPath("Upload/");

                //lstrFileName = FileUploadField1.PostedFile.FileName;  //获得文件名称
                //注:FileUploadField1.PostedFile.FileName 返回的是通过文件对话框选择的文件名,这之中包含了文件的目录信息

                lstrFileName = System.IO.Path.GetFileName(FileUploadField1.PostedFile.FileName);  //去掉目录信息,返回文件名称

                //判断上传目录是否存在,不存在就建立 
                if (!System.IO.Directory.Exists(lstrFileFolder)) System.IO.Directory.CreateDirectory(lstrFileFolder);
                string dtime = DateTime.Now.ToString("yyyyMMddHHmmss");
                lstrFileNamePath = lstrFileFolder + "SF" + dtime + System.IO.Path.GetExtension(lstrFileName); //得到上传目录及文件名称 

                //151124.增加上传附件判断.
                string postfix = Path.GetExtension(lstrFileName);
                string postfixraw = Path.GetExtension(lstrFileName);
                int indexf = postfix.IndexOf('.');
                if (indexf != -1)
                {
                    postfixraw = postfixraw.Substring(1);
                }
                string station = hdStation.Value.ToString();
                string sql = "select * from FileRule where StationCode='" + station + "'";
                DataTable dtrule = dbc.GetData("eReimbursement", sql);
                if (dtrule.Rows.Count < 1)
                {
                    string sqlnew = "select * from FileRule where StationCode='DEFAULT'";
                    DataTable dtnew = dbc.GetData("eReimbursement", sqlnew);

                    if (dtnew.Select("Allow=0 and PostfixRaw='" + postfixraw + "'").Count() == 1)
                    {
                        //不允许上传该文件类型
                        X.AddScript("Ext.Msg.show({ title: 'Warning', msg: 'Not allowed file type.Please contact local MIS.', buttons: { ok: 'Ok' }, fn: function (btn) { return false; } });");
                        return;
                    }
                    else if (dtnew.Select("Allow=1 and PostfixRaw='" + postfixraw + "'").Count() == 1)
                    {
                        //允许上传的文件类型
                        FileUploadField1.PostedFile.SaveAs(lstrFileNamePath);       //上传文件到服务器
                        string filename = "SF" + dtime + System.IO.Path.GetExtension(lstrFileName);

                        HLAttachFile.Text = filename; hdScanFile.Value = filename;
                        HLAttachFile.NavigateUrl = "./Upload/" + filename;
                        string tpl = "Uploaded file: {0}<br/>Size: {1} bytes";
                        //更新数据
                        if (hdDetailID.Value.ToString() != "")
                        {
                            string updatesql = "update EeommonDetail set Attach='" + filename + "' where ID=" + hdDetailID.Value.ToString();

                            string update = dbc.UpdateData("eReimbursement", updatesql, "Update");
                        }
                        X.Msg.Show(new MessageBoxConfig
                        {
                            Buttons = MessageBox.Button.OK,
                            Icon = MessageBox.Icon.INFO,
                            Title = "Success",
                            Message = string.Format(tpl, this.FileUploadField1.PostedFile.FileName, this.FileUploadField1.PostedFile.ContentLength)
                        });
                    }
                    else
                    {
                        //未知文件类型
                        FileUploadField1.PostedFile.SaveAs(lstrFileNamePath);       //上传文件到服务器
                        //压缩文件
                        cs.ZipFloClass zip = new cs.ZipFloClass();
                        string filename = "SF" + dtime + postfix;
                        string filepath = lstrFileNamePath;
                        string zipfilepath = lstrFileFolder + "SF" + dtime + ".zip";
                        zip.ZipSingleFile(lstrFileName, filepath, zipfilepath);
                        string newfilename = "SF" + dtime + ".zip";

                        HLAttachFile.Text = newfilename; hdScanFile.Value = newfilename;
                        HLAttachFile.NavigateUrl = "./Upload/" + newfilename;
                        string tpl = "Uploaded file: {0}<br/>Size: {1} bytes";
                        //更新数据
                        if (hdDetailID.Value.ToString() != "")
                        {
                            string updatesql = "update EeommonDetail set Attach='" + newfilename + "' where ID=" + hdDetailID.Value.ToString();

                            string update = dbc.UpdateData("eReimbursement", updatesql, "Update");
                        }
                        X.Msg.Show(new MessageBoxConfig
                        {
                            Buttons = MessageBox.Button.OK,
                            Icon = MessageBox.Icon.INFO,
                            Title = "Success",
                            Message = string.Format(tpl, this.FileUploadField1.PostedFile.FileName, this.FileUploadField1.PostedFile.ContentLength)
                        });
                    }
                }
                else
                {
                    if (dtrule.Select("Allow=0 and PostfixRaw='" + postfixraw + "'").Count() == 1)
                    {
                        //不允许上传该文件类型
                        X.AddScript("Ext.Msg.show({ title: 'Warning', msg: 'Not allowed file type.Please contact local MIS.', buttons: { ok: 'Ok' }, fn: function (btn) { return false; } });");
                        return;
                    }
                    else if (dtrule.Select("Allow=1 and PostfixRaw='" + postfixraw + "'").Count() == 1)
                    {
                        //允许上传的文件类型
                        FileUploadField1.PostedFile.SaveAs(lstrFileNamePath);       //上传文件到服务器
                        string filename = "SF" + dtime + System.IO.Path.GetExtension(lstrFileName);

                        HLAttachFile.Text = filename; hdScanFile.Value = filename;
                        HLAttachFile.NavigateUrl = "./Upload/" + filename;
                        string tpl = "Uploaded file: {0}<br/>Size: {1} bytes";
                        //更新数据
                        if (hdDetailID.Value.ToString() != "")
                        {
                            string updatesql = "update EeommonDetail set Attach='" + filename + "' where ID=" + hdDetailID.Value.ToString();

                            string update = dbc.UpdateData("eReimbursement", updatesql, "Update");
                        }
                        X.Msg.Show(new MessageBoxConfig
                        {
                            Buttons = MessageBox.Button.OK,
                            Icon = MessageBox.Icon.INFO,
                            Title = "Success",
                            Message = string.Format(tpl, this.FileUploadField1.PostedFile.FileName, this.FileUploadField1.PostedFile.ContentLength)
                        });
                    }
                    else
                    {
                        //未知文件类型
                        FileUploadField1.PostedFile.SaveAs(lstrFileNamePath);       //上传文件到服务器
                        //压缩文件
                        cs.ZipFloClass zip = new cs.ZipFloClass();
                        string filename = "SF" + dtime + postfix;
                        string filepath = lstrFileNamePath;
                        string zipfilepath = lstrFileFolder + "SF" + dtime + ".zip";
                        zip.ZipSingleFile(lstrFileName, filepath, zipfilepath);
                        string newfilename = "SF" + dtime + ".zip";

                        HLAttachFile.Text = newfilename; hdScanFile.Value = newfilename;
                        HLAttachFile.NavigateUrl = "./Upload/" + newfilename;
                        string tpl = "Uploaded file: {0}<br/>Size: {1} bytes";
                        //更新数据
                        if (hdDetailID.Value.ToString() != "")
                        {
                            string updatesql = "update EeommonDetail set Attach='" + newfilename + "' where ID=" + hdDetailID.Value.ToString();

                            string update = dbc.UpdateData("eReimbursement", updatesql, "Update");
                        }
                        X.Msg.Show(new MessageBoxConfig
                        {
                            Buttons = MessageBox.Button.OK,
                            Icon = MessageBox.Icon.INFO,
                            Title = "Success",
                            Message = string.Format(tpl, this.FileUploadField1.PostedFile.FileName, this.FileUploadField1.PostedFile.ContentLength)
                        });
                    }
                }
            }
        }
Пример #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                //hdCurrency.Value = 6.1M;
                cs.DBCommand dbc = new cs.DBCommand();
                DataSet ds2 = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(Request.QueryString["apply_userid"].ToString());
                string station = "";
                if (ds2.Tables[0].Rows.Count == 1)
                {
                    DataTable dt1 = ds2.Tables[0];
                    station = dt1.Rows[0]["stationCode"].ToString();
                    hdStation.Value = dt1.Rows[0]["stationCode"].ToString();
                    //cbxTStation.Text = dt1.Rows[0]["CostCenter"].ToString();
                    LabelCurrency.Text = DIMERCO.SDK.Utilities.LSDK.GetStationCurrencyByCode(station);
                    DataTable dttemp = new DataTable();
                    string sqltemp = "select * from ESUSER where Userid='" + Request.QueryString["apply_userid"].ToString() + "'";
                    dttemp = dbc.GetData("eReimbursement", sqltemp);
                    if (dttemp.Rows.Count > 0)
                    {
                        LabelCurrency.Text = dttemp.Rows[0]["Currency"].ToString();//页面只显示登陆人币种
                    }
                }
                //160922 Andy Kang,垫付费用时,成本中心显示为被垫付人所属成本中心
                DataSet dsOnbehalf = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(Request.QueryString["UserID"].ToString());
                if (dsOnbehalf.Tables[0].Rows.Count == 1)
                {
                    DataTable dt1 = dsOnbehalf.Tables[0];
                    station = dt1.Rows[0]["stationCode"].ToString();
                    cbxTStation.Text = dt1.Rows[0]["CostCenter"].ToString();
                }
                if (Request.QueryString["Draft"] != null)
                {
                    if (Request.QueryString["Draft"].ToString() == "1")
                    {
                        X.AddScript("Button51.disable();Button6.disable();btnSave.disable();");
                    }
                    else if (Request.QueryString["Draft"].ToString() == "2")
                    {
                        X.AddScript("Button51.disable();Button6.disable();btnSave.disable();btnUploadScanFile.disable();Button1.disable();");
                    }
                }
                ////设置币种
                //if (Request.QueryString["Cur"] != null)
                //{
                //    LabelCurrency.Text = Request.QueryString["Cur"].ToString();
                //}
                //DataSet dsdep = DIMERCO.SDK.Utilities.LSDK.getCRPDepartment();
                //DataTable dtdep = new DataTable();
                //dtdep.Columns.Add(new DataColumn("Depart", typeof(String)));
                //for (int i = 0; i < dsdep.Tables[0].Rows.Count; i++)
                //{
                //    DataRow dr = dtdep.NewRow();
                //    dr[0] = dsdep.Tables[0].Rows[i][2].ToString();
                //    dtdep.Rows.Add(dr);
                //}
                //StoreDepartment.DataSource = dtdep;
                //StoreDepartment.DataBind();

                //string sqltype = "";
                //if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                //{
                //    sqltype += "select [Text]=CText,[Value]=CValue from Edic where KeyValue='PayType'";
                //}
                //else
                //{
                //    sqltype += "select [Text]=EText,[Value]=CValue from Edic where KeyValue='PayType'";
                //}
                //DataTable dttype = dbc.GetData("eReimbursement", sqltype);
                //StorePayType.DataSource = dttype;
                //StorePayType.DataBind();
            }
        }
Пример #11
0
        protected void LoadData(DataTable dt,bool CheckCopy)
        {
            string ID = dt.Rows[0]["RequestID"].ToString();
            cs.DBCommand dbc = new cs.DBCommand();
            cbxOwner.SelectedItem.Value = dt.Rows[0]["PersonID"].ToString();
            if (CheckCopy)//根据Copy判断是否需要判断Copy状态
            {
                if (Request.QueryString["Copy"] != null)
                {
                    if (Request.QueryString["Copy"].ToString() == "T")//Copy而已,作为新增
                    {
                        hdTravelRequestID.Value = "";
                        hdTravelRequestNo.Value = "";
                        if (Request.QueryString["CopyType"] != null)
                        {
                            if (Request.QueryString["CopyType"].ToString() == "A")
                            {
                                if (dt.Rows[0]["ReportFile"].ToString() != "")
                                {
                                    linkTravelReport.Text = dt.Rows[0]["ReportFile"].ToString();
                                    linkTravelReport.NavigateUrl = "./Upload/" + dt.Rows[0]["ReportFile"].ToString();
                                    hdReport.Value = dt.Rows[0]["ReportFile"].ToString();
                                }
                                if (dt.Rows[0]["Attach"].ToString() != "")
                                {
                                    linkScanFile.Text = dt.Rows[0]["Attach"].ToString();
                                    linkScanFile.NavigateUrl = "./Upload/" + dt.Rows[0]["Attach"].ToString();
                                    hdScanFile.Value = dt.Rows[0]["Attach"].ToString();
                                }
                            }
                        }
                        //检查是否已经为该申请人设置过审批人
                        string sqlCheckFlow = "";
                        if (dt.Rows[0]["Budget"].ToString() == "1")//使用Budget审批流程
                        {
                            sqlCheckFlow = "select * from GroupFlow where [Type]!=2 and GID=(select GID from GroupUsers where UserID='" + cbxOwner.Value.ToString() + "')";
                        }
                        else//使用unBudget审批流程
                        {
                            sqlCheckFlow = "select * from GroupFlow where [Type]=2 and GID=(select GID from GroupUsers where UserID='" + cbxOwner.Value.ToString() + "')";
                        }
                        DataTable dtGroupFlowData = dbc.GetData("eReimbursement", sqlCheckFlow);
                        if (dtGroupFlowData.Rows.Count < 1)
                        {
                            if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                            {
                                ErrorHandle("请先设置审批人.");
                            }
                            else
                            {
                                ErrorHandle("Not set Approve flow,please contact with Local MIS.");
                            }
                            return;
                        }
                    }
                    else
                    {
                        ErrorHandle("Data Error.");
                    }
                }
                else
                {
                    hdTravelRequestID.Value = ID;
                    hdTravelRequestNo.Value = dt.Rows[0]["No"].ToString();
                    if (dt.Rows[0]["ReportFile"].ToString() != "")
                    {
                        linkTravelReport.Text = dt.Rows[0]["ReportFile"].ToString();
                        linkTravelReport.NavigateUrl = "./Upload/" + dt.Rows[0]["ReportFile"].ToString();
                        hdReport.Value = dt.Rows[0]["ReportFile"].ToString();
                    }
                    if (dt.Rows[0]["Attach"].ToString() != "")
                    {
                        linkScanFile.Text = dt.Rows[0]["Attach"].ToString();
                        linkScanFile.NavigateUrl = "./Upload/" + dt.Rows[0]["Attach"].ToString();
                        hdScanFile.Value = dt.Rows[0]["Attach"].ToString();
                    }
                    X.AddScript("btnExport.enable();");
                }
            }
            else
            {
                hdTravelRequestID.Value = ID;
                hdTravelRequestNo.Value = dt.Rows[0]["No"].ToString();
                if (dt.Rows[0]["ReportFile"].ToString() != "")
                {
                    linkTravelReport.Text = dt.Rows[0]["ReportFile"].ToString();
                    linkTravelReport.NavigateUrl = "./Upload/" + dt.Rows[0]["ReportFile"].ToString();
                    hdReport.Value = dt.Rows[0]["ReportFile"].ToString();
                }
                if (dt.Rows[0]["Attach"].ToString() != "")
                {
                    linkScanFile.Text = dt.Rows[0]["Attach"].ToString();
                    linkScanFile.NavigateUrl = "./Upload/" + dt.Rows[0]["Attach"].ToString();
                    hdScanFile.Value = dt.Rows[0]["Attach"].ToString();
                }
            }
            cbxBudget.SelectedItem.Value = dt.Rows[0]["Budget"].ToString() == "1" ? "YES" : "NO";
            
            labelStation.Text = dt.Rows[0]["Station"].ToString();
            labelDepartment.Text = dt.Rows[0]["Department"].ToString();
            //获取该人币种
            DataSet ds1 = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(dt.Rows[0]["PersonID"].ToString());
            if (ds1.Tables[0].Rows.Count == 1)
            {
                DataTable dt1 = ds1.Tables[0];
                LabelCurrency.Text = DIMERCO.SDK.Utilities.LSDK.GetStationCurrencyByCode(dt1.Rows[0]["stationCode"].ToString());

                DataTable dttemp = new DataTable();
                string sqltemp = "select * from ESUSER where Userid='" + dt.Rows[0]["PersonID"].ToString() + "'";
                dttemp = dbc.GetData("eReimbursement", sqltemp);
                if (dttemp.Rows.Count > 0)
                {
                    LabelCurrency.Text = dttemp.Rows[0]["Currency"].ToString();
                }
            }
            else
            {
                ErrorHandle("Data Error."); return;
            }
            dfBdate.Text = dt.Rows[0]["Bdate"].ToString() == "" ? "" : Convert.ToDateTime(dt.Rows[0]["Bdate"].ToString()).ToString("yyyy/MM/dd");
            dfEdate.Text = dt.Rows[0]["Edate"].ToString() == "" ? "" : Convert.ToDateTime(dt.Rows[0]["Edate"].ToString()).ToString("yyyy/MM/dd");

            //根据语言设置
            string sqlp = "";
            if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
            {
                sqlp += ",[COAName]=t2.ADes";
            }
            else
            {
                sqlp += ",[COAName]=t2.SAccountName";
            }

            string detailsql = "select t1.*" + sqlp + " from ETraveleDetail t1 left join AccoundCode t2 on t2.SAccountCode=t1.AccountCode where t1.No='" + ID + "'";
            DataTable dtdetail = new DataTable();
            dtdetail = dbc.GetData("eReimbursement", detailsql);
            DataTable dtnew = new DataTable();
            dtnew.Columns.Add("DetailID", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Tocity", System.Type.GetType("System.String"));
            dtnew.Columns.Add("AccountName", System.Type.GetType("System.String"));
            dtnew.Columns.Add("AccountCode", System.Type.GetType("System.String"));
            dtnew.Columns.Add("AccountDes", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Cur", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Pamount", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Camount", System.Type.GetType("System.String"));
            dtnew.Columns.Add("TSation", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Tdate", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Type", System.Type.GetType("System.String"));
            dtnew.Columns.Add("COAName", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Department1", System.Type.GetType("System.String"));
            decimal psum = 0, csum = 0;
            for (int i = 0; i < dtdetail.Rows.Count; i++)
            {
                DataRow dr = dtnew.NewRow();
                dr["DetailID"] = dtdetail.Rows[i]["ID"].ToString();
                dr["Tocity"] = dtdetail.Rows[i]["Tocity"].ToString();
                dr["AccountName"] = dtdetail.Rows[i]["AccountName"].ToString();
                dr["AccountCode"] = dtdetail.Rows[i]["AccountCode"].ToString();
                dr["AccountDes"] = dtdetail.Rows[i]["AccountDes"].ToString();
                dr["Cur"] = dtdetail.Rows[i]["Cur"].ToString();
                dr["Pamount"] = dtdetail.Rows[i]["Pamount"].ToString();
                dr["Camount"] = dtdetail.Rows[i]["Camount"].ToString();
                dr["TSation"] = dtdetail.Rows[i]["TSation"].ToString();
                dr["Tdate"] = dtdetail.Rows[i]["Tdate"].ToString() == "" ? "" : Convert.ToDateTime(dtdetail.Rows[i]["Tdate"].ToString()).ToString("yyyy/MM/dd");
                dr["Type"] = hdStatus.Value.ToString();//传递给子页面以判断按钮状态 0:允许修改,允许上传;1:不允许修改,允许上传;2:全不允许
                dr["COAName"] = dtdetail.Rows[i]["COAName"].ToString();
                dr["Department1"] = dtdetail.Rows[i]["Department1"].ToString();
                dtnew.Rows.Add(dr);
                psum += dtdetail.Rows[i]["Pamount"].ToString() == "" ? 0 : Convert.ToDecimal(dtdetail.Rows[i]["Pamount"].ToString());
                csum += dtdetail.Rows[i]["Camount"].ToString() == "" ? 0 : Convert.ToDecimal(dtdetail.Rows[i]["Camount"].ToString());
            }
            Store3.DataSource = dtnew;
            Store3.DataBind();
            //txtSum.Text = (psum + csum).ToString("c");
            txtSum.Text = (psum + csum).ToString("#,##0.00"); hdSum.Value = (psum + csum).ToString();
            txtPersonalSum.Text = psum.ToString("#,##0.00"); hdPamountSum.Value = psum.ToString();
            txtCompanySum.Text = csum.ToString("#,##0.00"); hdCamountSum.Value = csum.ToString();
            txtRemark.Text = dt.Rows[0]["Remark"].ToString();
            if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
            {
                GridPanel2.Title = "张数合计: " + dtdetail.Rows.Count.ToString() + ", 金额合计: " + (psum + csum).ToString("#,##0.00");
            }
            else
            {
                GridPanel2.Title = "Total sheets: " + dtdetail.Rows.Count.ToString() + ", Sum: " + (psum + csum).ToString("#,##0.00");
            }
            if (dt.Rows[0]["CCMailList"].ToString()!="")
            {
                ToolTipCC.Html = dt.Rows[0]["CCMailList"].ToString().Replace(",", "<br />");
                DataTable dtCCMailList = new DataTable();
                dtCCMailList.Columns.Add("Email", typeof(String));
                for (int i = 0; i < dt.Rows[0]["CCMailList"].ToString().Split(',').Length; i++)
                {
                    DataRow dr = dtCCMailList.NewRow();
                    dr["Email"] = dt.Rows[0]["CCMailList"].ToString().Split(',')[i];
                    dtCCMailList.Rows.Add(dr);
                }
                StoreCCList.DataSource = dtCCMailList;
                StoreCCList.DataBind();
            }
        }
Пример #12
0
        protected void ChangeBudget(object sender, DirectEventArgs e)
        {
            cs.DBCommand dbc = new cs.DBCommand();
            //检查是否已经为该申请人设置过审批人
            string sqlCheckFlow = "";
            if (cbxBudget.Value.ToString() == "YES")//使用Budget审批流程
            {
                sqlCheckFlow = "select * from GroupFlow where [Type]!=2 and GID=(select GID from GroupUsers where UserID='" + cbxOwner.Value.ToString() + "')";
            }
            else//使用unBudget审批流程
            {
                sqlCheckFlow = "select * from GroupFlow where [Type]=2 and GID=(select GID from GroupUsers where UserID='" + cbxOwner.Value.ToString() + "')";
            }

            //string sqlCheckFlow = "select * from GroupFlow where GID=(select GID from GroupUsers where UserID='" + cbxOwner.Text + "')";
            DataTable dtCheckFlow = dbc.GetData("eReimbursement", sqlCheckFlow);
            if (dtCheckFlow.Rows.Count < 1)
            {
                if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                {
                    ErrorHandleNojump("请联系Local MIS设置审批人.");
                }
                else
                {
                    ErrorHandleNojump("Not set Approve flow,please contact with Local MIS.");
                }
            }
        }
Пример #13
0
        protected void Search(object sender, DirectEventArgs e)
        {
            cs.DBCommand dbc = new cs.DBCommand();
            string       sql = "";

            //string sql = "select * from V_Eflow_ETravel where [Active]=1 or [Active]=2 ";

            if (!string.IsNullOrEmpty(txtNo.Text))
            {
                string rem = dbc.ConvertString(txtNo.Text).IndexOf('\\') == -1 ? (dbc.ConvertString(txtNo.Text) + "%'") : (dbc.ConvertString(txtNo.Text) + @"%' escape '\'");
                sql += "and ([No] like '%" + rem + ") ";
            }
            if (!string.IsNullOrEmpty(cbxType.Text))
            {
                sql += "and [Type]='" + cbxType.Text + "' ";
            }
            if (!string.IsNullOrEmpty(txtAmount1.Text))
            {
                sql += "and [Tamount]>='" + txtAmount1.Text + "' ";
            }
            if (!string.IsNullOrEmpty(txtAmount2.Text))
            {
                sql += "and [Tamount]<='" + txtAmount2.Text + "' ";
            }
            if (!string.IsNullOrEmpty(txtRemark.Text))
            {
                string rem = dbc.ConvertString(txtRemark.Text).IndexOf('\\') == -1 ? (dbc.ConvertString(txtRemark.Text) + "%'") : (dbc.ConvertString(txtRemark.Text) + @"%' escape '\'");
                sql += "and ([Remark] like '%" + rem + ") ";
            }
            if (!string.IsNullOrEmpty(dfTDate1.RawText))
            {
                sql += "and convert(varchar(10),CreadedDate,111)>='" + dfTDate1.RawText + "' ";
            }
            if (!string.IsNullOrEmpty(dfTDate2.RawText))
            {
                sql += "and convert(varchar(10),CreadedDate,111)<='" + dfTDate2.RawText + "' ";
            }
            if (!string.IsNullOrEmpty(cbxSubType.Text))
            {
                sql += cbxSubType.Text == "0" ? "and [Step]!=0 " : "and [Step]=0 ";
            }
            if (!string.IsNullOrEmpty(cbxPerson.Text))
            {
                sql += "and PersonID='" + cbxPerson.Text + "' ";
            }
            if (!string.IsNullOrEmpty(cbxCreatedBy.Text))
            {
                sql += "and CreadedByID='" + cbxCreatedBy.Text + "' ";
            }
            if (!string.IsNullOrEmpty(cbxProcess.Text))
            {
                sql += "and Status='" + cbxProcess.Text + "' ";
                //switch (cbxProcess.Text)
                //{
                //    case "待批":
                //        sql += "and Status=1 ";
                //        break;
                //    case "Pending":
                //        sql += "and Status=1 ";
                //        break;
                //    case "已批":
                //        sql += "and Status=2 ";
                //        break;
                //    case "Approved":
                //        sql += "and Status=2 ";
                //        break;
                //    case "已拒绝":
                //        sql += "and Status=3 ";
                //        break;
                //    case "Rejected":
                //        sql += "and Status=3 ";
                //        break;
                //    case "待申请":
                //        sql += "and Status=0 ";
                //        break;
                //    case "Not Apply":
                //        sql += "and Status=0 ";
                //        break;
                //    default:
                //        break;
                //}
            }
            if (!string.IsNullOrEmpty(cbxStation.Text))
            {
                sql += "and Station='" + cbxStation.Text + "' ";
            }
            else
            {
                string    getright  = "select * from StationRole where UserID='" + Request.Cookies.Get("eReimUserID").Value + "'";
                DataTable dtright   = dbc.GetData("eReimbursement", getright);
                DataTable dtStation = new DataTable();
                dtStation.Columns.Add("Text", System.Type.GetType("System.String"));
                dtStation.Columns.Add("Value", System.Type.GetType("System.String"));
                for (int j = 0; j < dtright.Rows.Count; j++)
                {
                    string[] dd = dtright.Rows[j]["Stations"].ToString().Split(',');
                    for (int i = 0; i < dd.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(dd[i].Trim()))
                        {
                            bool have = false;
                            for (int g = 0; g < dtStation.Rows.Count; g++)
                            {
                                if (dtStation.Rows[g]["Text"].ToString() == dd[i].Trim())
                                {
                                    have = true;
                                    break;
                                }
                            }
                            if (!have)
                            {
                                DataRow dr1 = dtStation.NewRow();
                                dr1["Text"]  = dd[i];
                                dr1["Value"] = dd[i];
                                dtStation.Rows.Add(dr1);
                            }
                        }
                    }
                }
                //获取被授权站点下的所有申请人
                string station = "";
                for (int i = 0; i < dtStation.Rows.Count; i++)
                {
                    station += "'" + dtStation.Rows[i]["Text"].ToString() + "',";
                }
                if (!string.IsNullOrEmpty(station))
                {
                    station = " and Station in (" + station.Substring(0, station.Length - 1) + ") ";
                    sql    += station;
                }
                else
                {
                    sql += " and FlowID is null ";
                }
            }
            string sql1 = "select t1.*";

            if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
            {
                sql1 += ",[Status1]=TDicStatus.CText,[Type1]=TDicMainType.CText,[Draft1]=TDicType.CText";
            }
            else
            {
                sql1 += ",[Status1]=TDicStatus.EText,[Type1]=TDicMainType.EText,[Draft1]=TDicType.EText";
            }
            sql1 += " from (select [Draft]=case when [Status]=0 then 1 else 0 end,* from V_Eflow_ETravel where FlowID>16097 and (Active=1 or Active=2) " + sql + ") t1";
            sql1 += " left join (select * from Edic where KeyValue='MainType') TDicMainType on TDicMainType.CValue=t1.Type";
            sql1 += " left join (select * from Edic where KeyValue='Status') TDicStatus on TDicStatus.CValue=t1.Status";
            sql1 += " left join (select * from Edic where KeyValue='Type') TDicType on TDicType.CValue=t1.Draft";


            DataTable dtdetail = new DataTable();

            dtdetail = dbc.GetData("eReimbursement", sql1);
            DataTable dtnew = new DataTable();

            dtnew.Columns.Add("FlowID", System.Type.GetType("System.String"));
            dtnew.Columns.Add("No", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Type", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Station", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Department", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Person", System.Type.GetType("System.String"));
            dtnew.Columns.Add("CreadedBy", System.Type.GetType("System.String"));
            dtnew.Columns.Add("CreadedDate", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Tamount", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Step", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Status", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Approver", System.Type.GetType("System.String"));
            dtnew.Columns.Add("ApproveDate", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Remark", System.Type.GetType("System.String"));
            dtnew.Columns.Add("ApproverID", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Draft", System.Type.GetType("System.String"));
            dtnew.Columns.Add("RequestID", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Status1", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Type1", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Draft1", System.Type.GetType("System.String"));
            //151010,解析申请人Cost Center by Andy Kang
            dtnew.Columns.Add("PersonID", System.Type.GetType("System.String"));
            dtnew.Columns.Add("CostCenter", System.Type.GetType("System.String"));
            dtnew.Columns.Add("CostCenterNew", System.Type.GetType("System.String"));
            for (int i = 0; i < dtdetail.Rows.Count; i++)
            {
                DataRow dr = dtnew.NewRow();
                dr["FlowID"]      = dtdetail.Rows[i]["FlowID"].ToString();
                dr["No"]          = dtdetail.Rows[i]["No"].ToString();
                dr["Type"]        = dtdetail.Rows[i]["Type"].ToString();
                dr["Station"]     = dtdetail.Rows[i]["Station"].ToString();
                dr["Department"]  = dtdetail.Rows[i]["Department"].ToString();
                dr["Person"]      = dtdetail.Rows[i]["Person"].ToString();
                dr["CreadedBy"]   = dtdetail.Rows[i]["CreadedBy"].ToString();
                dr["CreadedDate"] = dtdetail.Rows[i]["CreadedDate"].ToString() == "" ? "" : Convert.ToDateTime(dtdetail.Rows[i]["CreadedDate"].ToString()).ToString("yyyy/MM/dd");
                dr["Tamount"]     = dtdetail.Rows[i]["Tamount"].ToString();
                dr["Step"]        = dtdetail.Rows[i]["Step"].ToString();
                dr["Status"]      = dtdetail.Rows[i]["Status"].ToString();
                dr["Approver"]    = dtdetail.Rows[i]["Approver"].ToString();
                dr["ApproveDate"] = dtdetail.Rows[i]["ApproveDate"].ToString() == "" ? "" : Convert.ToDateTime(dtdetail.Rows[i]["ApproveDate"].ToString()).ToString("yyyy/MM/dd");
                dr["Remark"]      = dtdetail.Rows[i]["Remark"].ToString();
                dr["ApproverID"]  = dtdetail.Rows[i]["ApproverID"].ToString();
                dr["Draft"]       = dtdetail.Rows[i]["Draft"].ToString();
                dr["RequestID"]   = dtdetail.Rows[i]["RequestID"].ToString();
                dr["Status1"]     = dtdetail.Rows[i]["Status1"].ToString();
                dr["Type1"]       = dtdetail.Rows[i]["Type1"].ToString();
                dr["Draft1"]      = dtdetail.Rows[i]["Draft1"].ToString();
                //151010,解析申请人Cost Center by Andy Kang
                dr["PersonID"]   = dtdetail.Rows[i]["PersonID"].ToString();
                dr["CostCenter"] = dtdetail.Rows[i]["CostCenter"].ToString();
                DataSet ds1 = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(dtdetail.Rows[i]["PersonID"].ToString());
                if (ds1.Tables[0].Rows.Count == 1)
                {
                    DataTable dt1 = ds1.Tables[0];
                    dr["CostCenterNew"] = dt1.Rows[0]["CostCenter"].ToString();
                }
                else
                {
                    dr["CostCenterNew"] = "N/A";
                }

                dtnew.Rows.Add(dr);
            }
            Store1.DataSource = dtnew;
            Store1.DataBind();
        }
Пример #14
0
        protected void GetDetail(object sender, DirectEventArgs e)
        {
            string RequestID = e.ExtraParams[0].Value;
            string Type      = e.ExtraParams[1].Value;
            string sql       = "select * from V_Eflow_ETravel where RequestID='" + RequestID + "' and [Type]='" + Type + "' order by Step,FlowID";

            cs.DBCommand dbc = new cs.DBCommand();
            DataTable    dt  = new DataTable();

            dt = dbc.GetData("eReimbursement", sql);
            if (dt != null && dt.Rows.Count > 0)
            {
                string html = "";
                string status1 = ""; string status2 = ""; string status3 = ""; string status4 = ""; string status5 = ""; string status6 = ""; string status7 = "";
                if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                {
                    status1 = "待提交";
                    status2 = "提交申请";
                    status3 = "待批";
                    status4 = "已批准";
                    status5 = "已拒绝";
                    status6 = "完成";
                    status7 = "待确认";
                }
                else
                {
                    status1 = "Pending.";
                    status2 = "Applied by";
                    status3 = "Waiting for app.";
                    status4 = "Approved.";
                    status5 = "Rejected by";
                    status6 = "Complete.";
                    status7 = "Waiting for cfm.";
                }


                bool tijiao   = false;
                int  countdiv = 0;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["Step"].ToString() == "0")
                    {
                        html += "<div class=\"StatusIcon Pending\">";
                        html += "<span class=\"spanIcon\">" + status1 + "<br />";
                        html += dt.Rows[i]["Person"].ToString();
                        html += "</span><b class=\"bIcon bIcon1\"></b>";
                        html += "</div>";
                        countdiv++;
                        break;
                    }
                    else
                    {
                        if (dt.Rows[i]["Step"].ToString() == "1" && !tijiao)
                        {
                            html += "<div class=\"StatusIcon StatusIcon0\">";
                            html += "<span class=\"spanIcon\">" + status2 + "<br />";
                            html += dt.Rows[i]["Person"].ToString();
                            html += dt.Rows[i]["CreadedDate"].ToString() == "" ? "" : "<br />" + Convert.ToDateTime(dt.Rows[i]["CreadedDate"].ToString()).ToString("yyyy/MM/dd");
                            html += "</span><b class=\"bIcon bIcon1\"></b>";
                            html += "</div>";
                            countdiv++;
                            tijiao = true;
                        }
                        if (dt.Rows[i]["Status"].ToString() == "1")
                        {
                            string msg = "";
                            if (dt.Rows[i]["FlowFn"].ToString().ToLower() == "verifier")
                            {
                                if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                                {
                                    msg = "待查.";
                                }
                                else
                                {
                                    msg = "To be Verified by";
                                }
                            }
                            else if (dt.Rows[i]["FlowFn"].ToString().ToLower() == "issuer")
                            {
                                if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                                {
                                    msg = "待发放.";
                                }
                                else
                                {
                                    msg = "To be Issued by";
                                }
                            }
                            else if (dt.Rows[i]["FlowFn"].ToString().ToLower() == "confirm")
                            {
                                if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                                {
                                    msg = "待确认.";
                                }
                                else
                                {
                                    msg = "Waiting for Confirmation by";
                                }
                            }
                            else
                            {
                                if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                                {
                                    msg = "待批.";
                                }
                                else
                                {
                                    msg = "Waiting for Approval by";
                                }
                            }

                            html += "<div class=\"StatusIcon Pending\">";
                            html += "<span class=\"spanIcon\">" + msg + "<br />";
                            html += dt.Rows[i]["Approver"].ToString();
                            html += "</span><b class=\"bIcon bIcon1\"></b>";
                            html += "</div>";
                            countdiv++;
                        }
                        else if (dt.Rows[i]["Status"].ToString() == "2")
                        {
                            string msg = "";
                            if (dt.Rows[i]["FlowFn"].ToString().ToLower() == "verifier")
                            {
                                if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                                {
                                    msg = "已查.";
                                }
                                else
                                {
                                    msg = "Verified by";
                                }
                            }
                            else if (dt.Rows[i]["FlowFn"].ToString().ToLower() == "issuer")
                            {
                                if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                                {
                                    msg = "已发放.";
                                }
                                else
                                {
                                    msg = "Issued by";
                                }
                            }
                            else if (dt.Rows[i]["FlowFn"].ToString().ToLower() == "confirm")
                            {
                                if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                                {
                                    msg = "已确认.";
                                }
                                else
                                {
                                    msg = "Confirmed by";
                                }
                            }
                            else
                            {
                                if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                                {
                                    msg = "已批.";
                                }
                                else
                                {
                                    msg = "Approved by";
                                }
                            }

                            html += "<div class=\"StatusIcon Approve\">";
                            html += "<span class=\"spanIcon\">" + msg + "<br />";
                            html += dt.Rows[i]["Approver"].ToString();
                            html += dt.Rows[i]["ApproveDate"].ToString() == "" ? "" : "<br />" + Convert.ToDateTime(dt.Rows[i]["ApproveDate"].ToString()).ToString("yyyy/MM/dd");
                            html += "</span><b class=\"bIcon bIcon1\"></b>";
                            html += "</div>";
                            countdiv++;
                        }
                        else if (dt.Rows[i]["Status"].ToString() == "3")
                        {
                            html += "<div class=\"StatusIcon Reject\">";
                            html += "<span class=\"spanIcon\">" + status5 + "<br />";
                            html += dt.Rows[i]["Approver"].ToString();
                            html += dt.Rows[i]["ApproveDate"].ToString() == "" ? "" : "<br />" + Convert.ToDateTime(dt.Rows[i]["ApproveDate"].ToString()).ToString("yyyy/MM/dd");
                            html += "</span><b class=\"bIcon bIcon1\"></b>";
                            html += "</div>";
                            countdiv++;
                        }
                        if (dt.Rows[i]["Active"].ToString() == "2")
                        {
                            html += "<div class=\"StatusIcon Complete\">";
                            html += "<span class=\"spanIcon\">" + status6;
                            html += "</span><b class=\"bIcon bIcon1\"></b>";
                            html += "</div>";
                            countdiv++;
                            break;
                        }
                    }
                }
                if (countdiv > 7)
                {
                    int width = countdiv * 110;
                    html = "'<div style=\"width:" + width.ToString() + "px\">" + html;
                }
                else
                {
                    html = "'<div>" + html;
                }
                html += "</div>'";
                X.AddScript("setFlow(" + html + ");Container2.show();");
            }
        }
Пример #15
0
        protected void BindData(string sql)
        {
            try
            {
                sql += " and (PersonID='" + Request.Cookies.Get("eReimUserID").Value + "' or CreadedByID='" + Request.Cookies.Get("eReimUserID").Value + "' ";
                //判断是否为代理人
                cs.DBCommand dbc            = new cs.DBCommand();
                string       ApplyIDByAgent = "";
                string       sqlagent       = "select * from Eagent where [St]=1 and [PAgentID]='" + Request.Cookies.Get("eReimUserID").Value + "' and getdate()<=Edate and getdate()>=Bdate";
                DataTable    dtagent        = dbc.GetData("eReimbursement", sqlagent);
                if (dtagent != null && dtagent.Rows.Count > 0)
                {
                    ApplyIDByAgent += " or PersonID in (";
                    for (int g = 0; g < dtagent.Rows.Count; g++)
                    {
                        if (g != dtagent.Rows.Count - 1)
                        {
                            ApplyIDByAgent += "'" + dtagent.Rows[g]["OwnerID"].ToString() + "',";
                        }
                        else
                        {
                            ApplyIDByAgent += "'" + dtagent.Rows[g]["OwnerID"].ToString() + "'";
                        }
                    }
                    ApplyIDByAgent += ")";
                }

                sql += ApplyIDByAgent + ")";

                string sql1 = "select t1.*";
                if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                {
                    sql1 += ",[Status1]=TDicStatus.CText,[Type1]=TDicMainType.CText,[Draft1]=TDicType.CText";
                }
                else
                {
                    sql1 += ",[Status1]=TDicStatus.EText,[Type1]=TDicMainType.EText,[Draft1]=TDicType.EText";
                }
                //if (Request.Cookies["lang"] != null)
                //{
                //    string lang = Request.Cookies["lang"].Value;
                //    if (lang.ToLower() == "en-us")
                //    {
                //        PagingToolbar1.DisplayMsg = "Displaying items {0} - {1} of {2}";
                //        ResourceManager1.Locale = "en-US";
                //        sql1 += ",[Status1]=TDicStatus.EText,[Type1]=TDicMainType.EText,[Draft1]=TDicType.EText";
                //    }
                //    else
                //    {
                //        PagingToolbar1.DisplayMsg = "显示 {0} - {1} of {2}";
                //        ResourceManager1.Locale = "zh-CN";
                //        sql1 += ",[Status1]=TDicStatus.CText,[Type1]=TDicMainType.CText,[Draft1]=TDicType.CText";
                //    }
                //}
                //else
                //{
                //    sql1 += ",[Status1]=TDicStatus.CText,[Type1]=TDicMainType.CText,[Draft1]=TDicType.CText";
                //}
                sql1 += " from (select [Draft]=case when [Status]=0 then 1 else 0 end,* from V_Eflow_ETravel where FlowID>16097 and (Active=1 or Active=2) " + sql + ") t1";
                sql1 += " left join (select * from Edic where KeyValue='MainType') TDicMainType on TDicMainType.CValue=t1.Type";
                sql1 += " left join (select * from Edic where KeyValue='Status') TDicStatus on TDicStatus.CValue=t1.Status";
                sql1 += " left join (select * from Edic where KeyValue='Type') TDicType on TDicType.CValue=t1.Draft  order by FlowID desc";

                DataTable dtdetail = new DataTable();
                dtdetail = dbc.GetData("eReimbursement", sql1);
                DataTable dtnew = new DataTable();
                dtnew.Columns.Add("FlowID", System.Type.GetType("System.String"));
                dtnew.Columns.Add("No", System.Type.GetType("System.String"));
                dtnew.Columns.Add("Type", System.Type.GetType("System.String"));
                dtnew.Columns.Add("Station", System.Type.GetType("System.String"));
                dtnew.Columns.Add("Department", System.Type.GetType("System.String"));
                dtnew.Columns.Add("Person", System.Type.GetType("System.String"));
                dtnew.Columns.Add("CreadedBy", System.Type.GetType("System.String"));
                dtnew.Columns.Add("CreadedDate", System.Type.GetType("System.String"));
                dtnew.Columns.Add("Tamount", System.Type.GetType("System.String"));
                dtnew.Columns.Add("Step", System.Type.GetType("System.String"));
                dtnew.Columns.Add("Status", System.Type.GetType("System.String"));
                dtnew.Columns.Add("Approver", System.Type.GetType("System.String"));
                dtnew.Columns.Add("ApproveDate", System.Type.GetType("System.String"));
                dtnew.Columns.Add("Remark", System.Type.GetType("System.String"));
                dtnew.Columns.Add("ApproverID", System.Type.GetType("System.String"));
                dtnew.Columns.Add("Draft", System.Type.GetType("System.String"));
                dtnew.Columns.Add("RequestID", System.Type.GetType("System.String"));
                dtnew.Columns.Add("Status1", System.Type.GetType("System.String"));
                dtnew.Columns.Add("Type1", System.Type.GetType("System.String"));
                dtnew.Columns.Add("Draft1", System.Type.GetType("System.String"));
                dtnew.Columns.Add("ApplyDate", System.Type.GetType("System.String"));
                for (int i = 0; i < dtdetail.Rows.Count; i++)
                {
                    DataRow dr = dtnew.NewRow();
                    dr["FlowID"]      = dtdetail.Rows[i]["FlowID"].ToString();
                    dr["No"]          = dtdetail.Rows[i]["No"].ToString();
                    dr["Type"]        = dtdetail.Rows[i]["Type"].ToString();
                    dr["Station"]     = dtdetail.Rows[i]["Station"].ToString();
                    dr["Department"]  = dtdetail.Rows[i]["Department"].ToString();
                    dr["Person"]      = dtdetail.Rows[i]["Person"].ToString();
                    dr["CreadedBy"]   = dtdetail.Rows[i]["CreadedBy"].ToString();
                    dr["CreadedDate"] = dtdetail.Rows[i]["CreadedDate"].ToString() == "" ? "" : Convert.ToDateTime(dtdetail.Rows[i]["CreadedDate"].ToString()).ToString("yyyy/MM/dd");
                    dr["Tamount"]     = dtdetail.Rows[i]["Tamount"].ToString();
                    dr["Step"]        = dtdetail.Rows[i]["Step"].ToString();
                    dr["Status"]      = dtdetail.Rows[i]["Status"].ToString();
                    dr["Approver"]    = dtdetail.Rows[i]["Approver"].ToString();
                    dr["ApproveDate"] = dtdetail.Rows[i]["ApproveDate"].ToString() == "" ? "" : Convert.ToDateTime(dtdetail.Rows[i]["ApproveDate"].ToString()).ToString("yyyy/MM/dd");
                    dr["Remark"]      = dtdetail.Rows[i]["Remark"].ToString();
                    dr["ApproverID"]  = dtdetail.Rows[i]["ApproverID"].ToString();
                    dr["Draft1"]      = dtdetail.Rows[i]["Draft1"].ToString();
                    dr["Draft"]       = dtdetail.Rows[i]["Draft"].ToString();
                    dr["RequestID"]   = dtdetail.Rows[i]["RequestID"].ToString();
                    dr["Status1"]     = dtdetail.Rows[i]["Status1"].ToString();
                    dr["Type1"]       = dtdetail.Rows[i]["Type1"].ToString();
                    dr["ApplyDate"]   = Convert.ToDateTime(dtdetail.Rows[i]["ApplyDate"].ToString()).ToString("yyyy/MM/dd");
                    dtnew.Rows.Add(dr);
                }
                Store1.DataSource = dtnew;
                Store1.DataBind();
                if (dtdetail.Rows.Count > 0)
                {
                    X.AddScript("btnExport.enable();");
                }
            }
            catch (Exception ex)
            {
                DIMERCO.SDK.MailMsg mail = new DIMERCO.SDK.MailMsg();

                mail.FromDispName = "eReimbursement";
                mail.From         = "*****@*****.**";
                mail.To           = "*****@*****.**";
                mail.Title        = "eReimbursement Bug" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:dd");
                mail.Body         = ex.Message + "<br/>" + ex.InnerException.ToString() + "</div>";
                mail.Send();
            }
        }
Пример #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                //DataSet dsuser = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList("A0703");
                //if (dsuser.Tables[0].Rows.Count == 1)
                //{
                //    DataTable dt1 = dsuser.Tables[0];
                //    dt1 = null;
                //}

                //DataTable newr = Comm.RtnEB("A0703", "Administration", "DIMYVR", "DIMYVR", "62010910", "2014", "1");
                //DataSet ds3 = DIMERCO.SDK.Utilities.LSDK.getStationHierarchy();
                //for (int i = 0; i < ds3.Tables[0].Rows.Count; i++)
                //{
                //    if (ds3.Tables[0].Rows[i][0].ToString()=="GCRSHA")
                //    {
                //        string sw = ds3.Tables[0].Rows[i][0].ToString();
                //    }
                //}
                //DataTable dttt = ds3.Tables[0];
                //判断登录状态
                //Session["UserID"] = "A5236"; Session["UserName"] = "******";
                //if (Request.Cookies["eReimUserID"] != null)
                //{
                //    Response.Cookies["eReimUserID"].Value = "A5236";  //将值写入到客户端硬盘Cookie
                //    Response.Cookies["eReimUserID"].Expires = DateTime.Now.AddHours(12);//设置Cookie过期时间
                //}
                //else
                //{
                //    HttpCookie cookie = new HttpCookie("eReimUserID", "A5236");
                //    cookie.Expires = DateTime.Now.AddHours(12);
                //    Response.Cookies.Add(cookie);
                //}
                //if (Request.Cookies["eReimUserName"] != null)
                //{
                //    Response.Cookies["eReimUserName"].Value = "Angel Chen";  //将值写入到客户端硬盘Cookie
                //    Response.Cookies["eReimUserName"].Expires = DateTime.Now.AddHours(12);//设置Cookie过期时间
                //}
                //else
                //{
                //    HttpCookie cookie = new HttpCookie("eReimUserName", "Angel Chen");
                //    cookie.Expires = DateTime.Now.AddHours(12);
                //    Response.Cookies.Add(cookie);
                //}

                cs.DBCommand dbc = new cs.DBCommand();
                if (Request.Cookies.Get("eReimUserID") == null)
                {
                    X.AddScript("loginWindow.show();Panel1.disable();");
                    return;
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "", "$('div.gn_person ul.q-menubox li:eq(0) a').text('" + Request.Cookies.Get("eReimUserName").Value + "');", true); X.AddScript("loginWindow.hide();Panel1.enable();");
                }
                //准备下拉菜单内容
                Ext.Net.ListItem li = new Ext.Net.ListItem(Request.Cookies.Get("eReimUserName").Value, Request.Cookies.Get("eReimUserID").Value);
                cbxPerson.Items.Add(li);
                string sqlitem = "select * from Eagent where [St]=1 and [PAgentID]='" + Request.Cookies.Get("eReimUserID").Value + "'";

                try
                {
                    DataTable dtitem = new DataTable();
                    dtitem = dbc.GetData("eReimbursement", sqlitem);
                    int itemcount = 0;
                    if (dtitem != null)
                    {
                        for (int j = 0; j < dtitem.Rows.Count; j++)
                        {
                            string sqlpara = sqlitem;
                            bool   d1      = true;
                            bool   d2      = false;
                            if (dtitem.Rows[j][5].ToString() != "")
                            {
                                //sqlpara += " and getdate()>='" + dtitem.Rows[j]["Bdate"].ToString() + "' ";
                                if (DateTime.Now >= Convert.ToDateTime(dtitem.Rows[j][5].ToString()))
                                {
                                    d1 = true;
                                }
                                else
                                {
                                    d1 = false;
                                }
                            }
                            if (dtitem.Rows[j][6].ToString() != "")
                            {
                                //sqlpara += " and getdate()<='" + dtitem.Rows[j]["Edate"].ToString() + "' ";
                                if (DateTime.Now <= Convert.ToDateTime(dtitem.Rows[j][6].ToString()))
                                {
                                    d2 = true;
                                }
                                else
                                {
                                    d2 = false;
                                }
                            }
                            if (d1 && d2)
                            {
                                li = new Ext.Net.ListItem(dtitem.Rows[j][1].ToString(), dtitem.Rows[j][2].ToString());
                                cbxPerson.Items.Add(li);
                                itemcount++;
                            }
                        }
                        if (itemcount < 1)
                        {
                            cbxPerson.SelectedIndex = 0;
                        }
                    }
                    else
                    {
                        DIMERCO.SDK.MailMsg mail = new DIMERCO.SDK.MailMsg();

                        mail.FromDispName = "eReimbursement";
                        mail.From         = "*****@*****.**";
                        mail.To           = "*****@*****.**";
                        mail.Title        = "eReimbursement Bug" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:dd");
                        mail.Body         = "<div>Error<br/>" + sqlitem + "</div>";
                        mail.Send();
                    }
                }
                catch (Exception ex)
                {
                    DIMERCO.SDK.MailMsg mail = new DIMERCO.SDK.MailMsg();

                    mail.FromDispName = "eReimbursement";
                    mail.From         = "*****@*****.**";
                    mail.To           = "*****@*****.**";
                    mail.Title        = "eReimbursement Bug" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:dd");
                    mail.Body         = ex.Message + "<br/>" + ex.InnerException.ToString() + sqlitem + "</div>";
                    mail.Send();
                }

                string sqltype  = "";
                string sqldraft = "";
                if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                {
                    PagingToolbar1.DisplayMsg = "显示 {0} - {1} of {2}";
                    ResourceManager1.Locale   = "zh-CN";
                    sqltype  += "select [Text]=CText,[Value]=CValue from Edic where KeyValue='MainType'";
                    sqldraft += "select [Text]=CText,[Value]=CValue from Edic where KeyValue='Type'";
                }
                else
                {
                    PagingToolbar1.DisplayMsg = "Displaying items {0} - {1} of {2}";
                    ResourceManager1.Locale   = "en-US";
                    sqltype  += "select [Text]=EText,[Value]=CValue from Edic where KeyValue='MainType'";
                    sqldraft += "select [Text]=EText,[Value]=CValue from Edic where KeyValue='Type'";
                }
                //if (Request.Cookies["lang"] != null)
                //{
                //    string lang = Request.Cookies["lang"].Value;
                //    if (lang.ToLower() == "en-us")
                //    {
                //        PagingToolbar1.DisplayMsg = "Displaying items {0} - {1} of {2}";
                //        ResourceManager1.Locale = "en-US";
                //        sqltype += "select [Text]=EText,[Value]=CValue from Edic where KeyValue='MainType'";
                //        sqldraft += "select [Text]=EText,[Value]=CValue from Edic where KeyValue='Type'";
                //    }
                //    else
                //    {
                //        PagingToolbar1.DisplayMsg = "显示 {0} - {1} of {2}";
                //        ResourceManager1.Locale = "zh-CN";
                //        sqltype += "select [Text]=CText,[Value]=CValue from Edic where KeyValue='MainType'";
                //        sqldraft += "select [Text]=CText,[Value]=CValue from Edic where KeyValue='Type'";
                //    }
                //}
                //else
                //{
                //    sqltype += "select [Text]=CText,[Value]=CValue from Edic where KeyValue='MainType'";
                //    sqldraft += "select [Text]=CText,[Value]=CValue from Edic where KeyValue='Type'";
                //}
                DataTable dttype = dbc.GetData("eReimbursement", sqltype);
                StoreType.DataSource = dttype;
                StoreType.DataBind();
                DataTable dtdraft = dbc.GetData("eReimbursement", sqldraft);
                StoreDraft.DataSource = dtdraft;
                StoreDraft.DataBind();

                //载入半年内申请
                string sqldate = " and ApplyDate >='" + DateTime.Now.AddMonths(-6).Date.ToString() + "' and ApplyDate <='" + DateTime.Now.AddDays(1).Date.ToString() + "'";
                BindData(sqldate);
            }
        }
Пример #17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                cs.DBCommand dbc = new cs.DBCommand();
                //取得基本信息
                //if (Request.QueryString["RequestID"] == null)
                //{
                //    ErrorHandle("Data Error."); return;
                //}

                if (Request.QueryString["RequestID"] != null && Request.QueryString["Type"] != null)
                {
                    string ID   = Request.QueryString["RequestID"].ToString();
                    string Type = Request.QueryString["Type"].ToString();
                    System.Text.RegularExpressions.Regex reg1 = new System.Text.RegularExpressions.Regex(@"^\d*$");
                    if (reg1.IsMatch(ID))
                    {
                        string    sql1 = "select * from V_Eflow_ETravel where RequestID=" + ID + " and [Type]='" + Type + "' order by Step,FlowID";
                        DataTable dt1  = new DataTable();
                        dt1 = dbc.GetData("eReimbursement", sql1);
                        if (dt1 != null && dt1.Rows.Count > 0)
                        {
                            //取得明细信息
                            if (Type == "T")
                            {
                                string sql = "select * from ETraveleDetail where [No]=" + ID + " order by ID";

                                DataTable        dtDetail = dbc.GetData("eReimbursement", sql);
                                List <Detail>    list     = new List <Detail>();
                                List <DetailAll> listall  = new List <DetailAll>();
                                DataTable        dtall    = new DataTable();
                                dtall.Columns.Add("Tocity", typeof(String));
                                dtall.Columns.Add("Date1", typeof(String));
                                dtall.Columns.Add("Date2", typeof(String));
                                for (int i = 0; i < 11; i++)
                                {
                                    dtall.Columns.Add("P" + i.ToString(), typeof(Decimal));
                                    dtall.Columns.Add("C" + i.ToString(), typeof(Decimal));
                                }
                                for (int i = 0; i < dtDetail.Rows.Count; i++)
                                {
                                    if (i % 11 == 0)
                                    {
                                        DataRow dr = dtall.NewRow();
                                        dtall.Rows.Add(dr);
                                        dtall.Rows[i / 11]["Tocity"] = dtDetail.Rows[i]["Tocity"].ToString();
                                        dtall.Rows[i / 11]["Date1"]  = Convert.ToDateTime(dtDetail.Rows[i]["Tdate0"].ToString()).ToString("yyyy/MM/dd");
                                        dtall.Rows[i / 11]["Date2"]  = Convert.ToDateTime(dtDetail.Rows[i]["Tdate"].ToString()).ToString("yyyy/MM/dd");
                                    }
                                    dtall.Rows[i / 11]["P" + (i % 11).ToString()] = dtDetail.Rows[i]["Pamount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Pamount"].ToString());
                                    dtall.Rows[i / 11]["C" + (i % 11).ToString()] = dtDetail.Rows[i]["Camount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Camount"].ToString());
                                }

                                //组成3*i的Datatable
                                DataTable dtnew = new DataTable();
                                dtnew.Columns.Add("Tocity", typeof(String));
                                dtnew.Columns.Add("Date1", typeof(String));
                                dtnew.Columns.Add("Date2", typeof(String));
                                dtnew.Columns.Add("Pamount", typeof(String)); //P0,P1,...,P10
                                dtnew.Columns.Add("Camount", typeof(String)); //C0,C1,...,C10
                                for (int i = 0; i < dtall.Rows.Count; i++)
                                {
                                    DataRow dr = dtnew.NewRow();
                                    dr["Tocity"] = dtall.Rows[i]["Tocity"].ToString();
                                    dr["Date1"]  = dtall.Rows[i]["Date1"].ToString();
                                    dr["Date2"]  = dtall.Rows[i]["Date2"].ToString();
                                    string Pamount = "";
                                    Pamount      += (string.IsNullOrEmpty(dtall.Rows[i]["P0"].ToString()) ? "0" : dtall.Rows[i]["P0"].ToString()) + ",";
                                    Pamount      += (string.IsNullOrEmpty(dtall.Rows[i]["P1"].ToString()) ? "0" : dtall.Rows[i]["P1"].ToString()) + ",";
                                    Pamount      += (string.IsNullOrEmpty(dtall.Rows[i]["P2"].ToString()) ? "0" : dtall.Rows[i]["P2"].ToString()) + ",";
                                    Pamount      += (string.IsNullOrEmpty(dtall.Rows[i]["P3"].ToString()) ? "0" : dtall.Rows[i]["P3"].ToString()) + ",";
                                    Pamount      += (string.IsNullOrEmpty(dtall.Rows[i]["P4"].ToString()) ? "0" : dtall.Rows[i]["P4"].ToString()) + ",";
                                    Pamount      += (string.IsNullOrEmpty(dtall.Rows[i]["P5"].ToString()) ? "0" : dtall.Rows[i]["P5"].ToString()) + ",";
                                    Pamount      += (string.IsNullOrEmpty(dtall.Rows[i]["P6"].ToString()) ? "0" : dtall.Rows[i]["P6"].ToString()) + ",";
                                    Pamount      += (string.IsNullOrEmpty(dtall.Rows[i]["P7"].ToString()) ? "0" : dtall.Rows[i]["P7"].ToString()) + ",";
                                    Pamount      += (string.IsNullOrEmpty(dtall.Rows[i]["P8"].ToString()) ? "0" : dtall.Rows[i]["P8"].ToString()) + ",";
                                    Pamount      += (string.IsNullOrEmpty(dtall.Rows[i]["P9"].ToString()) ? "0" : dtall.Rows[i]["P9"].ToString()) + ",";
                                    Pamount      += string.IsNullOrEmpty(dtall.Rows[i]["P10"].ToString()) ? "0" : dtall.Rows[i]["P10"].ToString();
                                    dr["Pamount"] = Pamount;

                                    string Camount = "";
                                    Camount      += (string.IsNullOrEmpty(dtall.Rows[i]["C0"].ToString()) ? "0" : dtall.Rows[i]["C0"].ToString()) + ",";
                                    Camount      += (string.IsNullOrEmpty(dtall.Rows[i]["C1"].ToString()) ? "0" : dtall.Rows[i]["C1"].ToString()) + ",";
                                    Camount      += (string.IsNullOrEmpty(dtall.Rows[i]["C2"].ToString()) ? "0" : dtall.Rows[i]["C2"].ToString()) + ",";
                                    Camount      += (string.IsNullOrEmpty(dtall.Rows[i]["C3"].ToString()) ? "0" : dtall.Rows[i]["C3"].ToString()) + ",";
                                    Camount      += (string.IsNullOrEmpty(dtall.Rows[i]["C4"].ToString()) ? "0" : dtall.Rows[i]["C4"].ToString()) + ",";
                                    Camount      += (string.IsNullOrEmpty(dtall.Rows[i]["C5"].ToString()) ? "0" : dtall.Rows[i]["C5"].ToString()) + ",";
                                    Camount      += (string.IsNullOrEmpty(dtall.Rows[i]["C6"].ToString()) ? "0" : dtall.Rows[i]["C6"].ToString()) + ",";
                                    Camount      += (string.IsNullOrEmpty(dtall.Rows[i]["C7"].ToString()) ? "0" : dtall.Rows[i]["C7"].ToString()) + ",";
                                    Camount      += (string.IsNullOrEmpty(dtall.Rows[i]["C8"].ToString()) ? "0" : dtall.Rows[i]["C8"].ToString()) + ",";
                                    Camount      += (string.IsNullOrEmpty(dtall.Rows[i]["C9"].ToString()) ? "0" : dtall.Rows[i]["C9"].ToString()) + ",";
                                    Camount      += string.IsNullOrEmpty(dtall.Rows[i]["C10"].ToString()) ? "0" : dtall.Rows[i]["C10"].ToString();
                                    dr["Camount"] = Camount;

                                    dtnew.Rows.Add(dr);
                                }
                                //
                                DataTable dt = new DataTable();

                                dt.Columns.Add("Row", typeof(Int32));
                                for (int i = 0; i < 4; i++)
                                {
                                    dt.Columns.Add("Station" + i.ToString(), typeof(String));
                                    dt.Columns.Add("Station" + i.ToString() + "_P", typeof(String));
                                    dt.Columns.Add("Station" + i.ToString() + "_C", typeof(String));
                                    dt.Columns.Add("Station" + i.ToString() + "_Date1", typeof(String));
                                    dt.Columns.Add("Station" + i.ToString() + "_Date2", typeof(String));
                                }
                                for (int i = 0; i < dtnew.Rows.Count / 4 + (dtnew.Rows.Count % 4 == 0 ? 0 : 1); i++)
                                {
                                    int     index = 0;
                                    DataRow dr    = dt.NewRow();
                                    dr["Row"] = i;
                                    for (int j = 0 + i * 4; j < (dtnew.Rows.Count <= (i + 1) * 4 ? dtnew.Rows.Count : (i + 1) * 4); j++)
                                    {
                                        dr["Station" + index.ToString()]            = dtnew.Rows[j]["Tocity"].ToString();
                                        dr["Station" + index.ToString() + "_P"]     = dtnew.Rows[j]["Pamount"].ToString();
                                        dr["Station" + index.ToString() + "_C"]     = dtnew.Rows[j]["Camount"].ToString();
                                        dr["Station" + index.ToString() + "_Date1"] = dtnew.Rows[j]["Date1"].ToString();
                                        dr["Station" + index.ToString() + "_Date2"] = dtnew.Rows[j]["Date2"].ToString();
                                        index++;
                                    }
                                    dt.Rows.Add(dr);
                                }
                                for (int i = 0; i < dt.Rows.Count; i++)
                                {
                                    if (dt.Rows[i]["Station0"].ToString() == "")
                                    {
                                        dt.Rows[i]["Station0_P"] = "0,0,0,0,0,0,0,0,0,0,0";
                                        dt.Rows[i]["Station0_C"] = "0,0,0,0,0,0,0,0,0,0,0";
                                    }
                                    if (dt.Rows[i]["Station1"].ToString() == "")
                                    {
                                        dt.Rows[i]["Station1_P"] = "0,0,0,0,0,0,0,0,0,0,0";
                                        dt.Rows[i]["Station1_C"] = "0,0,0,0,0,0,0,0,0,0,0";
                                    }
                                    if (dt.Rows[i]["Station2"].ToString() == "")
                                    {
                                        dt.Rows[i]["Station2_P"] = "0,0,0,0,0,0,0,0,0,0,0";
                                        dt.Rows[i]["Station2_C"] = "0,0,0,0,0,0,0,0,0,0,0";
                                    }
                                    if (dt.Rows[i]["Station3"].ToString() == "")
                                    {
                                        dt.Rows[i]["Station3_P"] = "0,0,0,0,0,0,0,0,0,0,0";
                                        dt.Rows[i]["Station3_C"] = "0,0,0,0,0,0,0,0,0,0,0";
                                    }
                                }
                                //获取审批流程
                                DataTable dtFlow = new DataTable();
                                dtFlow.Columns.Add("Row", typeof(String));
                                dtFlow.Columns.Add("SubmitPerson", typeof(String));
                                dtFlow.Columns.Add("SubmitDate", typeof(String));
                                for (int i = 0; i < 5; i++)
                                {
                                    dtFlow.Columns.Add("Approver" + i.ToString());
                                    dtFlow.Columns.Add("Approver" + i.ToString() + "_Date");
                                }
                                if (dt1.Rows[0]["Step"].ToString() == "0")//草稿
                                {
                                    DataRow dr = dtFlow.NewRow();
                                    dr[0] = "0";
                                    dr[1] = "Submitted by:";
                                    dtFlow.Rows.Add(dr);
                                }
                                else//已正式申请
                                {
                                    for (int i = 0; i < dt1.Rows.Count; i++)
                                    {
                                        if (dt1.Rows[i]["Active"].ToString() == "2")
                                        {
                                            for (int j = dt1.Rows.Count - 1; j > i; j--)
                                            {
                                                dt1.Rows.RemoveAt(j);
                                            }
                                            break;
                                        }
                                    }
                                    for (int i = 0; i < dt1.Rows.Count / 5 + (dt1.Rows.Count % 5 == 0 ? 0 : 1); i++)
                                    {
                                        int     index = 0;
                                        DataRow dr    = dtFlow.NewRow();
                                        dr["Row"] = i;
                                        if (i == 0)//只在第一行显示一次提单人Submitted by
                                        {
                                            dr["SubmitPerson"] = "Submitted by:\n" + dt1.Rows[0]["CreadedBy"].ToString();
                                            dr["SubmitDate"]   = dt1.Rows[0]["CreadedDate"].ToString() == "" ? "" : Convert.ToDateTime(dt1.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd");
                                        }
                                        for (int j = 0 + i * 5; j < ((i + 1) * 5 > dt1.Rows.Count ? dt1.Rows.Count : (i + 1) * 5); j++)//
                                        {
                                            if (dt1.Rows[j]["Status"].ToString() == "1")
                                            {
                                                string msg1 = "";
                                                if (dt1.Rows[j]["FlowFn"].ToString().ToLower() == "verifier")
                                                {
                                                    msg1 = ". To Be Verified:";
                                                }
                                                else if (dt1.Rows[j]["FlowFn"].ToString().ToLower() == "issuer")
                                                {
                                                    msg1 = ". To Be Issued:";
                                                }
                                                else
                                                {
                                                    msg1 = ". Waiting for Approval:";
                                                }
                                                dr["Approver" + index.ToString()] = (j + 1).ToString() + msg1 + "\n" + dt1.Rows[j]["Approver"].ToString();
                                                //dr["Approver" + index.ToString() + "_Date"] = dt1.Rows[j]["ApproveDate"].ToString() == "" ? "Pending" : Convert.ToDateTime(dt1.Rows[j]["ApproveDate"].ToString()).ToString("yyyy/MM/dd");
                                            }
                                            else if (dt1.Rows[j]["Status"].ToString() == "2")
                                            {
                                                string msg1 = "";
                                                if (dt1.Rows[j]["FlowFn"].ToString().ToLower() == "verifier")
                                                {
                                                    msg1 = ". Verified by:";
                                                }
                                                else if (dt1.Rows[j]["FlowFn"].ToString().ToLower() == "issuer")
                                                {
                                                    msg1 = ". Issued by:";
                                                }
                                                else
                                                {
                                                    msg1 = ". Approved by:";
                                                }
                                                if (dt1.Rows[j]["Active"].ToString() == "2")
                                                {
                                                    dr["Approver" + index.ToString()]           = (j + 1).ToString() + msg1 + "\n" + dt1.Rows[j]["Approver"].ToString();
                                                    dr["Approver" + index.ToString() + "_Date"] = dt1.Rows[j]["ApproveDate"].ToString() == "" ? "" : ("(Complete)" + Convert.ToDateTime(dt1.Rows[j]["ApproveDate"].ToString()).ToString("yyyy/MM/dd"));
                                                }
                                                else
                                                {
                                                    dr["Approver" + index.ToString()]           = (j + 1).ToString() + msg1 + "\n" + dt1.Rows[j]["Approver"].ToString();
                                                    dr["Approver" + index.ToString() + "_Date"] = dt1.Rows[j]["ApproveDate"].ToString() == "" ? "" : Convert.ToDateTime(dt1.Rows[j]["ApproveDate"].ToString()).ToString("yyyy/MM/dd");
                                                }
                                            }
                                            else
                                            {
                                                dr["Approver" + index.ToString()]           = (j + 1).ToString() + ". Rejected by:\n" + dt1.Rows[j]["Approver"].ToString();
                                                dr["Approver" + index.ToString() + "_Date"] = dt1.Rows[j]["ApproveDate"].ToString() == "" ? "" : ("(Complete)" + Convert.ToDateTime(dt1.Rows[j]["ApproveDate"].ToString()).ToString("yyyy/MM/dd"));
                                            }
                                            index++;
                                        }
                                        dtFlow.Rows.Add(dr);
                                    }
                                }


                                ReportViewer1.ProcessingMode = ProcessingMode.Local;
                                //控制导出格式
                                RenderingExtension[] resut = ReportViewer1.LocalReport.ListRenderingExtensions();
                                foreach (RenderingExtension item in ReportViewer1.LocalReport.ListRenderingExtensions())
                                {
                                    // item 具有Visable属性,但是这个属性是只读属性,不能修改,所以通过反射进行了修改
                                    if (item.Name.ToUpper() == "PDF")
                                    {
                                        // 显示excel2003格式导出按钮
                                        FieldInfo fi = item.GetType().GetField("m_isVisible", BindingFlags.Instance | BindingFlags.NonPublic);
                                        fi.SetValue(item, true);
                                    }
                                    else
                                    {
                                        FieldInfo fi = item.GetType().GetField("m_isVisible", BindingFlags.Instance | BindingFlags.NonPublic);
                                        fi.SetValue(item, false);
                                    }
                                }
                                ReportViewer1.LocalReport.SetBasePermissionsForSandboxAppDomain(new PermissionSet(PermissionState.Unrestricted));
                                ReportViewer1.LocalReport.ReportPath = MapPath("~/rdlc/ReportT.rdlc");
                                ReportViewer1.LocalReport.DataSources.Clear();

                                ReportDataSource rds = new ReportDataSource("DataSet1", dt);
                                ReportViewer1.LocalReport.DataSources.Add(rds);
                                ReportDataSource rds2 = new ReportDataSource("DataSet2", dtFlow);
                                ReportViewer1.LocalReport.DataSources.Add(rds2);

                                ReportParameter rpCur = new ReportParameter("Currency", dt1.Rows[0]["Cur"].ToString());
                                ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rpCur });
                                ReportParameter rp = new ReportParameter("Person", dt1.Rows[0]["Person"].ToString());
                                ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp });

                                ReportParameter rpDocNo = new ReportParameter("DocNo", dt1.Rows[0]["No"].ToString());
                                ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rpDocNo });

                                ReportParameter rpRemark = new ReportParameter("Remark", dt1.Rows[0]["Remark"].ToString());
                                ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rpRemark });

                                string          budget   = dt1.Rows[0]["Budget"].ToString() == "1" ? "Budgeted" : "UnBudgeted";
                                ReportParameter rpBudget = new ReportParameter("Budget", budget);
                                ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rpBudget });

                                string bb = "";
                                if (dt1.Rows[0]["Bdate"].ToString() != "")
                                {
                                    bb += Convert.ToDateTime(dt1.Rows[0]["Bdate"].ToString()).ToString("yyyy/MM/dd");
                                }
                                if (dt1.Rows[0]["Edate"].ToString() != "")
                                {
                                    bb += " - " + Convert.ToDateTime(dt1.Rows[0]["Edate"].ToString()).ToString("yyyy/MM/dd");
                                }
                                ReportParameter rpTravelPeriod = new ReportParameter("Period", bb);
                                ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rpTravelPeriod });

                                ReportViewer1.LocalReport.Refresh();
                            }
                            else if (Type == "G")
                            {
                                string aName = "";
                                if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                                {
                                    aName = "ADes";
                                }
                                else
                                {
                                    aName = "SAccountName";
                                }
                                string    sql      = "select [AName]=t2." + aName + ",CONVERT(varchar, Tdate, 111) as Tdate1,t1.ID,t1.Type,t1.Amount,t1.TSation,t1.Fcity,t1.Tcity,t1.Ecompany,t1.Eperson,CONVERT(varchar, t1.EffectTime, 111) as ET,t1.Months,t1.AccountDes from (select * from EeommonDetail where [No]='" + ID + "') t1 left join AccoundCode t2 on t2.SAccountCode=t1.AccountCode order by [Type],[AccountCode]";
                                DataTable dtDetail = new DataTable();
                                dtDetail = dbc.GetData("eReimbursement", sql);

                                DataTable dt = new DataTable();
                                dt.Columns.Add("AName", typeof(String));
                                dt.Columns.Add("Tdate1", typeof(String));
                                dt.Columns.Add("ID", typeof(String));
                                dt.Columns.Add("Type", typeof(String));
                                dt.Columns.Add("Amount", typeof(String));
                                dt.Columns.Add("TSation", typeof(String));
                                dt.Columns.Add("Fcity", typeof(String));
                                dt.Columns.Add("Tcity", typeof(String));
                                dt.Columns.Add("Ecompany", typeof(String));
                                dt.Columns.Add("Eperson", typeof(String));
                                dt.Columns.Add("Months", typeof(String));
                                dt.Columns.Add("AccountDes", typeof(String));
                                dt.Columns.Add("Mark", typeof(String));
                                //int ECount = 0; int TCount = 0; int CCount = 0; int OCount = 0;
                                decimal total = 0;
                                for (int i = 0; i < dtDetail.Rows.Count; i++)
                                {
                                    total += dtDetail.Rows[i]["Amount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Amount"].ToString());
                                    //添加分类标题行
                                    if (dtDetail.Rows[i]["Type"].ToString() == "E")
                                    {
                                        if (i == 0 || (dtDetail.Rows[i - 1]["Type"].ToString() != "E"))
                                        {
                                            DataRow dr = dt.NewRow();
                                            dr["ID"]     = "E1";
                                            dr["AName"]  = "Entertainment:";
                                            dr["Amount"] = "0";
                                            dr["Mark"]   = "-1";
                                            dt.Rows.Add(dr);
                                            dr               = dt.NewRow();
                                            dr["ID"]         = "E2";
                                            dr["AName"]      = "Expense Type";
                                            dr["Tdate1"]     = "Date";
                                            dr["Type"]       = "";
                                            dr["Amount"]     = "0";
                                            dr["TSation"]    = "Cost Center";
                                            dr["Fcity"]      = "";
                                            dr["Tcity"]      = "";
                                            dr["Ecompany"]   = "Customer";
                                            dr["Eperson"]    = "Guest";
                                            dr["Months"]     = "";
                                            dr["AccountDes"] = "Remark";
                                            dr["Mark"]       = "-1";
                                            dt.Rows.Add(dr);
                                        }
                                    }
                                    else if (dtDetail.Rows[i]["Type"].ToString() == "T")
                                    {
                                        if (i == 0 || (dtDetail.Rows[i - 1]["Type"].ToString() != "T"))
                                        {
                                            DataRow dr = dt.NewRow();
                                            dr["ID"]     = "T1";
                                            dr["AName"]  = "Transportation:";
                                            dr["Amount"] = "0";
                                            dr["Mark"]   = "-1";
                                            dt.Rows.Add(dr);
                                            dr               = dt.NewRow();
                                            dr["ID"]         = "T2";
                                            dr["AName"]      = "Expense Type";
                                            dr["Tdate1"]     = "Date";
                                            dr["Type"]       = "";
                                            dr["Amount"]     = "0";
                                            dr["TSation"]    = "Cost Center";
                                            dr["Fcity"]      = "";
                                            dr["Tcity"]      = "";
                                            dr["Ecompany"]   = "Origin";
                                            dr["Eperson"]    = "Destination";
                                            dr["Months"]     = "";
                                            dr["AccountDes"] = "Remark";
                                            dt.Rows.Add(dr);
                                        }
                                    }
                                    else if (dtDetail.Rows[i]["Type"].ToString() == "C")
                                    {
                                        if (i == 0 || (dtDetail.Rows[i - 1]["Type"].ToString() != "C"))
                                        {
                                            DataRow dr = dt.NewRow();
                                            dr["ID"]     = "C1";
                                            dr["AName"]  = "Communication:";
                                            dr["Amount"] = "0";
                                            dr["Mark"]   = "-1";
                                            dt.Rows.Add(dr);
                                            dr               = dt.NewRow();
                                            dr["ID"]         = "C2";
                                            dr["AName"]      = "Expense Type";
                                            dr["Tdate1"]     = "Period";
                                            dr["Type"]       = "";
                                            dr["Amount"]     = "0";
                                            dr["TSation"]    = "Cost Center";
                                            dr["Fcity"]      = "";
                                            dr["Tcity"]      = "";
                                            dr["Ecompany"]   = "";
                                            dr["Eperson"]    = "";
                                            dr["Months"]     = "";
                                            dr["AccountDes"] = "Remark";
                                            dr["Mark"]       = "-1";
                                            dt.Rows.Add(dr);
                                        }
                                    }
                                    else
                                    {
                                        if (i == 0 || (dtDetail.Rows[i - 1]["Type"].ToString() != "O"))
                                        {
                                            DataRow dr = dt.NewRow();
                                            dr["ID"]     = "O1";
                                            dr["AName"]  = "Others:";
                                            dr["Amount"] = "0";
                                            dr["Mark"]   = "-1";
                                            dt.Rows.Add(dr);
                                            dr               = dt.NewRow();
                                            dr["ID"]         = "O2";
                                            dr["AName"]      = "Expense Type";
                                            dr["Tdate1"]     = "Date";
                                            dr["Type"]       = "";
                                            dr["Amount"]     = "0";
                                            dr["TSation"]    = "Cost Center";
                                            dr["Fcity"]      = "";
                                            dr["Tcity"]      = "";
                                            dr["Ecompany"]   = "";
                                            dr["Eperson"]    = "";
                                            dr["Months"]     = "";
                                            dr["AccountDes"] = "Remark";
                                            dt.Rows.Add(dr);
                                        }
                                    }
                                    DataRow drdetail = dt.NewRow();
                                    drdetail["AName"] = dtDetail.Rows[i]["AName"].ToString();
                                    if (dtDetail.Rows[i]["Type"].ToString() == "C")
                                    {
                                        drdetail["Tdate1"] = dtDetail.Rows[i]["ET"].ToString();
                                    }
                                    else
                                    {
                                        drdetail["Tdate1"] = dtDetail.Rows[i]["Tdate1"].ToString();
                                    }
                                    drdetail["ID"]         = dtDetail.Rows[i]["ID"].ToString();
                                    drdetail["Type"]       = dtDetail.Rows[i]["Type"].ToString();
                                    drdetail["Amount"]     = dtDetail.Rows[i]["Amount"].ToString();
                                    drdetail["TSation"]    = dtDetail.Rows[i]["TSation"].ToString();
                                    drdetail["Fcity"]      = dtDetail.Rows[i]["Fcity"].ToString();
                                    drdetail["Tcity"]      = dtDetail.Rows[i]["Tcity"].ToString();
                                    drdetail["Ecompany"]   = dtDetail.Rows[i]["Ecompany"].ToString();
                                    drdetail["Eperson"]    = dtDetail.Rows[i]["Eperson"].ToString();
                                    drdetail["Months"]     = dtDetail.Rows[i]["Months"].ToString();
                                    drdetail["AccountDes"] = dtDetail.Rows[i]["AccountDes"].ToString();
                                    dt.Rows.Add(drdetail);

                                    //if (dtDetail.Rows[i]["Type"].ToString() == "E")
                                    //{
                                    //    ECount++;
                                    //}
                                    //else if (dtDetail.Rows[i]["Type"].ToString() == "T")
                                    //{
                                    //    TCount++;
                                    //}
                                    //else if (dtDetail.Rows[i]["Type"].ToString() == "C")
                                    //{
                                    //    CCount++;
                                    //}
                                    //else
                                    //{
                                    //    OCount++;
                                    //}
                                }
                                //获取审批流程
                                DataTable dtFlow = new DataTable();
                                dtFlow.Columns.Add("Row", typeof(String));
                                dtFlow.Columns.Add("SubmitPerson", typeof(String));
                                dtFlow.Columns.Add("SubmitDate", typeof(String));
                                for (int i = 0; i < 6; i++)
                                {
                                    dtFlow.Columns.Add("Approver" + i.ToString());
                                    dtFlow.Columns.Add("Approver" + i.ToString() + "_Date");
                                }
                                if (dt1.Rows[0]["Step"].ToString() == "0")//草稿
                                {
                                    DataRow dr = dtFlow.NewRow();
                                    dr[0] = "0";
                                    dr[1] = "Submitted by:";
                                    dtFlow.Rows.Add(dr);
                                }
                                else//已正式申请
                                {
                                    for (int i = 0; i < dt1.Rows.Count; i++)
                                    {
                                        if (dt1.Rows[i]["Active"].ToString() == "2")
                                        {
                                            for (int j = dt1.Rows.Count - 1; j > i; j--)
                                            {
                                                dt1.Rows.RemoveAt(j);
                                            }
                                            break;
                                        }
                                    }
                                    for (int i = 0; i < dt1.Rows.Count / 6 + (dt1.Rows.Count % 6 == 0 ? 0 : 1); i++)
                                    {
                                        int     index = 0;
                                        DataRow dr    = dtFlow.NewRow();
                                        dr["Row"] = i;
                                        if (i == 0)//只在第一行显示一次提单人Submitted by
                                        {
                                            dr["SubmitPerson"] = "Submitted by:\n" + dt1.Rows[0]["CreadedBy"].ToString();
                                            dr["SubmitDate"]   = dt1.Rows[0]["CreadedDate"].ToString() == "" ? "" : Convert.ToDateTime(dt1.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd");
                                        }
                                        for (int j = 0 + i * 6; j < ((i + 1) * 6 > dt1.Rows.Count ? dt1.Rows.Count : (i + 1) * 6); j++)//
                                        {
                                            if (dt1.Rows[j]["Status"].ToString() == "1")
                                            {
                                                string msg1 = "";
                                                if (dt1.Rows[j]["FlowFn"].ToString().ToLower() == "verifier")
                                                {
                                                    msg1 = ". To Be Verified:";
                                                }
                                                else if (dt1.Rows[j]["FlowFn"].ToString().ToLower() == "issuer")
                                                {
                                                    msg1 = ". To Be Issued:";
                                                }
                                                else
                                                {
                                                    msg1 = ". Waiting for Approval:";
                                                }
                                                dr["Approver" + index.ToString()] = (j + 1).ToString() + msg1 + "\n" + dt1.Rows[j]["Approver"].ToString();
                                                //dr["Approver" + index.ToString() + "_Date"] = dt1.Rows[j]["ApproveDate"].ToString() == "" ? "Pending" : Convert.ToDateTime(dt1.Rows[j]["ApproveDate"].ToString()).ToString("yyyy/MM/dd");
                                            }
                                            else if (dt1.Rows[j]["Status"].ToString() == "2")
                                            {
                                                string msg1 = "";
                                                if (dt1.Rows[j]["FlowFn"].ToString().ToLower() == "verifier")
                                                {
                                                    msg1 = ". Verified by:";
                                                }
                                                else if (dt1.Rows[j]["FlowFn"].ToString().ToLower() == "issuer")
                                                {
                                                    msg1 = ". Issued by:";
                                                }
                                                else
                                                {
                                                    msg1 = ". Approved by:";
                                                }

                                                if (dt1.Rows[j]["Active"].ToString() == "2")
                                                {
                                                    dr["Approver" + index.ToString()]           = (j + 1).ToString() + msg1 + "\n" + dt1.Rows[j]["Approver"].ToString();
                                                    dr["Approver" + index.ToString() + "_Date"] = dt1.Rows[j]["ApproveDate"].ToString() == "" ? "" : ("(Complete)" + Convert.ToDateTime(dt1.Rows[j]["ApproveDate"].ToString()).ToString("yyyy/MM/dd"));
                                                }
                                                else
                                                {
                                                    dr["Approver" + index.ToString()]           = (j + 1).ToString() + msg1 + "\n" + dt1.Rows[j]["Approver"].ToString();
                                                    dr["Approver" + index.ToString() + "_Date"] = dt1.Rows[j]["ApproveDate"].ToString() == "" ? "" : Convert.ToDateTime(dt1.Rows[j]["ApproveDate"].ToString()).ToString("yyyy/MM/dd");
                                                }
                                            }
                                            else
                                            {
                                                dr["Approver" + index.ToString()]           = (j + 1).ToString() + ". Rejected by:\n" + dt1.Rows[j]["Approver"].ToString();
                                                dr["Approver" + index.ToString() + "_Date"] = dt1.Rows[j]["ApproveDate"].ToString() == "" ? "" : ("(Complete)" + Convert.ToDateTime(dt1.Rows[j]["ApproveDate"].ToString()).ToString("yyyy/MM/dd"));
                                            }
                                            index++;
                                        }
                                        dtFlow.Rows.Add(dr);
                                    }
                                }

                                ReportViewer1.ProcessingMode = ProcessingMode.Local;
                                //控制导出格式
                                RenderingExtension[] resut = ReportViewer1.LocalReport.ListRenderingExtensions();
                                foreach (RenderingExtension item in ReportViewer1.LocalReport.ListRenderingExtensions())
                                {
                                    // item 具有Visable属性,但是这个属性是只读属性,不能修改,所以通过反射进行了修改
                                    if (item.Name.ToUpper() == "PDF")
                                    {
                                        // 显示excel2003格式导出按钮
                                        FieldInfo fi = item.GetType().GetField("m_isVisible", BindingFlags.Instance | BindingFlags.NonPublic);
                                        fi.SetValue(item, true);
                                    }
                                    else
                                    {
                                        FieldInfo fi = item.GetType().GetField("m_isVisible", BindingFlags.Instance | BindingFlags.NonPublic);
                                        fi.SetValue(item, false);
                                    }
                                }

                                ReportViewer1.LocalReport.ReportPath = MapPath("~/rdlc/ReportG1.rdlc");
                                ReportViewer1.LocalReport.DataSources.Clear();

                                ReportDataSource rds = new ReportDataSource("DataSet1", dt);
                                ReportViewer1.LocalReport.DataSources.Add(rds);

                                ReportDataSource rds2 = new ReportDataSource("DataSet2", dtFlow);
                                ReportViewer1.LocalReport.DataSources.Add(rds2);

                                ReportParameter rpCur = new ReportParameter("Currency", dt1.Rows[0]["Cur"].ToString());
                                ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rpCur });

                                ReportParameter rp = new ReportParameter("Person", dt1.Rows[0]["Person"].ToString());
                                ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp });

                                ReportParameter rpMonth = new ReportParameter("Month", dt1.Rows[0]["Month"].ToString());
                                ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rpMonth });

                                ReportParameter rpSum = new ReportParameter("Sum", total.ToString());
                                ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rpSum });

                                ReportParameter rpRows = new ReportParameter("Rows", dt.Rows.Count.ToString());
                                ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rpRows });

                                ReportParameter rpDepartment = new ReportParameter("Department", dt1.Rows[0]["Department"].ToString() + " @ " + dt1.Rows[0]["Station"].ToString());
                                ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rpDepartment });

                                string          budget   = dt1.Rows[0]["Budget"].ToString() == "1" ? "Budgeted" : "UnBudgeted";
                                ReportParameter rpBudget = new ReportParameter("Budget", budget);
                                ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rpBudget });

                                ReportViewer1.LocalReport.Refresh();
                            }
                        }
                    }
                }
            }
        }
Пример #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                cs.DBCommand dbc = new cs.DBCommand();
                //取得基本信息
                //if (Request.QueryString["RequestID"] == null)
                //{
                //    ErrorHandle("Data Error."); return;
                //}

                if (Request.QueryString["RequestID"] != null && Request.QueryString["Type"] != null)
                {
                    string ID = Request.QueryString["RequestID"].ToString();
                    string Type = Request.QueryString["Type"].ToString();
                    System.Text.RegularExpressions.Regex reg1 = new System.Text.RegularExpressions.Regex(@"^\d*$");
                    if (reg1.IsMatch(ID))
                    {
                        string sql1 = "select * from V_Eflow_ETravel where RequestID=" + ID + " and [Type]='" + Type + "' order by Step,FlowID";
                        DataTable dt1 = new DataTable();
                        dt1 = dbc.GetData("eReimbursement", sql1);
                        if (dt1 != null && dt1.Rows.Count > 0)
                        {
                            //取得明细信息
                            if (Type == "T")
                            {
                                string sql = "select * from ETraveleDetail where [No]=" + ID + " order by ID";

                                DataTable dtDetail = dbc.GetData("eReimbursement", sql);
                                List<Detail> list = new List<Detail>();
                                List<DetailAll> listall = new List<DetailAll>();
                                DataTable dtall = new DataTable();
                                dtall.Columns.Add("Tocity", typeof(String));
                                dtall.Columns.Add("Date1", typeof(String));
                                dtall.Columns.Add("Date2", typeof(String));
                                for (int i = 0; i < 11; i++)
                                {
                                    dtall.Columns.Add("P" + i.ToString(), typeof(Decimal));
                                    dtall.Columns.Add("C" + i.ToString(), typeof(Decimal));
                                }
                                for (int i = 0; i < dtDetail.Rows.Count; i++)
                                {
                                    if (i % 11 == 0)
                                    {
                                        DataRow dr = dtall.NewRow();
                                        dtall.Rows.Add(dr);
                                        dtall.Rows[i / 11]["Tocity"] = dtDetail.Rows[i]["Tocity"].ToString();
                                        dtall.Rows[i / 11]["Date1"] = Convert.ToDateTime(dtDetail.Rows[i]["Tdate0"].ToString()).ToString("yyyy/MM/dd");
                                        dtall.Rows[i / 11]["Date2"] = Convert.ToDateTime(dtDetail.Rows[i]["Tdate"].ToString()).ToString("yyyy/MM/dd");
                                    }
                                    dtall.Rows[i / 11]["P" + (i % 11).ToString()] = dtDetail.Rows[i]["Pamount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Pamount"].ToString());
                                    dtall.Rows[i / 11]["C" + (i % 11).ToString()] = dtDetail.Rows[i]["Camount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Camount"].ToString());
                                }

                                //组成3*i的Datatable
                                DataTable dtnew = new DataTable();
                                dtnew.Columns.Add("Tocity", typeof(String));
                                dtnew.Columns.Add("Date1", typeof(String));
                                dtnew.Columns.Add("Date2", typeof(String));
                                dtnew.Columns.Add("Pamount", typeof(String));//P0,P1,...,P10
                                dtnew.Columns.Add("Camount", typeof(String));//C0,C1,...,C10
                                for (int i = 0; i < dtall.Rows.Count; i++)
                                {
                                    DataRow dr = dtnew.NewRow();
                                    dr["Tocity"] = dtall.Rows[i]["Tocity"].ToString();
                                    dr["Date1"] = dtall.Rows[i]["Date1"].ToString();
                                    dr["Date2"] = dtall.Rows[i]["Date2"].ToString();
                                    string Pamount = "";
                                    Pamount += (string.IsNullOrEmpty(dtall.Rows[i]["P0"].ToString()) ? "0" : dtall.Rows[i]["P0"].ToString()) + ",";
                                    Pamount += (string.IsNullOrEmpty(dtall.Rows[i]["P1"].ToString()) ? "0" : dtall.Rows[i]["P1"].ToString()) + ",";
                                    Pamount += (string.IsNullOrEmpty(dtall.Rows[i]["P2"].ToString()) ? "0" : dtall.Rows[i]["P2"].ToString()) + ",";
                                    Pamount += (string.IsNullOrEmpty(dtall.Rows[i]["P3"].ToString()) ? "0" : dtall.Rows[i]["P3"].ToString()) + ",";
                                    Pamount += (string.IsNullOrEmpty(dtall.Rows[i]["P4"].ToString()) ? "0" : dtall.Rows[i]["P4"].ToString()) + ",";
                                    Pamount += (string.IsNullOrEmpty(dtall.Rows[i]["P5"].ToString()) ? "0" : dtall.Rows[i]["P5"].ToString()) + ",";
                                    Pamount += (string.IsNullOrEmpty(dtall.Rows[i]["P6"].ToString()) ? "0" : dtall.Rows[i]["P6"].ToString()) + ",";
                                    Pamount += (string.IsNullOrEmpty(dtall.Rows[i]["P7"].ToString()) ? "0" : dtall.Rows[i]["P7"].ToString()) + ",";
                                    Pamount += (string.IsNullOrEmpty(dtall.Rows[i]["P8"].ToString()) ? "0" : dtall.Rows[i]["P8"].ToString()) + ",";
                                    Pamount += (string.IsNullOrEmpty(dtall.Rows[i]["P9"].ToString()) ? "0" : dtall.Rows[i]["P9"].ToString()) + ",";
                                    Pamount += string.IsNullOrEmpty(dtall.Rows[i]["P10"].ToString()) ? "0" : dtall.Rows[i]["P10"].ToString();
                                    dr["Pamount"] = Pamount;

                                    string Camount = "";
                                    Camount += (string.IsNullOrEmpty(dtall.Rows[i]["C0"].ToString()) ? "0" : dtall.Rows[i]["C0"].ToString()) + ",";
                                    Camount += (string.IsNullOrEmpty(dtall.Rows[i]["C1"].ToString()) ? "0" : dtall.Rows[i]["C1"].ToString()) + ",";
                                    Camount += (string.IsNullOrEmpty(dtall.Rows[i]["C2"].ToString()) ? "0" : dtall.Rows[i]["C2"].ToString()) + ",";
                                    Camount += (string.IsNullOrEmpty(dtall.Rows[i]["C3"].ToString()) ? "0" : dtall.Rows[i]["C3"].ToString()) + ",";
                                    Camount += (string.IsNullOrEmpty(dtall.Rows[i]["C4"].ToString()) ? "0" : dtall.Rows[i]["C4"].ToString()) + ",";
                                    Camount += (string.IsNullOrEmpty(dtall.Rows[i]["C5"].ToString()) ? "0" : dtall.Rows[i]["C5"].ToString()) + ",";
                                    Camount += (string.IsNullOrEmpty(dtall.Rows[i]["C6"].ToString()) ? "0" : dtall.Rows[i]["C6"].ToString()) + ",";
                                    Camount += (string.IsNullOrEmpty(dtall.Rows[i]["C7"].ToString()) ? "0" : dtall.Rows[i]["C7"].ToString()) + ",";
                                    Camount += (string.IsNullOrEmpty(dtall.Rows[i]["C8"].ToString()) ? "0" : dtall.Rows[i]["C8"].ToString()) + ",";
                                    Camount += (string.IsNullOrEmpty(dtall.Rows[i]["C9"].ToString()) ? "0" : dtall.Rows[i]["C9"].ToString()) + ",";
                                    Camount += string.IsNullOrEmpty(dtall.Rows[i]["C10"].ToString()) ? "0" : dtall.Rows[i]["C10"].ToString();
                                    dr["Camount"] = Camount;

                                    dtnew.Rows.Add(dr);
                                }
                                //
                                DataTable dt = new DataTable();

                                dt.Columns.Add("Row", typeof(Int32));
                                for (int i = 0; i < 4; i++)
                                {
                                    dt.Columns.Add("Station" + i.ToString(), typeof(String));
                                    dt.Columns.Add("Station" + i.ToString() + "_P", typeof(String));
                                    dt.Columns.Add("Station" + i.ToString() + "_C", typeof(String));
                                    dt.Columns.Add("Station" + i.ToString() + "_Date1", typeof(String));
                                    dt.Columns.Add("Station" + i.ToString() + "_Date2", typeof(String));
                                }
                                for (int i = 0; i < dtnew.Rows.Count / 4 + (dtnew.Rows.Count % 4 == 0 ? 0 : 1); i++)
                                {
                                    int index = 0;
                                    DataRow dr = dt.NewRow();
                                    dr["Row"] = i;
                                    for (int j = 0 + i * 4; j < (dtnew.Rows.Count <= (i + 1) * 4 ? dtnew.Rows.Count : (i + 1) * 4); j++)
                                    {
                                        dr["Station" + index.ToString()] = dtnew.Rows[j]["Tocity"].ToString();
                                        dr["Station" + index.ToString() + "_P"] = dtnew.Rows[j]["Pamount"].ToString();
                                        dr["Station" + index.ToString() + "_C"] = dtnew.Rows[j]["Camount"].ToString();
                                        dr["Station" + index.ToString() + "_Date1"] = dtnew.Rows[j]["Date1"].ToString();
                                        dr["Station" + index.ToString() + "_Date2"] = dtnew.Rows[j]["Date2"].ToString();
                                        index++;
                                    }
                                    dt.Rows.Add(dr);
                                }
                                for (int i = 0; i < dt.Rows.Count; i++)
                                {
                                    if (dt.Rows[i]["Station0"].ToString() == "")
                                    {
                                        dt.Rows[i]["Station0_P"] = "0,0,0,0,0,0,0,0,0,0,0";
                                        dt.Rows[i]["Station0_C"] = "0,0,0,0,0,0,0,0,0,0,0";
                                    }
                                    if (dt.Rows[i]["Station1"].ToString() == "")
                                    {
                                        dt.Rows[i]["Station1_P"] = "0,0,0,0,0,0,0,0,0,0,0";
                                        dt.Rows[i]["Station1_C"] = "0,0,0,0,0,0,0,0,0,0,0";
                                    }
                                    if (dt.Rows[i]["Station2"].ToString() == "")
                                    {
                                        dt.Rows[i]["Station2_P"] = "0,0,0,0,0,0,0,0,0,0,0";
                                        dt.Rows[i]["Station2_C"] = "0,0,0,0,0,0,0,0,0,0,0";
                                    }
                                    if (dt.Rows[i]["Station3"].ToString() == "")
                                    {
                                        dt.Rows[i]["Station3_P"] = "0,0,0,0,0,0,0,0,0,0,0";
                                        dt.Rows[i]["Station3_C"] = "0,0,0,0,0,0,0,0,0,0,0";
                                    }
                                }
                                //获取审批流程
                                DataTable dtFlow = new DataTable();
                                dtFlow.Columns.Add("Row", typeof(String));
                                dtFlow.Columns.Add("SubmitPerson", typeof(String));
                                dtFlow.Columns.Add("SubmitDate", typeof(String));
                                for (int i = 0; i < 5; i++)
                                {
                                    dtFlow.Columns.Add("Approver" + i.ToString());
                                    dtFlow.Columns.Add("Approver" + i.ToString() + "_Date");
                                }
                                if (dt1.Rows[0]["Step"].ToString() == "0")//草稿
                                {
                                    DataRow dr = dtFlow.NewRow();
                                    dr[0] = "0";
                                    dr[1] = "Submitted by:";
                                    dtFlow.Rows.Add(dr);
                                }
                                else//已正式申请
                                {
                                    for (int i = 0; i < dt1.Rows.Count; i++)
                                    {
                                        if (dt1.Rows[i]["Active"].ToString() == "2")
                                        {
                                            for (int j = dt1.Rows.Count - 1; j > i; j--)
                                            {
                                                dt1.Rows.RemoveAt(j);
                                            }
                                            break;
                                        }
                                    }
                                    for (int i = 0; i < dt1.Rows.Count / 5 + (dt1.Rows.Count % 5 == 0 ? 0 : 1); i++)
                                    {
                                        int index = 0;
                                        DataRow dr = dtFlow.NewRow();
                                        dr["Row"] = i;
                                        if (i == 0)//只在第一行显示一次提单人Submitted by
                                        {
                                            dr["SubmitPerson"] = "Submitted by:\n" + dt1.Rows[0]["CreadedBy"].ToString();
                                            dr["SubmitDate"] = dt1.Rows[0]["CreadedDate"].ToString() == "" ? "" : Convert.ToDateTime(dt1.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd");
                                        }
                                        for (int j = 0 + i * 5; j < ((i + 1) * 5 > dt1.Rows.Count ? dt1.Rows.Count : (i + 1) * 5); j++)//
                                        {
                                            if (dt1.Rows[j]["Status"].ToString() == "1")
                                            {
                                                string msg1 = "";
                                                if (dt1.Rows[j]["FlowFn"].ToString().ToLower() == "verifier")
                                                {
                                                    msg1 = ". To Be Verified:";
                                                }
                                                else if (dt1.Rows[j]["FlowFn"].ToString().ToLower() == "issuer")
                                                {
                                                    msg1 = ". To Be Issued:";
                                                }
                                                else
                                                {
                                                    msg1 = ". Waiting for Approval:";
                                                }
                                                dr["Approver" + index.ToString()] = (j + 1).ToString() + msg1 + "\n" + dt1.Rows[j]["Approver"].ToString();
                                                //dr["Approver" + index.ToString() + "_Date"] = dt1.Rows[j]["ApproveDate"].ToString() == "" ? "Pending" : Convert.ToDateTime(dt1.Rows[j]["ApproveDate"].ToString()).ToString("yyyy/MM/dd");
                                            }
                                            else if (dt1.Rows[j]["Status"].ToString() == "2")
                                            {
                                                string msg1 = "";
                                                if (dt1.Rows[j]["FlowFn"].ToString().ToLower() == "verifier")
                                                {
                                                    msg1 = ". Verified by:";
                                                }
                                                else if (dt1.Rows[j]["FlowFn"].ToString().ToLower() == "issuer")
                                                {
                                                    msg1 = ". Issued by:";
                                                }
                                                else
                                                {
                                                    msg1 = ". Approved by:";
                                                }
                                                if (dt1.Rows[j]["Active"].ToString() == "2")
                                                {
                                                    dr["Approver" + index.ToString()] = (j + 1).ToString() + msg1 + "\n" + dt1.Rows[j]["Approver"].ToString();
                                                    dr["Approver" + index.ToString() + "_Date"] = dt1.Rows[j]["ApproveDate"].ToString() == "" ? "" : ("(Complete)" + Convert.ToDateTime(dt1.Rows[j]["ApproveDate"].ToString()).ToString("yyyy/MM/dd"));
                                                }
                                                else
                                                {
                                                    dr["Approver" + index.ToString()] = (j + 1).ToString() + msg1 + "\n" + dt1.Rows[j]["Approver"].ToString();
                                                    dr["Approver" + index.ToString() + "_Date"] = dt1.Rows[j]["ApproveDate"].ToString() == "" ? "" : Convert.ToDateTime(dt1.Rows[j]["ApproveDate"].ToString()).ToString("yyyy/MM/dd");
                                                }
                                            }
                                            else
                                            {
                                                dr["Approver" + index.ToString()] = (j + 1).ToString() + ". Rejected by:\n" + dt1.Rows[j]["Approver"].ToString();
                                                dr["Approver" + index.ToString() + "_Date"] = dt1.Rows[j]["ApproveDate"].ToString() == "" ? "" : ("(Complete)" + Convert.ToDateTime(dt1.Rows[j]["ApproveDate"].ToString()).ToString("yyyy/MM/dd"));
                                            }
                                            index++;
                                        }
                                        dtFlow.Rows.Add(dr);
                                    }
                                }


                                ReportViewer1.ProcessingMode = ProcessingMode.Local;
                                //控制导出格式
                                RenderingExtension[] resut = ReportViewer1.LocalReport.ListRenderingExtensions();
                                foreach (RenderingExtension item in ReportViewer1.LocalReport.ListRenderingExtensions())
                                {
                                    // item 具有Visable属性,但是这个属性是只读属性,不能修改,所以通过反射进行了修改
                                    if (item.Name.ToUpper() == "PDF")
                                    {
                                        // 显示excel2003格式导出按钮
                                        FieldInfo fi = item.GetType().GetField("m_isVisible", BindingFlags.Instance | BindingFlags.NonPublic);
                                        fi.SetValue(item, true);
                                    }
                                    else
                                    {
                                        FieldInfo fi = item.GetType().GetField("m_isVisible", BindingFlags.Instance | BindingFlags.NonPublic);
                                        fi.SetValue(item, false);
                                    }
                                }
                                ReportViewer1.LocalReport.SetBasePermissionsForSandboxAppDomain(new PermissionSet(PermissionState.Unrestricted));
                                ReportViewer1.LocalReport.ReportPath = MapPath("~/rdlc/ReportT.rdlc");
                                ReportViewer1.LocalReport.DataSources.Clear();

                                ReportDataSource rds = new ReportDataSource("DataSet1", dt);
                                ReportViewer1.LocalReport.DataSources.Add(rds);
                                ReportDataSource rds2 = new ReportDataSource("DataSet2", dtFlow);
                                ReportViewer1.LocalReport.DataSources.Add(rds2);

                                ReportParameter rpCur = new ReportParameter("Currency", dt1.Rows[0]["Cur"].ToString());
                                ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rpCur });
                                ReportParameter rp = new ReportParameter("Person", dt1.Rows[0]["Person"].ToString());
                                ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp });

                                ReportParameter rpDocNo = new ReportParameter("DocNo", dt1.Rows[0]["No"].ToString());
                                ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rpDocNo });

                                ReportParameter rpRemark = new ReportParameter("Remark", dt1.Rows[0]["Remark"].ToString());
                                ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rpRemark });

                                string budget = dt1.Rows[0]["Budget"].ToString() == "1" ? "Budgeted" : "UnBudgeted";
                                ReportParameter rpBudget = new ReportParameter("Budget", budget);
                                ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rpBudget });

                                string bb = "";
                                if (dt1.Rows[0]["Bdate"].ToString() != "")
                                {
                                    bb += Convert.ToDateTime(dt1.Rows[0]["Bdate"].ToString()).ToString("yyyy/MM/dd");
                                }
                                if (dt1.Rows[0]["Edate"].ToString() != "")
                                {
                                    bb += " - " + Convert.ToDateTime(dt1.Rows[0]["Edate"].ToString()).ToString("yyyy/MM/dd");
                                }
                                ReportParameter rpTravelPeriod = new ReportParameter("Period", bb);
                                ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rpTravelPeriod });

                                ReportViewer1.LocalReport.Refresh();
                            }
                            else if (Type == "G")
                            {
                                string aName = "";
                                if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                                {
                                    aName = "ADes";
                                }
                                else
                                {
                                    aName = "SAccountName";
                                }
                                string sql = "select [AName]=t2." + aName + ",CONVERT(varchar, Tdate, 111) as Tdate1,t1.ID,t1.Type,t1.Amount,t1.TSation,t1.Fcity,t1.Tcity,t1.Ecompany,t1.Eperson,CONVERT(varchar, t1.EffectTime, 111) as ET,t1.Months,t1.AccountDes from (select * from EeommonDetail where [No]='" + ID + "') t1 left join AccoundCode t2 on t2.SAccountCode=t1.AccountCode order by [Type],[AccountCode]";
                                DataTable dtDetail = new DataTable();
                                dtDetail = dbc.GetData("eReimbursement", sql);

                                DataTable dt = new DataTable();
                                dt.Columns.Add("AName", typeof(String));
                                dt.Columns.Add("Tdate1", typeof(String));
                                dt.Columns.Add("ID", typeof(String));
                                dt.Columns.Add("Type", typeof(String));
                                dt.Columns.Add("Amount", typeof(String));
                                dt.Columns.Add("TSation", typeof(String));
                                dt.Columns.Add("Fcity", typeof(String));
                                dt.Columns.Add("Tcity", typeof(String));
                                dt.Columns.Add("Ecompany", typeof(String));
                                dt.Columns.Add("Eperson", typeof(String));
                                dt.Columns.Add("Months", typeof(String));
                                dt.Columns.Add("AccountDes", typeof(String));
                                dt.Columns.Add("Mark", typeof(String));
                                //int ECount = 0; int TCount = 0; int CCount = 0; int OCount = 0;
                                decimal total = 0;
                                for (int i = 0; i < dtDetail.Rows.Count; i++)
                                {
                                    total += dtDetail.Rows[i]["Amount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Amount"].ToString());
                                    //添加分类标题行
                                    if (dtDetail.Rows[i]["Type"].ToString() == "E")
                                    {
                                        if (i == 0 || (dtDetail.Rows[i - 1]["Type"].ToString() != "E"))
                                        {
                                            DataRow dr = dt.NewRow();
                                            dr["ID"] = "E1";
                                            dr["AName"] = "Entertainment:";
                                            dr["Amount"] = "0";
                                            dr["Mark"] = "-1";
                                            dt.Rows.Add(dr);
                                            dr = dt.NewRow();
                                            dr["ID"] = "E2";
                                            dr["AName"] = "Expense Type";
                                            dr["Tdate1"] = "Date";
                                            dr["Type"] = "";
                                            dr["Amount"] = "0";
                                            dr["TSation"] = "Cost Center";
                                            dr["Fcity"] = "";
                                            dr["Tcity"] = "";
                                            dr["Ecompany"] = "Customer";
                                            dr["Eperson"] = "Guest";
                                            dr["Months"] = "";
                                            dr["AccountDes"] = "Remark";
                                            dr["Mark"] = "-1";
                                            dt.Rows.Add(dr);
                                        }
                                    }
                                    else if (dtDetail.Rows[i]["Type"].ToString() == "T")
                                    {
                                        if (i == 0 || (dtDetail.Rows[i - 1]["Type"].ToString() != "T"))
                                        {
                                            DataRow dr = dt.NewRow();
                                            dr["ID"] = "T1";
                                            dr["AName"] = "Transportation:";
                                            dr["Amount"] = "0";
                                            dr["Mark"] = "-1";
                                            dt.Rows.Add(dr);
                                            dr = dt.NewRow();
                                            dr["ID"] = "T2";
                                            dr["AName"] = "Expense Type";
                                            dr["Tdate1"] = "Date";
                                            dr["Type"] = "";
                                            dr["Amount"] = "0";
                                            dr["TSation"] = "Cost Center";
                                            dr["Fcity"] = "";
                                            dr["Tcity"] = "";
                                            dr["Ecompany"] = "Origin";
                                            dr["Eperson"] = "Destination";
                                            dr["Months"] = "";
                                            dr["AccountDes"] = "Remark";
                                            dt.Rows.Add(dr);
                                        }
                                    }
                                    else if (dtDetail.Rows[i]["Type"].ToString() == "C")
                                    {
                                        if (i == 0 || (dtDetail.Rows[i - 1]["Type"].ToString() != "C"))
                                        {
                                            DataRow dr = dt.NewRow();
                                            dr["ID"] = "C1";
                                            dr["AName"] = "Communication:";
                                            dr["Amount"] = "0";
                                            dr["Mark"] = "-1";
                                            dt.Rows.Add(dr);
                                            dr = dt.NewRow();
                                            dr["ID"] = "C2";
                                            dr["AName"] = "Expense Type";
                                            dr["Tdate1"] = "Period";
                                            dr["Type"] = "";
                                            dr["Amount"] = "0";
                                            dr["TSation"] = "Cost Center";
                                            dr["Fcity"] = "";
                                            dr["Tcity"] = "";
                                            dr["Ecompany"] = "";
                                            dr["Eperson"] = "";
                                            dr["Months"] = "";
                                            dr["AccountDes"] = "Remark";
                                            dr["Mark"] = "-1";
                                            dt.Rows.Add(dr);
                                        }
                                    }
                                    else
                                    {
                                        if (i == 0 || (dtDetail.Rows[i - 1]["Type"].ToString() != "O"))
                                        {
                                            DataRow dr = dt.NewRow();
                                            dr["ID"] = "O1";
                                            dr["AName"] = "Others:";
                                            dr["Amount"] = "0";
                                            dr["Mark"] = "-1";
                                            dt.Rows.Add(dr);
                                            dr = dt.NewRow();
                                            dr["ID"] = "O2";
                                            dr["AName"] = "Expense Type";
                                            dr["Tdate1"] = "Date";
                                            dr["Type"] = "";
                                            dr["Amount"] = "0";
                                            dr["TSation"] = "Cost Center";
                                            dr["Fcity"] = "";
                                            dr["Tcity"] = "";
                                            dr["Ecompany"] = "";
                                            dr["Eperson"] = "";
                                            dr["Months"] = "";
                                            dr["AccountDes"] = "Remark";
                                            dt.Rows.Add(dr);
                                        }
                                    }
                                    DataRow drdetail = dt.NewRow();
                                    drdetail["AName"] = dtDetail.Rows[i]["AName"].ToString();
                                    if (dtDetail.Rows[i]["Type"].ToString() == "C")
                                    {
                                        drdetail["Tdate1"] = dtDetail.Rows[i]["ET"].ToString();
                                    }
                                    else
                                    {
                                        drdetail["Tdate1"] = dtDetail.Rows[i]["Tdate1"].ToString();
                                    }
                                    drdetail["ID"] = dtDetail.Rows[i]["ID"].ToString();
                                    drdetail["Type"] = dtDetail.Rows[i]["Type"].ToString();
                                    drdetail["Amount"] = dtDetail.Rows[i]["Amount"].ToString();
                                    drdetail["TSation"] = dtDetail.Rows[i]["TSation"].ToString();
                                    drdetail["Fcity"] = dtDetail.Rows[i]["Fcity"].ToString();
                                    drdetail["Tcity"] = dtDetail.Rows[i]["Tcity"].ToString();
                                    drdetail["Ecompany"] = dtDetail.Rows[i]["Ecompany"].ToString();
                                    drdetail["Eperson"] = dtDetail.Rows[i]["Eperson"].ToString();
                                    drdetail["Months"] = dtDetail.Rows[i]["Months"].ToString();
                                    drdetail["AccountDes"] = dtDetail.Rows[i]["AccountDes"].ToString();
                                    dt.Rows.Add(drdetail);

                                    //if (dtDetail.Rows[i]["Type"].ToString() == "E")
                                    //{
                                    //    ECount++;
                                    //}
                                    //else if (dtDetail.Rows[i]["Type"].ToString() == "T")
                                    //{
                                    //    TCount++;
                                    //}
                                    //else if (dtDetail.Rows[i]["Type"].ToString() == "C")
                                    //{
                                    //    CCount++;
                                    //}
                                    //else
                                    //{
                                    //    OCount++;
                                    //}
                                }
                                //获取审批流程
                                DataTable dtFlow = new DataTable();
                                dtFlow.Columns.Add("Row", typeof(String));
                                dtFlow.Columns.Add("SubmitPerson", typeof(String));
                                dtFlow.Columns.Add("SubmitDate", typeof(String));
                                for (int i = 0; i < 6; i++)
                                {
                                    dtFlow.Columns.Add("Approver" + i.ToString());
                                    dtFlow.Columns.Add("Approver" + i.ToString() + "_Date");
                                }
                                if (dt1.Rows[0]["Step"].ToString() == "0")//草稿
                                {
                                    DataRow dr = dtFlow.NewRow();
                                    dr[0] = "0";
                                    dr[1] = "Submitted by:";
                                    dtFlow.Rows.Add(dr);
                                }
                                else//已正式申请
                                {
                                    for (int i = 0; i < dt1.Rows.Count; i++)
                                    {
                                        if (dt1.Rows[i]["Active"].ToString() == "2")
                                        {
                                            for (int j = dt1.Rows.Count - 1; j > i; j--)
                                            {
                                                dt1.Rows.RemoveAt(j);
                                            }
                                            break;
                                        }
                                    }
                                    for (int i = 0; i < dt1.Rows.Count / 6 + (dt1.Rows.Count % 6 == 0 ? 0 : 1); i++)
                                    {
                                        int index = 0;
                                        DataRow dr = dtFlow.NewRow();
                                        dr["Row"] = i;
                                        if (i == 0)//只在第一行显示一次提单人Submitted by
                                        {
                                            dr["SubmitPerson"] = "Submitted by:\n" + dt1.Rows[0]["CreadedBy"].ToString();
                                            dr["SubmitDate"] = dt1.Rows[0]["CreadedDate"].ToString() == "" ? "" : Convert.ToDateTime(dt1.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd");
                                        }
                                        for (int j = 0 + i * 6; j < ((i + 1) * 6 > dt1.Rows.Count ? dt1.Rows.Count : (i + 1) * 6); j++)//
                                        {
                                            if (dt1.Rows[j]["Status"].ToString() == "1")
                                            {
                                                string msg1 = "";
                                                if (dt1.Rows[j]["FlowFn"].ToString().ToLower() == "verifier")
                                                {
                                                    msg1 = ". To Be Verified:";
                                                }
                                                else if (dt1.Rows[j]["FlowFn"].ToString().ToLower() == "issuer")
                                                {
                                                    msg1 = ". To Be Issued:";
                                                }
                                                else
                                                {
                                                    msg1 = ". Waiting for Approval:";
                                                }
                                                dr["Approver" + index.ToString()] = (j + 1).ToString() + msg1 + "\n" + dt1.Rows[j]["Approver"].ToString();
                                                //dr["Approver" + index.ToString() + "_Date"] = dt1.Rows[j]["ApproveDate"].ToString() == "" ? "Pending" : Convert.ToDateTime(dt1.Rows[j]["ApproveDate"].ToString()).ToString("yyyy/MM/dd");
                                            }
                                            else if (dt1.Rows[j]["Status"].ToString() == "2")
                                            {
                                                string msg1 = "";
                                                if (dt1.Rows[j]["FlowFn"].ToString().ToLower() == "verifier")
                                                {
                                                    msg1 = ". Verified by:";
                                                }
                                                else if (dt1.Rows[j]["FlowFn"].ToString().ToLower() == "issuer")
                                                {
                                                    msg1 = ". Issued by:";
                                                }
                                                else
                                                {
                                                    msg1 = ". Approved by:";
                                                }

                                                if (dt1.Rows[j]["Active"].ToString() == "2")
                                                {
                                                    dr["Approver" + index.ToString()] = (j + 1).ToString() + msg1 + "\n" + dt1.Rows[j]["Approver"].ToString();
                                                    dr["Approver" + index.ToString() + "_Date"] = dt1.Rows[j]["ApproveDate"].ToString() == "" ? "" : ("(Complete)" + Convert.ToDateTime(dt1.Rows[j]["ApproveDate"].ToString()).ToString("yyyy/MM/dd"));
                                                }
                                                else
                                                {
                                                    dr["Approver" + index.ToString()] = (j + 1).ToString() + msg1 + "\n" + dt1.Rows[j]["Approver"].ToString();
                                                    dr["Approver" + index.ToString() + "_Date"] = dt1.Rows[j]["ApproveDate"].ToString() == "" ? "" : Convert.ToDateTime(dt1.Rows[j]["ApproveDate"].ToString()).ToString("yyyy/MM/dd");
                                                }
                                            }
                                            else
                                            {
                                                dr["Approver" + index.ToString()] = (j + 1).ToString() + ". Rejected by:\n" + dt1.Rows[j]["Approver"].ToString();
                                                dr["Approver" + index.ToString() + "_Date"] = dt1.Rows[j]["ApproveDate"].ToString() == "" ? "" : ("(Complete)" + Convert.ToDateTime(dt1.Rows[j]["ApproveDate"].ToString()).ToString("yyyy/MM/dd"));
                                            }
                                            index++;
                                        }
                                        dtFlow.Rows.Add(dr);
                                    }
                                }

                                ReportViewer1.ProcessingMode = ProcessingMode.Local;
                                //控制导出格式
                                RenderingExtension[] resut = ReportViewer1.LocalReport.ListRenderingExtensions();
                                foreach (RenderingExtension item in ReportViewer1.LocalReport.ListRenderingExtensions())
                                {
                                    // item 具有Visable属性,但是这个属性是只读属性,不能修改,所以通过反射进行了修改
                                    if (item.Name.ToUpper() == "PDF")
                                    {
                                        // 显示excel2003格式导出按钮
                                        FieldInfo fi = item.GetType().GetField("m_isVisible", BindingFlags.Instance | BindingFlags.NonPublic);
                                        fi.SetValue(item, true);
                                    }
                                    else
                                    {
                                        FieldInfo fi = item.GetType().GetField("m_isVisible", BindingFlags.Instance | BindingFlags.NonPublic);
                                        fi.SetValue(item, false);
                                    }
                                }

                                ReportViewer1.LocalReport.ReportPath = MapPath("~/rdlc/ReportG1.rdlc");
                                ReportViewer1.LocalReport.DataSources.Clear();

                                ReportDataSource rds = new ReportDataSource("DataSet1", dt);
                                ReportViewer1.LocalReport.DataSources.Add(rds);

                                ReportDataSource rds2 = new ReportDataSource("DataSet2", dtFlow);
                                ReportViewer1.LocalReport.DataSources.Add(rds2);

                                ReportParameter rpCur = new ReportParameter("Currency", dt1.Rows[0]["Cur"].ToString());
                                ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rpCur });

                                ReportParameter rp = new ReportParameter("Person", dt1.Rows[0]["Person"].ToString());
                                ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp });

                                ReportParameter rpMonth = new ReportParameter("Month", dt1.Rows[0]["Month"].ToString());
                                ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rpMonth });

                                ReportParameter rpSum = new ReportParameter("Sum", total.ToString());
                                ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rpSum });

                                ReportParameter rpRows = new ReportParameter("Rows", dt.Rows.Count.ToString());
                                ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rpRows });

                                ReportParameter rpDepartment = new ReportParameter("Department", dt1.Rows[0]["Department"].ToString() + " @ " + dt1.Rows[0]["Station"].ToString());
                                ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rpDepartment });

                                ReportParameter rpDocNo = new ReportParameter("DocNo", dt1.Rows[0]["No"].ToString());
                                ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rpDocNo });

                                string budget = dt1.Rows[0]["Budget"].ToString() == "1" ? "Budgeted" : "UnBudgeted";
                                ReportParameter rpBudget = new ReportParameter("Budget", budget);
                                ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rpBudget });

                                ReportViewer1.LocalReport.Refresh();
                            }
                        }
                    }
                }

            }

        }
Пример #19
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!X.IsAjaxRequest)
     {
         //判断登录状态
         cs.DBCommand dbc = new cs.DBCommand();
         if (Request.Cookies.Get("eReimUserID") == null)
         {
             X.AddScript("loginWindow.show();Panel1.disable();");
             return;
         }
         else
         {
             ScriptManager.RegisterStartupScript(this, GetType(), "", "$('div.gn_person ul.q-menubox li:eq(0) a').text('" + Request.Cookies.Get("eReimUserName").Value + "');", true); X.AddScript("loginWindow.hide();Panel1.enable();");
         }
         string sqltype = "";
         string sqldraft = "";
         string sqlProcess = "";
         if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
         {
             PagingToolbar1.DisplayMsg = "显示 {0} - {1} of {2}";
             ResourceManager1.Locale = "zh-CN";
             sqltype += "select [Text]=CText,[Value]=CValue from Edic where KeyValue='MainType'";
             sqldraft += "select [Text]=CText,[Value]=CValue from Edic where KeyValue='Type'";
             sqlProcess += "select [Text]=CText,[Value]=CValue from Edic where KeyValue='Status'";
         }
         else
         {
             PagingToolbar1.DisplayMsg = "Displaying items {0} - {1} of {2}";
             ResourceManager1.Locale = "en-US";
             sqltype += "select [Text]=EText,[Value]=CValue from Edic where KeyValue='MainType'";
             sqldraft += "select [Text]=EText,[Value]=CValue from Edic where KeyValue='Type'";
             sqlProcess += "select [Text]=EText,[Value]=CValue from Edic where KeyValue='Status'";
         }
         
         DataTable dttype = dbc.GetData("eReimbursement", sqltype);
         StoreType.DataSource = dttype;
         StoreType.DataBind();
         DataTable dtdraft = dbc.GetData("eReimbursement", sqldraft);
         StoreDraft.DataSource = dtdraft;
         StoreDraft.DataBind();
         DataTable dtProcess = dbc.GetData("eReimbursement", sqlProcess);
         StoreProcess.DataSource = dtProcess;
         StoreProcess.DataBind();
         //获取被授权站点
         string getright = "select * from StationRole where UserID='" + Request.Cookies.Get("eReimUserID").Value + "'";
         DataTable dtright = dbc.GetData("eReimbursement", getright);
         DataTable dtStation = new DataTable();
         dtStation.Columns.Add("Text", System.Type.GetType("System.String"));
         dtStation.Columns.Add("Value", System.Type.GetType("System.String"));
         for (int j = 0; j < dtright.Rows.Count; j++)
         {
             string[] dd = dtright.Rows[j]["Stations"].ToString().Split(',');
             for (int i = 0; i < dd.Length; i++)
             {
                 if (!string.IsNullOrEmpty(dd[i].Trim()))
                 {
                     bool have = false;
                     for (int g = 0; g < dtStation.Rows.Count; g++)
                     {
                         if (dtStation.Rows[g]["Text"].ToString()==dd[i].Trim())
                         {
                             have = true;
                             break;
                         }
                     }
                     if (!have)
                     {
                         DataRow dr1 = dtStation.NewRow();
                         dr1["Text"] = dd[i];
                         dr1["Value"] = dd[i];
                         dtStation.Rows.Add(dr1);
                     }
                 }
             }
         }
         dtStation.DefaultView.Sort = "Text ASC";
         StoreStation.DataSource = dtStation.DefaultView.ToTable();
         StoreStation.DataBind();
         //获取被授权站点下的所有申请人
         string station = "";
         for (int i = 0; i < dtStation.Rows.Count; i++)
         {
             station += "'" + dtStation.Rows[i]["Text"].ToString() + "',";
         }
         if (!string.IsNullOrEmpty(station))
         {
             station = " and Station in (" + station.Substring(0, station.Length - 1) + ") ";
         }
         string sqlgetPerson = "";
         if (station.Length>0)
         {
             sqlgetPerson = "select distinct [Text]=Person,[Value]=PersonID from V_Eflow_ETravel where (Active=1 or Active=2) and Person!='' " + station;
         }
         else
         {
             sqlgetPerson = "select distinct [Text]=Person,[Value]=PersonID from V_Eflow_ETravel where (Active=1 or Active=2) and Person!='' and FlowID is null";
         }
         DataTable dtperson = dbc.GetData("eReimbursement", sqlgetPerson);
         dtperson.DefaultView.Sort = "Text ASC";
         StorePerson.DataSource = dtperson.DefaultView.ToTable();
         StorePerson.DataBind();
         //获取被授权站点下的所有提单人
         string sqlgetCreatedBy = "";
         if (station.Length > 0)
         {
             sqlgetCreatedBy = "select distinct [Text]=CreadedBy,[Value]=CreadedByID from V_Eflow_ETravel where (Active=1 or Active=2) and CreadedBy!='' " + station;
         }
         else
         {
             sqlgetCreatedBy = "select distinct [Text]=CreadedBy,[Value]=CreadedByID from V_Eflow_ETravel where (Active=1 or Active=2) and CreadedBy!='' and FlowID is null";
         }
         DataTable dtcreatedby = dbc.GetData("eReimbursement", sqlgetCreatedBy);
         dtcreatedby.DefaultView.Sort = "Text ASC";
         StoreCreatedBy.DataSource = dtcreatedby.DefaultView.ToTable();
         StoreCreatedBy.DataBind();
     }
 }
Пример #20
0
 public void Delete(string RequestID, string Type, string rowIndex)
 {
     string sqldel = "";
     if (Type == "T")
     {
         sqldel += "select * from Eflow where RequestID='" + RequestID + "' and [Type]='T';";
         sqldel += "select * from ETravel where ID='" + RequestID + "';";
         sqldel += "select * from ETraveleDetail where [No]='" + RequestID + "';";
         //sqldel += "delete from Eflow where RequestID='" + RequestID + "' and [Type]='T';";
         //sqldel += "delete from ETravel where ID='" + RequestID + "';";
         //sqldel += "delete from ETraveleDetail where [No]='" + RequestID + "';";
         sqldel += "update ETravel set Void=1 where ID='" + RequestID + "';";
     }
     else if (Type == "G")
     {
         sqldel += "select * from Eflow where RequestID='" + RequestID + "' and [Type]='G';";
         sqldel += "select * from Ecommon where ID='" + RequestID + "';";
         sqldel += "select * from EeommonDetail where [No]='" + RequestID + "';";
         //sqldel += "delete from Eflow where RequestID='" + RequestID + "' and [Type]='G';";
         //sqldel += "delete from Ecommon where ID='" + RequestID + "';";
         //sqldel += "delete from EeommonDetail where [No]='" + RequestID + "';";
         sqldel += "update Ecommon set Void=1 where ID='" + RequestID + "';";
     }
     cs.DBCommand dbc = new cs.DBCommand();
     string sqlre = dbc.UpdateData("eReimbursement", sqldel, "Update");
     //X.AddScript("Store1.removeAt(" + rowIndex + ");Store1.load();");
 }
Пример #21
0
 public void DeleteRule(string TempNO)
 {
     cs.DBCommand dbc   = new cs.DBCommand();
     string       sql   = "delete from FileRule where ID=" + TempNO;
     string       sqlre = dbc.UpdateData("eReimbursement", sql, "Update");
 }
Пример #22
0
        protected bool SendMail()
        {
            //发送提醒邮件
            cs.DBCommand dbc = new cs.DBCommand();
            string sql = "select * from V_Eflow_ETravel where [Type]='T' and Step!=0 and RequestID=" + hdTravelRequestID.Value.ToString() + " order by Step,FlowID";
            DataTable dtMail = new DataTable();
            dtMail = dbc.GetData("eReimbursement", sql);
            
            if (dtMail != null && dtMail.Rows.Count > 0)
            {
                string msg = "";
                if (dtMail.Rows[0]["FlowFn"].ToString().ToLower() == "verifier")
                {
                    msg = "Process Checking.";
                }
                else if (dtMail.Rows[0]["FlowFn"].ToString().ToLower() == "issuer")
                {
                    msg = "Process Paying.";
                }
                else
                {
                    msg = "Seek For Your Approval.";
                }
                string budget = dtMail.Rows[0]["Budget"].ToString() == "1" ? "(Budget)" : "(UnBudget)";

                DIMERCO.SDK.MailMsg mail = new DIMERCO.SDK.MailMsg();
                mail.Title = "Dimerco eReimbursement "+budget+" " + dtMail.Rows[0]["Person"].ToString() + " - " + msg;
                mail.FromDispName = "eReimbursement";
                mail.From = "*****@*****.**";

                string mailto = "";
                DataSet dsTo = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(dtMail.Rows[0]["ApproverID"].ToString());
                if (dsTo.Tables[0].Rows.Count == 1)
                {
                    mailto += dsTo.Tables[0].Rows[0]["eMail"].ToString() + ",";
                }
                else
                {
                    ErrorHandle("Error mail address."); return false;
                }

                string mailcc = "";
                DataSet dsCC = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(dtMail.Rows[0]["PersonID"].ToString());
                if (dsCC.Tables[0].Rows.Count == 1)
                {
                    mailcc += dsCC.Tables[0].Rows[0]["eMail"].ToString() + ",";
                }
                else
                {
                    ErrorHandle("Error mail address."); return false;
                }
                if (dtMail.Rows[0]["CreadedByID"].ToString() != "" && dtMail.Rows[0]["CreadedByID"].ToString() != dtMail.Rows[0]["PersonID"].ToString())//代理人
                {
                    dsCC = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(dtMail.Rows[0]["CreadedByID"].ToString());
                    mailcc += dsCC.Tables[0].Rows[0]["eMail"].ToString() + ",";
                }
                if (dtMail.Rows[0]["CCMailList"].ToString()!="")
                {
                    mailcc += dtMail.Rows[0]["CCMailList"].ToString();
                }
                mail.To = mailto;
                mail.Cc = mailcc;
                string divstyle = "style='font-size:small;'";
                string divstyleCurrent = "style='font-size:small;color:blue;'";
                string tdstyle = "style='border:silver 1px ridge; font-size:small;background-color: #FFFFFF;empty-cells:show;'";
                StringBuilder sb = new StringBuilder();
                sb.Append("<div>");
                sb.Append("<div " + divstyle + "> Dear " + dtMail.Rows[0]["Approver"].ToString() + ",</div><br />");
                sb.Append("<div " + divstyle + ">The following eReimbursement application:"+msg+"</div><br /><br />");
                
                sb.Append("<div " + divstyle + ">No#:" + dtMail.Rows[0]["No"].ToString() + budget + "</div>");
                sb.Append("<div " + divstyle + ">Owner:" + dtMail.Rows[0]["Person"].ToString() + "</div>");
                sb.Append("<div " + divstyle + ">Station:" + dtMail.Rows[0]["Station"].ToString() + "</div>");
                sb.Append("<div " + divstyle + ">Department:" + dtMail.Rows[0]["Department"].ToString() + "</div>");
                string period = "";
                period += dtMail.Rows[0]["Bdate"].ToString() == "" ? "From NA " : ("From " + Convert.ToDateTime(dtMail.Rows[0]["Bdate"].ToString()).ToString("yyyy/MM/dd") + " ");
                period += dtMail.Rows[0]["Edate"].ToString() == "" ? "To NA" : "To " + Convert.ToDateTime(dtMail.Rows[0]["Edate"].ToString()).ToString("yyyy/MM/dd");
                sb.Append("<div " + divstyle + ">Period:" + period + "</div><br />");
                sb.Append("<div><table style='border-collapse:collapse'><thead><tr><th colspan=\"13\" " + tdstyle + ">Expense Detail</th></tr><tr>");
                sb.Append("<th " + tdstyle + "></th>");
                sb.Append("<th " + tdstyle + ">Location</th>");
                sb.Append("<th " + tdstyle + ">Date</th>");
                sb.Append("<th " + tdstyle + ">Expense Type</th>");
                sb.Append("<th " + tdstyle + ">Currency</th>");
                sb.Append("<th " + tdstyle + ">Employee Pay</th>");
                sb.Append("<th " + tdstyle + ">Company Pay</th>");
                sb.Append("<th " + tdstyle + ">Cost Center</th>");
                sb.Append("<th style='border:silver 1px ridge; font-size:small;background-color: #FFFFFF;empty-cells:show;width:160px;'>Remark</th>");
                sb.Append("<th " + tdstyle + ">Station Budget:(Used/All)</th>");
                sb.Append("<th " + tdstyle + ">Department Budget:(Used/All)</th>");
                sb.Append("<th " + tdstyle + ">Person Budget:(Used/All)</th>");
                sb.Append("<th " + tdstyle + ">Person Budget One Year:(Used/All)</th></tr></thead>");

                sb.Append("<tbody>");
                decimal ptotal = 0; decimal ctotal = 0;
                string sqldetail = "select [StationBudget]='',[DepartmentBudget]='',[PersonBudget]='',[PersonBudgetOneYear]='',t2.SAccountName,t1.* from ETraveleDetail t1 left join AccoundCode t2 on t2.SAccountCode=t1.AccountCode where t1.[No]='" + hdTravelRequestID.Value.ToString() + "'";
                DataTable dtdetail = new DataTable();
                dtdetail = dbc.GetData("eReimbursement", sqldetail);
                for (int i = 0; i < dtdetail.Rows.Count; i++)
                {
                    //载入预算内容
                    string userid = dtMail.Rows[0]["PersonID"].ToString();
                    string dpt = dtdetail.Rows[i]["Department1"].ToString();
                    string ostation = "";
                    DataSet ds1 = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(userid);
                    if (ds1.Tables[0].Rows.Count == 1)
                    {
                        DataTable dt1 = ds1.Tables[0];
                        //dpt = dt1.Rows[0]["DepartmentName"].ToString();
                        ostation = dt1.Rows[0]["stationCode"].ToString();
                    }
                    string tstation = dtdetail.Rows[i]["TSation"].ToString() == "" ? ostation : dtdetail.Rows[i]["TSation"].ToString();
                    string accountcode = dtdetail.Rows[i]["AccountCode"].ToString();
                    string Years = Convert.ToDateTime(Convert.ToDateTime(dtdetail.Rows[i]["Tdate"].ToString())).Year.ToString();
                    string month = Convert.ToDateTime(Convert.ToDateTime(dtdetail.Rows[i]["Tdate"].ToString())).Month.ToString();

                    DataTable dtBG = new DataTable();
                    dtBG = Comm.RtnEB(userid, dpt, ostation, tstation, accountcode, Years, month);
                    if (dtBG != null && dtBG.Rows.Count > 0)
                    {
                        for (int j = 0; j < dtBG.Rows.Count; j++)
                        {
                            if (dtBG.Rows[j]["Type"].ToString() == "站点")
                            {
                                string stationbg = Convert.ToDecimal(dtBG.Rows[j]["Used"].ToString()).ToString("#,##0.00") + "/" + Convert.ToDecimal(dtBG.Rows[j]["Budget"].ToString()).ToString("#,##0.00");
                                dtdetail.Rows[i]["StationBudget"] = stationbg;
                            }
                        }
                        for (int j = 0; j < dtBG.Rows.Count; j++)
                        {
                            if (dtBG.Rows[j]["Type"].ToString() == "部门")
                            {
                                string stationbg = Convert.ToDecimal(dtBG.Rows[j]["Used"].ToString()).ToString("#,##0.00") + "/" + Convert.ToDecimal(dtBG.Rows[j]["Budget"].ToString()).ToString("#,##0.00");
                                dtdetail.Rows[i]["DepartmentBudget"] = stationbg;
                            }
                        }
                        for (int j = 0; j < dtBG.Rows.Count; j++)
                        {
                            if (dtBG.Rows[j]["Type"].ToString() == "个人")
                            {
                                string stationbg = Convert.ToDecimal(dtBG.Rows[j]["Used"].ToString()).ToString("#,##0.00") + "/" + Convert.ToDecimal(dtBG.Rows[j]["Budget"].ToString()).ToString("#,##0.00");
                                dtdetail.Rows[i]["PersonBudget"] = stationbg;
                            }
                        }
                        for (int j = 0; j < dtBG.Rows.Count; j++)
                        {
                            if (dtBG.Rows[j]["Type"].ToString() == "全年")
                            {
                                string stationbg = Convert.ToDecimal(dtBG.Rows[j]["Used"].ToString()).ToString("#,##0.00") + "/" + Convert.ToDecimal(dtBG.Rows[j]["Budget"].ToString()).ToString("#,##0.00");
                                dtdetail.Rows[i]["PersonBudgetOneYear"] = stationbg;
                            }
                        }
                    }

                    sb.Append("<tr><th " + tdstyle + ">" + (i + 1).ToString() + "</th>");
                    sb.Append("<td " + tdstyle + ">" + dtdetail.Rows[i]["Tocity"].ToString() + "</td>");
                    string tdate = dtdetail.Rows[i]["Tdate"].ToString() == "" ? "" : Convert.ToDateTime(dtdetail.Rows[i]["Tdate"].ToString()).ToString("yyyy/MM/dd");
                    sb.Append("<td " + tdstyle + ">" + tdate + "</td>");
                    sb.Append("<td " + tdstyle + ">" + dtdetail.Rows[i]["SAccountName"].ToString() + "</td>");
                    sb.Append("<td " + tdstyle + ">" + dtdetail.Rows[i]["Cur"].ToString() + "</td>");
                    sb.Append("<td " + tdstyle + ">" + (dtdetail.Rows[i]["Pamount"].ToString() == "" ? "" : Convert.ToDecimal(dtdetail.Rows[i]["Pamount"].ToString()).ToString("#,##0.00")) + "</td>");
                    sb.Append("<td " + tdstyle + ">" + (dtdetail.Rows[i]["Camount"].ToString() == "" ? "" : Convert.ToDecimal(dtdetail.Rows[i]["Camount"].ToString()).ToString("#,##0.00")) + "</td>");
                    sb.Append("<td " + tdstyle + ">" + dtdetail.Rows[i]["TSation"].ToString() + "</td>");
                    sb.Append("<td " + tdstyle + ">" + dtdetail.Rows[i]["AccountDes"].ToString() + "</td>");
                    sb.Append("<td " + tdstyle + ">" + dtdetail.Rows[i]["StationBudget"].ToString() + "</td>");
                    sb.Append("<td " + tdstyle + ">" + dtdetail.Rows[i]["DepartmentBudget"].ToString() + "</td>");
                    sb.Append("<td " + tdstyle + ">" + dtdetail.Rows[i]["PersonBudget"].ToString() + "</td>");
                    sb.Append("<td " + tdstyle + ">" + dtdetail.Rows[i]["PersonBudgetOneYear"].ToString() + "</td></tr>");
                    ptotal += dtdetail.Rows[i]["Pamount"].ToString() == "" ? 0 : Convert.ToDecimal(dtdetail.Rows[i]["Pamount"].ToString());
                    ctotal += dtdetail.Rows[i]["Camount"].ToString() == "" ? 0 : Convert.ToDecimal(dtdetail.Rows[i]["Camount"].ToString());
                }
                sb.Append("</tbody>");
                sb.Append("<tfoot><tr>");
                sb.Append("<th " + tdstyle + ">Total:</th>");
                sb.Append("<td colspan=\"3\" " + tdstyle + "></td>");
                sb.Append("<td " + tdstyle + ">" + dtdetail.Rows[0]["Cur"].ToString() + "</td>");
                sb.Append("<td " + tdstyle + ">" + ptotal.ToString("#,##0.00") + "</td>");
                sb.Append("<td " + tdstyle + ">" + ctotal.ToString("#,##0.00") + "</td>");
                sb.Append("<td colspan=\"6\" " + tdstyle + "></td>");
                sb.Append("</tr></tfoot></table></div><br />");
                sb.Append("<div " + divstyle + ">Apply Remark:" + dtMail.Rows[0]["Remark"].ToString() + "</div><br />");

                StringBuilder sb1 = new StringBuilder();
                sb1.Append("<div><span " + divstyle + ">Approval Flow:</span>");
                for (int i = 0; i < dtMail.Rows.Count; i++)
                {
                    if (i == 0)
                    {
                        sb1.Append("<div " + divstyleCurrent + ">" + (i + 1).ToString());
                    }
                    else
                    {
                        sb1.Append("<div " + divstyle + ">" + (i + 1).ToString());
                    }

                    string msg1 = "";
                    if (dtMail.Rows[i]["FlowFn"].ToString().ToLower() == "verifier")
                    {
                        msg1 = ". To Be Verified: " + dtMail.Rows[i]["Approver"].ToString() + "</div>";
                    }
                    else if (dtMail.Rows[i]["FlowFn"].ToString().ToLower() == "issuer")
                    {
                        msg1 = ". To Be Issued: " + dtMail.Rows[i]["Approver"].ToString() + "</div>";
                    }
                    else
                    {
                        msg1 = ". Waiting for Approval: " + dtMail.Rows[i]["Approver"].ToString() + "</div>";
                    }
                    sb1.Append(msg1);
                }
                sb1.Append("</div><br />");
                sb.Append(sb1.ToString());
                string url = "";
                if (Request.Url.Host!="localhost")
                {
                    url = "http://" + Request.Url.Authority + "/eReimbursement/Approve.aspx";
                }
                else
                {
                    url = "http://" + Request.Url.Authority + "/Approve.aspx";
                } 
                sb.Append("<div><a href=\"" + url + "?FlowID=" + dtMail.Rows[0]["FlowID"].ToString() + "\" style=\"color: #0000FF\">Click here to visit Dimerco eReimbursement.</a></div>");
                sb.Append("</div>");
                mail.Body = sb.ToString();
                mail.Send();
            }
            else
            {
                return false;
            }
            return true;
        }
Пример #23
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                //判断登录状态
                cs.DBCommand dbc = new cs.DBCommand();
                //string ssw = dbc.ConvertString(txtRemark.Text);
                //string newstr = "select * from ETravel where [Remark] like '%" + ssw + @"%' escape '\'";
                //DataTable dttt = dbc.GetData("eReimbursement", newstr);

                if (Request.Cookies.Get("eReimUserID") == null)
                {
                    X.AddScript("loginWindow.show();Panel1.disable();");
                    return;
                }
                else
                {
                    hdUser.Value = Request.Cookies.Get("eReimUserID").Value;
                    ScriptManager.RegisterStartupScript(this, GetType(), "", "$('div.gn_person ul.q-menubox li:eq(0) a').text('" + Request.Cookies.Get("eReimUserName").Value + "');", true); 
                    X.AddScript("loginWindow.hide();Panel1.enable();");

                    

                    string sql = "select";
                    if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                    {
                        //PagingToolbar1.DisplayMsg = "显示 {0} - {1} of {2}";
                        //PagingToolbar2.DisplayMsg = "显示 {0} - {1} of {2}";
                        ResourceManager1.Locale = "zh-CN";
                        sql += " ADes as [COAName]";
                    }
                    else
                    {
                        //PagingToolbar1.DisplayMsg = "Displaying items {0} - {1} of {2}";
                        //PagingToolbar2.DisplayMsg = "Displaying items {0} - {1} of {2}";
                        ResourceManager1.Locale = "en-US";
                        sql += " SAccountName as [COAName]";
                    }
                    sql += ",SAccountCode as [COACode] from AccoundCode where Remark like '%差旅費%'";
                    DataTable dt = new DataTable();
                    dt = dbc.GetData("eReimbursement", sql);
                    StoreCOA.DataSource = dt;
                    StoreCOA.DataBind();
                }
                
                hdStatus.Value = "0";

                if (Request.QueryString["ID"] != null)//判断链接地址是否正确
                {
                    string ID = Request.QueryString["ID"].ToString();
                    System.Text.RegularExpressions.Regex reg1 = new System.Text.RegularExpressions.Regex(@"^\d*$");
                    if (reg1.IsMatch(ID))
                    {
                        string sql = "select * from V_Eflow_ETravel where RequestID='" + ID + "' and [Type]='T' and (Active=1 or Active=2)";

                        DataTable dt = new DataTable();
                        dt = dbc.GetData("eReimbursement", sql);

                        if (dt != null && dt.Rows.Count == 1)
                        {

                            if (Request.Cookies.Get("eReimUserID").Value == dt.Rows[0]["PersonID"].ToString())//本人
                            {
                                //准备下拉菜单内容
                                Ext.Net.ListItem li = new Ext.Net.ListItem(Request.Cookies.Get("eReimUserName").Value, Request.Cookies.Get("eReimUserID").Value);
                                cbxOwner.Items.Add(li);
                                string sqlitem = "select * from Eagent where [St]=1 and [PAgentID]='" + Request.Cookies.Get("eReimUserID").Value + "'";
                                DataTable dtitem = dbc.GetData("eReimbursement", sqlitem);
                                int itemcount = 0;
                                for (int j = 0; j < dtitem.Rows.Count; j++)
                                {
                                    string sqlpara = sqlitem;
                                    if (dtitem.Rows[j][5].ToString() != "")
                                    {
                                        sqlpara += " and getdate()>='" + dtitem.Rows[j][5].ToString() + "' ";
                                    }
                                    if (dtitem.Rows[j][6].ToString() != "")
                                    {
                                        sqlpara += " and getdate()<='" + dtitem.Rows[j][6].ToString() + "' ";
                                    }
                                    DataTable dtitem1 = dbc.GetData("eReimbursement", sqlpara);
                                    for (int m = 0; m < dtitem1.Rows.Count; m++)
                                    {
                                        li = new Ext.Net.ListItem(dtitem.Rows[m][1].ToString(), dtitem.Rows[m][2].ToString());
                                        cbxOwner.Items.Add(li);
                                        itemcount++;
                                    }
                                }
                                //更改按钮状态
                                if (dt.Rows[0]["Step"].ToString() != "0")//正式申请单
                                {
                                    if (Request.QueryString["Copy"] != null)
                                    {
                                        if (Request.QueryString["Copy"].ToString() == "T")//Copy,作为新增
                                        {
                                            X.AddScript("btnSaveAndSend.enable();cbxBudget.setReadOnly(false);");
                                        }
                                        else
                                        {
                                            ErrorHandle("Data Error.");
                                        }
                                    }
                                    else//已申请数据
                                    {
                                        string app = "";
                                        if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                                        {
                                            Panel3.Title = "差旅费申请单: " + dt.Rows[0]["No"].ToString();
                                            //读取当前状态,显示在下方文本框内
                                            
                                            if (dt.Rows[0]["Status"].ToString() == "1")
                                            {
                                                app += "提单人: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                app += ", 等待审批: " + dt.Rows[0]["Approver"].ToString();
                                            }
                                            else if (dt.Rows[0]["Status"].ToString() == "2")
                                            {
                                                app += "提单人: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                app += ", 完成审批: " + dt.Rows[0]["Approver"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["ApproveDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                            }
                                            else if (dt.Rows[0]["Status"].ToString() == "3")
                                            {
                                                app += "提单人: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                app += ", 拒绝审批: " + dt.Rows[0]["Approver"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["ApproveDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                            }

                                            if (dt.Rows[0]["Active"].ToString() == "2")//已完成
                                            {
                                                hdStatus.Value = "2";
                                                app += ". 完成.";
                                                X.AddScript("btnGeteLeave.disable();btnEditDetail.disable();btnNewDetail.disable();btnSaveDraft.disable();btnUploadReport.disable();btnUploadScanFile.disable();Button1.disable();Button2.disable();btnCC.disable();");
                                            }
                                            else//待审批
                                            {
                                                hdStatus.Value = "1";
                                                X.AddScript("btnGeteLeave.disable();btnEditDetail.disable();btnNewDetail.disable();btnSaveDraft.disable();btnCC.disable();");
                                            }
                                            
                                        }
                                        else
                                        {
                                            Panel3.Title = "Travel Expense Form: " + dt.Rows[0]["No"].ToString();
                                            //读取当前状态,显示在下方文本框内

                                            if (dt.Rows[0]["Status"].ToString() == "1")
                                            {
                                                app += "Applied by: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                app += ", Waiting for approval By: " + dt.Rows[0]["Approver"].ToString();
                                            }
                                            else if (dt.Rows[0]["Status"].ToString() == "2")
                                            {
                                                app += "Applied by: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                app += ", Approved by: " + dt.Rows[0]["Approver"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["ApproveDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                            }
                                            else if (dt.Rows[0]["Status"].ToString() == "3")
                                            {
                                                app += "Applied by: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                app += ", Rejected by: " + dt.Rows[0]["Approver"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["ApproveDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                            }

                                            if (dt.Rows[0]["Active"].ToString() == "2")//已完成
                                            {
                                                hdStatus.Value = "2";
                                                app += ". Complete.";
                                                X.AddScript("btnGeteLeave.disable();btnEditDetail.disable();btnNewDetail.disable();btnSaveDraft.disable();btnUploadReport.disable();btnUploadScanFile.disable();Button1.disable();Button2.disable();btnCC.disable();");
                                            }
                                            else//待审批
                                            {
                                                hdStatus.Value = "1";
                                                X.AddScript("btnGeteLeave.disable();btnEditDetail.disable();btnNewDetail.disable();btnSaveDraft.disable();btnCC.disable();");
                                            }
                                        }
                                        labelInfo.Text = app;
                                    }
                                }
                                else//草稿
                                {
                                    if (Request.QueryString["Copy"] != null)
                                    {
                                        if (Request.QueryString["Copy"].ToString() == "T")//Copy,作为新增
                                        {
                                            X.AddScript("btnSaveAndSend.enable();cbxBudget.setReadOnly(false);");
                                        }
                                        else
                                        {
                                            ErrorHandle("Data Error.");
                                        }
                                    }
                                    else
                                    {
                                        if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                                        {
                                            Panel3.Title = "差旅费申请单草稿: " + dt.Rows[0]["No"].ToString();
                                        }
                                        else
                                        {
                                            Panel3.Title = "Travel Expense Draft: " + dt.Rows[0]["No"].ToString();
                                        }

                                        X.AddScript("btnSaveAndSend.enable();cbxBudget.setReadOnly(false);");
                                    }
                                }
                                //载入通用数据
                                LoadData(dt, true);
                            }
                            else
                            {
                                //判断是否为代理人
                                bool isagent = false;//记录Session["UserID"]是否为代理人
                                string sqlagent = "select * from Eagent where [St]=1 and [OwnerID]='" + dt.Rows[0]["PersonID"].ToString() + "' and getdate()<=Edate and getdate()>=Bdate";
                                DataTable dtagent = dbc.GetData("eReimbursement", sqlagent);
                                for (int g = 0; g < dtagent.Rows.Count; g++)
                                {
                                    if (Request.Cookies.Get("eReimUserID").Value == dtagent.Rows[g]["PAgentID"].ToString())
                                    {
                                        isagent = true;
                                        break;
                                    }
                                }
                                if (isagent)//代理人访问
                                {
                                    Ext.Net.ListItem li = new Ext.Net.ListItem(dt.Rows[0]["Person"].ToString(), dt.Rows[0]["PersonID"].ToString());
                                    cbxOwner.Items.Add(li);
                                    //更改按钮状态
                                    if (dt.Rows[0]["Step"].ToString() != "0")//正式申请单
                                    {
                                        if (Request.QueryString["Copy"] != null)
                                        {
                                            if (Request.QueryString["Copy"].ToString() == "T")//Copy,作为新增
                                            {
                                                X.AddScript("btnSaveAndSend.enable();cbxBudget.setReadOnly(false);");
                                            }
                                            else
                                            {
                                                ErrorHandle("Data Error.");
                                            }
                                        }
                                        else
                                        {
                                            string app = "";
                                            if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                                            {
                                                Panel3.Title = "差旅费申请单: " + dt.Rows[0]["No"].ToString();
                                                //读取当前状态,显示在下方文本框内

                                                if (dt.Rows[0]["Status"].ToString() == "1")
                                                {
                                                    app += "提单人: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                    app += ", 等待审批: " + dt.Rows[0]["Approver"].ToString();
                                                }
                                                else if (dt.Rows[0]["Status"].ToString() == "2")
                                                {
                                                    app += "提单人: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                    app += ", 完成审批: " + dt.Rows[0]["Approver"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["ApproveDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                }
                                                else if (dt.Rows[0]["Status"].ToString() == "3")
                                                {
                                                    app += "提单人: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                    app += ", 拒绝审批: " + dt.Rows[0]["Approver"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["ApproveDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                }

                                                if (dt.Rows[0]["Active"].ToString() == "2")//已完成
                                                {
                                                    hdStatus.Value = "2";
                                                    app += ". 完成.";
                                                    X.AddScript("btnGeteLeave.disable();btnEditDetail.disable();btnNewDetail.disable();btnSaveDraft.disable();btnUploadReport.disable();btnUploadScanFile.disable();Button1.disable();Button2.disable();btnCC.disable();");
                                                }
                                                else//待审批
                                                {
                                                    hdStatus.Value = "1";
                                                    X.AddScript("btnGeteLeave.disable();btnEditDetail.disable();btnNewDetail.disable();btnSaveDraft.disable();btnCC.disable();");
                                                }

                                            }
                                            else
                                            {
                                                Panel3.Title = "Travel Expense Form: " + dt.Rows[0]["No"].ToString();
                                                //读取当前状态,显示在下方文本框内

                                                if (dt.Rows[0]["Status"].ToString() == "1")
                                                {
                                                    app += "Applied by: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                    app += ", Waiting for approval By: " + dt.Rows[0]["Approver"].ToString();
                                                }
                                                else if (dt.Rows[0]["Status"].ToString() == "2")
                                                {
                                                    app += "Applied by: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                    app += ", Approved by: " + dt.Rows[0]["Approver"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["ApproveDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                }
                                                else if (dt.Rows[0]["Status"].ToString() == "3")
                                                {
                                                    app += "Applied by: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                    app += ", Rejected by: " + dt.Rows[0]["Approver"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["ApproveDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                }

                                                if (dt.Rows[0]["Active"].ToString() == "2")//已完成
                                                {
                                                    hdStatus.Value = "2";
                                                    app += ". Complete.";
                                                    X.AddScript("btnGeteLeave.disable();btnEditDetail.disable();btnNewDetail.disable();btnSaveDraft.disable();btnUploadReport.disable();btnUploadScanFile.disable();Button1.disable();Button2.disable();btnCC.disable();");
                                                }
                                                else//待审批
                                                {
                                                    hdStatus.Value = "1";
                                                    X.AddScript("btnGeteLeave.disable();btnEditDetail.disable();btnNewDetail.disable();btnSaveDraft.disable();btnCC.disable();");
                                                }
                                            }
                                            labelInfo.Text = app;
                                        }
                                    }
                                    else//草稿
                                    {
                                        if (Request.QueryString["Copy"] != null)
                                        {
                                            if (Request.QueryString["Copy"].ToString() == "T")//Copy,作为新增
                                            {
                                                X.AddScript("btnSaveAndSend.enable();cbxBudget.setReadOnly(false);");
                                            }
                                            else
                                            {
                                                ErrorHandle("Data Error.");
                                            }
                                        }
                                        else
                                        {
                                            if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                                            {
                                                Panel3.Title = "差旅费申请单草稿: " + dt.Rows[0]["No"].ToString();
                                            }
                                            else
                                            {
                                                Panel3.Title = "Travel Expense Draft: " + dt.Rows[0]["No"].ToString();
                                            }
                                            X.AddScript("btnSaveAndSend.enable();cbxBudget.setReadOnly(false);");
                                        }
                                    }
                                    //载入通用数据
                                    LoadData(dt, true);
                                }
                                else//判断是否有跨站权限
                                {

                                    bool hasright = false;
                                    string getright = "select * from StationRole where UserID='" + Request.Cookies.Get("eReimUserID").Value + "'";
                                    DataTable dtright = dbc.GetData("eReimbursement", getright);
                                    for (int j = 0; j < dtright.Rows.Count; j++)
                                    {
                                        string[] dd = dtright.Rows[j]["Stations"].ToString().Split(',');
                                        for (int i = 0; i < dd.Length; i++)
                                        {
                                            if (dd[i] == dt.Rows[0]["Station"].ToString())//有权限
                                            {
                                                hasright = true;
                                                break;
                                            }
                                        }
                                    }
                                    if (hasright)
                                    {
                                        Ext.Net.ListItem li = new Ext.Net.ListItem(dt.Rows[0]["Person"].ToString(), dt.Rows[0]["PersonID"].ToString());
                                        cbxOwner.Items.Add(li);
                                        //更改按钮状态
                                        if (dt.Rows[0]["Step"].ToString() != "0")//正式申请单
                                        {
                                            string app = "";
                                            if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                                            {
                                                Panel3.Title = "差旅费申请单: " + dt.Rows[0]["No"].ToString();
                                                //读取当前状态,显示在下方文本框内

                                                if (dt.Rows[0]["Status"].ToString() == "1")
                                                {
                                                    app += "提单人: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                    app += ", 等待审批: " + dt.Rows[0]["Approver"].ToString();
                                                }
                                                else if (dt.Rows[0]["Status"].ToString() == "2")
                                                {
                                                    app += "提单人: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                    app += ", 完成审批: " + dt.Rows[0]["Approver"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["ApproveDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                }
                                                else if (dt.Rows[0]["Status"].ToString() == "3")
                                                {
                                                    app += "提单人: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                    app += ", 拒绝审批: " + dt.Rows[0]["Approver"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["ApproveDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                }

                                                if (dt.Rows[0]["Active"].ToString() == "2")//已完成
                                                {
                                                    hdStatus.Value = "2";
                                                    app += ". 完成.";
                                                    X.AddScript("btnGeteLeave.disable();btnEditDetail.disable();btnNewDetail.disable();btnSaveDraft.disable();btnUploadReport.disable();btnUploadScanFile.disable();Button1.disable();Button2.disable();btnCC.disable();");
                                                }
                                                else//待审批
                                                {
                                                    hdStatus.Value = "1";
                                                    X.AddScript("btnGeteLeave.disable();btnEditDetail.disable();btnNewDetail.disable();btnSaveDraft.disable();btnCC.disable();");
                                                }

                                            }
                                            else
                                            {
                                                Panel3.Title = "Travel Expense Form: " + dt.Rows[0]["No"].ToString();
                                                //读取当前状态,显示在下方文本框内

                                                if (dt.Rows[0]["Status"].ToString() == "1")
                                                {
                                                    app += "Applied by: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                    app += ", Waiting for approval By: " + dt.Rows[0]["Approver"].ToString();
                                                }
                                                else if (dt.Rows[0]["Status"].ToString() == "2")
                                                {
                                                    app += "Applied by: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                    app += ", Approved by: " + dt.Rows[0]["Approver"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["ApproveDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                }
                                                else if (dt.Rows[0]["Status"].ToString() == "3")
                                                {
                                                    app += "Applied by: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                    app += ", Rejected by: " + dt.Rows[0]["Approver"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["ApproveDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                }

                                                if (dt.Rows[0]["Active"].ToString() == "2")//已完成
                                                {
                                                    hdStatus.Value = "2";
                                                    app += ". Complete.";
                                                    X.AddScript("btnGeteLeave.disable();btnEditDetail.disable();btnNewDetail.disable();btnSaveDraft.disable();btnUploadReport.disable();btnUploadScanFile.disable();Button1.disable();Button2.disable();btnCC.disable();");
                                                }
                                                else//待审批
                                                {
                                                    hdStatus.Value = "1";
                                                    X.AddScript("btnGeteLeave.disable();btnEditDetail.disable();btnNewDetail.disable();btnSaveDraft.disable();btnCC.disable();");
                                                }
                                            }
                                            labelInfo.Text = app;
                                        }
                                        else//草稿
                                        {
                                            if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                                            {
                                                Panel3.Title = "差旅费申请单草稿: " + dt.Rows[0]["No"].ToString();
                                            }
                                            else
                                            {
                                                Panel3.Title = "Travel Expense Draft: " + dt.Rows[0]["No"].ToString();
                                            }
                                            
                                            //X.AddScript("btnSaveAndSend.enable();");
                                        }
                                        hdStatus.Value = "2";//不允许传递到子页面时修改或者上传
                                        X.AddScript("btnGeteLeave.disable();btnEditDetail.disable();btnNewDetail.disable();btnSaveDraft.disable();btnCC.disable();");
                                        //无需判断Copy
                                        //载入通用数据
                                        LoadData(dt, false);
                                    }
                                    else
                                    {
                                        ErrorHandle("No right.");
                                    }
                                }
                            }
                        }
                        else
                        {
                            ErrorHandle("Data Error.");
                        }
                    }
                    else
                    {
                        ErrorHandle("Data Error.");
                    }
                }
                else
                {
                    //准备下拉菜单内容
                    Ext.Net.ListItem li = new Ext.Net.ListItem(Request.Cookies.Get("eReimUserName").Value, Request.Cookies.Get("eReimUserID").Value);
                    cbxOwner.Items.Add(li);
                    string sqlitem = "select * from Eagent where [St]=1 and [PAgentID]='" + Request.Cookies.Get("eReimUserID").Value + "'";
                    DataTable dtitem = dbc.GetData("eReimbursement", sqlitem);
                    int itemcount = 0;
                    for (int j = 0; j < dtitem.Rows.Count; j++)
                    {
                        string sqlpara = sqlitem;
                        bool d1 = true;
                        bool d2 = false;
                        if (dtitem.Rows[j][5].ToString() != "")
                        {
                            //sqlpara += " and getdate()>='" + dtitem.Rows[j]["Bdate"].ToString() + "' ";
                            if (DateTime.Now >= Convert.ToDateTime(dtitem.Rows[j][5].ToString()))
                            {
                                d1 = true;
                            }
                            else
                            {
                                d1 = false;
                            }
                        }
                        if (dtitem.Rows[j][6].ToString() != "")
                        {
                            //sqlpara += " and getdate()<='" + dtitem.Rows[j]["Edate"].ToString() + "' ";
                            if (DateTime.Now <= Convert.ToDateTime(dtitem.Rows[j][6].ToString()))
                            {
                                d2 = true;
                            }
                            else
                            {
                                d2 = false;
                            }
                        }
                        if (d1 && d2)
                        {
                            li = new Ext.Net.ListItem(dtitem.Rows[j]["Owner"].ToString(), dtitem.Rows[j]["OwnerID"].ToString());
                            cbxOwner.Items.Add(li);
                        }
                    }
                    //新增记录时,默认为登录用户
                    cbxOwner.SelectedItem.Value = Request.Cookies.Get("eReimUserID").Value;
                    cbxOwner.SelectedItem.Text = Request.Cookies.Get("eReimUserName").Value;
                    labelStation.Text = Request.Cookies.Get("eReimStation").Value;
                    labelDepartment.Text = Request.Cookies.Get("eReimDepartment").Value;
                    LabelCurrency.Text = DIMERCO.SDK.Utilities.LSDK.GetStationCurrencyByCode(Request.Cookies.Get("eReimStation").Value);
                    X.AddScript("btnSaveAndSend.enable();cbxBudget.setReadOnly(false);");

                    //检查是否已经为该申请人设置过审批人
                    string sqlCheckFlow = "";
                    sqlCheckFlow = "select * from GroupFlow where [Type]!=2 and GID=(select GID from GroupUsers where UserID='" + cbxOwner.Value.ToString() + "')";
                    DataTable dtGroupFlowData = dbc.GetData("eReimbursement", sqlCheckFlow);
                    if (dtGroupFlowData.Rows.Count < 1)
                    {
                        if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                        {
                            ErrorHandle("请先设置审批人.");
                        }
                        else
                        {
                            ErrorHandle("Not set Approve flow,please contact with Local MIS.");
                        }
                        return;
                    }
                }
                DataSet dsdep = DIMERCO.SDK.Utilities.LSDK.getCRPDepartment();
                DataTable dtdep = new DataTable();
                dtdep.Columns.Add(new DataColumn("Depart", typeof(String)));
                for (int i = 0; i < dsdep.Tables[0].Rows.Count; i++)
                {
                    DataRow dr = dtdep.NewRow();
                    dr[0] = dsdep.Tables[0].Rows[i][2].ToString();
                    dtdep.Rows.Add(dr);
                }
                StoreDepartment.DataSource = dtdep;
                StoreDepartment.DataBind();
            }
        }
Пример #24
0
        protected void btnLogin_Click(object sender, DirectEventArgs e)
        {
            cs.DBCommand dbc = new cs.DBCommand();
            DataSet      ds1 = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(tfUserID.Text);

            if (ds1.Tables[0].Rows.Count == 1)
            {
                DataTable dt1 = ds1.Tables[0];
                Session["UserID"]     = dt1.Rows[0]["UserID"].ToString();
                Session["UserName"]   = dt1.Rows[0]["fullName"].ToString();
                Session["Station"]    = dt1.Rows[0]["stationCode"].ToString();
                Session["Department"] = dt1.Rows[0]["CRPDepartmentName"].ToString();
                Session["CostCenter"] = dt1.Rows[0]["CostCenter"].ToString();
                if (Request.Cookies["eReimUserID"] != null)
                {
                    Response.Cookies["eReimUserID"].Value   = dt1.Rows[0]["UserID"].ToString(); //将值写入到客户端硬盘Cookie
                    Response.Cookies["eReimUserID"].Expires = DateTime.Now.AddHours(12);        //设置Cookie过期时间
                }
                else
                {
                    HttpCookie cookie = new HttpCookie("eReimUserID", dt1.Rows[0]["UserID"].ToString());
                    cookie.Expires = DateTime.Now.AddHours(12);
                    Response.Cookies.Add(cookie);
                }
                if (Request.Cookies["eReimUserName"] != null)
                {
                    Response.Cookies["eReimUserName"].Value   = dt1.Rows[0]["fullName"].ToString(); //将值写入到客户端硬盘Cookie
                    Response.Cookies["eReimUserName"].Expires = DateTime.Now.AddHours(12);          //设置Cookie过期时间
                }
                else
                {
                    HttpCookie cookie = new HttpCookie("eReimUserName", dt1.Rows[0]["fullName"].ToString());
                    cookie.Expires = DateTime.Now.AddHours(12);
                    Response.Cookies.Add(cookie);
                }
                if (Request.Cookies["eReimStation"] != null)
                {
                    Response.Cookies["eReimStation"].Value   = dt1.Rows[0]["stationCode"].ToString(); //将值写入到客户端硬盘Cookie
                    Response.Cookies["eReimStation"].Expires = DateTime.Now.AddHours(12);             //设置Cookie过期时间
                }
                else
                {
                    HttpCookie cookie = new HttpCookie("eReimStation", dt1.Rows[0]["stationCode"].ToString());
                    cookie.Expires = DateTime.Now.AddHours(12);
                    Response.Cookies.Add(cookie);
                }
                if (Request.Cookies["eReimDepartment"] != null)
                {
                    Response.Cookies["eReimDepartment"].Value   = dt1.Rows[0]["CRPDepartmentName"].ToString(); //将值写入到客户端硬盘Cookie
                    Response.Cookies["eReimDepartment"].Expires = DateTime.Now.AddHours(12);                   //设置Cookie过期时间
                }
                else
                {
                    HttpCookie cookie = new HttpCookie("eReimDepartment", dt1.Rows[0]["CRPDepartmentName"].ToString());
                    cookie.Expires = DateTime.Now.AddHours(12);
                    Response.Cookies.Add(cookie);
                }
                if (Request.Cookies["eReimCostCenter"] != null)
                {
                    Response.Cookies["eReimCostCenter"].Value   = dt1.Rows[0]["CostCenter"].ToString(); //将值写入到客户端硬盘Cookie
                    Response.Cookies["eReimCostCenter"].Expires = DateTime.Now.AddHours(12);            //设置Cookie过期时间
                }
                else
                {
                    HttpCookie cookie = new HttpCookie("eReimCostCenter", dt1.Rows[0]["CostCenter"].ToString());
                    cookie.Expires = DateTime.Now.AddHours(12);
                    Response.Cookies.Add(cookie);
                }
                X.AddScript("window.location.reload();");
            }
            else
            {
                X.Msg.Alert("Message", "Data Error.").Show();
                return;
            }
        }
Пример #25
0
        public void SaveAll(string type, string detail, string MailList)
        {
            if (Request.Cookies.Get("eReimUserID") == null || hdUser.Value.ToString() != Request.Cookies.Get("eReimUserID").Value)
            {
                if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                {
                    X.AddScript("Ext.Msg.show({ title: '提示', msg: '已切换用户,将刷新页面.', buttons: { ok: 'Ok' }, fn: function (btn) { window.location.reload(); } });");
                }
                else
                {
                    X.AddScript("Ext.Msg.show({ title: 'Message', msg: 'Current user changed,reloading...', buttons: { ok: 'Ok' }, fn: function (btn) { window.location.reload(); } });");
                }
                return;
            }
            //如果正式申请必须上传出差报告
            if (type == "ND")
            {
                if (hdReport.Value.ToString() == "")
                {
                    if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                    {
                        X.AddScript("Ext.Msg.show({ title: '提示', msg: '必须上传出差报告.', buttons: { ok: 'Ok' }, fn: function (btn) { return false;} });");
                    }
                    else
                    {
                        X.AddScript("Ext.Msg.show({ title: 'Message', msg: 'Please upload travel report.', buttons: { ok: 'Ok' }, fn: function (btn) {return false;} });");
                    }
                    return;
                }
            }
            DateTime dtnull = new DateTime(1, 1, 1, 0, 0, 0);
            cs.DBCommand dbc = new cs.DBCommand();
            string userid = cbxOwner.Value.ToString();
            string ostation = "";
            DataSet ds2 = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(userid);
            if (ds2.Tables[0].Rows.Count == 1)
            {
                DataTable dt1 = ds2.Tables[0];
                //dpt = dt1.Rows[0]["DepartmentName"].ToString();
                ostation = dt1.Rows[0]["stationCode"].ToString();

                DataTable dttemp = new DataTable();
                string sqltemp = "select * from ESUSER where Userid='" + userid + "'";
                dttemp = dbc.GetData("eReimbursement", sqltemp);
                if (dttemp.Rows.Count > 0)
                {
                    ostation = dttemp.Rows[0]["Station"].ToString();
                }
            }
            //判断Budget下是否符合预算要求
            if (cbxBudget.Value.ToString()=="YES")
            {
                JavaScriptSerializer ser1 = new JavaScriptSerializer();
                List<DetailExpense> DetailList = ser1.Deserialize<List<DetailExpense>>(detail);
                for (int ig = 0; ig < DetailList.Count; ig++)
                {
                    DetailExpense detailitem = DetailList[ig];
                    
                    string dpt = detailitem.Department1;
                    
                    string tstation = detailitem.TSation == "" ? ostation : detailitem.TSation;
                    string accountcode = detailitem.AccountCode;
                    string Years = Convert.ToDateTime(detailitem.Tdate).Year.ToString();
                    string month = Convert.ToDateTime(detailitem.Tdate).Month.ToString();

                    DataTable dt = new DataTable();
                    dt = Comm.RtnEB(userid, dpt, ostation, tstation, accountcode, Years, month);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        decimal stationbudget = 0, departmentbudget = 0, personbudget = 0;
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            if (dt.Rows[i]["Type"].ToString() == "站点")
                            {
                                stationbudget = Convert.ToDecimal(dt.Rows[i]["Budget"].ToString());
                            }
                        }
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            if (dt.Rows[i]["Type"].ToString() == "部门")
                            {
                                departmentbudget = Convert.ToDecimal(dt.Rows[i]["Budget"].ToString());
                            }
                        }
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            if (dt.Rows[i]["Type"].ToString() == "个人")
                            {
                                personbudget = Convert.ToDecimal(dt.Rows[i]["Budget"].ToString());
                            }
                        }
                        if (stationbudget == 0 && departmentbudget == 0 && personbudget == 0)
                        {
                            //hdBudget.Value = "0";
                            //ErrorHandleNojump("No budget,please check with Account.");
                            //X.AddScript("Ext.Msg.show({ title: 'Message', msg: 'No budget,please check with Account.', buttons: { ok: 'Ok' }, fn: function (btn) { RowSelectionModel1.selectRow("+ig.ToString()+") } });");
                            X.AddScript("RowSelectionModel1.selectRow(" + ig.ToString() + ")");
                            return;
                        }
                        //else
                        //{
                        //    hdBudget.Value = "1";
                        //}
                    }
                    else
                    {
                        //hdBudget.Value = "0";
                        ErrorHandleNojump("Data error.");
                        return;
                    }
                }

                //foreach (DetailExpense detailitem in DetailList)
                //{
                    
                //}
            }
            //return;
            //处理抄送人列表
            string CCMailList = "";
            JavaScriptSerializer ser = new JavaScriptSerializer();
            List<CCMailList> CCMailList1 = ser.Deserialize<List<CCMailList>>(MailList);
            foreach (CCMailList mail in CCMailList1)
            {
                CCMailList += mail.Email + ",";
            }
            CCMailList = CCMailList.Length > 0 ? CCMailList.Substring(0, CCMailList.Length - 1) : "";
            //检查是否已经为该申请人设置过审批人
            string sqlCheckFlow = "";
            if (cbxBudget.Value.ToString() == "YES")//使用Budget审批流程
            {
                sqlCheckFlow = "select * from GroupFlow where [Type]!=2 and GID=(select GID from GroupUsers where UserID='" + cbxOwner.Value.ToString() + "')";
            }
            else//使用unBudget审批流程
            {
                sqlCheckFlow = "select * from GroupFlow where [Type]=2 and GID=(select GID from GroupUsers where UserID='" + cbxOwner.Value.ToString() + "')";
            }
            DataTable dtGroupFlowData = dbc.GetData("eReimbursement", sqlCheckFlow);
            if (dtGroupFlowData.Rows.Count < 1)
            {
                if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                {
                    ErrorHandleNojump("请先设置审批人.");
                }
                else
                {
                    ErrorHandleNojump("Not set Approve flow,please contact with Local MIS.");
                }
                return;
            }
            string para = type;
            string station = ""; string department = "";
            DataSet ds1 = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(cbxOwner.Value.ToString());
            if (ds1.Tables[0].Rows.Count == 1)
            {
                DataTable dt1 = ds1.Tables[0];
                station = dt1.Rows[0]["stationCode"].ToString();
                department = dt1.Rows[0]["DepartmentName"].ToString();
            }
            if (para == "ND")//保存并申请
            {
                if (hdTravelRequestID.Value.ToString() == "")//直接新增申请,不通过草稿
                {
                    string word = "[No],[Person],[Station],[Department],[ReportFile],[Tamount],[Pamout],[Camount],[CreadedBy],[CreadedDate],[Attach],[Remark],[Bdate],[Edate],[PersonID],[CreadedByID],[ApplyDate],[CCMailList],[Budget],[Station2]";
                    string value = "";
                    value += "'" + station + DateTime.Now.Year.ToString().Substring(2, 2) + DateTime.Now.Month.ToString().PadLeft(2, '0') + "',";//edit
                    value += "'" + X.GetValue("cbxOwner") + "',"; value += "'" + station + "',"; value += "'" + department + "',";//edit
                    value += "'" + hdReport.Value.ToString() + "',";
                    value += hdSum.Value.ToString() == "" ? "null" : hdSum.Value.ToString();
                    value += "," + (hdPamountSum.Value.ToString() == "" ? "null" : hdPamountSum.Value.ToString());
                    value += "," + (hdCamountSum.Value.ToString() == "" ? "null" : hdCamountSum.Value.ToString());
                    value += ",'" + Request.Cookies.Get("eReimUserName").Value + "'";//edit
                    value += ",'" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "',";
                    value += "'" + hdScanFile.Value.ToString() + "',";
                    value += "'" + txtRemark.Text.Replace("'", "''") + "',";
                    string Bdate = "";
                    if (dfBdate.SelectedDate != dtnull)
                    {
                        Bdate = dfBdate.SelectedDate.ToString();
                    }
                    value += Bdate == "" ? "null," : "'" + Bdate + "',";
                    string Edate = "";
                    if (dfEdate.SelectedDate != dtnull)
                    {
                        Edate = dfEdate.SelectedDate.ToString();
                    }
                    value += Edate == "" ? "null" : "'" + Edate + "'";
                    value += ",'" + cbxOwner.Value.ToString() + "'";
                    value += ",'" + Request.Cookies.Get("eReimUserID").Value + "'";
                    value += ",'" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "'";
                    value += ",'" + CCMailList + "'";
                    value += "," + (cbxBudget.Value.ToString() == "YES" ? "1" : "0");
                    value += ",'"+ostation+"'";
                    string updatesql = "insert into ETravel (" + word + ") values(" + value + ");update ETravel set [No]=[No]+(select [MonthCount]=right('0000'+cast(count(ID) as varchar(10)),4) from ETravel where (month(ApplyDate) in (select month(ApplyDate) from ETravel where [ID]=@@IDENTITY) and (year(ApplyDate) in (select year(ApplyDate) from ETravel where [ID]=@@IDENTITY)) and Station=(select Station from ETravel where ID=@@IDENTITY)))+'T' where ID=@@IDENTITY;select [msg]=convert(varchar,ID)+','+[No] from ETravel where ID=@@IDENTITY";

                    string newid = dbc.UpdateData("eReimbursement", updatesql, "Insert");

                    //操作Flow表
                    //根据cbxBudget,选择不同的审批流程
                    //string sqlGetGroupFlowData = "";
                    //if (cbxBudget.Value.ToString() == "YES")//使用Budget审批流程
                    //{
                    //    sqlGetGroupFlowData = "select * from GroupFlow where [Type]!=2 and GID=(select GID from GroupUsers where UserID='" + cbxOwner.Value.ToString() + "')";
                    //}
                    //else//使用unBudget审批流程
                    //{
                    //    sqlGetGroupFlowData = "select * from GroupFlow where [Type]=2 and GID=(select GID from GroupUsers where UserID='" + cbxOwner.Value.ToString() + "')";
                    //}
                    //DataTable dtGroupFlowData = new DataTable();
                    //dtGroupFlowData = dbc.GetData("eReimbursement", sqlGetGroupFlowData);
                    string rows = "";
                    for (int i = 0; i < dtGroupFlowData.Rows.Count; i++)
                    {
                        string wordflow = "[No],[Type],[Station],[Department],[Person],[CreadedBy],[CreatedDate],[Tamount],[Step],[Status],[Approver],[ApproverID],[RequestID],[FlowFn]";
                        if (dtGroupFlowData.Rows[i]["FlowNo"].ToString() == "1")
                        {
                            wordflow += ",[Active]";
                        }
                        string valueflow = "";
                        valueflow += "'" + newid.Split(',')[1] + "',";
                        valueflow += "'T',";
                        valueflow += "'" + station + "',";
                        valueflow += "'" + department + "',";
                        valueflow += "'" + X.GetValue("cbxOwner") + "',";
                        valueflow += "'" + Request.Cookies.Get("eReimUserName").Value + "',";
                        valueflow += "'" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "',";
                        valueflow += hdSum.Value.ToString() == "" ? "null," : hdSum.Value.ToString() + ",";
                        valueflow += dtGroupFlowData.Rows[i]["FlowNo"].ToString() + ",";
                        valueflow += "1,";
                        valueflow += "'" + dtGroupFlowData.Rows[i]["FlowUser"].ToString() + "',";
                        valueflow += "'" + dtGroupFlowData.Rows[i]["FlowUserid"].ToString() + "',";
                        valueflow += "'" + newid.Split(',')[0] + "'";
                        valueflow += ",'" + (dtGroupFlowData.Rows[i]["Fn"].ToString() == "" ? "Approver" : dtGroupFlowData.Rows[i]["Fn"].ToString()) + "'";
                        if (dtGroupFlowData.Rows[i]["FlowNo"].ToString() == "1")
                        {
                            valueflow += ",1";
                        }
                        string sqlupdateEFlow = "insert into Eflow (" + wordflow + ") values(" + valueflow + ")";
                        rows = dbc.UpdateData("eReimbursement", sqlupdateEFlow, "Update");
                    }
                    if (newid == "-1" || rows == "-1" || rows == "")
                    {
                        ErrorHandle("Data Error.");
                        return;
                    }
                    else
                    {
                        hdTravelRequestID.Value = newid.Split(',')[0];//新增后记录ID
                        hdTravelRequestNo.Value = newid.Split(',')[1];//新增后记录No
                        
                        if (!SaveDetail(detail) || !SendMail())
                        {
                            ErrorHandle("Data Error.");
                            return;
                        }
                        if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                        {
                            Panel3.Title = "差旅费申请单: " + newid.Split(',')[1];
                            UpdateMSG("保存申请单:" + newid.Split(',')[1] + "成功.");
                        }
                        else
                        {
                            Panel3.Title = "Travel Expense Form: " + newid.Split(',')[1];
                            UpdateMSG("Saved Travel Expense Form: " + newid.Split(',')[1] + " successfully.");
                        }
                        
                    }
                    //
                }
                else//由草稿升级为正式申请
                {
                    string updatesql = "update ETravel set [Person]='" + X.GetValue("cbxOwner");
                    updatesql += "',[Station]='" + station;
                    updatesql += "',[Department]='" + department;
                    updatesql += "',[ReportFile]='" + hdReport.Value.ToString();
                    updatesql += "',[Tamount]=" + (hdSum.Value.ToString() == "" ? "null" : hdSum.Value.ToString());
                    updatesql += ",[Pamout]=" + (hdPamountSum.Value.ToString() == "" ? "null" : hdPamountSum.Value.ToString());
                    updatesql += ",[Camount]=" + (hdCamountSum.Value.ToString() == "" ? "null" : hdCamountSum.Value.ToString());
                    updatesql += ",[Remark]='" + txtRemark.Text.Replace("'", "''") + "'";
                    updatesql += ",[Attach]='" + hdScanFile.Value.ToString() + "'";
                    updatesql += ",[Type]=0";
                    updatesql += ",[PersonID]='" + cbxOwner.Value.ToString() + "'";
                    string oldno = hdTravelRequestNo.Value.ToString();
                    string newno = hdTravelRequestNo.Value.ToString().Substring(0, hdTravelRequestNo.Value.ToString().Length - 1);
                    updatesql += ",[No]='" + newno + "',";
                    updatesql += "[CreadedDate]='" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "',";
                    updatesql += "[CreadedBy]='" + Request.Cookies.Get("eReimUserName").Value + "',";
                    updatesql += "[CreadedByID]='" + Request.Cookies.Get("eReimUserID").Value + "'";
                    string Bdate = "";
                    if (dfBdate.SelectedDate != dtnull)
                    {
                        Bdate = dfBdate.SelectedDate.ToString();
                    }
                    updatesql += Bdate == "" ? ",Bdate=null" : ",Bdate='" + Bdate + "'";
                    string Edate = "";
                    if (dfEdate.SelectedDate != dtnull)
                    {
                        Edate = dfEdate.SelectedDate.ToString();
                    }
                    updatesql += Edate == "" ? ",Edate=null" : ",Edate='" + Edate + "'";
                    updatesql += ",[CCMailList]='" + CCMailList + "'";
                    updatesql += ",[Budget]=" + (cbxBudget.Value.ToString() == "YES" ? "1" : "0");
                    updatesql += ",[Station2]='"+ostation+"'";
                    updatesql += " where ID=" + hdTravelRequestID.Value.ToString();

                    string newid = dbc.UpdateData("eReimbursement", updatesql, "Update");

                    //操作Flow表
                    string sqlDeleteEflow = "delete from Eflow where [Type]='T' and [RequestID]='" + hdTravelRequestID.Value.ToString() + "'";
                    string deleterows = dbc.UpdateData("eReimbursement", sqlDeleteEflow, "Update");
                    //根据cbxBudget,选择不同的审批流程
                    //string sqlGetGroupFlowData = "";
                    //if (cbxBudget.Value.ToString() == "YES")//使用Budget审批流程
                    //{
                    //    sqlGetGroupFlowData = "select * from GroupFlow where [Type]!=2 and GID=(select GID from GroupUsers where UserID='" + cbxOwner.Value.ToString() + "')";
                    //}
                    //else//使用unBudget审批流程
                    //{
                    //    sqlGetGroupFlowData = "select * from GroupFlow where [Type]=2 and GID=(select GID from GroupUsers where UserID='" + cbxOwner.Value.ToString() + "')";
                    //}
                    //DataTable dtGroupFlowData = new DataTable();
                    //dtGroupFlowData = dbc.GetData("eReimbursement", sqlGetGroupFlowData);
                    string rows = "";
                    for (int i = 0; i < dtGroupFlowData.Rows.Count; i++)
                    {
                        string wordflow = "[No],[Type],[Station],[Department],[Person],[CreadedBy],[CreatedDate],[Tamount],[Step],[Status],[Approver],[ApproverID],[RequestID],[FlowFn]";
                        if (dtGroupFlowData.Rows[i]["FlowNo"].ToString() == "1")
                        {
                            wordflow += ",[Active]";
                        }
                        string valueflow = "";
                        valueflow += "'" + newno + "',";
                        valueflow += "'T',";
                        valueflow += "'" + station + "',";
                        valueflow += "'" + department + "',";
                        valueflow += "'" + X.GetValue("cbxOwner") + "',";
                        valueflow += "'" + Request.Cookies.Get("eReimUserName").Value + "',";
                        valueflow += "'" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "',";
                        valueflow += hdSum.Value.ToString() == "" ? "null," : hdSum.Value.ToString() + ",";
                        valueflow += dtGroupFlowData.Rows[i]["FlowNo"].ToString() + ",";
                        valueflow += "1,";
                        valueflow += "'" + dtGroupFlowData.Rows[i]["FlowUser"].ToString() + "',";
                        valueflow += "'" + dtGroupFlowData.Rows[i]["FlowUserid"].ToString() + "',";
                        valueflow += hdTravelRequestID.Value.ToString();
                        valueflow += ",'" + (dtGroupFlowData.Rows[i]["Fn"].ToString() == "" ? "Approver" : dtGroupFlowData.Rows[i]["Fn"].ToString()) + "'";
                        if (dtGroupFlowData.Rows[i]["FlowNo"].ToString() == "1")
                        {
                            valueflow += ",1";
                        }
                        string sqlupdateEFlow = "insert into Eflow (" + wordflow + ") values(" + valueflow + ")";
                        rows = dbc.UpdateData("eReimbursement", sqlupdateEFlow, "Update");
                    }
                    //
                    if (newid == "-1" || rows == "-1" || rows == "")
                    {
                        ErrorHandle("Data Error.");
                        return;
                    }
                    else
                    {
                        hdTravelRequestNo.Value = newno;
                        
                        if (!SaveDetail(detail) || !SendMail())
                        {
                            ErrorHandle("Data Error.");
                            return;
                        }
                        

                        if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                        {
                            Panel3.Title = "差旅费申请单:" + newno;
                            UpdateMSG("保存差旅费申请单:" + hdTravelRequestNo.Value.ToString() + "成功.");
                        }
                        else
                        {
                            Panel3.Title = "Travel Expense Form: " + newno;
                            UpdateMSG("Saved Travel Expense Form: " + hdTravelRequestNo.Value.ToString() + " successfully.");
                        }
                        
                    }
                }
                X.AddScript("btnGeteLeave.disable();btnEditDetail.disable();btnNewDetail.disable();btnSaveDraft.disable();btnSaveAndSend.disable();cbxBudget.setReadOnly(true);btnExport.enable();btnCC.disable();");
            }
            else//保存草稿
            {
                if (hdTravelRequestID.Value.ToString() != "")//由链接进入的草稿更新
                {
                    string updatesql = "update ETravel set [Person]='" + X.GetValue("cbxOwner");
                    updatesql += "',[Station]='" + station;
                    updatesql += "',[Department]='" + department;
                    updatesql += "',[ReportFile]='" + hdReport.Value.ToString();
                    updatesql += "',[Tamount]=" + (hdSum.Value.ToString() == "" ? "null" : hdSum.Value.ToString());
                    updatesql += ",[Pamout]=" + (hdPamountSum.Value.ToString() == "" ? "null" : hdPamountSum.Value.ToString());
                    updatesql += ",[Camount]=" + (hdCamountSum.Value.ToString() == "" ? "null" : hdCamountSum.Value.ToString());
                    updatesql += ",[Remark]='" + txtRemark.Text.Replace("'", "''") + "'";
                    updatesql += ",[Attach]='" + hdScanFile.Value.ToString() + "'";
                    updatesql += ",[PersonID]='" + cbxOwner.Value.ToString() + "'";
                    
                    string Bdate = "";
                    if (dfBdate.SelectedDate != dtnull)
                    {
                        Bdate = dfBdate.SelectedDate.ToString();
                    }
                    updatesql += Bdate == "" ? ",Bdate=null" : ",Bdate='" + Bdate + "'";
                    string Edate = "";
                    if (dfEdate.SelectedDate != dtnull)
                    {
                        Edate = dfEdate.SelectedDate.ToString();
                    }
                    updatesql += Edate == "" ? ",Edate=null" : ",Edate='" + Edate + "'";
                    updatesql += ",[CCMailList]='" + CCMailList + "'";
                    updatesql += ",[Budget]=" + (cbxBudget.Value.ToString() == "YES" ? "1" : "0");
                    updatesql += ",[Station2]='"+ostation+"'";
                    updatesql += " where ID=" + hdTravelRequestID.Value.ToString();

                    string newid = dbc.UpdateData("eReimbursement", updatesql, "Update");

                    ////更新Eflow表
                    //string sqlupdateflow = "update Eflow set [Station]='" + station + "',";
                    //sqlupdateflow += "[Department]='" + department + "',";
                    //sqlupdateflow += "[Person]='" + X.GetValue("cbxOwner") + "',";
                    //sqlupdateflow += "[Tamount]=" + (hdSum.Value.ToString() == "" ? "null" : hdSum.Value.ToString());
                    //sqlupdateflow += " where [No]='" + hdTravelRequestNo.Value.ToString() + "'";

                    //string rows = dbc.UpdateData("eReimbursement", sqlupdateflow, "Update");
                    if (newid == "-1")
                    {
                        ErrorHandle("Data Error.");
                        return;
                    }
                    else
                    {
                        if (!SaveDetail(detail))
                        {
                            ErrorHandle("Data Error.");
                            return;
                        }
                        //hdTravelRequestID.Value = newid.Split(',')[0];//新增后记录ID
                        //Panel3.Title = "差旅费申请单:" + newid.Split(',')[1];
                        //X.AddScript("GridPanel2.submitData();");
                        if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                        {
                            UpdateMSG("保存差旅费申请单草稿: " + hdTravelRequestNo.Value.ToString() + "成功.");
                        }
                        else
                        {
                            UpdateMSG("Saved Travel Expense Draft: " + hdTravelRequestNo.Value.ToString() + " successfully.");
                        }
                    }

                }
                else//如果ID为空则判断为新增草稿
                {
                    string word = "[No],[Person],[Station],[Department],[ReportFile],[Tamount],[Pamout],[Camount],[Attach],[Remark],[Bdate],[Edate],[Type],[PersonID],[ApplyDate],[CCMailList],[Station2],[Budget]";
                    string value = "";
                    value += "'" + station + DateTime.Now.Year.ToString().Substring(2, 2) + DateTime.Now.Month.ToString().PadLeft(2, '0') + "',";//edit
                    value += "'" + X.GetValue("cbxOwner") + "',"; value += "'" + station + "',"; value += "'" + department + "',";//edit
                    value += "'" + hdReport.Value.ToString() + "',";
                    value += (hdSum.Value.ToString() == "" ? "null" : hdSum.Value.ToString());
                    value += "," + (hdPamountSum.Value.ToString() == "" ? "null" : hdPamountSum.Value.ToString());
                    value += "," + (hdCamountSum.Value.ToString() == "" ? "null" : hdCamountSum.Value.ToString());
                    value += ",'" + hdScanFile.Value.ToString() + "',";
                    value += "'" + txtRemark.Text.Replace("'", "''") + "',";
                    string Bdate = "";
                    if (dfBdate.SelectedDate != dtnull)
                    {
                        Bdate = dfBdate.SelectedDate.ToString();
                    }
                    value += Bdate == "" ? "null," : "'" + Bdate + "',";
                    string Edate = "";
                    if (dfEdate.SelectedDate != dtnull)
                    {
                        Edate = dfEdate.SelectedDate.ToString();
                    }
                    value += Edate == "" ? "null," : "'" + Edate + "',";
                    value += "1";//标识为草稿
                    value += ",'" + cbxOwner.Value.ToString() + "'";
                    value += ",'" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "'";
                    value += ",'" + CCMailList + "'";
                    value += ",'"+ostation+"'";
                    value += "," + (cbxBudget.Value.ToString() == "YES" ? "1" : "0");
                    string updatesql = "insert into ETravel (" + word + ") values(" + value + ");update ETravel set [No]=[No]+(select [MonthCount]=right('0000'+cast(count(ID) as varchar(10)),4) from ETravel where (month(ApplyDate) in (select month(ApplyDate) from ETravel where [ID]=@@IDENTITY) and (year(ApplyDate) in (select year(ApplyDate) from ETravel where [ID]=@@IDENTITY)) and Station=(select Station from ETravel where ID=@@IDENTITY)))+'TD' where ID=@@IDENTITY;select [msg]=convert(varchar,ID)+','+[No] from ETravel where ID=@@IDENTITY";

                    string newid = dbc.UpdateData("eReimbursement", updatesql, "Insert");

                    //操作Flow表
                    string wordflow = "[No],[Type],[Station],[Department],[Person],[CreadedBy],[CreatedDate],[Tamount],[RequestID],[Active]";
                    string valueflow = "";
                    valueflow += "'" + newid.Split(',')[1] + "',";
                    valueflow += "'T',";
                    valueflow += "'" + station + "',";
                    valueflow += "'" + department + "',";
                    valueflow += "'" + X.GetValue("cbxOwner") + "',";
                    valueflow += "'" + Request.Cookies.Get("eReimUserName").Value + "',";
                    valueflow += "'" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "',";
                    valueflow += hdSum.Value.ToString() == "" ? "null," : hdSum.Value.ToString() + ",";
                    valueflow += "'" + newid.Split(',')[0] + "'";
                    valueflow += ",1";
                    string sqlupdateEFlow = "insert into Eflow (" + wordflow + ") values(" + valueflow + ")";
                    string rows = dbc.UpdateData("eReimbursement", sqlupdateEFlow, "Update");
                    //
                    if (newid == "-1" || rows == "-1")
                    {
                        ErrorHandle("Data Error."); return;
                    }
                    else
                    {
                        hdTravelRequestID.Value = newid.Split(',')[0];//新增后记录ID
                        hdTravelRequestNo.Value = newid.Split(',')[1];//新增后记录No
                        if (!SaveDetail(detail))
                        {
                            ErrorHandle("Data Error.");
                            return;
                        }
                        if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                        {
                            Panel3.Title = "差旅费申请单草稿: " + newid.Split(',')[1];
                            UpdateMSG("新增差旅费申请单草稿: " + newid.Split(',')[1] + "成功.");
                        }
                        else
                        {
                            Panel3.Title = "Travel Expense Draft: " + newid.Split(',')[1];
                            UpdateMSG("Added Travel Expense Draft: " + newid.Split(',')[1] + " successfully.");
                        }
                    }
                }
            }
        }
Пример #26
0
        public void Add(string address)
        {
            cs.DBCommand dbc = new cs.DBCommand();
            string sConnection = ConfigurationManager.ConnectionStrings["eReimbursement"].ConnectionString;
            SqlConnection DbConnection = new SqlConnection(sConnection);
            SqlCommand command = new SqlCommand("SP_MailSetting", DbConnection);

            command.CommandType = CommandType.StoredProcedure;

            SqlParameter sp = new SqlParameter("@UserID", SqlDbType.VarChar, 50);
            sp.Value = Request.Cookies.Get("eReimUserID").Value;
            command.Parameters.Add(sp);

            //处理抄送人列表
            string CCMailList = "";
            JavaScriptSerializer serd = new JavaScriptSerializer();
            List<CCMailList> CCMailList1 = serd.Deserialize<List<CCMailList>>(address);
            foreach (CCMailList mail in CCMailList1)
            {
                CCMailList += mail.Email + ",";
            }
            CCMailList = CCMailList.Length > 0 ? CCMailList.Substring(0, CCMailList.Length - 1) : "";

            sp = new SqlParameter("@MailList", SqlDbType.VarChar, 2000);
            sp.Value = CCMailList;
            command.Parameters.Add(sp);

            sp = new SqlParameter("@Return", SqlDbType.Int);
            sp.Direction = ParameterDirection.Output;
            command.Parameters.Add(sp);

            DbConnection.Open();
            int rowsAffected = command.ExecuteNonQuery();
            //int result = (int)command.Parameters["Returnvalue"].Value;
            //string rw = command.Parameters["@Return"].Value.ToString();
            int newID = (int)command.Parameters["@Return"].Value;
            DbConnection.Close();
        }
Пример #27
0
        public void LoadBG(string command,string GetDetailOrUpdate)
        {
            cs.DBCommand dbc = new cs.DBCommand();
            string userid = cbxOwner.Value.ToString();
            string dpt = cbxDepartment.Text;
            string ostation = "";
            DataSet ds1 = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(userid);
            if (ds1.Tables[0].Rows.Count == 1)
            {
                DataTable dt1 = ds1.Tables[0];
                //dpt = dt1.Rows[0]["DepartmentName"].ToString();
                ostation = dt1.Rows[0]["stationCode"].ToString();

                DataTable dttemp = new DataTable();
                string sqltemp = "select * from ESUSER where Userid='" + userid + "'";
                dttemp = dbc.GetData("eReimbursement", sqltemp);
                if (dttemp.Rows.Count > 0)
                {
                    ostation = dttemp.Rows[0]["Station"].ToString();
                }
            }
            string tstation = cbxCOACenter.Value == null ? ostation : cbxCOACenter.Value.ToString();
            string accountcode = cbxCOA.Value.ToString();
            string Years = Convert.ToDateTime(dfDate.Value.ToString()).Year.ToString();
            string month = Convert.ToDateTime(dfDate.Value.ToString()).Month.ToString();

            DataTable dt = new DataTable();
            //Comm.RtnEB("A1306","Finance/Accounting","CRP","62012021","2013","9")
            //userid = "A1306";
            //dpt = "Finance/Accounting";
            //ostation = "CRP";
            //tstation = "CRP";
            //accountcode = "62012021";
            //Years = "2013";
            //month = "9";
            dt = Comm.RtnEB(userid, dpt, ostation, tstation, accountcode, Years, month);
            if (dt != null && dt.Rows.Count > 0)
            {
                LabelStationBG.Text = "Station:NA";
                LabelDepartmentBG.Text = "Department:NA";
                LabelPersonBG.Text = "Person:NA";
                LabelPersonBGOneYear.Text = "Person(YTD):NA";
                decimal stationbudget = 0, departmentbudget = 0, personbudget = 0;
                LabelCOA.Text = X.GetValue("cbxCOA") + ":";
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["Type"].ToString() == "站点")
                    {
                        stationbudget = Convert.ToDecimal(dt.Rows[i]["Budget"].ToString());
                        string stationbg = dt.Rows[i]["Station"].ToString() + ": " + Convert.ToDecimal(dt.Rows[i]["Used"].ToString()).ToString("#,##0.00") + "/" + Convert.ToDecimal(dt.Rows[i]["Budget"].ToString()).ToString("#,##0.00");
                        //X.AddScript("LabelStationBG.setText('" + stationbg + "');PanelBudget.show();");
                        LabelStationBG.Text = stationbg;
                        //X.AddScript("LabelStationBG.setText('" + stationbg + "');");
                    }
                }
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["Type"].ToString() == "部门")
                    {
                        departmentbudget = Convert.ToDecimal(dt.Rows[i]["Budget"].ToString());
                        string stationbg = dpt + ": " + Convert.ToDecimal(dt.Rows[i]["Used"].ToString()).ToString("#,##0.00") + "/" + Convert.ToDecimal(dt.Rows[i]["Budget"].ToString()).ToString("#,##0.00");
                        //X.AddScript("LabelStationBG.setText('" + stationbg + "');PanelBudget.show();");
                        LabelDepartmentBG.Text = stationbg;
                        //X.AddScript("LabelDepartmentBG.setText('" + stationbg + "');");
                    }
                }
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["Type"].ToString() == "个人")
                    {
                        personbudget = Convert.ToDecimal(dt.Rows[i]["Budget"].ToString());
                        string stationbg = X.GetValue("cbxOwner") + ": " + Convert.ToDecimal(dt.Rows[i]["Used"].ToString()).ToString("#,##0.00") + "/" + Convert.ToDecimal(dt.Rows[i]["Budget"].ToString()).ToString("#,##0.00");
                        //X.AddScript("LabelStationBG.setText('" + stationbg + "');PanelBudget.show();");
                        LabelPersonBG.Text = stationbg;
                        //X.AddScript("LabelPersonBG.setText('" + stationbg + "');");
                    }
                }
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["Type"].ToString() == "全年")
                    {
                        string stationbg = "Person(YTD): " + Convert.ToDecimal(dt.Rows[i]["Used"].ToString()).ToString("#,##0.00") + "/" + Convert.ToDecimal(dt.Rows[i]["Budget"].ToString()).ToString("#,##0.00");
                        //X.AddScript("LabelStationBG.setText('" + stationbg + "');PanelBudget.show();");
                        LabelPersonBGOneYear.Text = stationbg;
                        //X.AddScript("LabelPersonBG.setText('" + stationbg + "');");
                    }
                }
                if (cbxBudget.Value.ToString() == "YES"&&stationbudget == 0 && departmentbudget == 0 && personbudget == 0)
                {
                    //hdBudget.Value = "0";
                    //ErrorHandleNojump("No budget,please check with Account.");
                    X.AddScript("Ext.Msg.show({ title: 'Message', msg: 'No budget,please check with Account.', buttons: { ok: 'Ok' }, fn: function (btn) { return false; } });");
                    return;
                }
                else
                {
                    //hdBudget.Value = "1";
                    if (GetDetailOrUpdate == "Update")
                    {
                        X.AddScript("UpdateList('" + command + "');");
                    }
                }
            }
            else
            {
                //hdBudget.Value = "0";
                ErrorHandleNojump("Data error.");
                return;
            }
        }
Пример #28
0
        public void GetDataFromeLeave()
        {
            DataTable dtnew = new DataTable();
            dtnew.Columns.Add("Owner", System.Type.GetType("System.String"));
            dtnew.Columns.Add("OwnerID", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Station", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Department", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Currency", System.Type.GetType("System.String"));//记录本人币种
            dtnew.Columns.Add("CurrencyBudget", System.Type.GetType("System.String"));//记录预算站点币种
            dtnew.Columns.Add("leaveStart", System.Type.GetType("System.String"));
            dtnew.Columns.Add("leaveStart1", System.Type.GetType("System.String"));
            dtnew.Columns.Add("leaveEnd", System.Type.GetType("System.String"));
            dtnew.Columns.Add("leaveEnd1", System.Type.GetType("System.String"));
            dtnew.Columns.Add("leaveCount", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Destination", System.Type.GetType("System.String"));
            dtnew.Columns.Add("CostCenter", System.Type.GetType("System.String"));
            //dtnew.Columns.Add("RateBudget", System.Type.GetType("System.String"));

            cs.DBCommand dbc = new cs.DBCommand();
            //添加本人eLeave信息
            DataSet ds = DIMERCO.SDK.Utilities.LSDK.GetBizTripByUserID(Request.Cookies.Get("eReimUserID").Value);
            if (ds != null && ds.Tables.Count == 1)
            {
                DataTable dteLeave = ds.Tables[0];
                for (int i = 0; i < dteLeave.Rows.Count; i++)
                {
                    DataRow dr = dtnew.NewRow();
                    dr["Owner"] = Request.Cookies.Get("eReimUserName").Value;
                    dr["OwnerID"] = Request.Cookies.Get("eReimUserID").Value;
                    DataSet dsuserinfo = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(Request.Cookies.Get("eReimUserID").Value);
                    DataTable dtuserinfo = dsuserinfo.Tables[0];
                    dr["Station"] = Request.Cookies.Get("eReimStation").Value;
                    dr["Department"] = Request.Cookies.Get("eReimDepartment").Value;
                    //获取该人币种
                    //string LocalCurrency = "";
                    dr["Currency"] = DIMERCO.SDK.Utilities.LSDK.GetStationCurrencyByCode(Request.Cookies.Get("eReimStation").Value);
                    //LocalCurrency = DIMERCO.SDK.Utilities.LSDK.GetStationCurrencyByCode(Request.Cookies.Get("eReimStation").Value);
                    //检查是否本地维护过特殊币种
                    DataTable dttemp = new DataTable();
                    string sqltemp = "select * from ESUSER where Userid='" + Request.Cookies.Get("eReimUserID").Value + "'";
                    dttemp = dbc.GetData("eReimbursement", sqltemp);
                    if (dttemp.Rows.Count > 0)
                    {
                        dr["Currency"] = dttemp.Rows[0]["Currency"].ToString();//如果单独设置了币种
                        //LocalCurrency = dttemp.Rows[0]["Currency"].ToString();//如果单独设置了币种
                    }
                    //获取预算站点币种
                    //string BudgetCurrency = DIMERCO.SDK.Utilities.LSDK.GetStationCurrencyByCode(Request.Cookies.Get("eReimCostCenter").Value);
                    dr["CurrencyBudget"] = DIMERCO.SDK.Utilities.LSDK.GetStationCurrencyByCode(Request.Cookies.Get("eReimCostCenter").Value);
                    dr["CostCenter"] = Request.Cookies.Get("eReimCostCenter").Value;

                    if (dteLeave.Rows[i]["leaveEnd"].ToString() != "" && dteLeave.Rows[i]["leaveStart"].ToString() != "")
                    {
                        TimeSpan ts = Convert.ToDateTime(dteLeave.Rows[i]["leaveEnd"].ToString()) - Convert.ToDateTime(dteLeave.Rows[i]["leaveStart"].ToString());
                        dr["leaveCount"] = ts.Days.ToString() + " Days " + ts.Hours.ToString() + " Hours";
                    }
                    dr["leaveStart"] = dteLeave.Rows[i]["leaveStart"].ToString() == "" ? "" : (Convert.ToDateTime(dteLeave.Rows[i]["leaveStart"].ToString()).ToString("yyyy/MM/dd") + " " + Convert.ToDateTime(dteLeave.Rows[i]["leaveStart"].ToString()).DayOfWeek.ToString());
                    dr["leaveEnd"] = dteLeave.Rows[i]["leaveEnd"].ToString() == "" ? "" : (Convert.ToDateTime(dteLeave.Rows[i]["leaveEnd"].ToString()).ToString("yyyy/MM/dd") + " " + Convert.ToDateTime(dteLeave.Rows[i]["leaveEnd"].ToString()).DayOfWeek.ToString());
                    dr["Destination"] = dteLeave.Rows[i]["Destination"].ToString();
                    dr["leaveStart1"] = dteLeave.Rows[i]["leaveStart"].ToString() == "" ? "" : (Convert.ToDateTime(dteLeave.Rows[i]["leaveStart"].ToString()).ToString("yyyy/MM/dd"));
                    dr["leaveEnd1"] = dteLeave.Rows[i]["leaveEnd"].ToString() == "" ? "" : (Convert.ToDateTime(dteLeave.Rows[i]["leaveEnd"].ToString()).ToString("yyyy/MM/dd"));
                    //如果2个币种不同,取得转换汇率,Budget:Local
                    //if (LocalCurrency != BudgetCurrency)
                    //{
                    //    dr["Rate"] = DIMERCO.SDK.Utilities.LSDK.GetBudgetConverRate(BudgetCurrency, LocalCurrency, 2014);
                    //}
                    //dr["Rate"] = System.Math.Round(1 / DIMERCO.SDK.Utilities.LSDK.GetLatestStationUSDConvertRate(dtuserinfo.Rows[0]["CostCenter"].ToString()), 3).ToString();
                    
                    dtnew.Rows.Add(dr);
                }
            }

            string sqlitem = "select * from Eagent where [St]=1 and [PAgentID]='" + Request.Cookies.Get("eReimUserID").Value + "'";
            DataTable dtitem = dbc.GetData("eReimbursement", sqlitem);
            for (int j = 0; j < dtitem.Rows.Count; j++)
            {
                string sqlpara = sqlitem;
                if (dtitem.Rows[j][5].ToString() != "")
                {
                    sqlpara += " and getdate()>='" + dtitem.Rows[j][5].ToString() + "' ";
                }
                if (dtitem.Rows[j][6].ToString() != "")
                {
                    sqlpara += " and getdate()<='" + dtitem.Rows[j][6].ToString() + "' ";
                }
                DataTable dtitem1 = dbc.GetData("eReimbursement", sqlpara);
                for (int m = 0; m < dtitem1.Rows.Count; m++)
                {
                    //li = new Ext.Net.ListItem(dtitem.Rows[m][1].ToString(), dtitem.Rows[m][2].ToString());
                    //cbxOwner.Items.Add(li);
                    DataSet dsAgent = DIMERCO.SDK.Utilities.LSDK.GetBizTripByUserID(dtitem.Rows[m][2].ToString());
                    if (dsAgent != null && dsAgent.Tables.Count == 1)
                    {
                        DataTable dteLeaveAgent = dsAgent.Tables[0];
                        for (int i = 0; i < dteLeaveAgent.Rows.Count; i++)
                        {
                            DataRow dr = dtnew.NewRow();
                            dr["Owner"] = dtitem.Rows[m][1].ToString();
                            dr["OwnerID"] = dtitem.Rows[m][2].ToString();
                            DataSet dsuserinfo = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(dtitem.Rows[m][2].ToString());
                            DataTable dtuserinfo = dsuserinfo.Tables[0];
                            dr["Station"] = dtuserinfo.Rows[0]["stationCode"].ToString();
                            dr["Department"] = dtuserinfo.Rows[0]["CRPDepartmentName"].ToString();
                            //获取该人币种
                            dr["Currency"] = DIMERCO.SDK.Utilities.LSDK.GetStationCurrencyByCode(dtuserinfo.Rows[0]["stationCode"].ToString());

                            DataTable dttemp = new DataTable();
                            string sqltemp = "select * from ESUSER where Userid='" + dtitem.Rows[m][2].ToString() + "'";
                            dttemp = dbc.GetData("eReimbursement", sqltemp);
                            if (dttemp.Rows.Count > 0)
                            {
                                dr["Currency"] = dttemp.Rows[0]["Currency"].ToString();//如果单独设置了币种
                            }
                            dr["CurrencyBudget"] = DIMERCO.SDK.Utilities.LSDK.GetStationCurrencyByCode(dtuserinfo.Rows[0]["CostCenter"].ToString());
                            dr["CostCenter"] = dtuserinfo.Rows[0]["CostCenter"].ToString();

                            if (dteLeaveAgent.Rows[i]["leaveEnd"].ToString() != "" && dteLeaveAgent.Rows[i]["leaveStart"].ToString() != "")
                            {
                                TimeSpan ts = Convert.ToDateTime(dteLeaveAgent.Rows[i]["leaveEnd"].ToString()) - Convert.ToDateTime(dteLeaveAgent.Rows[i]["leaveStart"].ToString());
                                dr["leaveCount"] = (ts.Days + 1).ToString() + " Days " + ts.Hours.ToString() + " Hours";
                            }
                            dr["leaveStart"] = dteLeaveAgent.Rows[i]["leaveStart"].ToString() == "" ? "" : (Convert.ToDateTime(dteLeaveAgent.Rows[i]["leaveStart"].ToString()).ToString("yyyy/MM/dd") + " " + Convert.ToDateTime(dteLeaveAgent.Rows[i]["leaveStart"].ToString()).DayOfWeek.ToString());
                            dr["leaveEnd"] = dteLeaveAgent.Rows[i]["leaveEnd"].ToString() == "" ? "" : (Convert.ToDateTime(dteLeaveAgent.Rows[i]["leaveEnd"].ToString()).ToString("yyyy/MM/dd") + " " + Convert.ToDateTime(dteLeaveAgent.Rows[i]["leaveEnd"].ToString()).DayOfWeek.ToString());
                            dr["Destination"] = dteLeaveAgent.Rows[i]["Destination"].ToString();
                            dr["leaveStart1"] = dteLeaveAgent.Rows[i]["leaveStart"].ToString() == "" ? "" : (Convert.ToDateTime(dteLeaveAgent.Rows[i]["leaveStart"].ToString()).ToString("yyyy/MM/dd"));
                            dr["leaveEnd1"] = dteLeaveAgent.Rows[i]["leaveEnd"].ToString() == "" ? "" : (Convert.ToDateTime(dteLeaveAgent.Rows[i]["leaveEnd"].ToString()).ToString("yyyy/MM/dd"));

                            //dr["Rate"] = System.Math.Round(1 / DIMERCO.SDK.Utilities.LSDK.GetLatestStationUSDConvertRate(dtuserinfo.Rows[0]["CostCenter"].ToString()), 3).ToString();
                            dtnew.Rows.Add(dr);
                        }
                    }
                }
            }

            Store1.DataSource = dtnew;
            Store1.DataBind();
        }
Пример #29
0
        protected void ChangePerson(object sender, DirectEventArgs e)
        {
            cs.DBCommand dbc = new cs.DBCommand();
            DataSet ds1 = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(cbxOwner.Value.ToString());
            if (ds1.Tables[0].Rows.Count == 1)
            {
                DataTable dt1 = ds1.Tables[0];
                labelStation.Text = dt1.Rows[0]["stationCode"].ToString();
                labelDepartment.Text = dt1.Rows[0]["DepartmentName"].ToString();
                LabelCurrency.Text = DIMERCO.SDK.Utilities.LSDK.GetStationCurrencyByCode(dt1.Rows[0]["stationCode"].ToString());

                //切换币种
                DataTable dttemp = new DataTable();
                string sqltemp = "select * from ESUSER where Userid='" + cbxOwner.Value.ToString() + "'";
                dttemp = dbc.GetData("eReimbursement", sqltemp);
                if (dttemp.Rows.Count > 0)
                {
                    LabelCurrency.Text = dttemp.Rows[0]["Currency"].ToString();
                }
            }
            //检查是否已经为该申请人设置过审批人
            string sqlCheckFlow = "";
            if (cbxBudget.Value.ToString() == "YES")//使用Budget审批流程
            {
                sqlCheckFlow = "select * from GroupFlow where [Type]!=2 and GID=(select GID from GroupUsers where UserID='" + cbxOwner.Value.ToString() + "')";
            }
            else//使用unBudget审批流程
            {
                sqlCheckFlow = "select * from GroupFlow where [Type]=2 and GID=(select GID from GroupUsers where UserID='" + cbxOwner.Value.ToString() + "')";
            }

            //string sqlCheckFlow = "select * from GroupFlow where GID=(select GID from GroupUsers where UserID='" + cbxOwner.Text + "')";
            DataTable dtCheckFlow = dbc.GetData("eReimbursement", sqlCheckFlow);
            if (dtCheckFlow.Rows.Count < 1)
            {
                if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                {
                    ErrorHandleNojump("请联系Local MIS设置审批人.");
                }
                else
                {
                    ErrorHandleNojump("Not set Approve flow,please contact with Local MIS.");
                }
            }
        }
Пример #30
0
        protected bool SendMail(string warningmsg)
        {
            //发送提醒邮件
            cs.DBCommand dbc = new cs.DBCommand();
            string sql = "select * from V_Eflow_ETravel where [Type]='T' and Step!=0 and RequestID=" + hdTravelRequestID.Value.ToString() + " order by Step,FlowID";
            DataTable dtMail = new DataTable();
            dtMail = dbc.GetData("eReimbursement", sql);

            if (dtMail != null && dtMail.Rows.Count > 0)
            {
                string msg = "";
                if (dtMail.Rows[0]["FlowFn"].ToString().ToLower() == "verifier")
                {
                    msg = "Process Checking.";
                }
                else if (dtMail.Rows[0]["FlowFn"].ToString().ToLower() == "issuer")
                {
                    msg = "Process Paying.";
                }
                else
                {
                    msg = "Seek For Your Approval.";
                }
                string budget = dtMail.Rows[0]["Budget"].ToString() == "1" ? "(Budget)" : "(UnBudget)";

                DIMERCO.SDK.MailMsg mail = new DIMERCO.SDK.MailMsg();
                mail.Title = "Dimerco eReimbursement " + budget + " " + dtMail.Rows[0]["Person"].ToString() + " - " + msg;
                mail.FromDispName = "eReimbursement";
                mail.From = "*****@*****.**";

                string mailto = "";
                DataSet dsTo = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(dtMail.Rows[0]["ApproverID"].ToString());
                if (dsTo.Tables[0].Rows.Count == 1)
                {
                    mailto += dsTo.Tables[0].Rows[0]["eMail"].ToString() + ",";
                }
                else
                {
                    ErrorHandle("Error mail address."); return false;
                }

                string mailcc = "";
                DataSet dsCC = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(dtMail.Rows[0]["PersonID"].ToString());
                if (dsCC.Tables[0].Rows.Count == 1)
                {
                    mailcc += dsCC.Tables[0].Rows[0]["eMail"].ToString() + ",";
                }
                else
                {
                    ErrorHandle("Error mail address."); return false;
                }
                if (dtMail.Rows[0]["CreadedByID"].ToString() != "" && dtMail.Rows[0]["CreadedByID"].ToString() != dtMail.Rows[0]["PersonID"].ToString())//代理人
                {
                    dsCC = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(dtMail.Rows[0]["CreadedByID"].ToString());
                    mailcc += dsCC.Tables[0].Rows[0]["eMail"].ToString() + ",";
                }
                if (dtMail.Rows[0]["CCMailList"].ToString() != "")
                {
                    mailcc += dtMail.Rows[0]["CCMailList"].ToString();
                }
                mail.To = mailto;
                mail.Cc = mailcc;
                string divstyle = "style='font-size:small;'";
                string divstyleCurrent = "style='font-size:small;color:blue;'";
                string divstylered = "style='font-size:small;color:Red;'";
                string tdstyle = "style='border:silver 1px ridge; font-size:small;background-color: #FFFFFF;empty-cells:show;' nowrap='nowrap'";
                StringBuilder sb = new StringBuilder();
                sb.Append("<div>");
                sb.Append("<div " + divstyle + "> Dear " + dtMail.Rows[0]["Approver"].ToString() + ",</div><br />");
                
                if (warningmsg!="")
                {
                    sb.Append("<div " + divstyle + ">The following eReimbursement application:" + msg + "</div><br />");
                    sb.Append("<div " + divstylered + ">" + warningmsg + "</div><br /><br />");
                }
                else
                {
                    sb.Append("<div " + divstyle + ">The following eReimbursement application:" + msg + "</div><br /><br />");
                }
                sb.Append("<div " + divstyle + ">No#:" + dtMail.Rows[0]["No"].ToString() + budget + "</div>");
                sb.Append("<div " + divstyle + ">Owner:" + dtMail.Rows[0]["Person"].ToString() + "</div>");
                sb.Append("<div " + divstyle + ">Station:" + dtMail.Rows[0]["Station"].ToString() + "</div>");
                sb.Append("<div " + divstyle + ">Department:" + dtMail.Rows[0]["Department"].ToString() + "</div>");
                //string period = "";
                string sqldetail2 = "select min(convert(varchar(10),Tdate0,111)) as Tdate0,max(convert(varchar(10),Tdate,111)) as Tdate1 from ETraveleDetail where [No]=" + hdTravelRequestID.Value.ToString() + "";
                DataTable dtder = dbc.GetData("eReimbursement", sqldetail2);
                if (dtder.Rows.Count == 1)
                {
                    sb.Append("<div " + divstyle + ">Period:From " + Convert.ToDateTime(dtder.Rows[0]["Tdate0"].ToString()).ToString("yyyy/MM/dd") + " To " + Convert.ToDateTime(dtder.Rows[0]["Tdate1"].ToString()).ToString("yyyy/MM/dd") + "</div>");
                }
                
                //period += dtMail.Rows[0]["Bdate"].ToString() == "" ? "From NA " : ("From " + Convert.ToDateTime(dtMail.Rows[0]["Bdate"].ToString()).ToString("yyyy/MM/dd") + " ");
                //period += dtMail.Rows[0]["Edate"].ToString() == "" ? "To NA" : "To " + Convert.ToDateTime(dtMail.Rows[0]["Edate"].ToString()).ToString("yyyy/MM/dd");
                sb.Append("<br />");
                sb.Append("<div><table style='border-collapse:collapse;'><thead><tr><th colspan=\"15\" " + tdstyle + ">Expense Detail</th></tr><tr>");
                sb.Append("<th " + tdstyle + "></th>");
                sb.Append("<th " + tdstyle + ">Destination</th>");
                sb.Append("<th " + tdstyle + ">Date</th>");
                sb.Append("<th " + tdstyle + ">Expense Type</th>");
                sb.Append("<th " + tdstyle + ">Currency</th>");
                sb.Append("<th " + tdstyle + ">Employee Pay</th>");
                sb.Append("<th " + tdstyle + ">Company Pay</th>");
                sb.Append("<th " + tdstyle + ">Cost Center</th>");
                sb.Append("<th style='border:silver 1px ridge; font-size:small;background-color: #FFFFFF;empty-cells:show;width:160px;' nowrap='nowrap'>Remark</th>");
                sb.Append("<th " + tdstyle + ">Station Budget MTD:(Used/All)</th>");
                sb.Append("<th " + tdstyle + ">Dept. Budget MTD:(Used/All)</th>");
                sb.Append("<th " + tdstyle + ">Person Budget MTD:(Used/All)</th>");
                sb.Append("<th " + tdstyle + ">Station Budget YTD:(Used/All)</th>");
                sb.Append("<th " + tdstyle + ">Dept. Budget YTD:(Used/All)</th>");
                sb.Append("<th " + tdstyle + ">Person Budget YTD:(Used/All)</th></tr></thead>");

                sb.Append("<tbody>");
                decimal ptotal = 0; decimal ctotal = 0;
                string sqlp = "";
                sqlp += "case when t1.DetailCode=0 then '1. Air Ticket - Intl' when t1.DetailCode=1 then 'Air Ticket - Domestic' ";
                sqlp += "when t1.DetailCode=2 then '2. Hotel Bill' when t1.DetailCode=3 then '3. Meals' ";
                sqlp += "when t1.DetailCode=4 then '4. Entertainment' when t1.DetailCode=5 then '5. Car Rental/Transportation' ";
                sqlp += "when t1.DetailCode=6 then '6. Communication' when t1.DetailCode=7 then '7. Local Trip Allowance' ";
                sqlp += "when t1.DetailCode=8 then '8. Overseas Trip Allowance' when t1.DetailCode=9 then '9. Airport Tax/Travel Insurance' ";
                sqlp += "when t1.DetailCode=10 then '10. Others' else t2.SAccountName end as [SAccountName]";
                string sqldetail = "select [StationBudget]='',[DepartmentBudget]='',[PersonBudget]='',[StationYTD]='',[DepartmentYTD]='',[PersonYTD]=''," + sqlp + ",t1.* from ETraveleDetail t1 left join AccoundCode t2 on t2.SAccountCode=t1.AccountCode where t1.[No]='" + hdTravelRequestID.Value.ToString() + "'";
                DataTable dtdetail = new DataTable();
                dtdetail = dbc.GetData("eReimbursement", sqldetail);
                for (int i = 0; i < dtdetail.Rows.Count; i++)
                {
                    //载入预算内容
                    string userid = dtMail.Rows[0]["PersonID"].ToString();
                    string dpt = "";
                    string ostation = "";
                    DataSet ds1 = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(userid);
                    if (ds1.Tables[0].Rows.Count == 1)
                    {
                        DataTable dt1 = ds1.Tables[0];
                        //dpt = dt1.Rows[0]["DepartmentName"].ToString();
                        ostation = dt1.Rows[0]["stationCode"].ToString();
                        dpt = dt1.Rows[0]["CRPDepartmentName"].ToString();
                        DataTable dttemp = new DataTable();
                        string sqltemp = "select * from ESUSER where Userid='" + userid + "'";
                        dttemp = dbc.GetData("eReimbursement", sqltemp);
                        if (dttemp.Rows.Count > 0)
                        {
                            ostation = dttemp.Rows[0]["Station"].ToString();
                        }
                    }
                    string tstation = dtdetail.Rows[i]["TSation"].ToString() == "" ? ostation : dtdetail.Rows[i]["TSation"].ToString();
                    string accountcode = dtdetail.Rows[i]["AccountCode"].ToString();
                    string Years = Convert.ToDateTime(dtdetail.Rows[i]["Tdate"].ToString()).Year.ToString();
                    string month = Convert.ToDateTime(dtdetail.Rows[i]["Tdate"].ToString()).Month.ToString();

                    DataTable dtbudget = new DataTable();
                    dtbudget = Comm.RtnEB(userid, dpt, ostation, tstation, accountcode, Years, month);
                    double re = System.Math.Round(DIMERCO.SDK.Utilities.LSDK.GetLatestStationUSDConvertRate(tstation) / DIMERCO.SDK.Utilities.LSDK.GetLatestStationUSDConvertRate(ostation), 4);
                    if (dtbudget != null && dtbudget.Rows.Count > 0)
                    {
                        string stationbudget = "", departmentbudget = "", personbudget = "", stationYear = "", departmentYear = "", personYear = "";
                        for (int j = 0; j < dtbudget.Rows.Count; j++)
                        {
                            decimal budget1 = 0, used = 0;
                            budget1 = Convert.ToDecimal(System.Math.Round(Convert.ToDouble(dtbudget.Rows[j]["Budget"].ToString()) * re, 2));
                            used = Convert.ToDecimal(System.Math.Round(Convert.ToDouble(dtbudget.Rows[j]["Used"].ToString()) * re, 2));

                            if (dtbudget.Rows[j]["Type"].ToString() == "站点")
                            {
                                stationbudget = used.ToString("#,##0.00") + "/" + budget1.ToString("#,##0.00");
                                dtdetail.Rows[i]["StationBudget"] = stationbudget;
                            }
                            else if (dtbudget.Rows[j]["Type"].ToString() == "部门")
                            {
                                departmentbudget = used.ToString("#,##0.00") + "/" + budget1.ToString("#,##0.00");
                                dtdetail.Rows[i]["DepartmentBudget"] = departmentbudget;
                            }
                            else if (dtbudget.Rows[j]["Type"].ToString() == "个人")
                            {
                                personbudget = used.ToString("#,##0.00") + "/" + budget1.ToString("#,##0.00");
                                dtdetail.Rows[i]["PersonBudget"] = personbudget;
                            }
                            else if (dtbudget.Rows[j]["Type"].ToString() == "全年个人")
                            {
                                personYear = used.ToString("#,##0.00") + "/" + budget1.ToString("#,##0.00");
                                dtdetail.Rows[i]["PersonYTD"] = personYear;
                            }
                            else if (dtbudget.Rows[j]["Type"].ToString() == "全年部门")
                            {
                                departmentYear = used.ToString("#,##0.00") + "/" + budget1.ToString("#,##0.00");
                                dtdetail.Rows[i]["DepartmentYTD"] = departmentYear;
                            }
                            else if (dtbudget.Rows[j]["Type"].ToString() == "全年站点")
                            {
                                stationYear = used.ToString("#,##0.00") + "/" + budget1.ToString("#,##0.00");
                                dtdetail.Rows[i]["StationYTD"] = stationYear;
                            }
                        }
                    }

                    sb.Append("<tr><th " + tdstyle + ">" + (i + 1).ToString() + "</th>");
                    sb.Append("<td " + tdstyle + " nowrap='nowrap'>" + dtdetail.Rows[i]["Tocity"].ToString() + "</td>");
                    string tdate = dtdetail.Rows[i]["Tdate"].ToString() == "" ? "" : Convert.ToDateTime(dtdetail.Rows[i]["Tdate"].ToString()).ToString("yyyy/MM/dd");
                    sb.Append("<td " + tdstyle + " nowrap='nowrap'>" + tdate + "</td>");
                    sb.Append("<td " + tdstyle + ">" + dtdetail.Rows[i]["SAccountName"].ToString() + "</td>");
                    sb.Append("<td " + tdstyle + ">" + dtdetail.Rows[i]["Cur"].ToString() + "</td>");
                    sb.Append("<td " + tdstyle + ">" + (dtdetail.Rows[i]["Pamount"].ToString() == "" ? "" : Convert.ToDecimal(dtdetail.Rows[i]["Pamount"].ToString()).ToString("#,##0.00")) + "</td>");
                    sb.Append("<td " + tdstyle + ">" + (dtdetail.Rows[i]["Camount"].ToString() == "" ? "" : Convert.ToDecimal(dtdetail.Rows[i]["Camount"].ToString()).ToString("#,##0.00")) + "</td>");
                    sb.Append("<td " + tdstyle + ">" + dtdetail.Rows[i]["TSation"].ToString() + "</td>");
                    sb.Append("<td " + tdstyle + ">" + dtdetail.Rows[i]["AccountDes"].ToString() + "</td>");
                    sb.Append("<td " + tdstyle + " nowrap='nowrap'>" + dtdetail.Rows[i]["StationBudget"].ToString() + "</td>");
                    sb.Append("<td " + tdstyle + " nowrap='nowrap'>" + dtdetail.Rows[i]["DepartmentBudget"].ToString() + "</td>");
                    sb.Append("<td " + tdstyle + " nowrap='nowrap'>" + dtdetail.Rows[i]["PersonBudget"].ToString() + "</td>");
                    sb.Append("<td " + tdstyle + " nowrap='nowrap'>" + dtdetail.Rows[i]["StationYTD"].ToString() + "</td>");
                    sb.Append("<td " + tdstyle + " nowrap='nowrap'>" + dtdetail.Rows[i]["DepartmentYTD"].ToString() + "</td>");
                    sb.Append("<td " + tdstyle + " nowrap='nowrap'>" + dtdetail.Rows[i]["PersonYTD"].ToString() + "</td></tr>");
                    ptotal += dtdetail.Rows[i]["Pamount"].ToString() == "" ? 0 : Convert.ToDecimal(dtdetail.Rows[i]["Pamount"].ToString());
                    ctotal += dtdetail.Rows[i]["Camount"].ToString() == "" ? 0 : Convert.ToDecimal(dtdetail.Rows[i]["Camount"].ToString());
                }
                sb.Append("</tbody>");
                sb.Append("<tfoot><tr>");
                sb.Append("<th " + tdstyle + ">Total:</th>");
                sb.Append("<td colspan=\"3\" " + tdstyle + "></td>");
                sb.Append("<td " + tdstyle + ">" + dtdetail.Rows[0]["Cur"].ToString() + "</td>");
                sb.Append("<td " + tdstyle + ">" + ptotal.ToString("#,##0.00") + "</td>");
                sb.Append("<td " + tdstyle + ">" + ctotal.ToString("#,##0.00") + "</td>");
                sb.Append("<td colspan=\"8\" " + tdstyle + "></td>");
                sb.Append("</tr></tfoot></table></div><br />");
                sb.Append("<div " + divstyle + ">Apply Remark:" + dtMail.Rows[0]["Remark"].ToString() + "</div><br />");

                StringBuilder sb1 = new StringBuilder();
                sb1.Append("<div><span " + divstyle + ">Approval Flow:</span>");
                for (int i = 0; i < dtMail.Rows.Count; i++)
                {
                    if (i == 0)
                    {
                        sb1.Append("<div " + divstyleCurrent + ">" + (i + 1).ToString());
                    }
                    else
                    {
                        sb1.Append("<div " + divstyle + ">" + (i + 1).ToString());
                    }

                    string msg1 = "";
                    if (dtMail.Rows[i]["FlowFn"].ToString().ToLower() == "verifier")
                    {
                        msg1 = ". To Be Verified: " + dtMail.Rows[i]["Approver"].ToString() + "</div>";
                    }
                    else if (dtMail.Rows[i]["FlowFn"].ToString().ToLower() == "issuer")
                    {
                        msg1 = ". To Be Issued: " + dtMail.Rows[i]["Approver"].ToString() + "</div>";
                    }
                    else
                    {
                        msg1 = ". Waiting for Approval: " + dtMail.Rows[i]["Approver"].ToString() + "</div>";
                    }
                    sb1.Append(msg1);
                }
                sb1.Append("</div><br />");
                sb.Append(sb1.ToString());
                string url = "";
                if (Request.Url.Host != "localhost")
                {
                    url = "http://" + Request.Url.Authority + "/eReimbursement/Approve.aspx";
                }
                else
                {
                    url = "http://" + Request.Url.Authority + "/Approve.aspx";
                }
                sb.Append("<div><a href=\"" + url + "?FlowID=" + dtMail.Rows[0]["FlowID"].ToString() + "\" style=\"color: #0000FF\">Click here to visit Dimerco eReimbursement.</a></div>");
                sb.Append("</div>");
                mail.Body = sb.ToString();
                mail.Send();
            }
            else
            {
                return false;
            }
            return true;
        }
Пример #31
0
        protected void UploadScanFileClick(object sender, DirectEventArgs e)
        {
            if (this.FileUploadField2.HasFile)
            {
                string lstrFileName = null;     //上传文件路径
                string lstrFileFolder = null;   //存放文件路径
                string lstrFileNamePath = null; //上传目录及文件名

                //获得上传到服务器的目录名称,如果上传目录为空,就使用"D:\"作为缺省上传目录 
                //if (dir.Value != "") lstrFileFolder = dir.Value; else lstrFileFolder = "D:\\";
                lstrFileFolder = System.Web.HttpContext.Current.Request.MapPath("Upload/");

                //lstrFileName = FileUploadField1.PostedFile.FileName;  //获得文件名称
                //注:FileUploadField1.PostedFile.FileName 返回的是通过文件对话框选择的文件名,这之中包含了文件的目录信息

                lstrFileName = System.IO.Path.GetFileName(FileUploadField2.PostedFile.FileName);  //去掉目录信息,返回文件名称

                //判断上传目录是否存在,不存在就建立 
                if (!System.IO.Directory.Exists(lstrFileFolder)) System.IO.Directory.CreateDirectory(lstrFileFolder);
                string dtime = DateTime.Now.ToString("yyyyMMddHHmmss");
                lstrFileNamePath = lstrFileFolder + "SF" + dtime + System.IO.Path.GetExtension(lstrFileName); //得到上传目录及文件名称  
                FileUploadField2.PostedFile.SaveAs(lstrFileNamePath);       //上传文件到服务器
                string filename = "SF" + dtime + System.IO.Path.GetExtension(lstrFileName);
                linkScanFile.Text = filename; hdScanFile.Value = filename;
                linkScanFile.NavigateUrl = "./Upload/" + filename;
                string tpl = "Uploaded file: {0}<br/>Size: {1} bytes";
                //更新数据
                if (hdTravelRequestID.Value.ToString() != "")
                {
                    string updatesql = "update ETravel set Attach='" + filename + "' where ID=" + hdTravelRequestID.Value.ToString();
                    cs.DBCommand dbc = new cs.DBCommand();
                    string update = dbc.UpdateData("eReimbursement", updatesql, "Update");
                }
                X.Msg.Show(new MessageBoxConfig
                {
                    Buttons = MessageBox.Button.OK,
                    Icon = MessageBox.Icon.INFO,
                    Title = "Success",
                    Message = string.Format(tpl, this.FileUploadField2.PostedFile.FileName, this.FileUploadField2.PostedFile.ContentLength)
                });
            }
        }
Пример #32
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //string station = ""; string department = "";
            //DataSet ds1 = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList("A0182");
            //if (ds1.Tables[0].Rows.Count == 1)
            //{
            //    DataTable dt1 = ds1.Tables[0];
            //    station = dt1.Rows[0]["stationCode"].ToString();
            //    department = dt1.Rows[0]["CRPDepartmentName"].ToString();
            //}
            if (!X.IsAjaxRequest)
            {
                
                //判断登录状态
                cs.DBCommand dbc = new cs.DBCommand();
                if (Request.Cookies.Get("eReimUserID") == null)
                {
                    X.AddScript("loginWindow.show();Panel1.disable();");
                    return;
                }
                else
                {
                    hdUser.Value = Request.Cookies.Get("eReimUserID").Value;
                    ScriptManager.RegisterStartupScript(this, GetType(), "", "$('div.gn_person ul.q-menubox li:eq(0) a').text('" + Request.Cookies.Get("eReimUserName").Value + "');", true);
                    X.AddScript("loginWindow.hide();Panel1.enable();");


                    if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                    {
                        ResourceManager1.Locale = "zh-CN";
                    }
                    else
                    {
                        ResourceManager1.Locale = "en-US";
                    }
                }

                //hdStatus.Value = "0";

                if (Request.QueryString["ID"] != null)//判断链接地址是否正确
                {
                    string ID = Request.QueryString["ID"].ToString();
                    System.Text.RegularExpressions.Regex reg1 = new System.Text.RegularExpressions.Regex(@"^\d*$");
                    if (reg1.IsMatch(ID))
                    {
                        string sql = "select * from V_Eflow_ETravel where RequestID='" + ID + "' and [Type]='T' and (Active=1 or Active=2)";

                        DataTable dt = new DataTable();
                        dt = dbc.GetData("eReimbursement", sql);

                        if (dt != null && dt.Rows.Count == 1)
                        {

                            if (Request.Cookies.Get("eReimUserID").Value == dt.Rows[0]["PersonID"].ToString())//本人
                            {
                                ////准备下拉菜单内容
                                //Ext.Net.ListItem li = new Ext.Net.ListItem(Request.Cookies.Get("eReimUserName").Value, Request.Cookies.Get("eReimUserID").Value);
                                //cbxOwner.Items.Add(li);
                                //string sqlitem = "select * from Eagent where [St]=1 and [PAgentID]='" + Request.Cookies.Get("eReimUserID").Value + "'";
                                //DataTable dtitem = dbc.GetData("eReimbursement", sqlitem);
                                //int itemcount = 0;
                                //for (int j = 0; j < dtitem.Rows.Count; j++)
                                //{
                                //    string sqlpara = sqlitem;
                                //    if (dtitem.Rows[j][5].ToString() != "")
                                //    {
                                //        sqlpara += " and getdate()>='" + dtitem.Rows[j][5].ToString() + "' ";
                                //    }
                                //    if (dtitem.Rows[j][6].ToString() != "")
                                //    {
                                //        sqlpara += " and getdate()<='" + dtitem.Rows[j][6].ToString() + "' ";
                                //    }
                                //    DataTable dtitem1 = dbc.GetData("eReimbursement", sqlpara);
                                //    for (int m = 0; m < dtitem1.Rows.Count; m++)
                                //    {
                                //        li = new Ext.Net.ListItem(dtitem.Rows[m][1].ToString(), dtitem.Rows[m][2].ToString());
                                //        cbxOwner.Items.Add(li);
                                //        itemcount++;
                                //    }
                                //}
                                //更改按钮状态
                                if (dt.Rows[0]["Step"].ToString() != "0")//正式申请单
                                {
                                    if (Request.QueryString["Copy"] != null)
                                    {
                                        if (Request.QueryString["Copy"].ToString() == "T")//Copy,作为新增
                                        {
                                            X.AddScript("btnSaveAndSend.enable();Radio1.enable();Radio2.enable();");
                                        }
                                        else
                                        {
                                            ErrorHandle("Data Error.");
                                        }
                                    }
                                    else//已申请数据
                                    {
                                        string app = "";
                                        if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                                        {
                                            Panel3.Title = "差旅费申请单: " + dt.Rows[0]["No"].ToString();
                                            //读取当前状态,显示在下方文本框内

                                            if (dt.Rows[0]["Status"].ToString() == "1")
                                            {
                                                app += "提单人: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                app += ", 等待审批: " + dt.Rows[0]["Approver"].ToString();
                                            }
                                            else if (dt.Rows[0]["Status"].ToString() == "2")
                                            {
                                                app += "提单人: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                app += ", 完成审批: " + dt.Rows[0]["Approver"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["ApproveDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                            }
                                            else if (dt.Rows[0]["Status"].ToString() == "3")
                                            {
                                                app += "提单人: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                app += ", 拒绝审批: " + dt.Rows[0]["Approver"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["ApproveDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                            }

                                            if (dt.Rows[0]["Active"].ToString() == "2")//已完成
                                            {
                                                //hdStatus.Value = "2";
                                                app += ". 完成.";
                                                X.AddScript("btnAddDSTN.disable();btnGeteLeave.disable();Radio1.disable();Radio2.disable();btnSaveDraft.disable();btnUploadReport.disable();btnUploadScanFile.disable();Button1.disable();Button2.disable();btnCC.disable();");
                                            }
                                            else//待审批
                                            {
                                                //hdStatus.Value = "1";
                                                X.AddScript("btnAddDSTN.disable();btnGeteLeave.disable();Radio1.disable();Radio2.disable();btnSaveDraft.disable();btnCC.disable();");
                                            }

                                        }
                                        else
                                        {
                                            Panel3.Title = "Travel Expense Form: " + dt.Rows[0]["No"].ToString();
                                            //读取当前状态,显示在下方文本框内

                                            if (dt.Rows[0]["Status"].ToString() == "1")
                                            {
                                                app += "Applied by: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                app += ", Waiting for approval By: " + dt.Rows[0]["Approver"].ToString();
                                            }
                                            else if (dt.Rows[0]["Status"].ToString() == "2")
                                            {
                                                app += "Applied by: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                app += ", Approved by: " + dt.Rows[0]["Approver"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["ApproveDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                            }
                                            else if (dt.Rows[0]["Status"].ToString() == "3")
                                            {
                                                app += "Applied by: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                app += ", Rejected by: " + dt.Rows[0]["Approver"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["ApproveDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                            }

                                            if (dt.Rows[0]["Active"].ToString() == "2")//已完成
                                            {
                                                //hdStatus.Value = "2";
                                                app += ". Complete.";
                                                X.AddScript("btnAddDSTN.disable();btnGeteLeave.disable();Radio1.disable();Radio2.disable();btnSaveDraft.disable();btnUploadReport.disable();btnUploadScanFile.disable();Button1.disable();Button2.disable();btnCC.disable();");
                                            }
                                            else//待审批
                                            {
                                                //hdStatus.Value = "1";
                                                X.AddScript("btnAddDSTN.disable();btnGeteLeave.disable();Radio1.disable();Radio2.disable();btnSaveDraft.disable();btnCC.disable();");
                                            }
                                        }
                                        labelInfo.Text = app;
                                    }
                                }
                                else//草稿
                                {
                                    if (Request.QueryString["Copy"] != null)
                                    {
                                        if (Request.QueryString["Copy"].ToString() == "T")//Copy,作为新增
                                        {
                                            X.AddScript("btnSaveAndSend.enable();Radio1.enable();Radio2.enable();");
                                        }
                                        else
                                        {
                                            ErrorHandle("Data Error.");
                                        }
                                    }
                                    else
                                    {
                                        if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                                        {
                                            Panel3.Title = "差旅费申请单草稿: " + dt.Rows[0]["No"].ToString();
                                        }
                                        else
                                        {
                                            Panel3.Title = "Travel Expense Draft: " + dt.Rows[0]["No"].ToString();
                                        }

                                        X.AddScript("btnSaveAndSend.enable();Radio1.enable();Radio2.enable();");
                                    }
                                }
                                //载入通用数据
                                LoadData(dt, true);
                            }
                            else
                            {
                                //判断是否为代理人
                                bool isagent = false;//记录Session["UserID"]是否为代理人
                                string sqlagent = "select * from Eagent where [St]=1 and [OwnerID]='" + dt.Rows[0]["PersonID"].ToString() + "' and getdate()<=Edate and getdate()>=Bdate";
                                DataTable dtagent = dbc.GetData("eReimbursement", sqlagent);
                                for (int g = 0; g < dtagent.Rows.Count; g++)
                                {
                                    if (Request.Cookies.Get("eReimUserID").Value == dtagent.Rows[g]["PAgentID"].ToString())
                                    {
                                        isagent = true;
                                        break;
                                    }
                                }
                                if (isagent)//代理人访问
                                {
                                    //Ext.Net.ListItem li = new Ext.Net.ListItem(dt.Rows[0]["Person"].ToString(), dt.Rows[0]["PersonID"].ToString());
                                    //cbxOwner.Items.Add(li);
                                    //更改按钮状态
                                    if (dt.Rows[0]["Step"].ToString() != "0")//正式申请单
                                    {
                                        if (Request.QueryString["Copy"] != null)
                                        {
                                            if (Request.QueryString["Copy"].ToString() == "T")//Copy,作为新增
                                            {
                                                X.AddScript("btnSaveAndSend.enable();Radio1.enable();Radio2.enable();");
                                            }
                                            else
                                            {
                                                ErrorHandle("Data Error.");
                                            }
                                        }
                                        else
                                        {
                                            string app = "";
                                            if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                                            {
                                                Panel3.Title = "差旅费申请单: " + dt.Rows[0]["No"].ToString();
                                                //读取当前状态,显示在下方文本框内

                                                if (dt.Rows[0]["Status"].ToString() == "1")
                                                {
                                                    app += "提单人: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                    app += ", 等待审批: " + dt.Rows[0]["Approver"].ToString();
                                                }
                                                else if (dt.Rows[0]["Status"].ToString() == "2")
                                                {
                                                    app += "提单人: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                    app += ", 完成审批: " + dt.Rows[0]["Approver"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["ApproveDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                }
                                                else if (dt.Rows[0]["Status"].ToString() == "3")
                                                {
                                                    app += "提单人: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                    app += ", 拒绝审批: " + dt.Rows[0]["Approver"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["ApproveDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                }

                                                if (dt.Rows[0]["Active"].ToString() == "2")//已完成
                                                {
                                                    //hdStatus.Value = "2";
                                                    app += ". 完成.";
                                                    X.AddScript("btnAddDSTN.disable();btnGeteLeave.disable();Radio1.disable();Radio2.disable();btnSaveDraft.disable();btnUploadReport.disable();btnUploadScanFile.disable();Button1.disable();Button2.disable();btnCC.disable();");
                                                }
                                                else//待审批
                                                {
                                                    //hdStatus.Value = "1";
                                                    X.AddScript("btnAddDSTN.disable();btnGeteLeave.disable();Radio1.disable();Radio2.disable();btnSaveDraft.disable();btnCC.disable();");
                                                }

                                            }
                                            else
                                            {
                                                Panel3.Title = "Travel Expense Form: " + dt.Rows[0]["No"].ToString();
                                                //读取当前状态,显示在下方文本框内

                                                if (dt.Rows[0]["Status"].ToString() == "1")
                                                {
                                                    app += "Applied by: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                    app += ", Waiting for approval By: " + dt.Rows[0]["Approver"].ToString();
                                                }
                                                else if (dt.Rows[0]["Status"].ToString() == "2")
                                                {
                                                    app += "Applied by: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                    app += ", Approved by: " + dt.Rows[0]["Approver"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["ApproveDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                }
                                                else if (dt.Rows[0]["Status"].ToString() == "3")
                                                {
                                                    app += "Applied by: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                    app += ", Rejected by: " + dt.Rows[0]["Approver"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["ApproveDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                }

                                                if (dt.Rows[0]["Active"].ToString() == "2")//已完成
                                                {
                                                    //hdStatus.Value = "2";
                                                    app += ". Complete.";
                                                    X.AddScript("btnAddDSTN.disable();btnGeteLeave.disable();Radio1.disable();Radio2.disable();btnSaveDraft.disable();btnUploadReport.disable();btnUploadScanFile.disable();Button1.disable();Button2.disable();btnCC.disable();");
                                                }
                                                else//待审批
                                                {
                                                    //hdStatus.Value = "1";
                                                    X.AddScript("btnAddDSTN.disable();btnGeteLeave.disable();Radio1.disable();Radio2.disable();btnSaveDraft.disable();btnCC.disable();");
                                                }
                                            }
                                            labelInfo.Text = app;
                                        }
                                    }
                                    else//草稿
                                    {
                                        if (Request.QueryString["Copy"] != null)
                                        {
                                            if (Request.QueryString["Copy"].ToString() == "T")//Copy,作为新增
                                            {
                                                X.AddScript("btnSaveAndSend.enable();Radio1.enable();Radio2.enable();");
                                            }
                                            else
                                            {
                                                ErrorHandle("Data Error.");
                                            }
                                        }
                                        else
                                        {
                                            if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                                            {
                                                Panel3.Title = "差旅费申请单草稿: " + dt.Rows[0]["No"].ToString();
                                            }
                                            else
                                            {
                                                Panel3.Title = "Travel Expense Draft: " + dt.Rows[0]["No"].ToString();
                                            }
                                            X.AddScript("btnSaveAndSend.enable();Radio1.enable();Radio2.enable();");
                                        }
                                    }
                                    //载入通用数据
                                    LoadData(dt, true);
                                }
                                else//判断是否有跨站权限
                                {

                                    bool hasright = false;
                                    string getright = "select * from StationRole where UserID='" + Request.Cookies.Get("eReimUserID").Value + "'";
                                    DataTable dtright = dbc.GetData("eReimbursement", getright);
                                    for (int j = 0; j < dtright.Rows.Count; j++)
                                    {
                                        string[] dd = dtright.Rows[j]["Stations"].ToString().Split(',');
                                        for (int i = 0; i < dd.Length; i++)
                                        {
                                            if (dd[i] == dt.Rows[0]["Station"].ToString())//有权限
                                            {
                                                hasright = true;
                                                break;
                                            }
                                        }
                                    }
                                    if (hasright)
                                    {
                                        //Ext.Net.ListItem li = new Ext.Net.ListItem(dt.Rows[0]["Person"].ToString(), dt.Rows[0]["PersonID"].ToString());
                                        //cbxOwner.Items.Add(li);
                                        //更改按钮状态
                                        if (dt.Rows[0]["Step"].ToString() != "0")//正式申请单
                                        {
                                            string app = "";
                                            if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                                            {
                                                Panel3.Title = "差旅费申请单: " + dt.Rows[0]["No"].ToString();
                                                //读取当前状态,显示在下方文本框内

                                                if (dt.Rows[0]["Status"].ToString() == "1")
                                                {
                                                    app += "提单人: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                    app += ", 等待审批: " + dt.Rows[0]["Approver"].ToString();
                                                }
                                                else if (dt.Rows[0]["Status"].ToString() == "2")
                                                {
                                                    app += "提单人: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                    app += ", 完成审批: " + dt.Rows[0]["Approver"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["ApproveDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                }
                                                else if (dt.Rows[0]["Status"].ToString() == "3")
                                                {
                                                    app += "提单人: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                    app += ", 拒绝审批: " + dt.Rows[0]["Approver"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["ApproveDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                }

                                                if (dt.Rows[0]["Active"].ToString() == "2")//已完成
                                                {
                                                    //hdStatus.Value = "2";
                                                    app += ". 完成.";
                                                    X.AddScript("btnAddDSTN.disable();btnGeteLeave.disable();Radio1.disable();Radio2.disable();btnSaveDraft.disable();btnUploadReport.disable();btnUploadScanFile.disable();Button1.disable();Button2.disable();btnCC.disable();");
                                                }
                                                else//待审批
                                                {
                                                    //hdStatus.Value = "1";
                                                    X.AddScript("btnAddDSTN.disable();btnGeteLeave.disable();Radio1.disable();Radio2.disable();btnSaveDraft.disable();btnCC.disable();");
                                                }

                                            }
                                            else
                                            {
                                                Panel3.Title = "Travel Expense Form: " + dt.Rows[0]["No"].ToString();
                                                //读取当前状态,显示在下方文本框内

                                                if (dt.Rows[0]["Status"].ToString() == "1")
                                                {
                                                    app += "Applied by: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                    app += ", Waiting for approval By: " + dt.Rows[0]["Approver"].ToString();
                                                }
                                                else if (dt.Rows[0]["Status"].ToString() == "2")
                                                {
                                                    app += "Applied by: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                    app += ", Approved by: " + dt.Rows[0]["Approver"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["ApproveDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                }
                                                else if (dt.Rows[0]["Status"].ToString() == "3")
                                                {
                                                    app += "Applied by: " + dt.Rows[0]["CreadedBy"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["CreadedDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                    app += ", Rejected by: " + dt.Rows[0]["Approver"].ToString() + " " + Convert.ToDateTime(dt.Rows[0]["ApproveDate"].ToString()).ToString("yyyy/MM/dd hh:mm");
                                                }

                                                if (dt.Rows[0]["Active"].ToString() == "2")//已完成
                                                {
                                                    //hdStatus.Value = "2";
                                                    app += ". Complete.";
                                                    X.AddScript("btnAddDSTN.disable();btnGeteLeave.disable();Radio1.disable();Radio2.disable();btnSaveDraft.disable();btnUploadReport.disable();btnUploadScanFile.disable();Button1.disable();Button2.disable();btnCC.disable();");
                                                }
                                                else//待审批
                                                {
                                                    //hdStatus.Value = "1";
                                                    X.AddScript("btnAddDSTN.disable();btnGeteLeave.disable();Radio1.disable();Radio2.disable();btnSaveDraft.disable();btnCC.disable();");
                                                }
                                            }
                                            labelInfo.Text = app;
                                        }
                                        else//草稿
                                        {
                                            if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                                            {
                                                Panel3.Title = "差旅费申请单草稿: " + dt.Rows[0]["No"].ToString();
                                            }
                                            else
                                            {
                                                Panel3.Title = "Travel Expense Draft: " + dt.Rows[0]["No"].ToString();
                                            }

                                            //X.AddScript("btnSaveAndSend.enable();");
                                        }
                                        //hdStatus.Value = "2";//不允许传递到子页面时修改或者上传
                                        X.AddScript("btnAddDSTN.disable();btnGeteLeave.disable();Radio1.disable();Radio2.disable();btnSaveDraft.disable();btnCC.disable();");
                                        //无需判断Copy
                                        //载入通用数据
                                        LoadData(dt, false);
                                    }
                                    else
                                    {
                                        ErrorHandle("No right.");
                                    }
                                }
                            }
                        }
                        else
                        {
                            ErrorHandle("Data Error.");
                        }
                    }
                    else
                    {
                        ErrorHandle("Data Error.");
                    }
                }
                else//新增申请
                {
                    ////准备下拉菜单内容
                    //Ext.Net.ListItem li = new Ext.Net.ListItem(Request.Cookies.Get("eReimUserName").Value, Request.Cookies.Get("eReimUserID").Value);
                    //cbxOwner.Items.Add(li);
                    //string sqlitem = "select * from Eagent where [St]=1 and [PAgentID]='" + Request.Cookies.Get("eReimUserID").Value + "'";
                    //DataTable dtitem = dbc.GetData("eReimbursement", sqlitem);
                    //for (int j = 0; j < dtitem.Rows.Count; j++)
                    //{
                    //    string sqlpara = sqlitem;
                    //    bool d1 = true;
                    //    bool d2 = false;
                    //    if (dtitem.Rows[j][5].ToString() != "")
                    //    {
                    //        //sqlpara += " and getdate()>='" + dtitem.Rows[j]["Bdate"].ToString() + "' ";
                    //        if (DateTime.Now >= Convert.ToDateTime(dtitem.Rows[j][5].ToString()))
                    //        {
                    //            d1 = true;
                    //        }
                    //        else
                    //        {
                    //            d1 = false;
                    //        }
                    //    }
                    //    if (dtitem.Rows[j][6].ToString() != "")
                    //    {
                    //        //sqlpara += " and getdate()<='" + dtitem.Rows[j]["Edate"].ToString() + "' ";
                    //        if (DateTime.Now <= Convert.ToDateTime(dtitem.Rows[j][6].ToString()))
                    //        {
                    //            d2 = true;
                    //        }
                    //        else
                    //        {
                    //            d2 = false;
                    //        }
                    //    }
                    //    if (d1 && d2)
                    //    {
                    //        li = new Ext.Net.ListItem(dtitem.Rows[j]["Owner"].ToString(), dtitem.Rows[j]["OwnerID"].ToString());
                    //        cbxOwner.Items.Add(li);
                    //    }
                    //}
                    ////新增记录时,默认为登录用户
                    //cbxOwner.SelectedItem.Value = Request.Cookies.Get("eReimUserID").Value;
                    //cbxOwner.SelectedItem.Text = Request.Cookies.Get("eReimUserName").Value;
                    //hdOwner.Value = Request.Cookies.Get("eReimUserName").Value;
                    //hdOwnerID.Value = Request.Cookies.Get("eReimUserID").Value;
                    //labelOwner.Text = Request.Cookies.Get("eReimUserName").Value;

                    //labelStation.Text = Request.Cookies.Get("eReimStation").Value;
                    //labelDepartment.Text = Request.Cookies.Get("eReimDepartment").Value;
                    //LabelCurrency.Text = DIMERCO.SDK.Utilities.LSDK.GetStationCurrencyByCode(Request.Cookies.Get("eReimCostCenter").Value);
                    //LabelText.Text = "Please load eLeave Data.";
                    

                    ////检查是否已经为该申请人设置过审批人
                    //string sqlCheckFlow = "";
                    //sqlCheckFlow = "select * from GroupFlow where [Type]!=2 and GID=(select GID from GroupUsers where UserID='" + Request.Cookies.Get("eReimUserID").Value + "')";
                    //DataTable dtGroupFlowData = dbc.GetData("eReimbursement", sqlCheckFlow);
                    //if (dtGroupFlowData.Rows.Count < 1)
                    //{
                    //    if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                    //    {
                    //        ErrorHandle("请先设置审批人.");
                    //    }
                    //    else
                    //    {
                    //        ErrorHandle("Not set Approve flow,please contact with Local MIS.");
                    //    }
                    //    return;
                    //}
                    X.AddScript("btnSaveAndSend.enable();Radio1.enable();Radio2.enable();");
                    DataTable dttest = new DataTable();
                    Store2.Reader[0].Fields.Add("Category", RecordFieldType.String);
                    dttest.Columns.Add("Category", typeof(String));
                    string fieldPName = "Station_0_P";
                    Store2.Reader[0].Fields.Add(fieldPName, RecordFieldType.String);
                    string fieldCName = "Station_0_C";
                    Store2.Reader[0].Fields.Add(fieldCName, RecordFieldType.String);
                    dttest.Columns.Add("Station_0_P", typeof(String));
                    dttest.Columns.Add("Station_0_C", typeof(String));
                    //
                    Store2.Reader[0].Fields.Add("Station_1_P", RecordFieldType.String);
                    Store2.Reader[0].Fields.Add("Station_1_C", RecordFieldType.String);
                    dttest.Columns.Add("Station_1_P", typeof(String));
                    dttest.Columns.Add("Station_1_C", typeof(String));

                    //合计列
                    Store2.Reader[0].Fields.Add("TotalP", RecordFieldType.String);
                    Store2.Reader[0].Fields.Add("TotalC", RecordFieldType.String);
                    dttest.Columns.Add("TotalP", typeof(String));
                    dttest.Columns.Add("TotalC", typeof(String));

                    DataRow dr = dttest.NewRow();
                    dr[0] = "1. Air Ticket - Int'l";
                    dttest.Rows.Add(dr);

                    dr = dttest.NewRow();
                    dr[0] = "Air Ticket - Domestic";
                    dttest.Rows.Add(dr);

                    dr = dttest.NewRow();
                    dr[0] = "2. Hotel Bill";
                    dttest.Rows.Add(dr);

                    dr = dttest.NewRow();
                    dr[0] = "3. Meals";
                    dttest.Rows.Add(dr);

                    dr = dttest.NewRow();
                    dr[0] = "4. Entertainment";
                    dttest.Rows.Add(dr);

                    dr = dttest.NewRow();
                    dr[0] = "5. Car Rental/Transportation";
                    dttest.Rows.Add(dr);

                    dr = dttest.NewRow();
                    dr[0] = "6. Communication";
                    dttest.Rows.Add(dr);

                    dr = dttest.NewRow();
                    dr[0] = "7. Local Trip Allowance";
                    dttest.Rows.Add(dr);

                    dr = dttest.NewRow();
                    dr[0] = "8. Overseas Trip Allowance";
                    dttest.Rows.Add(dr);

                    dr = dttest.NewRow();
                    dr[0] = "9. Airport Tax/Travel Insurance";
                    dttest.Rows.Add(dr);

                    dr = dttest.NewRow();
                    dr[0] = "10. Others";
                    dttest.Rows.Add(dr);

                    dr = dttest.NewRow();
                    dr[0] = "Total";
                    dttest.Rows.Add(dr);

                    Store2.DataSource = dttest;
                    Store2.DataBind();


                    var TitleCol = new Column();
                    TitleCol.DataIndex = "Category";
                    TitleCol.Sortable = false;
                    TitleCol.Resizable = false;
                    TitleCol.MenuDisabled = true;
                    TitleCol.Width = 180;
                    this.GridPanel2.ColumnModel.Columns.Add(TitleCol);

                    var txtP = new Ext.Net.NumberField();
                    //txtP.Listeners.Blur.Fn = "Cal";
                    //txtP.Listeners.Blur.Delay = 50;
                    var colP = new Column();
                    colP.Header = "Person Pay";
                    colP.DataIndex = fieldPName;
                    colP.Sortable = false;
                    colP.Resizable = false;
                    colP.MenuDisabled = true;
                    colP.Width = 110;
                    colP.Locked = true;
                    colP.Editor.Add(txtP);
                    this.GridPanel2.ColumnModel.Columns.Add(colP);

                    var txtC = new Ext.Net.NumberField();
                    //txtC.Listeners.Blur.Fn = "Cal";
                    //txtC.Listeners.Blur.Delay = 50;
                    var colC = new Column();
                    colC.Header = "Company Pay";
                    colC.DataIndex = fieldCName;
                    colC.Sortable = false;
                    colC.Resizable = false;
                    colC.MenuDisabled = true;
                    colC.Width = 110;
                    colP.Locked = true;
                    colC.Editor.Add(txtC);
                    this.GridPanel2.ColumnModel.Columns.Add(colC);
                    //
                    var txtP1 = new Ext.Net.NumberField();
                    //txtP1.Listeners.Blur.Fn = "Cal";
                    //txtP1.Listeners.Blur.Delay = 50;
                    var colP1 = new Column();
                    colP1.Header = "Person Pay";
                    colP1.DataIndex = "Station_1_P";
                    colP1.Sortable = false;
                    colP1.Resizable = false;
                    colP1.MenuDisabled = true;
                    colP1.Width = 110;
                    colP1.Locked = true;
                    colP1.Editor.Add(txtP1);
                    colP1.Hidden = true;
                    this.GridPanel2.ColumnModel.Columns.Add(colP1);

                    var txtC1 = new Ext.Net.NumberField();
                    //txtC1.Listeners.Blur.Fn = "Cal";
                    //txtC1.Listeners.Blur.Delay = 50;
                    var colC1 = new Column();
                    colC1.Header = "Company Pay";
                    colC1.DataIndex = "Station_1_C";
                    colC1.Sortable = false;
                    colC1.Resizable = false;
                    colC1.MenuDisabled = true;
                    colC1.Width = 110;
                    colC1.Locked = true;
                    colC1.Editor.Add(txtC1);
                    colC1.Hidden = true;
                    this.GridPanel2.ColumnModel.Columns.Add(colC1);
                    //
                    var TotalP = new Ext.Net.TextField();
                    TotalP.ReadOnly = true;
                    var colTotalP = new Column();
                    colTotalP.DataIndex = "TotalP";
                    colTotalP.Sortable = false;
                    colTotalP.Resizable = false;
                    colTotalP.MenuDisabled = true;
                    colTotalP.Width = 110;
                    colTotalP.Locked = true;
                    colTotalP.Editor.Add(TotalP);
                    this.GridPanel2.ColumnModel.Columns.Add(colTotalP);

                    var TotalC = new Ext.Net.TextField();
                    TotalC.ReadOnly = true;
                    var colTotalC = new Column();
                    colTotalC.DataIndex = "TotalC";
                    colTotalC.Sortable = false;
                    colTotalC.Resizable = false;
                    colTotalC.MenuDisabled = true;
                    colTotalC.Width = 110;
                    colTotalC.Locked = true;
                    colTotalC.Editor.Add(TotalC);
                    this.GridPanel2.ColumnModel.Columns.Add(colTotalC);

                    var Title1 = new Ext.Net.Label();
                    Title1.Text = "Destination:";
                    HeaderColumn hcTitle1 = new HeaderColumn();
                    hcTitle1.Component.Add(Title1);
                    this.GridPanel2.GetView().HeaderRows[0].Columns.Add(hcTitle1);

                    var Station = new Ext.Net.TextField();
                    HeaderColumn hcStation = new HeaderColumn();
                    hcStation.Component.Add(Station);
                    this.GridPanel2.GetView().HeaderRows[0].Columns.Add(hcStation);
                    //var Station = new Ext.Net.ComboBox();
                    //Station.DisplayField = "CityCode";
                    //Station.ValueField = "CityCode";
                    //Station.TypeAhead = true;
                    //Station.ForceSelection = true;
                    //Station.MinChars = 2;
                    //Station.Mode = DataLoadMode.Local;
                    //var storeStation = new Ext.Net.Store();
                    //storeStation.Reader.Add(new Ext.Net.JsonReader());
                    //DataSet GetCityInfo = DIMERCO.SDK.Utilities.LSDK.GetCityInfo("", 8000);
                    //DataTable dtstation = GetCityInfo.Tables[0];
                    //storeStation.Reader[0].Fields.Add("CityCode", RecordFieldType.String);
                    //Station.Store.Add(storeStation);
                    //storeStation.DataSource = dtstation;
                    //storeStation.DataBind();
                    //HeaderColumn hcStation = new HeaderColumn();
                    //hcStation.Component.Add(Station);
                    //this.GridPanel2.GetView().HeaderRows[0].Columns.Add(hcStation);

                    var Button = new Ext.Net.Button();
                    Button.Text = "Remove";
                    Button.Listeners.Click.Handler = "removecol(this,0);";
                    Button.Listeners.Click.Delay = 50;
                    HeaderColumn hcButton = new HeaderColumn();
                    hcButton.Component.Add(Button);
                    this.GridPanel2.GetView().HeaderRows[0].Columns.Add(hcButton);
                    //
                    var Station1 = new Ext.Net.TextField();
                    HeaderColumn hcStation1 = new HeaderColumn();
                    hcStation1.Component.Add(Station1);
                    this.GridPanel2.GetView().HeaderRows[0].Columns.Add(hcStation1);
                    //var Station1 = new Ext.Net.ComboBox();
                    //Station1.DisplayField = "CityCode";
                    //Station1.ValueField = "CityCode";
                    //Station1.TypeAhead = true;
                    //Station1.MinChars = 2;
                    //Station1.ForceSelection = true;
                    //Station1.Mode = DataLoadMode.Local;
                    //var storeStation1 = new Ext.Net.Store();
                    //storeStation1.Reader.Add(new Ext.Net.JsonReader());
                    //DataTable dtStation1 = new DataTable();
                    //dtStation1.Columns.Add("CityCode", typeof(String));
                    //for (int i = 0; i < 20; i++)
                    //{
                    //    DataRow dr2 = dtStation1.NewRow();
                    //    if (i < 5)
                    //    {
                    //        dr2[0] = "CN" + i.ToString();
                    //    }
                    //    else if (i >= 5 && i < 10)
                    //    {
                    //        dr2[0] = "GCR" + i.ToString();
                    //    }
                    //    else
                    //    {
                    //        dr2[0] = "CRP" + i.ToString();
                    //    }
                    //    dtStation1.Rows.Add(dr2);
                    //}
                    //storeStation1.Reader[0].Fields.Add("CityCode", RecordFieldType.String);
                    //Station1.Store.Add(storeStation1);
                    //storeStation1.DataSource = dtstation;
                    //storeStation1.DataBind();
                    //HeaderColumn hcStation1 = new HeaderColumn();
                    //hcStation1.Component.Add(Station1);
                    //this.GridPanel2.GetView().HeaderRows[0].Columns.Add(hcStation1);

                    var Button1 = new Ext.Net.Button();
                    Button1.Text = "Remove";
                    Button1.Listeners.Click.Handler = "removecol(this,1);";
                    Button1.Listeners.Click.Delay = 50;
                    HeaderColumn hcButton1 = new HeaderColumn();
                    hcButton1.Component.Add(Button1);
                    this.GridPanel2.GetView().HeaderRows[0].Columns.Add(hcButton1);
                    //
                    HeaderColumn hcTotal1 = new HeaderColumn();
                    this.GridPanel2.GetView().HeaderRows[0].Columns.Add(hcTotal1);

                    HeaderColumn hcTotal2 = new HeaderColumn();
                    this.GridPanel2.GetView().HeaderRows[0].Columns.Add(hcTotal2);


                    var Title2 = new Ext.Net.Label();
                    Title2.Text = "Cost Center:";
                    HeaderColumn hcTitle2 = new HeaderColumn();
                    hcTitle2.Component.Add(Title2);
                    this.GridPanel2.GetView().HeaderRows[1].Columns.Add(hcTitle2);

                    var CostCenter = new Ext.Net.TextField();
                    CostCenter.Disabled = true;
                    CostCenter.EmptyText = "Station Code";
                    HeaderColumn hcCostCenter = new HeaderColumn();
                    hcCostCenter.Component.Add(CostCenter);
                    this.GridPanel2.GetView().HeaderRows[1].Columns.Add(hcCostCenter);
                    //var CostCenter = new Ext.Net.ComboBox();
                    //CostCenter.DisplayField = "StationCode";
                    //CostCenter.ValueField = "StationCode";
                    //CostCenter.TypeAhead = true;
                    //CostCenter.ForceSelection = true;
                    //CostCenter.MinChars = 2;
                    //CostCenter.Mode = DataLoadMode.Local;
                    //var storeCostCenter = new Ext.Net.Store();
                    //storeCostCenter.Reader.Add(new Ext.Net.JsonReader());
                    //DataSet GetCostCenterInfo = DIMERCO.SDK.Utilities.LSDK.getCostCenterBYStationCode("", 8000);
                    //DataTable dtCostCenter = GetCostCenterInfo.Tables[0];
                    //storeCostCenter.Reader[0].Fields.Add("StationCode", RecordFieldType.String);
                    //CostCenter.Store.Add(storeCostCenter);
                    //storeCostCenter.DataSource = dtCostCenter;
                    //storeCostCenter.DataBind();
                    //HeaderColumn hcCostCenter = new HeaderColumn();
                    //hcCostCenter.Component.Add(CostCenter);
                    //this.GridPanel2.GetView().HeaderRows[1].Columns.Add(hcCostCenter);

                    //HeaderColumn hcCostCenter1 = new HeaderColumn();
                    //this.GridPanel2.GetView().HeaderRows[1].Columns.Add(hcCostCenter1);
                    var ButtonGetSum = new Ext.Net.Button();
                    ButtonGetSum.Text = "Calculate";
                    ButtonGetSum.Listeners.Click.Handler = "GetSum();";
                    ButtonGetSum.Listeners.Click.Delay = 50;
                    HeaderColumn hcButtonGetSum = new HeaderColumn();
                    hcButtonGetSum.Component.Add(ButtonGetSum);
                    this.GridPanel2.GetView().HeaderRows[1].Columns.Add(hcButtonGetSum);
                    //
                    var CostCenter0 = new Ext.Net.TextField();
                    CostCenter0.Disabled = true;
                    CostCenter0.EmptyText = "Station Code";
                    HeaderColumn hcCostCenter0 = new HeaderColumn();
                    hcCostCenter0.Component.Add(CostCenter0);
                    this.GridPanel2.GetView().HeaderRows[1].Columns.Add(hcCostCenter0);
                    //var CostCenter1 = new Ext.Net.ComboBox();
                    //CostCenter1.DisplayField = "StationCode";
                    //CostCenter1.ValueField = "StationCode";
                    //CostCenter1.TypeAhead = true;
                    //CostCenter1.ForceSelection = true;
                    //CostCenter1.MinChars = 2;
                    //CostCenter1.Mode = DataLoadMode.Local;
                    //var storeCostCenter1 = new Ext.Net.Store();
                    //storeCostCenter1.Reader.Add(new Ext.Net.JsonReader());
                    //storeCostCenter1.Reader[0].Fields.Add("StationCode", RecordFieldType.String);
                    //CostCenter1.Store.Add(storeCostCenter1);
                    //storeCostCenter1.DataSource = dtCostCenter;
                    //storeCostCenter1.DataBind();
                    //HeaderColumn hcCostCenter1 = new HeaderColumn();
                    //hcCostCenter1.Component.Add(CostCenter1);
                    //this.GridPanel2.GetView().HeaderRows[1].Columns.Add(hcCostCenter1);

                    //HeaderColumn hcCostCenter01 = new HeaderColumn();
                    //this.GridPanel2.GetView().HeaderRows[1].Columns.Add(hcCostCenter01);
                    var ButtonGetSum1 = new Ext.Net.Button();
                    ButtonGetSum1.Text = "Calculate";
                    ButtonGetSum1.Listeners.Click.Handler = "GetSum();";
                    ButtonGetSum1.Listeners.Click.Delay = 50;
                    HeaderColumn hcButtonGetSum1 = new HeaderColumn();
                    hcButtonGetSum1.Component.Add(ButtonGetSum1);
                    this.GridPanel2.GetView().HeaderRows[1].Columns.Add(hcButtonGetSum1);
                    //
                    HeaderColumn hcTotal3 = new HeaderColumn();
                    this.GridPanel2.GetView().HeaderRows[1].Columns.Add(hcTotal3);

                    HeaderColumn hcTotal4 = new HeaderColumn();
                    this.GridPanel2.GetView().HeaderRows[1].Columns.Add(hcTotal4);

                    var Title3 = new Ext.Net.Label();
                    Title3.Text = "Travel Period:";
                    HeaderColumn hcTitle3 = new HeaderColumn();
                    hcTitle3.Component.Add(Title3);
                    this.GridPanel2.GetView().HeaderRows[2].Columns.Add(hcTitle3);

                    HeaderColumn hcDate1 = new HeaderColumn();
                    var Date1 = new DateField();
                    Date1.EmptyText = "yyyy/MM/dd";
                    Date1.Format = "yyyy/MM/dd";
                    //Date1.SetValue("2013/11/1");
                    hcDate1.Component.Add(Date1);
                    this.GridPanel2.GetView().HeaderRows[2].Columns.Add(hcDate1);

                    HeaderColumn hcDate2 = new HeaderColumn();
                    var Date2 = new DateField();
                    Date2.EmptyText = "yyyy/MM/dd";
                    Date2.Format = "yyyy/MM/dd";
                    //Date2.SetValue("2013/11/2");
                    hcDate2.Component.Add(Date2);
                    this.GridPanel2.GetView().HeaderRows[2].Columns.Add(hcDate2);
                    //
                    HeaderColumn hcDate3 = new HeaderColumn();
                    var Date3 = new DateField();
                    Date3.EmptyText = "yyyy/MM/dd";
                    Date3.Format = "yyyy/MM/dd";
                    //Date3.SetValue("2013/11/1");
                    hcDate3.Component.Add(Date3);
                    this.GridPanel2.GetView().HeaderRows[2].Columns.Add(hcDate3);

                    HeaderColumn hcDate4 = new HeaderColumn();
                    var Date4 = new DateField();
                    Date4.EmptyText = "yyyy/MM/dd";
                    Date4.Format = "yyyy/MM/dd";
                    //Date4.SetValue("2013/11/2");
                    hcDate4.Component.Add(Date4);
                    this.GridPanel2.GetView().HeaderRows[2].Columns.Add(hcDate4);
                    //

                    //HeaderColumn hcTotal5 = new HeaderColumn();
                    //this.GridPanel2.GetView().HeaderRows[2].Columns.Add(hcTotal5);

                    //HeaderColumn hcTotal6 = new HeaderColumn();
                    //this.GridPanel2.GetView().HeaderRows[2].Columns.Add(hcTotal6);

                    var TitleTotalP = new Ext.Net.Label();
                    TitleTotalP.Text = "Total(Person)";
                    TitleTotalP.Cls = "custom-row";
                    HeaderColumn hcTitleTotalP = new HeaderColumn();
                    hcTitleTotalP.Component.Add(TitleTotalP);
                    this.GridPanel2.GetView().HeaderRows[2].Columns.Add(hcTitleTotalP);

                    var TitleTotalC = new Ext.Net.Label();
                    TitleTotalC.Text = "Total(Comp)";
                    TitleTotalC.Cls = "custom-row";
                    HeaderColumn hcTitleTotalC = new HeaderColumn();
                    hcTitleTotalC.Component.Add(TitleTotalC);
                    this.GridPanel2.GetView().HeaderRows[2].Columns.Add(hcTitleTotalC);

                    X.AddScript("GridPanel2.colModel.setHidden(3, true);GridPanel2.colModel.setHidden(4, true);Store2.removeField('Station_1_P');Store2.removeField('Station_1_C');");
                }
                //DataSet dsdep = DIMERCO.SDK.Utilities.LSDK.getCRPDepartment();
                //DataTable dtdep = new DataTable();
                //dtdep.Columns.Add(new DataColumn("Depart", typeof(String)));
                //for (int i = 0; i < dsdep.Tables[0].Rows.Count; i++)
                //{
                //    DataRow dr = dtdep.NewRow();
                //    dr[0] = dsdep.Tables[0].Rows[i][2].ToString();
                //    dtdep.Rows.Add(dr);
                //}
                //StoreDepartment.DataSource = dtdep;
                //StoreDepartment.DataBind();

            }
        }
Пример #33
0
        public void GetBudget(string detailjson)
        {
            //160922 Andy Kang,如果登陆人与被垫付人不同,则不显示预算
            string useridonbehalf = Request.QueryString["UserID"].ToString();
            string loginuserid = Request.Cookies.Get("eReimUserID").Value.ToString();
            if (useridonbehalf != loginuserid)
            {
                return;
            }
            cs.DBCommand dbc = new cs.DBCommand();
            DataTable dtbudget = new DataTable();
            //StoreBudget添加Field
            //StoreBudget.Reader[0].Fields.Clear();
            StoreBudget.Reader[0].Fields.Add("Year", RecordFieldType.String);
            StoreBudget.Reader[0].Fields.Add("EName", RecordFieldType.String);
            StoreBudget.Reader[0].Fields.Add("COACode", RecordFieldType.String);
            StoreBudget.Reader[0].Fields.Add("Current", RecordFieldType.String);
            StoreBudget.Reader[0].Fields.Add("PU", RecordFieldType.String);
            StoreBudget.Reader[0].Fields.Add("PB", RecordFieldType.String);
            StoreBudget.Reader[0].Fields.Add("PPercent", RecordFieldType.String);
            StoreBudget.Reader[0].Fields.Add("DU", RecordFieldType.String);
            StoreBudget.Reader[0].Fields.Add("DB", RecordFieldType.String);
            StoreBudget.Reader[0].Fields.Add("DPercent", RecordFieldType.String);
            StoreBudget.Reader[0].Fields.Add("SU", RecordFieldType.String);
            StoreBudget.Reader[0].Fields.Add("SB", RecordFieldType.String);
            StoreBudget.Reader[0].Fields.Add("SPercent", RecordFieldType.String);

            //如果不是复制而来,Status=2或者3
            string ID = "";
            if (!String.IsNullOrEmpty(Request.QueryString["RequestID"]))
            {
                ID = Request.QueryString["RequestID"].ToString();
                DataTable dtnn = new DataTable();
                string sqlbu = "select Year,EName,COACode,LocalAmount as [Current],PU,PB,PPercent,DU,DB,DPercent,SU,SB,SPercent from Budget_Complete where FormType='G' and RequestID=" + ID;
                dtnn = dbc.GetData("eReimbursement", sqlbu);
                if (dtnn.Rows.Count > 0)
                {
                    dtbudget = dtnn;
                    bool PB = false, DB = false, SB = false;
                    //计算%,取得名称,预算转换为本地汇率
                    for (int i = 0; i < dtbudget.Rows.Count; i++)
                    {
                        if (Convert.ToDecimal(dtbudget.Rows[i]["PB"].ToString()) != 0)//如果Budget不为0,则计算%
                        {
                            if (!PB)
                            {
                                PB = true;
                            }
                        }
                        if (Convert.ToDecimal(dtbudget.Rows[i]["DB"].ToString()) != 0)//如果Budget不为0,则计算%
                        {
                            if (!DB)
                            {
                                DB = true;
                            }
                        }
                        if (Convert.ToDecimal(dtbudget.Rows[i]["SB"].ToString()) != 0)//如果Budget不为0,则计算%
                        {
                            if (!SB)
                            {
                                SB = true;
                            }
                        }
                    }
                    //添加数据列
                    var cm = GridPanelBudget.ColumnModel;
                    cm.Columns.Add(new Column
                    {
                        DataIndex = "EName",
                        Header = "Expense Item",
                        Sortable = false,
                        Resizable = false,
                        MenuDisabled = true,
                        Width = 100
                    });
                    cm.Columns.Add(new Column
                    {
                        DataIndex = "Current",
                        Header = "Current",
                        Renderer = new Renderer { Fn = "GetNumber" },
                        Sortable = false,
                        Resizable = false,
                        MenuDisabled = true,
                        Width = 100
                    });
                    cm.Columns.Add(new Column
                    {
                        DataIndex = "Year",
                        Header = "Budget Year",
                        Sortable = false,
                        Resizable = false,
                        MenuDisabled = true,
                        Width = 100
                    });
                    //显示个人预算部分
                    if (PB)
                    {
                        cm.Columns.Add(new Column
                        {
                            DataIndex = "PU",
                            Header = "Personal Used",
                            Renderer = new Renderer { Fn = "GetNumber" },
                            Sortable = false,
                            Resizable = false,
                            MenuDisabled = true,
                            Width = 100
                        });
                        cm.Columns.Add(new Column
                        {
                            DataIndex = "PB",
                            Header = "Personal Budget",
                            Renderer = new Renderer { Fn = "GetNumber" },
                            Sortable = false,
                            Resizable = false,
                            MenuDisabled = true,
                            Width = 100
                        });
                        cm.Columns.Add(new Column
                        {
                            DataIndex = "PPercent",
                            Header = "%(Current+Used/Budget)",
                            Renderer = new Renderer { Fn = "GetNumberPercent" },
                            Sortable = false,
                            Resizable = false,
                            MenuDisabled = true,
                            Width = 100
                        });
                    }
                    if (DB)
                    {
                        cm.Columns.Add(new Column
                        {
                            DataIndex = "DU",
                            Header = "Department Used",
                            Renderer = new Renderer { Fn = "GetNumber" },
                            Sortable = false,
                            Resizable = false,
                            MenuDisabled = true,
                            Width = 100
                        });
                        cm.Columns.Add(new Column
                        {
                            DataIndex = "DB",
                            Header = "Department Budget",
                            Renderer = new Renderer { Fn = "GetNumber" },
                            Sortable = false,
                            Resizable = false,
                            MenuDisabled = true,
                            Width = 100
                        });
                        cm.Columns.Add(new Column
                        {
                            DataIndex = "DPercent",
                            Header = "%(Current+Used/Budget)",
                            Renderer = new Renderer { Fn = "GetNumberPercent" },
                            Sortable = false,
                            Resizable = false,
                            MenuDisabled = true,
                            Width = 100
                        });
                    }
                    if (SB)
                    {
                        cm.Columns.Add(new Column
                        {
                            DataIndex = "SU",
                            Header = "Unit Used",
                            Renderer = new Renderer { Fn = "GetNumber" },
                            Sortable = false,
                            Resizable = false,
                            MenuDisabled = true,
                            Width = 100
                        });
                        cm.Columns.Add(new Column
                        {
                            DataIndex = "SB",
                            Header = "Unit Budget",
                            Renderer = new Renderer { Fn = "GetNumber" },
                            Sortable = false,
                            Resizable = false,
                            MenuDisabled = true,
                            Width = 100
                        });
                        cm.Columns.Add(new Column
                        {
                            DataIndex = "SPercent",
                            Header = "%(Current+Used/Budget)",
                            Renderer = new Renderer { Fn = "GetNumberPercent" },
                            Sortable = false,
                            Resizable = false,
                            MenuDisabled = true,
                            Width = 100
                        });
                    }
                }
            }
            else
            {
                string station_applyperson = ""; string costcenter_applyperson = ""; string dept_applyperson = "";
                DataSet ds_apply = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(Request.QueryString["apply_userid"].ToString());
                if (ds_apply.Tables[0].Rows.Count == 1)
                {
                    DataTable dt_apply = ds_apply.Tables[0];
                    dept_applyperson = dt_apply.Rows[0]["DepartmentName"].ToString();
                    station_applyperson = dt_apply.Rows[0]["stationCode"].ToString();
                    costcenter_applyperson = dt_apply.Rows[0]["CostCenter"].ToString();
                }

                string userid = Request.QueryString["UserID"].ToString();
                string ostation = ""; string station = ""; string department = "";
                DataSet ds2 = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(userid);
                if (ds2.Tables[0].Rows.Count == 1)
                {
                    DataTable dt1 = ds2.Tables[0];
                    ostation = dt1.Rows[0]["CostCenter"].ToString();//记录用户预算站点,即CostCenter
                    station = dt1.Rows[0]["stationCode"].ToString();//记录用户所在站点
                    department = dt1.Rows[0]["CRPDepartmentName"].ToString();
                }

                decimal rate = 1;//记录用户币种与预算站点币种汇率
                string CurLocal = DIMERCO.SDK.Utilities.LSDK.GetStationCurrencyByCode(costcenter_applyperson);
                //检查是否本地维护过特殊币种
                DataTable dttemp = new DataTable();
                string sqltemp = "select * from ESUSER where Userid='" + Request.QueryString["apply_userid"].ToString() + "'";
                dttemp = dbc.GetData("eReimbursement", sqltemp);
                if (dttemp.Rows.Count > 0)
                {
                    CurLocal = dttemp.Rows[0]["Currency"].ToString();//如果单独设置了币种
                }
                string CurBudget = DIMERCO.SDK.Utilities.LSDK.GetStationCurrencyByCode(ostation);//预算站点币种


                dtbudget.Columns.Add("Year", typeof(System.String));//区分跨年情况
                dtbudget.Columns.Add("EName", typeof(System.String));
                dtbudget.Columns.Add("COACode", typeof(System.String));
                dtbudget.Columns.Add("Current", typeof(System.Decimal));
                dtbudget.Columns.Add("PU", typeof(System.Decimal));
                dtbudget.Columns.Add("PB", typeof(System.Decimal));
                dtbudget.Columns.Add("PPercent", typeof(System.Decimal));
                dtbudget.Columns.Add("DU", typeof(System.Decimal));
                dtbudget.Columns.Add("DB", typeof(System.Decimal));
                dtbudget.Columns.Add("DPercent", typeof(System.Decimal));
                dtbudget.Columns.Add("SU", typeof(System.Decimal));
                dtbudget.Columns.Add("SB", typeof(System.Decimal));
                dtbudget.Columns.Add("SPercent", typeof(System.Decimal));



                //基础数据
                DataTable dtA = new DataTable();
                dtA.Columns.Add("EName", typeof(System.String));
                dtA.Columns.Add("COACode", typeof(System.String));
                dtA.Columns.Add("Amount", typeof(System.Decimal));
                dtA.Columns.Add("Year", typeof(System.String));

                JavaScriptSerializer ser = new JavaScriptSerializer();
                List<DetailExpense> Details = ser.Deserialize<List<DetailExpense>>(detailjson);
                foreach (DetailExpense detail in Details)
                {
                    DataRow dr = dtA.NewRow();
                    string EName = "";
                    if (detail.Type == "E")
                    {
                        EName = "Entertainment";
                    }
                    else if (detail.Type == "T")
                    {
                        EName = "Transportation";
                    }
                    else if (detail.Type == "C")
                    {
                        EName = "Communication";
                    }
                    else
                    {
                        EName = detail.COAName;
                    }
                    dr["EName"] = EName;
                    dr["COACode"] = detail.AccountCode;
                    dr["Amount"] = Convert.ToDecimal(detail.Amount);
                    if (detail.Type == "C")
                    {
                        dr["Year"] = Convert.ToDateTime(detail.EffectTime).Year.ToString();
                    }
                    else
                    {
                        dr["Year"] = Convert.ToDateTime(detail.Tdate).Year.ToString();
                    }
                    dtA.Rows.Add(dr);
                }
                //合计数据
                DataTable dtB = new DataTable();
                dtB.Columns.Add("EName", typeof(System.String));
                dtB.Columns.Add("COACode", typeof(System.String));
                dtB.Columns.Add("Amount", typeof(System.Decimal));
                dtB.Columns.Add("Year", typeof(System.String));
                for (int i = 0; i < dtA.Rows.Count; i++)
                {
                    bool er = false;
                    for (int j = 0; j < dtB.Rows.Count; j++)
                    {
                        if (dtB.Rows[j]["COACode"].ToString() == dtA.Rows[i]["COACode"].ToString() && dtB.Rows[j]["Year"].ToString() == dtA.Rows[i]["Year"].ToString())//已有记录
                        {
                            er = true;
                            break;
                        }
                    }
                    if (!er)//不存在重复记录
                    {
                        DataRow dr = dtB.NewRow();
                        dr["EName"] = dtA.Rows[i]["EName"].ToString();
                        dr["COACode"] = dtA.Rows[i]["COACode"].ToString();
                        dr["Amount"] = dtA.Compute("Sum(Amount)", "Year = " + dtA.Rows[i]["Year"].ToString() + " and COACode = " + dtA.Rows[i]["COACode"].ToString());
                        dr["Year"] = dtA.Rows[i]["Year"].ToString();
                        dtB.Rows.Add(dr);
                    }
                }
                string accountcode = "";
                for (int g = 0; g < dtB.Rows.Count; g++)
                {
                    if (Convert.ToDecimal(dtB.Rows[g]["Amount"].ToString()) != 0)
                    {
                        DataRow dr = dtbudget.NewRow();
                        dr["EName"] = dtB.Rows[g]["EName"].ToString();
                        dr["Current"] = Convert.ToDecimal(dtB.Rows[g]["Amount"].ToString());
                        dr["COACode"] = dtB.Rows[g]["COACode"].ToString();
                        dr["Year"] = dtB.Rows[g]["Year"].ToString();
                        accountcode = dtB.Rows[g]["COACode"].ToString();
                        DataTable dtC = new DataTable();
                        dtC = Comm.RtnEB(userid, department, ostation, ostation, accountcode, dtB.Rows[g]["Year"].ToString(), "1");
                        for (int i = 0; i < dtC.Rows.Count; i++)
                        {
                            if (dtC.Rows[i]["Type"].ToString() == "全年个人")
                            {
                                dr["PU"] = Convert.ToDecimal(dtC.Rows[i]["Used"].ToString());
                                dr["PB"] = Convert.ToDecimal(dtC.Rows[i]["Budget"].ToString());
                            }
                            else if (dtC.Rows[i]["Type"].ToString() == "全年部门")
                            {
                                dr["DU"] = Convert.ToDecimal(dtC.Rows[i]["Used"].ToString());
                                dr["DB"] = Convert.ToDecimal(dtC.Rows[i]["Budget"].ToString());
                            }
                            else if (dtC.Rows[i]["Type"].ToString() == "全年站点")
                            {
                                dr["SU"] = Convert.ToDecimal(dtC.Rows[i]["Used"].ToString());
                                dr["SB"] = Convert.ToDecimal(dtC.Rows[i]["Budget"].ToString());
                            }
                        }
                        dtbudget.Rows.Add(dr);
                    }
                }
                bool UnBudget = false;
                bool PB = false, DB = false, SB = false;
                //计算%,取得名称,转为本地币种汇率,增加列记录Currency为邮件准备
                dtbudget.Columns.Add("Currency", typeof(System.String));
                for (int i = 0; i < dtbudget.Rows.Count; i++)
                {
                    dtbudget.Rows[i]["Currency"] = CurLocal;
                    if (CurLocal != CurBudget)
                    {
                        rate = DIMERCO.SDK.Utilities.LSDK.GetBudgetConverRate(CurLocal, CurBudget, Convert.ToInt16(dtbudget.Rows[i]["Year"].ToString()));
                    }
                    if (Convert.ToDecimal(dtbudget.Rows[i]["PB"].ToString()) != 0)//如果Budget不为0,则计算%
                    {
                        decimal PPercent = System.Math.Round(Convert.ToDecimal(dtbudget.Rows[i]["PU"].ToString()) * 100 / Convert.ToDecimal(dtbudget.Rows[i]["PB"].ToString()), 2);
                        dtbudget.Rows[i]["PPercent"] = PPercent;
                        if (!UnBudget)
                        {
                            if (PPercent > 100)
                            {
                                UnBudget = true;
                            }
                        }
                        if (!PB)
                        {
                            PB = true;
                        }
                    }
                    if (Convert.ToDecimal(dtbudget.Rows[i]["DB"].ToString()) != 0)//如果Budget不为0,则计算%
                    {
                        decimal DPercent = System.Math.Round(Convert.ToDecimal(dtbudget.Rows[i]["DU"].ToString()) * 100 / Convert.ToDecimal(dtbudget.Rows[i]["DB"].ToString()), 2);
                        dtbudget.Rows[i]["DPercent"] = DPercent;
                        if (!UnBudget)
                        {
                            if (DPercent > 100)
                            {
                                UnBudget = true;
                            }
                        }
                        if (!DB)
                        {
                            DB = true;
                        }
                    }
                    if (Convert.ToDecimal(dtbudget.Rows[i]["SB"].ToString()) != 0)//如果Budget不为0,则计算%
                    {
                        decimal SPercent = System.Math.Round(Convert.ToDecimal(dtbudget.Rows[i]["SU"].ToString()) * 100 / Convert.ToDecimal(dtbudget.Rows[i]["SB"].ToString()), 2);
                        dtbudget.Rows[i]["SPercent"] = SPercent;
                        if (!UnBudget)
                        {
                            if (SPercent > 100)
                            {
                                UnBudget = true;
                            }
                        }
                        if (!SB)
                        {
                            SB = true;
                        }
                    }
                    if (Convert.ToDecimal(dtbudget.Rows[i]["PB"].ToString()) == 0 && Convert.ToDecimal(dtbudget.Rows[i]["DB"].ToString()) == 0 && Convert.ToDecimal(dtbudget.Rows[i]["SB"].ToString()) == 0)
                    {
                        //如果个人,部门,站点,全未分配预算,则判断为Un-Budget
                        if (!UnBudget)
                        {
                            UnBudget = true;
                        }
                    }
                    dtbudget.Rows[i]["PU"] = System.Math.Round(rate * Convert.ToDecimal(dtbudget.Rows[i]["PU"].ToString()), 2);
                    dtbudget.Rows[i]["PB"] = System.Math.Round(rate * Convert.ToDecimal(dtbudget.Rows[i]["PB"].ToString()), 2);
                    dtbudget.Rows[i]["DU"] = System.Math.Round(rate * Convert.ToDecimal(dtbudget.Rows[i]["DU"].ToString()), 2);
                    dtbudget.Rows[i]["DB"] = System.Math.Round(rate * Convert.ToDecimal(dtbudget.Rows[i]["DB"].ToString()), 2);
                    dtbudget.Rows[i]["SU"] = System.Math.Round(rate * Convert.ToDecimal(dtbudget.Rows[i]["SU"].ToString()), 2);
                    dtbudget.Rows[i]["SB"] = System.Math.Round(rate * Convert.ToDecimal(dtbudget.Rows[i]["SB"].ToString()), 2);
                }

                //添加数据列
                var cm = GridPanelBudget.ColumnModel;
                cm.Columns.Clear();
                cm.Columns.Add(new Column
                {
                    DataIndex = "EName",
                    Header = "Expense Item",
                    Sortable = false,
                    Resizable = false,
                    MenuDisabled = true,
                    Width = 160
                });
                cm.Columns.Add(new Column
                {
                    DataIndex = "Current",
                    Header = "Current",
                    Renderer = new Renderer { Fn = "GetNumber" },
                    Sortable = false,
                    Resizable = false,
                    MenuDisabled = true,
                    Width = 100
                });
                cm.Columns.Add(new Column
                {
                    DataIndex = "Year",
                    Header = "Budget Year",
                    Sortable = false,
                    Resizable = false,
                    MenuDisabled = true,
                    Width = 100
                });
                //显示个人预算部分
                if (PB)
                {
                    cm.Columns.Add(new Column
                    {
                        DataIndex = "PU",
                        Header = "Personal Used",
                        Renderer = new Renderer { Fn = "GetNumber" },
                        Sortable = false,
                        Resizable = false,
                        MenuDisabled = true,
                        Width = 100
                    });
                    cm.Columns.Add(new Column
                    {
                        DataIndex = "PB",
                        Header = "Personal Budget",
                        Renderer = new Renderer { Fn = "GetNumber" },
                        Sortable = false,
                        Resizable = false,
                        MenuDisabled = true,
                        Width = 100
                    });
                    cm.Columns.Add(new Column
                    {
                        DataIndex = "PPercent",
                        Header = "%(Used/Budget)",
                        Renderer = new Renderer { Fn = "GetNumberPercent" },
                        Sortable = false,
                        Resizable = false,
                        MenuDisabled = true,
                        Width = 100
                    });
                }
                if (DB)
                {
                    cm.Columns.Add(new Column
                    {
                        DataIndex = "DU",
                        Header = "Department Used",
                        Renderer = new Renderer { Fn = "GetNumber" },
                        Sortable = false,
                        Resizable = false,
                        MenuDisabled = true,
                        Width = 100
                    });
                    cm.Columns.Add(new Column
                    {
                        DataIndex = "DB",
                        Header = "Department Budget",
                        Renderer = new Renderer { Fn = "GetNumber" },
                        Sortable = false,
                        Resizable = false,
                        MenuDisabled = true,
                        Width = 100
                    });
                    cm.Columns.Add(new Column
                    {
                        DataIndex = "DPercent",
                        Header = "%(Used/Budget)",
                        Renderer = new Renderer { Fn = "GetNumberPercent" },
                        Sortable = false,
                        Resizable = false,
                        MenuDisabled = true,
                        Width = 100
                    });
                }
                if (SB)
                {
                    cm.Columns.Add(new Column
                    {
                        DataIndex = "SU",
                        Header = "Unit Used",
                        Renderer = new Renderer { Fn = "GetNumber" },
                        Sortable = false,
                        Resizable = false,
                        MenuDisabled = true,
                        Width = 100
                    });
                    cm.Columns.Add(new Column
                    {
                        DataIndex = "SB",
                        Header = "Unit Budget",
                        Renderer = new Renderer { Fn = "GetNumber" },
                        Sortable = false,
                        Resizable = false,
                        MenuDisabled = true,
                        Width = 100
                    });
                    cm.Columns.Add(new Column
                    {
                        DataIndex = "SPercent",
                        Header = "%(Used/Budget)",
                        Renderer = new Renderer { Fn = "GetNumberPercent" },
                        Sortable = false,
                        Resizable = false,
                        MenuDisabled = true,
                        Width = 100
                    });
                }
            }



            StoreBudget.DataSource = dtbudget;
            StoreBudget.DataBind();
            GridPanelBudget.Render();
        }
Пример #34
0
        public void SaveAll1(string type, string detail, string MailList, string header0string, string header1string, string header2string, string Cur, string dept,string warningmsg)
        {
            DateTime dtnull = new DateTime(1, 1, 1, 0, 0, 0);
            cs.DBCommand dbc = new cs.DBCommand();
            //检查是否已经为该申请人设置过审批人
            string sqlCheckFlow = "";
            if (Radio1.Checked)
            //if (cbxBudget.Value.ToString() == "YES")//使用Budget审批流程
            {
                sqlCheckFlow = "select * from GroupFlow where [Type]!=2 and GID=(select GID from GroupUsers where UserID='" + hdOwnerID.Value.ToString() + "')";
            }
            else//使用unBudget审批流程
            {
                sqlCheckFlow = "select * from GroupFlow where [Type]=2 and GID=(select GID from GroupUsers where UserID='" + hdOwnerID.Value.ToString() + "')";
            }
            DataTable dtGroupFlowData = dbc.GetData("eReimbursement", sqlCheckFlow);
            if (dtGroupFlowData.Rows.Count < 1)
            {
                if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                {
                    ErrorHandle("请先设置审批人.");
                }
                else
                {
                    ErrorHandle("Not set Approve flow,please contact with Local MIS.");
                }
                return;
            }

            //处理抄送人列表
            string CCMailList = "";
            JavaScriptSerializer ser = new JavaScriptSerializer();
            List<CCMailList> CCMailList1 = ser.Deserialize<List<CCMailList>>(MailList);
            foreach (CCMailList mail in CCMailList1)
            {
                CCMailList += mail.Email + ",";
            }
            CCMailList = CCMailList.Length > 0 ? CCMailList.Substring(0, CCMailList.Length - 1) : "";

            string userid = hdOwnerID.Value.ToString();
            string ostation = ""; string station = ""; string department = "";
            DataSet ds2 = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(userid);
            if (ds2.Tables[0].Rows.Count == 1)
            {
                DataTable dt1 = ds2.Tables[0];
                //dpt = dt1.Rows[0]["DepartmentName"].ToString();
                ostation = dt1.Rows[0]["stationCode"].ToString();
                station = dt1.Rows[0]["stationCode"].ToString();
                department = dt1.Rows[0]["CRPDepartmentName"].ToString();
                DataTable dttemp = new DataTable();
                string sqltemp = "select * from ESUSER where Userid='" + userid + "'";
                dttemp = dbc.GetData("eReimbursement", sqltemp);
                if (dttemp.Rows.Count > 0)
                {
                    ostation = dttemp.Rows[0]["Station"].ToString();
                }
            }
            string para = type;
            if (para == "ND")//保存并申请
            {
                if (hdTravelRequestID.Value.ToString() == "")//直接新增申请,不通过草稿
                {
                    string word = "[No],[Person],[Station],[Department],[ReportFile],[Tamount],[Pamout],[Camount],[CreadedBy],[CreadedDate],[Attach],[Remark],[Bdate],[Edate],[PersonID],[CreadedByID],[ApplyDate],[CCMailList],[Budget],[Station2]";
                    string value = "";
                    value += "'" + station + DateTime.Now.Year.ToString().Substring(2, 2) + DateTime.Now.Month.ToString().PadLeft(2, '0') + "',";//edit
                    value += "'" + hdOwner.Value.ToString() + "',"; value += "'" + station + "',"; value += "'" + department + "',";//edit
                    value += "'" + hdReport.Value.ToString() + "',";
                    value += hdSum.Value.ToString() == "" ? "null" : hdSum.Value.ToString();
                    value += "," + (hdPamountSum.Value.ToString() == "" ? "null" : hdPamountSum.Value.ToString());
                    value += "," + (hdCamountSum.Value.ToString() == "" ? "null" : hdCamountSum.Value.ToString());
                    value += ",'" + Request.Cookies.Get("eReimUserName").Value + "'";//edit
                    value += ",'" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "',";
                    value += "'" + hdScanFile.Value.ToString() + "',";
                    value += "'" + txtRemark.Text.Replace("'", "''") + "',";
                    value += "null,null";
                    value += ",'" + hdOwnerID.Value.ToString() + "'";
                    value += ",'" + Request.Cookies.Get("eReimUserID").Value + "'";
                    value += ",'" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "'";
                    value += ",'" + CCMailList + "'";
                    value += "," + (Radio1.Checked ? "1" : "0");
                    //value += "," + (cbxBudget.Value.ToString() == "YES" ? "1" : "0");
                    value += ",'" + ostation + "'";
                    string updatesql = "insert into ETravel (" + word + ") values(" + value + ");update ETravel set [No]=[No]+(select [MonthCount]=right('0000'+cast(count(ID) as varchar(10)),4) from ETravel where (month(ApplyDate) in (select month(ApplyDate) from ETravel where [ID]=@@IDENTITY) and (year(ApplyDate) in (select year(ApplyDate) from ETravel where [ID]=@@IDENTITY)) and Station=(select Station from ETravel where ID=@@IDENTITY)))+'T' where ID=@@IDENTITY;select [msg]=convert(varchar,ID)+','+[No] from ETravel where ID=@@IDENTITY";

                    string newid = dbc.UpdateData("eReimbursement", updatesql, "Insert");

                    string rows = "";
                    for (int i = 0; i < dtGroupFlowData.Rows.Count; i++)
                    {
                        string wordflow = "[No],[Type],[Station],[Department],[Person],[CreadedBy],[CreatedDate],[Tamount],[Step],[Status],[Approver],[ApproverID],[RequestID],[FlowFn]";
                        if (dtGroupFlowData.Rows[i]["FlowNo"].ToString() == "1")
                        {
                            wordflow += ",[Active]";
                        }
                        string valueflow = "";
                        valueflow += "'" + newid.Split(',')[1] + "',";
                        valueflow += "'T',";
                        valueflow += "'" + station + "',";
                        valueflow += "'" + department + "',";
                        valueflow += "'" + hdOwner.Value.ToString() + "',";
                        valueflow += "'" + Request.Cookies.Get("eReimUserName").Value + "',";
                        valueflow += "'" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "',";
                        valueflow += hdSum.Value.ToString() == "" ? "null," : hdSum.Value.ToString() + ",";
                        valueflow += dtGroupFlowData.Rows[i]["FlowNo"].ToString() + ",";
                        valueflow += "1,";
                        valueflow += "'" + dtGroupFlowData.Rows[i]["FlowUser"].ToString() + "',";
                        valueflow += "'" + dtGroupFlowData.Rows[i]["FlowUserid"].ToString() + "',";
                        valueflow += "'" + newid.Split(',')[0] + "'";
                        valueflow += ",'" + (dtGroupFlowData.Rows[i]["Fn"].ToString() == "" ? "Approver" : dtGroupFlowData.Rows[i]["Fn"].ToString()) + "'";
                        if (dtGroupFlowData.Rows[i]["FlowNo"].ToString() == "1")
                        {
                            valueflow += ",1";
                        }
                        string sqlupdateEFlow = "insert into Eflow (" + wordflow + ") values(" + valueflow + ")";
                        rows = dbc.UpdateData("eReimbursement", sqlupdateEFlow, "Update");
                    }
                    if (newid == "-1" || rows == "-1" || rows == "")
                    {
                        ErrorHandle("Data Error.");
                        return;
                    }
                    else
                    {
                        hdTravelRequestID.Value = newid.Split(',')[0];//新增后记录ID
                        hdTravelRequestNo.Value = newid.Split(',')[1];//新增后记录No

                        if (!SaveDetail(detail, header0string, header1string, header2string, Cur, dept) || !SendMail(warningmsg))
                        {
                            ErrorHandle("Data Error.");
                            return;
                        }
                        if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                        {
                            Panel3.Title = "差旅费申请单: " + newid.Split(',')[1];
                            UpdateMSG("保存申请单:" + newid.Split(',')[1] + "成功.");
                        }
                        else
                        {
                            Panel3.Title = "Travel Expense Form: " + newid.Split(',')[1];
                            UpdateMSG("Saved Travel Expense Form: " + newid.Split(',')[1] + " successfully.");
                        }

                    }
                    //
                }
                else//由草稿升级为正式申请
                {
                    string updatesql = "update ETravel set [Person]='" + hdOwner.Value.ToString();
                    updatesql += "',[Station]='" + station;
                    updatesql += "',[Department]='" + department;
                    updatesql += "',[ReportFile]='" + hdReport.Value.ToString();
                    updatesql += "',[Tamount]=" + (hdSum.Value.ToString() == "" ? "null" : hdSum.Value.ToString());
                    updatesql += ",[Pamout]=" + (hdPamountSum.Value.ToString() == "" ? "null" : hdPamountSum.Value.ToString());
                    updatesql += ",[Camount]=" + (hdCamountSum.Value.ToString() == "" ? "null" : hdCamountSum.Value.ToString());
                    updatesql += ",[Remark]='" + txtRemark.Text.Replace("'", "''") + "'";
                    updatesql += ",[Attach]='" + hdScanFile.Value.ToString() + "'";
                    updatesql += ",[Type]=0";
                    updatesql += ",[PersonID]='" + hdOwnerID.Value.ToString() + "'";
                    string oldno = hdTravelRequestNo.Value.ToString();
                    string newno = hdTravelRequestNo.Value.ToString().Substring(0, hdTravelRequestNo.Value.ToString().Length - 1);
                    updatesql += ",[No]='" + newno + "',";
                    updatesql += "[CreadedDate]='" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "',";
                    updatesql += "[CreadedBy]='" + Request.Cookies.Get("eReimUserName").Value + "',";
                    updatesql += "[CreadedByID]='" + Request.Cookies.Get("eReimUserID").Value + "'";
                    updatesql += ",[CCMailList]='" + CCMailList + "'";
                    updatesql += ",[Budget]=" + (Radio1.Checked ? "1" : "0");
                    //updatesql += ",[Budget]=" + (cbxBudget.Value.ToString() == "YES" ? "1" : "0");
                    updatesql += ",[Station2]='" + ostation + "'";
                    updatesql += " where ID=" + hdTravelRequestID.Value.ToString();

                    string newid = dbc.UpdateData("eReimbursement", updatesql, "Update");

                    //操作Flow表
                    string sqlDeleteEflow = "delete from Eflow where [Type]='T' and [RequestID]='" + hdTravelRequestID.Value.ToString() + "'";
                    string deleterows = dbc.UpdateData("eReimbursement", sqlDeleteEflow, "Update");
                    string rows = "";
                    for (int i = 0; i < dtGroupFlowData.Rows.Count; i++)
                    {
                        string wordflow = "[No],[Type],[Station],[Department],[Person],[CreadedBy],[CreatedDate],[Tamount],[Step],[Status],[Approver],[ApproverID],[RequestID],[FlowFn]";
                        if (dtGroupFlowData.Rows[i]["FlowNo"].ToString() == "1")
                        {
                            wordflow += ",[Active]";
                        }
                        string valueflow = "";
                        valueflow += "'" + newno + "',";
                        valueflow += "'T',";
                        valueflow += "'" + station + "',";
                        valueflow += "'" + department + "',";
                        valueflow += "'" + hdOwner.Value.ToString() + "',";
                        valueflow += "'" + Request.Cookies.Get("eReimUserName").Value + "',";
                        valueflow += "'" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "',";
                        valueflow += hdSum.Value.ToString() == "" ? "null," : hdSum.Value.ToString() + ",";
                        valueflow += dtGroupFlowData.Rows[i]["FlowNo"].ToString() + ",";
                        valueflow += "1,";
                        valueflow += "'" + dtGroupFlowData.Rows[i]["FlowUser"].ToString() + "',";
                        valueflow += "'" + dtGroupFlowData.Rows[i]["FlowUserid"].ToString() + "',";
                        valueflow += hdTravelRequestID.Value.ToString();
                        valueflow += ",'" + (dtGroupFlowData.Rows[i]["Fn"].ToString() == "" ? "Approver" : dtGroupFlowData.Rows[i]["Fn"].ToString()) + "'";
                        if (dtGroupFlowData.Rows[i]["FlowNo"].ToString() == "1")
                        {
                            valueflow += ",1";
                        }
                        string sqlupdateEFlow = "insert into Eflow (" + wordflow + ") values(" + valueflow + ")";
                        rows = dbc.UpdateData("eReimbursement", sqlupdateEFlow, "Update");
                    }
                    //
                    if (newid == "-1" || rows == "-1" || rows == "")
                    {
                        ErrorHandle("Data Error.");
                        return;
                    }
                    else
                    {
                        hdTravelRequestNo.Value = newno;

                        if (!SaveDetail(detail, header0string, header1string, header2string, Cur, dept) || !SendMail(warningmsg))
                        {
                            ErrorHandle("Data Error.");
                            return;
                        }


                        if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                        {
                            Panel3.Title = "差旅费申请单:" + newno;
                            UpdateMSG("保存差旅费申请单:" + hdTravelRequestNo.Value.ToString() + "成功.");
                        }
                        else
                        {
                            Panel3.Title = "Travel Expense Form: " + newno;
                            UpdateMSG("Saved Travel Expense Form: " + hdTravelRequestNo.Value.ToString() + " successfully.");
                        }

                    }
                }
                X.AddScript("btnAddDSTN.disable();btnGeteLeave.disable();btnSaveDraft.disable();btnSaveAndSend.disable();Radio1.disable();Radio2.disable();btnExport.enable();btnCC.disable();");
                //X.AddScript("btnAddDSTN.disable();btnGeteLeave.disable();btnSaveDraft.disable();btnSaveAndSend.disable();cbxBudget.setReadOnly(true);btnExport.enable();btnCC.disable();");
            }
            else//保存草稿
            {
                if (hdTravelRequestID.Value.ToString() != "")//由链接进入的草稿更新
                {
                    string updatesql = "update ETravel set [Person]='" + hdOwner.Value.ToString();
                    updatesql += "',[Station]='" + station;
                    updatesql += "',[Department]='" + department;
                    updatesql += "',[ReportFile]='" + hdReport.Value.ToString();
                    updatesql += "',[Tamount]=" + (hdSum.Value.ToString() == "" ? "null" : hdSum.Value.ToString());
                    updatesql += ",[Pamout]=" + (hdPamountSum.Value.ToString() == "" ? "null" : hdPamountSum.Value.ToString());
                    updatesql += ",[Camount]=" + (hdCamountSum.Value.ToString() == "" ? "null" : hdCamountSum.Value.ToString());
                    updatesql += ",[Remark]='" + txtRemark.Text.Replace("'", "''") + "'";
                    updatesql += ",[Attach]='" + hdScanFile.Value.ToString() + "'";
                    updatesql += ",[PersonID]='" + hdOwnerID.Value.ToString() + "'";
                    updatesql += ",[CCMailList]='" + CCMailList + "'";
                    updatesql += ",[Budget]=" + (Radio1.Checked ? "1" : "0");
                    //updatesql += ",[Budget]=" + (cbxBudget.Value.ToString() == "YES" ? "1" : "0");
                    updatesql += ",[Station2]='" + ostation + "'";
                    updatesql += " where ID=" + hdTravelRequestID.Value.ToString();

                    string newid = dbc.UpdateData("eReimbursement", updatesql, "Update");

                    if (newid == "-1")
                    {
                        ErrorHandle("Data Error.");
                        return;
                    }
                    else
                    {
                        if (!SaveDetail(detail, header0string, header1string, header2string, Cur, dept))
                        {
                            ErrorHandle("Data Error.");
                            return;
                        }
                        //hdTravelRequestID.Value = newid.Split(',')[0];//新增后记录ID
                        //Panel3.Title = "差旅费申请单:" + newid.Split(',')[1];
                        //X.AddScript("GridPanel2.submitData();");
                        if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                        {
                            UpdateMSG("保存差旅费申请单草稿: " + hdTravelRequestNo.Value.ToString() + "成功.");
                        }
                        else
                        {
                            UpdateMSG("Saved Travel Expense Draft: " + hdTravelRequestNo.Value.ToString() + " successfully.");
                        }
                    }

                }
                else//如果ID为空则判断为新增草稿
                {
                    string word = "[No],[Person],[Station],[Department],[ReportFile],[Tamount],[Pamout],[Camount],[Attach],[Remark],[Bdate],[Edate],[Type],[PersonID],[ApplyDate],[CCMailList],[Station2],[Budget]";
                    string value = "";
                    value += "'" + station + DateTime.Now.Year.ToString().Substring(2, 2) + DateTime.Now.Month.ToString().PadLeft(2, '0') + "',";//edit
                    value += "'" + hdOwner.Value.ToString() + "',"; value += "'" + station + "',"; value += "'" + department + "',";//edit
                    value += "'" + hdReport.Value.ToString() + "',";
                    value += (hdSum.Value.ToString() == "" ? "null" : hdSum.Value.ToString());
                    value += "," + (hdPamountSum.Value.ToString() == "" ? "null" : hdPamountSum.Value.ToString());
                    value += "," + (hdCamountSum.Value.ToString() == "" ? "null" : hdCamountSum.Value.ToString());
                    value += ",'" + hdScanFile.Value.ToString() + "',";
                    value += "'" + txtRemark.Text.Replace("'", "''") + "',";
                    value += "null,null,";
                    value += "1";//标识为草稿
                    value += ",'" + hdOwnerID.Value.ToString() + "'";
                    value += ",'" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "'";
                    value += ",'" + CCMailList + "'";
                    value += ",'" + ostation + "'";
                    value += "," + (Radio1.Checked ? "1" : "0");
                    //value += "," + (cbxBudget.Value.ToString() == "YES" ? "1" : "0");
                    string updatesql = "insert into ETravel (" + word + ") values(" + value + ");update ETravel set [No]=[No]+(select [MonthCount]=right('0000'+cast(count(ID) as varchar(10)),4) from ETravel where (month(ApplyDate) in (select month(ApplyDate) from ETravel where [ID]=@@IDENTITY) and (year(ApplyDate) in (select year(ApplyDate) from ETravel where [ID]=@@IDENTITY)) and Station=(select Station from ETravel where ID=@@IDENTITY)))+'TD' where ID=@@IDENTITY;select [msg]=convert(varchar,ID)+','+[No] from ETravel where ID=@@IDENTITY";

                    string newid = dbc.UpdateData("eReimbursement", updatesql, "Insert");

                    //操作Flow表
                    string wordflow = "[No],[Type],[Station],[Department],[Person],[CreadedBy],[CreatedDate],[Tamount],[RequestID],[Active]";
                    string valueflow = "";
                    valueflow += "'" + newid.Split(',')[1] + "',";
                    valueflow += "'T',";
                    valueflow += "'" + station + "',";
                    valueflow += "'" + department + "',";
                    valueflow += "'" + hdOwner.Value.ToString() + "',";
                    valueflow += "'" + Request.Cookies.Get("eReimUserName").Value + "',";
                    valueflow += "'" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "',";
                    valueflow += hdSum.Value.ToString() == "" ? "null," : hdSum.Value.ToString() + ",";
                    valueflow += "'" + newid.Split(',')[0] + "'";
                    valueflow += ",1";
                    string sqlupdateEFlow = "insert into Eflow (" + wordflow + ") values(" + valueflow + ")";
                    string rows = dbc.UpdateData("eReimbursement", sqlupdateEFlow, "Update");
                    //
                    if (newid == "-1" || rows == "-1")
                    {
                        ErrorHandle("Data Error."); return;
                    }
                    else
                    {
                        hdTravelRequestID.Value = newid.Split(',')[0];//新增后记录ID
                        hdTravelRequestNo.Value = newid.Split(',')[1];//新增后记录No
                        if (!SaveDetail(detail, header0string, header1string, header2string, Cur, dept))
                        {
                            ErrorHandle("Data Error.");
                            return;
                        }
                        if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                        {
                            Panel3.Title = "差旅费申请单草稿: " + newid.Split(',')[1];
                            UpdateMSG("新增差旅费申请单草稿: " + newid.Split(',')[1] + "成功.");
                        }
                        else
                        {
                            Panel3.Title = "Travel Expense Draft: " + newid.Split(',')[1];
                            UpdateMSG("Added Travel Expense Draft: " + newid.Split(',')[1] + " successfully.");
                        }
                    }
                }
            }
        }
Пример #35
0
        public void LoadBG(string command, string GetDetailOrUpdate, decimal sum)
        {
            string userid = Request.QueryString["UserID"].ToString();
            string dpt = "";
            string ostation = "";
            string username = "";
            DataSet ds1 = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(userid);
            if (ds1.Tables[0].Rows.Count == 1)
            {
                DataTable dt1 = ds1.Tables[0];
                //dpt = dt1.Rows[0]["DepartmentName"].ToString();
                ostation = dt1.Rows[0]["stationCode"].ToString();
                username = dt1.Rows[0]["fullname"].ToString();
                dpt = dt1.Rows[0]["CRPDepartmentName"].ToString();
                cs.DBCommand dbc = new cs.DBCommand();
                DataTable dttemp = new DataTable();
                string sqltemp = "select * from ESUSER where Userid='" + userid + "'";
                dttemp = dbc.GetData("eReimbursement", sqltemp);
                if (dttemp.Rows.Count > 0)
                {
                    ostation = dttemp.Rows[0]["Station"].ToString();
                }
            }
            string tstation = cbxTStation.Value == null ? ostation : cbxTStation.Value.ToString();
            string accountcode = "62010500";
            string Years = Convert.ToDateTime(dfDate.Value.ToString()).Year.ToString();
            string month = Convert.ToDateTime(dfDate.Value.ToString()).Month.ToString();

            DataTable dt = new DataTable();
            dt = Comm.RtnEB(userid, dpt, ostation, tstation, accountcode, Years, month);
            if (dt != null && dt.Rows.Count > 0)
            {
                LabelStationBG.Text = "Station(YTD): NA";
                LabelDepartmentBG.Text = "Department(YTD): NA";
                LabelPersonBG.Text = "Person(YTD): NA";
                decimal stationbudget = 0, departmentbudget = 0, personbudget = 0, StationUsed = 0;
                LabelCOA.Text = "Communication:";
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    decimal budget = 0, used = 0;
                    budget = Convert.ToDecimal(System.Math.Round(Convert.ToDouble(dt.Rows[i]["Budget"].ToString()) * (DIMERCO.SDK.Utilities.LSDK.GetLatestStationUSDConvertRate(tstation) / DIMERCO.SDK.Utilities.LSDK.GetLatestStationUSDConvertRate(ostation)), 2));
                    used = Convert.ToDecimal(System.Math.Round(Convert.ToDouble(dt.Rows[i]["Used"].ToString()) * (DIMERCO.SDK.Utilities.LSDK.GetLatestStationUSDConvertRate(tstation) / DIMERCO.SDK.Utilities.LSDK.GetLatestStationUSDConvertRate(ostation)), 2));
                    if (dt.Rows[i]["Type"].ToString() == "全年站点")
                    {
                        //stationbudget = Convert.ToDecimal(dt.Rows[i]["Budget"].ToString());
                        //StationUsed = Convert.ToDecimal(dt.Rows[i]["Used"].ToString());
                        //string stationbg = dt.Rows[i]["Station"].ToString() + "(YTD): " + Convert.ToDecimal(dt.Rows[i]["Used"].ToString()).ToString("#,##0.00") + "/" + Convert.ToDecimal(dt.Rows[i]["Budget"].ToString()).ToString("#,##0.00");
                        //LabelStationBG.Text = stationbg;
                        stationbudget = budget;
                        StationUsed = used;
                        string stationbg = dt.Rows[i]["Station"].ToString() + "(YTD): " + used.ToString("#,##0.00") + "/" + budget.ToString("#,##0.00");
                        LabelStationBG.Text = stationbg;
                        
                    }
                    else if (dt.Rows[i]["Type"].ToString() == "全年部门")
                    {
                        //departmentbudget = Convert.ToDecimal(dt.Rows[i]["Budget"].ToString());
                        //string stationbg = dpt + "(YTD): " + Convert.ToDecimal(dt.Rows[i]["Used"].ToString()).ToString("#,##0.00") + "/" + Convert.ToDecimal(dt.Rows[i]["Budget"].ToString()).ToString("#,##0.00");
                        //LabelDepartmentBG.Text = stationbg;
                        departmentbudget = budget;
                        string stationbg = dpt + "(YTD): " + used.ToString("#,##0.00") + "/" + budget.ToString("#,##0.00");
                        LabelDepartmentBG.Text = stationbg;
                    }
                    else if (dt.Rows[i]["Type"].ToString() == "全年个人")
                    {
                        //personbudget = Convert.ToDecimal(dt.Rows[i]["Budget"].ToString());
                        //string stationbg = username + "(YTD): " + Convert.ToDecimal(dt.Rows[i]["Used"].ToString()).ToString("#,##0.00") + "/" + Convert.ToDecimal(dt.Rows[i]["Budget"].ToString()).ToString("#,##0.00");
                        //LabelPersonBG.Text = stationbg;
                        personbudget = budget;
                        string stationbg = username + "(YTD): " + used.ToString("#,##0.00") + "/" + budget.ToString("#,##0.00");
                        LabelPersonBG.Text = stationbg;
                    }
                }
                if (stationbudget == 0 && departmentbudget == 0 && personbudget == 0)
                {
                    X.AddScript("Ext.Msg.show({ title: 'Message', msg: 'No budget,please check with Account.', buttons: { ok: 'Ok' }, fn: function (btn) { return false; } });");
                    return;
                }
            }
            else
            {
                //hdBudget.Value = "0";
                ErrorHandleNojump("Data error.");
                return;
            }
        }
Пример #36
0
        public void SaveAll(string type, string detail, string MailList, string header0string, string header1string, string header2string, string Cur, string dept)
        {
            if (Request.Cookies.Get("eReimUserID") == null || hdUser.Value.ToString() != Request.Cookies.Get("eReimUserID").Value)
            {
                if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                {
                    X.AddScript("Ext.Msg.show({ title: '提示', msg: '已切换用户,将刷新页面.', buttons: { ok: 'Ok' }, fn: function (btn) { window.location.reload(); } });");
                }
                else
                {
                    X.AddScript("Ext.Msg.show({ title: 'Message', msg: 'Current user changed,reloading...', buttons: { ok: 'Ok' }, fn: function (btn) { window.location.reload(); } });");
                }
                return;
            }
            
            DateTime dtnull = new DateTime(1, 1, 1, 0, 0, 0);
            cs.DBCommand dbc = new cs.DBCommand();
            ////检查是否已经为该申请人设置过审批人
            string sqlCheckFlow = "";
            //if (Radio1.Checked)
            ////if (cbxBudget.Value.ToString() == "YES")//使用Budget审批流程
            //{
            sqlCheckFlow = "select * from GroupFlow where [Type]!=2 and GID=(select GID from GroupUsers where UserID='" + hdOwnerID.Value.ToString() + "')";
            //}
            //else//使用unBudget审批流程
            //{
            //    sqlCheckFlow = "select * from GroupFlow where [Type]=2 and GID=(select GID from GroupUsers where UserID='" + hdOwnerID.Value.ToString() + "')";
            //}
            DataTable dtGroupFlowData = dbc.GetData("eReimbursement", sqlCheckFlow);
            //if (dtGroupFlowData.Rows.Count < 1)
            //{
            //    if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
            //    {
            //        ErrorHandle("请先设置审批人.");
            //    }
            //    else
            //    {
            //        ErrorHandle("Not set Approve flow,please contact with Local MIS.");
            //    }
            //    return;
            //}

            //处理抄送人列表
            string CCMailList = "";
            JavaScriptSerializer ser = new JavaScriptSerializer();
            List<CCMailList> CCMailList1 = ser.Deserialize<List<CCMailList>>(MailList);
            foreach (CCMailList mail in CCMailList1)
            {
                CCMailList += mail.Email + ",";
            }
            CCMailList = CCMailList.Length > 0 ? CCMailList.Substring(0, CCMailList.Length - 1) : "";

            string userid = hdOwnerID.Value.ToString();
            string ostation = ""; string station = ""; string department = "";
            DataSet ds2 = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(userid);
            if (ds2.Tables[0].Rows.Count == 1)
            {
                DataTable dt1 = ds2.Tables[0];
                //dpt = dt1.Rows[0]["DepartmentName"].ToString();
                ostation = dt1.Rows[0]["CostCenter"].ToString();
                station = dt1.Rows[0]["stationCode"].ToString();
                department = dt1.Rows[0]["CRPDepartmentName"].ToString();
                //DataTable dttemp = new DataTable();
                //string sqltemp = "select * from ESUSER where Userid='" + userid + "'";
                //dttemp = dbc.GetData("eReimbursement", sqltemp);
                //if (dttemp.Rows.Count > 0)
                //{
                //    ostation = dttemp.Rows[0]["Station"].ToString();
                //}
            }
            string para = type;
            for (int i = 0; i < header0string.Split(',').Length; i++)
            {
                //判断出差站点名称是否合法
                //if (header0string.Split(',')[i] != "NA")//站点为空则不更新
                //{
                //    bool isstation = DIMERCO.SDK.Utilities.LSDK.isStationExist(header0string.Split(',')[i]);
                //    if (!isstation)//如果不是合法站点,提示可选站点
                //    {
                //        DataSet GetCityInfo = DIMERCO.SDK.Utilities.LSDK.GetCityInfo(header0string.Split(',')[i], 5);
                //        DataTable dtGetCityInfo = (DataTable)GetCityInfo.Tables[0];
                //        string suggestStation = "";
                //        for (int j = 0; j < dtGetCityInfo.Rows.Count; j++)
                //        {
                //            suggestStation += dtGetCityInfo.Rows[j]["CityCode"].ToString() + ",";
                //        }
                //        if (suggestStation.Trim()!="")
                //        {
                //            suggestStation = suggestStation.Substring(0, suggestStation.Length - 1);
                //            X.AddScript("Ext.Msg.show({ title: 'Message', msg: 'Invalid DSTN(" + header0string.Split(',')[i] + ").Suggestion:" + suggestStation + ".', buttons: { ok: 'Ok' }, fn: function (btn) {  } });");
                //            return;
                //        }
                //        else
                //        {
                //            X.AddScript("Ext.Msg.show({ title: 'Message', msg: 'Please input valid DSTN.', buttons: { ok: 'Ok' }, fn: function (btn) {  } });");
                //            return;
                //        }
                //    }
                //}
                //判断成本中心名称是否合法
                if (header0string.Split(',')[i] != "NA" && header1string.Split(',')[i]!="NA")//站点为空则不更新
                {
                    bool isstation = DIMERCO.SDK.Utilities.LSDK.isCostCenterExist(header1string.Split(',')[i]);
                    if (!isstation)//如果不是合法站点,提示可选站点
                    {
                        DataSet GetCityInfo = DIMERCO.SDK.Utilities.LSDK.getCostCenterBYStationCode(header1string.Split(',')[i], 5);
                        DataTable dtGetCityInfo = (DataTable)GetCityInfo.Tables[0];
                        string suggestStation = "";
                        for (int j = 0; j < dtGetCityInfo.Rows.Count; j++)
                        {
                            suggestStation += dtGetCityInfo.Rows[j]["StationCode"].ToString() + ",";
                        }
                        if (suggestStation.Trim() != "")
                        {
                            suggestStation = suggestStation.Substring(0, suggestStation.Length - 1);
                            X.AddScript("Ext.Msg.show({ title: 'Message', msg: 'Invalid Cost Center(" + header1string.Split(',')[i] + ").Suggestion:" + suggestStation + ".', buttons: { ok: 'Ok' }, fn: function (btn) {  } });");
                            return;
                        }
                        else
                        {
                            X.AddScript("Ext.Msg.show({ title: 'Message', msg: 'Please input valid Cost Center.', buttons: { ok: 'Ok' }, fn: function (btn) {  } });");
                            return;
                        }
                    }
                }
            }

            //140306
            if (true)
            {
                DataTable dtbudget = new DataTable();
                dtbudget.Columns.Add("EName", typeof(System.String));
                dtbudget.Columns.Add("COACode", typeof(System.String));
                dtbudget.Columns.Add("Current", typeof(System.Decimal));
                dtbudget.Columns.Add("PU", typeof(System.Decimal));
                dtbudget.Columns.Add("PB", typeof(System.Decimal));
                dtbudget.Columns.Add("PPercent", typeof(System.Decimal));
                dtbudget.Columns.Add("DU", typeof(System.Decimal));
                dtbudget.Columns.Add("DB", typeof(System.Decimal));
                dtbudget.Columns.Add("DPercent", typeof(System.Decimal));
                dtbudget.Columns.Add("SU", typeof(System.Decimal));
                dtbudget.Columns.Add("SB", typeof(System.Decimal));
                dtbudget.Columns.Add("SPercent", typeof(System.Decimal));

                DataTable dtA = new DataTable();
                dtA.Columns.Add("COACode", typeof(System.String));
                dtA.Columns.Add("Amount", typeof(System.Decimal));
                dtA.Columns.Add("Date", typeof(System.DateTime));

                StoreSubmitDataEventArgs eSubmit = new StoreSubmitDataEventArgs(detail, null);
                XmlNode xml = eSubmit.Xml;
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(xml.InnerXml);
                int dtcol = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(0).ChildNodes.Count;
                int dtrow = doc.SelectNodes("records").Item(0).SelectNodes("record").Count;
                int groupcount = (dtcol - 3) / 2;//多少个站点会被更新,如果站点为空则不更新
                //string tstation = "", year = "", month = "", coacode = "";
                for (int i = 0; i < groupcount; i++)
                {
                    if (header0string.Split(',')[i] != "NA")//站点为空则不更新
                    {
                        //1. Air Ticket - Int'l
                        if ((doc.SelectNodes("records").Item(0).SelectNodes("record").Item(0).ChildNodes[1 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(0).ChildNodes[1 + i * 2].InnerText) != 0) || (doc.SelectNodes("records").Item(0).SelectNodes("record").Item(0).ChildNodes[2 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(0).ChildNodes[2 + i * 2].InnerText) != 0))
                        {
                            DataRow drnew = dtA.NewRow();
                            drnew["COACode"] = "62012000";
                            drnew["Date"] = Convert.ToDateTime(header2string.Split(',')[i * 2]);
                            decimal r1 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(0).ChildNodes[1 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(0).ChildNodes[1 + i * 2].InnerText);
                            decimal r2 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(0).ChildNodes[2 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(0).ChildNodes[2 + i * 2].InnerText);
                            drnew["Amount"] = r1 + r2;
                            dtA.Rows.Add(drnew);
                        }
                        //Domestic
                        if ((doc.SelectNodes("records").Item(0).SelectNodes("record").Item(1).ChildNodes[1 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(1).ChildNodes[1 + i * 2].InnerText) != 0) || (doc.SelectNodes("records").Item(0).SelectNodes("record").Item(1).ChildNodes[2 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(1).ChildNodes[2 + i * 2].InnerText) != 0))
                        {
                            DataRow drnew = dtA.NewRow();
                            drnew["COACode"] = "62012000";
                            drnew["Date"] = Convert.ToDateTime(header2string.Split(',')[i * 2]);
                            decimal r1 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(1).ChildNodes[1 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(1).ChildNodes[1 + i * 2].InnerText);
                            decimal r2 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(1).ChildNodes[2 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(1).ChildNodes[2 + i * 2].InnerText);
                            drnew["Amount"] = r1 + r2;
                            dtA.Rows.Add(drnew);
                        }
                        //2. Hotel Bill
                        if ((doc.SelectNodes("records").Item(0).SelectNodes("record").Item(2).ChildNodes[1 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(2).ChildNodes[1 + i * 2].InnerText) != 0) || (doc.SelectNodes("records").Item(0).SelectNodes("record").Item(2).ChildNodes[2 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(2).ChildNodes[2 + i * 2].InnerText) != 0))
                        {
                            DataRow drnew = dtA.NewRow();
                            drnew["COACode"] = "62012000";
                            drnew["Date"] = Convert.ToDateTime(header2string.Split(',')[i * 2]);
                            decimal r1 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(2).ChildNodes[1 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(2).ChildNodes[1 + i * 2].InnerText);
                            decimal r2 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(2).ChildNodes[2 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(2).ChildNodes[2 + i * 2].InnerText);
                            drnew["Amount"] = r1 + r2;
                            dtA.Rows.Add(drnew);
                        }
                        //3. Meals
                        if ((doc.SelectNodes("records").Item(0).SelectNodes("record").Item(3).ChildNodes[1 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(3).ChildNodes[1 + i * 2].InnerText) != 0) || (doc.SelectNodes("records").Item(0).SelectNodes("record").Item(3).ChildNodes[2 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(3).ChildNodes[2 + i * 2].InnerText) != 0))
                        {
                            DataRow drnew = dtA.NewRow();
                            drnew["COACode"] = "62012000";
                            drnew["Date"] = Convert.ToDateTime(header2string.Split(',')[i * 2]);
                            decimal r1 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(3).ChildNodes[1 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(3).ChildNodes[1 + i * 2].InnerText);
                            decimal r2 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(3).ChildNodes[2 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(3).ChildNodes[2 + i * 2].InnerText);
                            drnew["Amount"] = r1 + r2;
                            dtA.Rows.Add(drnew);
                        }
                        //4. Entertainment
                        if ((doc.SelectNodes("records").Item(0).SelectNodes("record").Item(4).ChildNodes[1 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(4).ChildNodes[1 + i * 2].InnerText) != 0) || (doc.SelectNodes("records").Item(0).SelectNodes("record").Item(4).ChildNodes[2 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(4).ChildNodes[2 + i * 2].InnerText) != 0))
                        {
                            DataRow drnew = dtA.NewRow();
                            drnew["COACode"] = "62010900";
                            drnew["Date"] = Convert.ToDateTime(header2string.Split(',')[i * 2]);
                            decimal r1 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(4).ChildNodes[1 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(4).ChildNodes[1 + i * 2].InnerText);
                            decimal r2 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(4).ChildNodes[2 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(4).ChildNodes[2 + i * 2].InnerText);
                            drnew["Amount"] = r1 + r2;
                            dtA.Rows.Add(drnew);
                        }
                        //5. Car Rental/Transportation
                        if ((doc.SelectNodes("records").Item(0).SelectNodes("record").Item(5).ChildNodes[1 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(5).ChildNodes[1 + i * 2].InnerText) != 0) || (doc.SelectNodes("records").Item(0).SelectNodes("record").Item(5).ChildNodes[2 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(5).ChildNodes[2 + i * 2].InnerText) != 0))
                        {
                            DataRow drnew = dtA.NewRow();
                            drnew["COACode"] = "62011900";
                            drnew["Date"] = Convert.ToDateTime(header2string.Split(',')[i * 2]);
                            decimal r1 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(5).ChildNodes[1 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(5).ChildNodes[1 + i * 2].InnerText);
                            decimal r2 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(5).ChildNodes[2 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(5).ChildNodes[2 + i * 2].InnerText);
                            drnew["Amount"] = r1 + r2;
                            dtA.Rows.Add(drnew);
                        }
                        //6. Communication
                        if ((doc.SelectNodes("records").Item(0).SelectNodes("record").Item(6).ChildNodes[1 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(6).ChildNodes[1 + i * 2].InnerText) != 0) || (doc.SelectNodes("records").Item(0).SelectNodes("record").Item(6).ChildNodes[2 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(6).ChildNodes[2 + i * 2].InnerText) != 0))
                        {
                            DataRow drnew = dtA.NewRow();
                            drnew["COACode"] = "62010500";
                            drnew["Date"] = Convert.ToDateTime(header2string.Split(',')[i * 2]);
                            decimal r1 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(6).ChildNodes[1 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(6).ChildNodes[1 + i * 2].InnerText);
                            decimal r2 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(6).ChildNodes[2 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(6).ChildNodes[2 + i * 2].InnerText);
                            drnew["Amount"] = r1 + r2;
                            dtA.Rows.Add(drnew);
                        }
                        //7. Local Trip
                        if ((doc.SelectNodes("records").Item(0).SelectNodes("record").Item(7).ChildNodes[1 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(7).ChildNodes[1 + i * 2].InnerText) != 0) || (doc.SelectNodes("records").Item(0).SelectNodes("record").Item(7).ChildNodes[2 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(7).ChildNodes[2 + i * 2].InnerText) != 0))
                        {
                            DataRow drnew = dtA.NewRow();
                            drnew["COACode"] = "62012000";
                            drnew["Date"] = Convert.ToDateTime(header2string.Split(',')[i * 2]);
                            decimal r1 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(7).ChildNodes[1 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(7).ChildNodes[1 + i * 2].InnerText);
                            decimal r2 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(7).ChildNodes[2 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(7).ChildNodes[2 + i * 2].InnerText);
                            drnew["Amount"] = r1 + r2;
                            dtA.Rows.Add(drnew);
                        }
                        //8. Overseas Trip USD15/day
                        if ((doc.SelectNodes("records").Item(0).SelectNodes("record").Item(8).ChildNodes[1 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(8).ChildNodes[1 + i * 2].InnerText) != 0) || (doc.SelectNodes("records").Item(0).SelectNodes("record").Item(8).ChildNodes[2 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(8).ChildNodes[2 + i * 2].InnerText) != 0))
                        {
                            DataRow drnew = dtA.NewRow();
                            drnew["COACode"] = "62012000";
                            drnew["Date"] = Convert.ToDateTime(header2string.Split(',')[i * 2]);
                            decimal r1 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(8).ChildNodes[1 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(8).ChildNodes[1 + i * 2].InnerText);
                            decimal r2 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(8).ChildNodes[2 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(8).ChildNodes[2 + i * 2].InnerText);
                            drnew["Amount"] = r1 + r2;
                            dtA.Rows.Add(drnew);
                        }
                        //9. Airport Tax/Travel Insurance
                        if ((doc.SelectNodes("records").Item(0).SelectNodes("record").Item(9).ChildNodes[1 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(9).ChildNodes[1 + i * 2].InnerText) != 0) || (doc.SelectNodes("records").Item(0).SelectNodes("record").Item(9).ChildNodes[2 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(9).ChildNodes[2 + i * 2].InnerText) != 0))
                        {
                            DataRow drnew = dtA.NewRow();
                            drnew["COACode"] = "62012000";
                            drnew["Date"] = Convert.ToDateTime(header2string.Split(',')[i * 2]);
                            decimal r1 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(9).ChildNodes[1 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(9).ChildNodes[1 + i * 2].InnerText);
                            decimal r2 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(9).ChildNodes[2 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(9).ChildNodes[2 + i * 2].InnerText);
                            drnew["Amount"] = r1 + r2;
                            dtA.Rows.Add(drnew);
                        }
                        //10. Others
                        if ((doc.SelectNodes("records").Item(0).SelectNodes("record").Item(10).ChildNodes[1 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(10).ChildNodes[1 + i * 2].InnerText) != 0) || (doc.SelectNodes("records").Item(0).SelectNodes("record").Item(10).ChildNodes[2 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(10).ChildNodes[2 + i * 2].InnerText) != 0))
                        {
                            DataRow drnew = dtA.NewRow();
                            drnew["COACode"] = "62012000";
                            drnew["Date"] = Convert.ToDateTime(header2string.Split(',')[i * 2]);
                            decimal r1 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(10).ChildNodes[1 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(10).ChildNodes[1 + i * 2].InnerText);
                            decimal r2 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(10).ChildNodes[2 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(10).ChildNodes[2 + i * 2].InnerText);
                            drnew["Amount"] = r1 + r2;
                            dtA.Rows.Add(drnew);
                        }
                    }
                }
                
                //合计
                DataTable dtB = new DataTable();
                dtB.Columns.Add("COACode", typeof(System.String));
                dtB.Columns.Add("Amount", typeof(System.Decimal));
                if (dtA.Compute("Sum(Amount)", "COACode = 62010900").ToString() != "" && Convert.ToDecimal(dtA.Compute("Sum(Amount)", "COACode = 62010900").ToString()) != 0)
                {
                    DataRow dr = dtB.NewRow();
                    dr["COACode"] = "62010900";
                    dr["Amount"] = Convert.ToDecimal(dtA.Compute("Sum(Amount)", "COACode = 62010900").ToString());
                    dtB.Rows.Add(dr);
                }
                if (dtA.Compute("Sum(Amount)", "COACode = 62011900").ToString() != "" && Convert.ToDecimal(dtA.Compute("Sum(Amount)", "COACode = 62011900").ToString()) != 0)
                {
                    DataRow dr = dtB.NewRow();
                    dr["COACode"] = "62011900";
                    dr["Amount"] = Convert.ToDecimal(dtA.Compute("Sum(Amount)", "COACode = 62011900").ToString());
                    dtB.Rows.Add(dr);
                }
                if (dtA.Compute("Sum(Amount)", "COACode = 62010500").ToString() != "" && Convert.ToDecimal(dtA.Compute("Sum(Amount)", "COACode = 62010500").ToString()) != 0)
                {
                    DataRow dr = dtB.NewRow();
                    dr["COACode"] = "62010500";
                    dr["Amount"] = Convert.ToDecimal(dtA.Compute("Sum(Amount)", "COACode = 62010500").ToString());
                    dtB.Rows.Add(dr);
                }
                if (dtA.Compute("Sum(Amount)", "COACode = 62012000").ToString() != "" && Convert.ToDecimal(dtA.Compute("Sum(Amount)", "COACode = 62012000").ToString()) != 0)
                {
                    DataRow dr = dtB.NewRow();
                    dr["COACode"] = "62012000";
                    dr["Amount"] = Convert.ToDecimal(dtA.Compute("Sum(Amount)", "COACode = 62012000").ToString());
                    dtB.Rows.Add(dr);
                }

                ////取得传递预算的参数
                //string userid = dt.Rows[0]["PersonID"].ToString();
                //string dpt = dt.Rows[0]["Department"].ToString();
                //string ostation = dt.Rows[0]["CostCenter"].ToString();//预算站点,与基本信息中的CostCenter一致(Station2)
                string tstation = ostation;//Etravel表中的Station2,目前与预算站点一致,不允许更改
                string year = Convert.ToDateTime(dtA.Compute("Min(Date)", "").ToString()).Year.ToString();
                string month = Convert.ToDateTime(dtA.Compute("Min(Date)", "").ToString()).Month.ToString();
                //string accountcode = "";
                //for (int g = 0; g < dtB.Rows.Count; g++)
                //{
                //    if (Convert.ToDecimal(dtB.Rows[g]["Amount"].ToString()) != 0)
                //    {
                //        DataRow dr = dtbudget.NewRow();
                //        dr["Current"] = Convert.ToDecimal(dtB.Rows[g]["Amount"].ToString());
                //        dr["Type"] = dtB.Rows[g]["Type"].ToString();
                //        accountcode = dtB.Rows[g]["Type"].ToString();
                //        DataTable dtC = new DataTable();
                //        dtC = Comm.RtnEB(userid, dpt, ostation, tstation, accountcode, year, month);
                //        for (int i = 0; i < dtC.Rows.Count; i++)
                //        {
                //            if (dtC.Rows[i]["Type"].ToString() == "全年个人")
                //            {
                //                dr["PU"] = Convert.ToDecimal(dtC.Rows[i]["Used"].ToString());
                //                dr["PB"] = Convert.ToDecimal(dtC.Rows[i]["Budget"].ToString());
                //            }
                //            else if (dtC.Rows[i]["Type"].ToString() == "全年部门")
                //            {
                //                dr["DU"] = Convert.ToDecimal(dtC.Rows[i]["Used"].ToString());
                //                dr["DB"] = Convert.ToDecimal(dtC.Rows[i]["Budget"].ToString());
                //            }
                //            else if (dtC.Rows[i]["Type"].ToString() == "全年站点")
                //            {
                //                dr["SU"] = Convert.ToDecimal(dtC.Rows[i]["Used"].ToString());
                //                dr["SB"] = Convert.ToDecimal(dtC.Rows[i]["Budget"].ToString());
                //            }
                //        }
                //        dtbudget.Rows.Add(dr);
                //    }
                //}
                ////计算%,取得名称
                //for (int i = 0; i < dtbudget.Rows.Count; i++)
                //{
                //    if (Convert.ToDecimal(dtbudget.Rows[i]["PB"].ToString()) != 0)//如果Budget不为0,则计算%
                //    {
                //        dtbudget.Rows[i]["PPercent"] = System.Math.Round(Convert.ToDecimal(dtbudget.Rows[i]["PU"].ToString()) / Convert.ToDecimal(dtbudget.Rows[i]["PB"].ToString()), 4) * 100;
                //    }
                //    if (Convert.ToDecimal(dtbudget.Rows[i]["DB"].ToString()) != 0)//如果Budget不为0,则计算%
                //    {
                //        dtbudget.Rows[i]["DPercent"] = System.Math.Round(Convert.ToDecimal(dtbudget.Rows[i]["DU"].ToString()) / Convert.ToDecimal(dtbudget.Rows[i]["DB"].ToString()), 4) * 100;
                //    }
                //    if (Convert.ToDecimal(dtbudget.Rows[i]["SB"].ToString()) != 0)//如果Budget不为0,则计算%
                //    {
                //        dtbudget.Rows[i]["SPercent"] = System.Math.Round(Convert.ToDecimal(dtbudget.Rows[i]["SU"].ToString()) / Convert.ToDecimal(dtbudget.Rows[i]["SB"].ToString()), 4) * 100;
                //    }
                //    if (dtbudget.Rows[i]["Type"].ToString() == "62010900")
                //    {
                //        dtbudget.Rows[i]["EName"] = "Travel expense";
                //    }
                //    else if (dtbudget.Rows[i]["Type"].ToString() == "62011900")
                //    {
                //        dtbudget.Rows[i]["EName"] = "Entertainment";
                //    }
                //    else if (dtbudget.Rows[i]["Type"].ToString() == "62010500")
                //    {
                //        dtbudget.Rows[i]["EName"] = "Transportation";
                //    }
                //    else if (dtbudget.Rows[i]["Type"].ToString() == "62012000")
                //    {
                //        dtbudget.Rows[i]["EName"] = "Communication";
                //    }
                //}

                //bool PB = false, DB = false, SB = false;
                //for (int i = 0; i < dtbudget.Rows.Count; i++)
                //{
                //    if (Convert.ToDecimal(dtbudget.Rows[i]["PB"].ToString()) != 0)//是否显示个人预算列
                //    {
                //        PB = true;
                //    }
                //    if (Convert.ToDecimal(dtbudget.Rows[i]["DB"].ToString()) != 0)//是否显示部门预算列
                //    {
                //        DB = true;
                //    }
                //    if (Convert.ToDecimal(dtbudget.Rows[i]["SB"].ToString()) != 0)//是否显示站点预算列
                //    {
                //        SB = true;
                //    }
                //}
                ////添加数据列
                //var cm = GridPanelBudget.ColumnModel;
                //cm.Columns.Add(new Column
                //{
                //    DataIndex = "EName",
                //    Header = "Expense Item",
                //    Sortable = false,
                //    Resizable = false,
                //    MenuDisabled = true,
                //    Width = 100
                //});
                //cm.Columns.Add(new Column
                //{
                //    DataIndex = "Current",
                //    Header = "Current",
                //    Renderer = new Renderer { Fn = "GetNumber" },
                //    Sortable = false,
                //    Resizable = false,
                //    MenuDisabled = true,
                //    Width = 100
                //});
                ////显示个人预算部分
                //if (PB)
                //{
                //    cm.Columns.Add(new Column
                //    {
                //        DataIndex = "PU",
                //        Header = "Personal Used",
                //        Renderer = new Renderer { Fn = "GetNumber" },
                //        Sortable = false,
                //        Resizable = false,
                //        MenuDisabled = true,
                //        Width = 100
                //    });
                //    cm.Columns.Add(new Column
                //    {
                //        DataIndex = "PB",
                //        Header = "Personal Budget",
                //        Renderer = new Renderer { Fn = "GetNumber" },
                //        Sortable = false,
                //        Resizable = false,
                //        MenuDisabled = true,
                //        Width = 100
                //    });
                //    cm.Columns.Add(new Column
                //    {
                //        DataIndex = "PPercent",
                //        Header = "%(Used/Budget)",
                //        Renderer = new Renderer { Fn = "GetNumberPercent" },
                //        Sortable = false,
                //        Resizable = false,
                //        MenuDisabled = true,
                //        Width = 100
                //    });
                //}
                //if (DB)
                //{
                //    cm.Columns.Add(new Column
                //    {
                //        DataIndex = "DU",
                //        Header = "Department Used",
                //        Renderer = new Renderer { Fn = "GetNumber" },
                //        Sortable = false,
                //        Resizable = false,
                //        MenuDisabled = true,
                //        Width = 100
                //    });
                //    cm.Columns.Add(new Column
                //    {
                //        DataIndex = "DB",
                //        Header = "Department Budget",
                //        Renderer = new Renderer { Fn = "GetNumber" },
                //        Sortable = false,
                //        Resizable = false,
                //        MenuDisabled = true,
                //        Width = 100
                //    });
                //    cm.Columns.Add(new Column
                //    {
                //        DataIndex = "DPercent",
                //        Header = "%(Used/Budget)",
                //        Renderer = new Renderer { Fn = "GetNumberPercent" },
                //        Sortable = false,
                //        Resizable = false,
                //        MenuDisabled = true,
                //        Width = 100
                //    });
                //}
                //if (SB)
                //{
                //    cm.Columns.Add(new Column
                //    {
                //        DataIndex = "SU",
                //        Header = "Unit Used",
                //        Renderer = new Renderer { Fn = "GetNumber" },
                //        Sortable = false,
                //        Resizable = false,
                //        MenuDisabled = true,
                //        Width = 100
                //    });
                //    cm.Columns.Add(new Column
                //    {
                //        DataIndex = "SB",
                //        Header = "Unit Budget",
                //        Renderer = new Renderer { Fn = "GetNumber" },
                //        Sortable = false,
                //        Resizable = false,
                //        MenuDisabled = true,
                //        Width = 100
                //    });
                //    cm.Columns.Add(new Column
                //    {
                //        DataIndex = "SPercent",
                //        Header = "%(Used/Budget)",
                //        Renderer = new Renderer { Fn = "GetNumberPercent" },
                //        Sortable = false,
                //        Resizable = false,
                //        MenuDisabled = true,
                //        Width = 100
                //    });
                //}
                //StoreBudget.DataSource = dtbudget;
                //StoreBudget.DataBind();
            }
            string srr = "";
            return;
            //判断Budget下是否符合预算要求
            DataTable dtlocal = new DataTable();
            dtlocal.Columns.Add(new DataColumn("Station", typeof(System.String)));
            dtlocal.Columns.Add(new DataColumn("COACode", typeof(System.String)));
            dtlocal.Columns.Add(new DataColumn("Year", typeof(System.Int16)));
            dtlocal.Columns.Add(new DataColumn("Month", typeof(System.Int16)));
            dtlocal.Columns.Add(new DataColumn("Amount", typeof(System.Decimal)));
            if (Radio1.Checked)
            //if (cbxBudget.Value.ToString() == "YES")
            {
                StoreSubmitDataEventArgs eSubmit = new StoreSubmitDataEventArgs(detail, null);
                XmlNode xml = eSubmit.Xml;
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(xml.InnerXml);
                int dtcol = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(0).ChildNodes.Count;
                //doc.SelectNodes("records").Item(0).SelectNodes("record").Item(i).ChildNodes[j].InnerText;
                int dtrow = doc.SelectNodes("records").Item(0).SelectNodes("record").Count;
                int groupcount = (dtcol - 3) / 2;//多少个站点会被更新,如果站点为空则不更新
                //string tstation = "", year = "", month = "", coacode = "";
                for (int i = 0; i < groupcount; i++)
                {
                    if (header0string.Split(',')[i] != "NA")//站点为空则不更新
                    {
                        //处理数据,准备合并后比较预算
                        string costcenter = header1string.Split(',')[i] == "NA" ? ostation : header1string.Split(',')[i];
                        //1. Air Ticket - Int'l
                        if ((doc.SelectNodes("records").Item(0).SelectNodes("record").Item(0).ChildNodes[1 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(0).ChildNodes[1 + i * 2].InnerText) != 0) || (doc.SelectNodes("records").Item(0).SelectNodes("record").Item(0).ChildNodes[2 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(0).ChildNodes[2 + i * 2].InnerText) != 0))
                        {
                            DataRow drnew = dtlocal.NewRow();
                            drnew["Station"] = costcenter;
                            drnew["Year"] = Convert.ToDateTime(header2string.Split(',')[i * 2 + 1]).Year.ToString();
                            drnew["Month"] = Convert.ToDateTime(header2string.Split(',')[i * 2 + 1]).Month.ToString();
                            drnew["COACode"] = "62012000";
                            decimal r1 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(0).ChildNodes[1 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(0).ChildNodes[1 + i * 2].InnerText);
                            decimal r2 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(0).ChildNodes[2 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(0).ChildNodes[2 + i * 2].InnerText);
                            drnew["Amount"] = r1 + r2;
                            dtlocal.Rows.Add(drnew);
                        }
                        //Domestic
                        if ((doc.SelectNodes("records").Item(0).SelectNodes("record").Item(1).ChildNodes[1 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(1).ChildNodes[1 + i * 2].InnerText) != 0) || (doc.SelectNodes("records").Item(0).SelectNodes("record").Item(1).ChildNodes[2 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(1).ChildNodes[2 + i * 2].InnerText) != 0))
                        {
                            DataRow drnew = dtlocal.NewRow();
                            drnew["Station"] = costcenter;
                            drnew["Year"] = Convert.ToDateTime(header2string.Split(',')[i * 2 + 1]).Year.ToString();
                            drnew["Month"] = Convert.ToDateTime(header2string.Split(',')[i * 2 + 1]).Month.ToString();
                            drnew["COACode"] = "62012000";
                            decimal r1 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(1).ChildNodes[1 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(1).ChildNodes[1 + i * 2].InnerText);
                            decimal r2 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(1).ChildNodes[2 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(1).ChildNodes[2 + i * 2].InnerText);
                            drnew["Amount"] = r1 + r2;
                            dtlocal.Rows.Add(drnew);
                        }
                        //2. Hotel Bill
                        if ((doc.SelectNodes("records").Item(0).SelectNodes("record").Item(2).ChildNodes[1 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(2).ChildNodes[1 + i * 2].InnerText) != 0) || (doc.SelectNodes("records").Item(0).SelectNodes("record").Item(2).ChildNodes[2 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(2).ChildNodes[2 + i * 2].InnerText) != 0))
                        {
                            DataRow drnew = dtlocal.NewRow();
                            drnew["Station"] = costcenter;
                            drnew["Year"] = Convert.ToDateTime(header2string.Split(',')[i * 2 + 1]).Year.ToString();
                            drnew["Month"] = Convert.ToDateTime(header2string.Split(',')[i * 2 + 1]).Month.ToString();
                            drnew["COACode"] = "62012000";
                            decimal r1 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(2).ChildNodes[1 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(2).ChildNodes[1 + i * 2].InnerText);
                            decimal r2 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(2).ChildNodes[2 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(2).ChildNodes[2 + i * 2].InnerText);
                            drnew["Amount"] = r1 + r2;
                            dtlocal.Rows.Add(drnew);
                        }
                        //3. Meals
                        if ((doc.SelectNodes("records").Item(0).SelectNodes("record").Item(3).ChildNodes[1 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(3).ChildNodes[1 + i * 2].InnerText) != 0) || (doc.SelectNodes("records").Item(0).SelectNodes("record").Item(3).ChildNodes[2 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(3).ChildNodes[2 + i * 2].InnerText) != 0))
                        {
                            DataRow drnew = dtlocal.NewRow();
                            drnew["Station"] = costcenter;
                            drnew["Year"] = Convert.ToDateTime(header2string.Split(',')[i * 2 + 1]).Year.ToString();
                            drnew["Month"] = Convert.ToDateTime(header2string.Split(',')[i * 2 + 1]).Month.ToString();
                            drnew["COACode"] = "62012000";
                            decimal r1 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(3).ChildNodes[1 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(3).ChildNodes[1 + i * 2].InnerText);
                            decimal r2 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(3).ChildNodes[2 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(3).ChildNodes[2 + i * 2].InnerText);
                            drnew["Amount"] = r1 + r2;
                            dtlocal.Rows.Add(drnew);
                        }
                        //4. Entertainment
                        if ((doc.SelectNodes("records").Item(0).SelectNodes("record").Item(4).ChildNodes[1 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(4).ChildNodes[1 + i * 2].InnerText) != 0) || (doc.SelectNodes("records").Item(0).SelectNodes("record").Item(4).ChildNodes[2 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(4).ChildNodes[2 + i * 2].InnerText) != 0))
                        {
                            DataRow drnew = dtlocal.NewRow();
                            drnew["Station"] = costcenter;
                            drnew["Year"] = Convert.ToDateTime(header2string.Split(',')[i * 2 + 1]).Year.ToString();
                            drnew["Month"] = Convert.ToDateTime(header2string.Split(',')[i * 2 + 1]).Month.ToString();
                            drnew["COACode"] = "62010900";
                            decimal r1 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(4).ChildNodes[1 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(4).ChildNodes[1 + i * 2].InnerText);
                            decimal r2 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(4).ChildNodes[2 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(4).ChildNodes[2 + i * 2].InnerText);
                            drnew["Amount"] = r1 + r2;
                            dtlocal.Rows.Add(drnew);
                        }
                        //5. Car Rental/Transportation
                        if ((doc.SelectNodes("records").Item(0).SelectNodes("record").Item(5).ChildNodes[1 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(5).ChildNodes[1 + i * 2].InnerText) != 0) || (doc.SelectNodes("records").Item(0).SelectNodes("record").Item(5).ChildNodes[2 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(5).ChildNodes[2 + i * 2].InnerText) != 0))
                        {
                            DataRow drnew = dtlocal.NewRow();
                            drnew["Station"] = costcenter;
                            drnew["Year"] = Convert.ToDateTime(header2string.Split(',')[i * 2 + 1]).Year.ToString();
                            drnew["Month"] = Convert.ToDateTime(header2string.Split(',')[i * 2 + 1]).Month.ToString();
                            drnew["COACode"] = "62011900";
                            decimal r1 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(5).ChildNodes[1 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(5).ChildNodes[1 + i * 2].InnerText);
                            decimal r2 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(5).ChildNodes[2 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(5).ChildNodes[2 + i * 2].InnerText);
                            drnew["Amount"] = r1 + r2;
                            dtlocal.Rows.Add(drnew);
                        }
                        //6. Communication
                        if ((doc.SelectNodes("records").Item(0).SelectNodes("record").Item(6).ChildNodes[1 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(6).ChildNodes[1 + i * 2].InnerText) != 0) || (doc.SelectNodes("records").Item(0).SelectNodes("record").Item(6).ChildNodes[2 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(6).ChildNodes[2 + i * 2].InnerText) != 0))
                        {
                            DataRow drnew = dtlocal.NewRow();
                            drnew["Station"] = costcenter;
                            drnew["Year"] = Convert.ToDateTime(header2string.Split(',')[i * 2 + 1]).Year.ToString();
                            drnew["Month"] = Convert.ToDateTime(header2string.Split(',')[i * 2 + 1]).Month.ToString();
                            drnew["COACode"] = "62010500";
                            decimal r1 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(6).ChildNodes[1 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(6).ChildNodes[1 + i * 2].InnerText);
                            decimal r2 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(6).ChildNodes[2 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(6).ChildNodes[2 + i * 2].InnerText);
                            drnew["Amount"] = r1 + r2;
                            dtlocal.Rows.Add(drnew);
                        }
                        //7. Local Trip
                        if ((doc.SelectNodes("records").Item(0).SelectNodes("record").Item(7).ChildNodes[1 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(7).ChildNodes[1 + i * 2].InnerText) != 0) || (doc.SelectNodes("records").Item(0).SelectNodes("record").Item(7).ChildNodes[2 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(7).ChildNodes[2 + i * 2].InnerText) != 0))
                        {
                            DataRow drnew = dtlocal.NewRow();
                            drnew["Station"] = costcenter;
                            drnew["Year"] = Convert.ToDateTime(header2string.Split(',')[i * 2 + 1]).Year.ToString();
                            drnew["Month"] = Convert.ToDateTime(header2string.Split(',')[i * 2 + 1]).Month.ToString();
                            drnew["COACode"] = "62012000";
                            decimal r1 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(7).ChildNodes[1 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(7).ChildNodes[1 + i * 2].InnerText);
                            decimal r2 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(7).ChildNodes[2 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(7).ChildNodes[2 + i * 2].InnerText);
                            drnew["Amount"] = r1 + r2;
                            dtlocal.Rows.Add(drnew);
                        }
                        //8. Overseas Trip USD15/day
                        if ((doc.SelectNodes("records").Item(0).SelectNodes("record").Item(8).ChildNodes[1 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(8).ChildNodes[1 + i * 2].InnerText) != 0) || (doc.SelectNodes("records").Item(0).SelectNodes("record").Item(8).ChildNodes[2 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(8).ChildNodes[2 + i * 2].InnerText) != 0))
                        {
                            DataRow drnew = dtlocal.NewRow();
                            drnew["Station"] = costcenter;
                            drnew["Year"] = Convert.ToDateTime(header2string.Split(',')[i * 2 + 1]).Year.ToString();
                            drnew["Month"] = Convert.ToDateTime(header2string.Split(',')[i * 2 + 1]).Month.ToString();
                            drnew["COACode"] = "62012000";
                            decimal r1 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(8).ChildNodes[1 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(8).ChildNodes[1 + i * 2].InnerText);
                            decimal r2 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(8).ChildNodes[2 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(8).ChildNodes[2 + i * 2].InnerText);
                            drnew["Amount"] = r1 + r2;
                            dtlocal.Rows.Add(drnew);
                        }
                        //9. Airport Tax/Travel Insurance
                        if ((doc.SelectNodes("records").Item(0).SelectNodes("record").Item(9).ChildNodes[1 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(9).ChildNodes[1 + i * 2].InnerText) != 0) || (doc.SelectNodes("records").Item(0).SelectNodes("record").Item(9).ChildNodes[2 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(9).ChildNodes[2 + i * 2].InnerText) != 0))
                        {
                            DataRow drnew = dtlocal.NewRow();
                            drnew["Station"] = costcenter;
                            drnew["Year"] = Convert.ToDateTime(header2string.Split(',')[i * 2 + 1]).Year.ToString();
                            drnew["Month"] = Convert.ToDateTime(header2string.Split(',')[i * 2 + 1]).Month.ToString();
                            drnew["COACode"] = "62012000";
                            decimal r1 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(9).ChildNodes[1 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(9).ChildNodes[1 + i * 2].InnerText);
                            decimal r2 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(9).ChildNodes[2 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(9).ChildNodes[2 + i * 2].InnerText);
                            drnew["Amount"] = r1 + r2;
                            dtlocal.Rows.Add(drnew);
                        }
                        //10. Others
                        if ((doc.SelectNodes("records").Item(0).SelectNodes("record").Item(10).ChildNodes[1 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(10).ChildNodes[1 + i * 2].InnerText) != 0) || (doc.SelectNodes("records").Item(0).SelectNodes("record").Item(10).ChildNodes[2 + i * 2].InnerText != "" && Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(10).ChildNodes[2 + i * 2].InnerText) != 0))
                        {
                            DataRow drnew = dtlocal.NewRow();
                            drnew["Station"] = costcenter;
                            drnew["Year"] = Convert.ToDateTime(header2string.Split(',')[i * 2 + 1]).Year.ToString();
                            drnew["Month"] = Convert.ToDateTime(header2string.Split(',')[i * 2 + 1]).Month.ToString();
                            drnew["COACode"] = "62012000";
                            decimal r1 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(10).ChildNodes[1 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(10).ChildNodes[1 + i * 2].InnerText);
                            decimal r2 = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(10).ChildNodes[2 + i * 2].InnerText == "" ? 0 : Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(10).ChildNodes[2 + i * 2].InnerText);
                            drnew["Amount"] = r1 + r2;
                            dtlocal.Rows.Add(drnew);
                        }
                    }
                }
            }
            decimal sum1 = 0M;
            DataTable dt3 = new DataTable();
            dt3.Columns.Add(new DataColumn("Station",typeof(System.String)));
            dt3.Columns.Add(new DataColumn("Year", typeof(System.Int16)));
            dt3.Columns.Add(new DataColumn("COACode", typeof(System.String)));
            dt3.Columns.Add(new DataColumn("Amount", typeof(System.Decimal)));
            DataTable drnw = new DataTable();
            dtlocal.DefaultView.Sort = "Station ASC,Year ASC,COACode ASC";
            drnw = dtlocal.DefaultView.ToTable();

            for (int i = 0; i < drnw.Rows.Count; i++)
            {
                sum1 += Convert.ToDecimal(drnw.Rows[i]["Amount"].ToString());
                if (i == drnw.Rows.Count - 1)//第一行,也是最后一行
                {
                    DataRow dr3 = dt3.NewRow();
                    dr3["Station"] = drnw.Rows[i]["Station"].ToString();
                    dr3["Year"] = Convert.ToInt16(drnw.Rows[i]["Year"].ToString());
                    dr3["COACode"] = drnw.Rows[i]["COACode"].ToString();
                    dr3["Amount"] = sum1;
                    dt3.Rows.Add(dr3);
                }
                else
                {
                    if ((drnw.Rows[i]["Station"].ToString() != drnw.Rows[i + 1]["Station"].ToString()) || (drnw.Rows[i]["Year"].ToString() != drnw.Rows[i + 1]["Year"].ToString()) || (drnw.Rows[i]["COACode"].ToString() != drnw.Rows[i + 1]["COACode"].ToString()))
                    {
                        //与下一行内容不同,新增一行合计后重置sum1
                        DataRow dr3 = dt3.NewRow();
                        dr3["Station"] = drnw.Rows[i]["Station"].ToString();
                        dr3["Year"] = Convert.ToInt16(drnw.Rows[i]["Year"].ToString());
                        dr3["COACode"] = drnw.Rows[i]["COACode"].ToString();
                        dr3["Amount"] = sum1;
                        dt3.Rows.Add(dr3);
                        sum1 = 0M;
                    }
                }
            }
            string warningmsg = "";
            for (int i = 0; i < dt3.Rows.Count; i++)
            {
                decimal budgetstation = 0M, budgetusedstation = 0M;
                DataTable dt4 = new DataTable();
                dt4 = Comm.RtnEB(userid, department, ostation, dt3.Rows[i]["Station"].ToString(), dt3.Rows[i]["COACode"].ToString(), dt3.Rows[i]["Year"].ToString(), "1");
                for (int j = 0; j < dt4.Rows.Count; j++)
                {
                    if (dt4.Rows[j]["Type"].ToString() == "全年站点")
                    {
                        budgetstation = Convert.ToDecimal(dt4.Rows[j]["Budget"].ToString());
                        budgetusedstation = Convert.ToDecimal(dt4.Rows[j]["Used"].ToString());
                        if (ostation!=dt3.Rows[i]["Station"].ToString())
                        {
                            budgetstation = Convert.ToDecimal(System.Math.Round(Convert.ToDouble(dt4.Rows[j]["Budget"].ToString()) * (DIMERCO.SDK.Utilities.LSDK.GetLatestStationUSDConvertRate(dt3.Rows[i]["Station"].ToString()) / DIMERCO.SDK.Utilities.LSDK.GetLatestStationUSDConvertRate(ostation)), 2));
                            budgetusedstation = Convert.ToDecimal(System.Math.Round(Convert.ToDouble(dt4.Rows[j]["Used"].ToString()) * (DIMERCO.SDK.Utilities.LSDK.GetLatestStationUSDConvertRate(dt3.Rows[i]["Station"].ToString()) / DIMERCO.SDK.Utilities.LSDK.GetLatestStationUSDConvertRate(ostation)), 2));
                        }
                        break;
                    }
                }
                if (dt3.Rows[i]["COACode"].ToString() == "62012000")
                {
                    if (Convert.ToDecimal(dt3.Rows[i]["Amount"].ToString()) + budgetusedstation - budgetstation > Convert.ToDecimal(6.01)*500)
                    {
                        X.AddScript("Ext.Msg.show({ title: 'Message', msg: '差旅费部分超出 " + dt3.Rows[i]["Station"].ToString() + " 全年预算总额500美元以上,仅可按<a style=\"color:Red\">Un-Budget</a>流程申请,是否接受?', buttons: { ok: 'Ok',cancel:'No' }, fn: function (btn) { if(btn=='ok'){Radio2.setValue(true);}else{return false;} } });");
                        //X.AddScript("Ext.Msg.show({ title: 'Message', msg: '差旅费部分超出 " + dt3.Rows[i]["Station"].ToString() + " 全年预算总额500美元以上,仅可按<a style=\"color:Red\">Un-Budget</a>流程申请.', buttons: { ok: 'Ok' }, fn: function (btn) { return false; } });");
                        return;
                    }
                }
                else
                {
                    if (Convert.ToDecimal(dt3.Rows[i]["Amount"].ToString()) + budgetusedstation - budgetstation > Convert.ToDecimal(6.01) * 500)
                    {
                        string rw = "";
                        switch (dt3.Rows[i]["COACode"].ToString())
                        {
                            case "62010900":
                                rw = "交际费";
                                break;
                            case "62011900":
                                rw = "交通费";
                                break;
                            case "62010500":
                                rw = "通讯费";
                                break;
                            default:
                                break;
                        }
                        warningmsg += rw + "部分超出 " + dt3.Rows[i]["Station"].ToString() + " 全年预算总额500美元以上.";
                    }
                }
            }
            
            if (warningmsg.Length>0)
            {
                //X.AddScript("Ext.Msg.show({ title: 'Message', msg: '" + warningmsg + "', buttons: { ok: 'Ok' }, fn: function (btn) { RM.SaveAll1('" + type + "','" + detail + "','" + MailList + "','" + header0string + "','" + header1string + "','" + header2string + "','" + Cur + "','" + dept + "',{eventMask:{showMask:true,target:'Page'}}); } });");
                X.AddScript("Ext.Msg.show({ title: 'Message', msg: '" + warningmsg + "', buttons: { ok: 'Ok' }, fn: function (btn) { SaveAll1('" + type + "','" + warningmsg + "')} });");
            }
            else
            {
                if (para == "ND")//保存并申请
                {
                    if (hdTravelRequestID.Value.ToString() == "")//直接新增申请,不通过草稿
                    {
                        string word = "[No],[Person],[Station],[Department],[ReportFile],[Tamount],[Pamout],[Camount],[CreadedBy],[CreadedDate],[Attach],[Remark],[Bdate],[Edate],[PersonID],[CreadedByID],[ApplyDate],[CCMailList],[Budget],[Station2]";
                        string value = "";
                        value += "'" + station + DateTime.Now.Year.ToString().Substring(2, 2) + DateTime.Now.Month.ToString().PadLeft(2, '0') + "',";//edit
                        value += "'" + hdOwner.Value.ToString() + "',"; value += "'" + station + "',"; value += "'" + department + "',";//edit
                        value += "'" + hdReport.Value.ToString() + "',";
                        value += hdSum.Value.ToString() == "" ? "null" : hdSum.Value.ToString();
                        value += "," + (hdPamountSum.Value.ToString() == "" ? "null" : hdPamountSum.Value.ToString());
                        value += "," + (hdCamountSum.Value.ToString() == "" ? "null" : hdCamountSum.Value.ToString());
                        value += ",'" + Request.Cookies.Get("eReimUserName").Value + "'";//edit
                        value += ",'" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "',";
                        value += "'" + hdScanFile.Value.ToString() + "',";
                        value += "'" + txtRemark.Text.Replace("'", "''") + "',";
                        value += "null,null";
                        value += ",'" + hdOwnerID.Value.ToString() + "'";
                        value += ",'" + Request.Cookies.Get("eReimUserID").Value + "'";
                        value += ",'" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "'";
                        value += ",'" + CCMailList + "'";
                        value += "," + (Radio1.Checked ? "1" : "0");
                        //value += "," + (cbxBudget.Value.ToString() == "YES" ? "1" : "0");
                        value += ",'" + ostation + "'";
                        string updatesql = "insert into ETravel (" + word + ") values(" + value + ");update ETravel set [No]=[No]+(select [MonthCount]=right('0000'+cast(count(ID) as varchar(10)),4) from ETravel where (month(ApplyDate) in (select month(ApplyDate) from ETravel where [ID]=@@IDENTITY) and (year(ApplyDate) in (select year(ApplyDate) from ETravel where [ID]=@@IDENTITY)) and Station=(select Station from ETravel where ID=@@IDENTITY)))+'T' where ID=@@IDENTITY;select [msg]=convert(varchar,ID)+','+[No] from ETravel where ID=@@IDENTITY";

                        string newid = dbc.UpdateData("eReimbursement", updatesql, "Insert");

                        string rows = "";
                        for (int i = 0; i < dtGroupFlowData.Rows.Count; i++)
                        {
                            string wordflow = "[No],[Type],[Station],[Department],[Person],[CreadedBy],[CreatedDate],[Tamount],[Step],[Status],[Approver],[ApproverID],[RequestID],[FlowFn]";
                            if (dtGroupFlowData.Rows[i]["FlowNo"].ToString() == "1")
                            {
                                wordflow += ",[Active]";
                            }
                            string valueflow = "";
                            valueflow += "'" + newid.Split(',')[1] + "',";
                            valueflow += "'T',";
                            valueflow += "'" + station + "',";
                            valueflow += "'" + department + "',";
                            valueflow += "'" + hdOwner.Value.ToString() + "',";
                            valueflow += "'" + Request.Cookies.Get("eReimUserName").Value + "',";
                            valueflow += "'" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "',";
                            valueflow += hdSum.Value.ToString() == "" ? "null," : hdSum.Value.ToString() + ",";
                            valueflow += dtGroupFlowData.Rows[i]["FlowNo"].ToString() + ",";
                            valueflow += "1,";
                            valueflow += "'" + dtGroupFlowData.Rows[i]["FlowUser"].ToString() + "',";
                            valueflow += "'" + dtGroupFlowData.Rows[i]["FlowUserid"].ToString() + "',";
                            valueflow += "'" + newid.Split(',')[0] + "'";
                            valueflow += ",'" + (dtGroupFlowData.Rows[i]["Fn"].ToString() == "" ? "Approver" : dtGroupFlowData.Rows[i]["Fn"].ToString()) + "'";
                            if (dtGroupFlowData.Rows[i]["FlowNo"].ToString() == "1")
                            {
                                valueflow += ",1";
                            }
                            string sqlupdateEFlow = "insert into Eflow (" + wordflow + ") values(" + valueflow + ")";
                            rows = dbc.UpdateData("eReimbursement", sqlupdateEFlow, "Update");
                        }
                        if (newid == "-1" || rows == "-1" || rows == "")
                        {
                            ErrorHandle("Data Error.");
                            return;
                        }
                        else
                        {
                            hdTravelRequestID.Value = newid.Split(',')[0];//新增后记录ID
                            hdTravelRequestNo.Value = newid.Split(',')[1];//新增后记录No

                            if (!SaveDetail(detail, header0string, header1string, header2string, Cur, dept) || !SendMail(warningmsg))
                            {
                                ErrorHandle("Data Error.");
                                return;
                            }
                            if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                            {
                                Panel3.Title = "差旅费申请单: " + newid.Split(',')[1];
                                UpdateMSG("保存申请单:" + newid.Split(',')[1] + "成功.");
                            }
                            else
                            {
                                Panel3.Title = "Travel Expense Form: " + newid.Split(',')[1];
                                UpdateMSG("Saved Travel Expense Form: " + newid.Split(',')[1] + " successfully.");
                            }

                        }
                        //
                    }
                    else//由草稿升级为正式申请
                    {
                        string updatesql = "update ETravel set [Person]='" + hdOwner.Value.ToString();
                        updatesql += "',[Station]='" + station;
                        updatesql += "',[Department]='" + department;
                        updatesql += "',[ReportFile]='" + hdReport.Value.ToString();
                        updatesql += "',[Tamount]=" + (hdSum.Value.ToString() == "" ? "null" : hdSum.Value.ToString());
                        updatesql += ",[Pamout]=" + (hdPamountSum.Value.ToString() == "" ? "null" : hdPamountSum.Value.ToString());
                        updatesql += ",[Camount]=" + (hdCamountSum.Value.ToString() == "" ? "null" : hdCamountSum.Value.ToString());
                        updatesql += ",[Remark]='" + txtRemark.Text.Replace("'", "''") + "'";
                        updatesql += ",[Attach]='" + hdScanFile.Value.ToString() + "'";
                        updatesql += ",[Type]=0";
                        updatesql += ",[PersonID]='" + hdOwnerID.Value.ToString() + "'";
                        string oldno = hdTravelRequestNo.Value.ToString();
                        string newno = hdTravelRequestNo.Value.ToString().Substring(0, hdTravelRequestNo.Value.ToString().Length - 1);
                        updatesql += ",[No]='" + newno + "',";
                        updatesql += "[CreadedDate]='" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "',";
                        updatesql += "[CreadedBy]='" + Request.Cookies.Get("eReimUserName").Value + "',";
                        updatesql += "[CreadedByID]='" + Request.Cookies.Get("eReimUserID").Value + "'";
                        updatesql += ",[CCMailList]='" + CCMailList + "'";
                        updatesql += ",[Budget]=" + (Radio1.Checked ? "1" : "0");
                        //updatesql += ",[Budget]=" + (cbxBudget.Value.ToString() == "YES" ? "1" : "0");
                        updatesql += ",[Station2]='" + ostation + "'";
                        updatesql += " where ID=" + hdTravelRequestID.Value.ToString();

                        string newid = dbc.UpdateData("eReimbursement", updatesql, "Update");

                        //操作Flow表
                        string sqlDeleteEflow = "delete from Eflow where [Type]='T' and [RequestID]='" + hdTravelRequestID.Value.ToString() + "'";
                        string deleterows = dbc.UpdateData("eReimbursement", sqlDeleteEflow, "Update");
                        string rows = "";
                        for (int i = 0; i < dtGroupFlowData.Rows.Count; i++)
                        {
                            string wordflow = "[No],[Type],[Station],[Department],[Person],[CreadedBy],[CreatedDate],[Tamount],[Step],[Status],[Approver],[ApproverID],[RequestID],[FlowFn]";
                            if (dtGroupFlowData.Rows[i]["FlowNo"].ToString() == "1")
                            {
                                wordflow += ",[Active]";
                            }
                            string valueflow = "";
                            valueflow += "'" + newno + "',";
                            valueflow += "'T',";
                            valueflow += "'" + station + "',";
                            valueflow += "'" + department + "',";
                            valueflow += "'" + hdOwner.Value.ToString() + "',";
                            valueflow += "'" + Request.Cookies.Get("eReimUserName").Value + "',";
                            valueflow += "'" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "',";
                            valueflow += hdSum.Value.ToString() == "" ? "null," : hdSum.Value.ToString() + ",";
                            valueflow += dtGroupFlowData.Rows[i]["FlowNo"].ToString() + ",";
                            valueflow += "1,";
                            valueflow += "'" + dtGroupFlowData.Rows[i]["FlowUser"].ToString() + "',";
                            valueflow += "'" + dtGroupFlowData.Rows[i]["FlowUserid"].ToString() + "',";
                            valueflow += hdTravelRequestID.Value.ToString();
                            valueflow += ",'" + (dtGroupFlowData.Rows[i]["Fn"].ToString() == "" ? "Approver" : dtGroupFlowData.Rows[i]["Fn"].ToString()) + "'";
                            if (dtGroupFlowData.Rows[i]["FlowNo"].ToString() == "1")
                            {
                                valueflow += ",1";
                            }
                            string sqlupdateEFlow = "insert into Eflow (" + wordflow + ") values(" + valueflow + ")";
                            rows = dbc.UpdateData("eReimbursement", sqlupdateEFlow, "Update");
                        }
                        //
                        if (newid == "-1" || rows == "-1" || rows == "")
                        {
                            ErrorHandle("Data Error.");
                            return;
                        }
                        else
                        {
                            hdTravelRequestNo.Value = newno;

                            if (!SaveDetail(detail, header0string, header1string, header2string, Cur, dept) || !SendMail(warningmsg))
                            {
                                ErrorHandle("Data Error.");
                                return;
                            }


                            if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                            {
                                Panel3.Title = "差旅费申请单:" + newno;
                                UpdateMSG("保存差旅费申请单:" + hdTravelRequestNo.Value.ToString() + "成功.");
                            }
                            else
                            {
                                Panel3.Title = "Travel Expense Form: " + newno;
                                UpdateMSG("Saved Travel Expense Form: " + hdTravelRequestNo.Value.ToString() + " successfully.");
                            }

                        }
                    }
                    X.AddScript("btnAddDSTN.disable();btnGeteLeave.disable();btnSaveDraft.disable();btnSaveAndSend.disable();Radio1.disable();Radio2.disable();btnExport.enable();btnCC.disable();");
                    //X.AddScript("btnAddDSTN.disable();btnGeteLeave.disable();btnSaveDraft.disable();btnSaveAndSend.disable();cbxBudget.setReadOnly(true);btnExport.enable();btnCC.disable();");
                }
                else//保存草稿
                {
                    if (hdTravelRequestID.Value.ToString() != "")//由链接进入的草稿更新
                    {
                        string updatesql = "update ETravel set [Person]='" + hdOwner.Value.ToString();
                        updatesql += "',[Station]='" + station;
                        updatesql += "',[Department]='" + department;
                        updatesql += "',[ReportFile]='" + hdReport.Value.ToString();
                        updatesql += "',[Tamount]=" + (hdSum.Value.ToString() == "" ? "null" : hdSum.Value.ToString());
                        updatesql += ",[Pamout]=" + (hdPamountSum.Value.ToString() == "" ? "null" : hdPamountSum.Value.ToString());
                        updatesql += ",[Camount]=" + (hdCamountSum.Value.ToString() == "" ? "null" : hdCamountSum.Value.ToString());
                        updatesql += ",[Remark]='" + txtRemark.Text.Replace("'", "''") + "'";
                        updatesql += ",[Attach]='" + hdScanFile.Value.ToString() + "'";
                        updatesql += ",[PersonID]='" + hdOwnerID.Value.ToString() + "'";
                        updatesql += ",[CCMailList]='" + CCMailList + "'";
                        updatesql += ",[Budget]=" + (Radio1.Checked ? "1" : "0");
                        //updatesql += ",[Budget]=" + (cbxBudget.Value.ToString() == "YES" ? "1" : "0");
                        updatesql += ",[Station2]='" + ostation + "'";
                        updatesql += " where ID=" + hdTravelRequestID.Value.ToString();

                        string newid = dbc.UpdateData("eReimbursement", updatesql, "Update");

                        if (newid == "-1")
                        {
                            ErrorHandle("Data Error.");
                            return;
                        }
                        else
                        {
                            if (!SaveDetail(detail, header0string, header1string, header2string, Cur, dept))
                            {
                                ErrorHandle("Data Error.");
                                return;
                            }
                            //hdTravelRequestID.Value = newid.Split(',')[0];//新增后记录ID
                            //Panel3.Title = "差旅费申请单:" + newid.Split(',')[1];
                            //X.AddScript("GridPanel2.submitData();");
                            if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                            {
                                UpdateMSG("保存差旅费申请单草稿: " + hdTravelRequestNo.Value.ToString() + "成功.");
                            }
                            else
                            {
                                UpdateMSG("Saved Travel Expense Draft: " + hdTravelRequestNo.Value.ToString() + " successfully.");
                            }
                        }

                    }
                    else//如果ID为空则判断为新增草稿
                    {
                        string word = "[No],[Person],[Station],[Department],[ReportFile],[Tamount],[Pamout],[Camount],[Attach],[Remark],[Bdate],[Edate],[Type],[PersonID],[ApplyDate],[CCMailList],[Station2],[Budget]";
                        string value = "";
                        value += "'" + station + DateTime.Now.Year.ToString().Substring(2, 2) + DateTime.Now.Month.ToString().PadLeft(2, '0') + "',";//edit
                        value += "'" + hdOwner.Value.ToString() + "',"; value += "'" + station + "',"; value += "'" + department + "',";//edit
                        value += "'" + hdReport.Value.ToString() + "',";
                        value += (hdSum.Value.ToString() == "" ? "null" : hdSum.Value.ToString());
                        value += "," + (hdPamountSum.Value.ToString() == "" ? "null" : hdPamountSum.Value.ToString());
                        value += "," + (hdCamountSum.Value.ToString() == "" ? "null" : hdCamountSum.Value.ToString());
                        value += ",'" + hdScanFile.Value.ToString() + "',";
                        value += "'" + txtRemark.Text.Replace("'", "''") + "',";
                        value += "null,null,";
                        value += "1";//标识为草稿
                        value += ",'" + hdOwnerID.Value.ToString() + "'";
                        value += ",'" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "'";
                        value += ",'" + CCMailList + "'";
                        value += ",'" + ostation + "'";
                        value += "," + (Radio1.Checked ? "1" : "0");
                        //value += "," + (cbxBudget.Value.ToString() == "YES" ? "1" : "0");
                        string updatesql = "insert into ETravel (" + word + ") values(" + value + ");update ETravel set [No]=[No]+(select [MonthCount]=right('0000'+cast(count(ID) as varchar(10)),4) from ETravel where (month(ApplyDate) in (select month(ApplyDate) from ETravel where [ID]=@@IDENTITY) and (year(ApplyDate) in (select year(ApplyDate) from ETravel where [ID]=@@IDENTITY)) and Station=(select Station from ETravel where ID=@@IDENTITY)))+'TD' where ID=@@IDENTITY;select [msg]=convert(varchar,ID)+','+[No] from ETravel where ID=@@IDENTITY";

                        string newid = dbc.UpdateData("eReimbursement", updatesql, "Insert");

                        //操作Flow表
                        string wordflow = "[No],[Type],[Station],[Department],[Person],[CreadedBy],[CreatedDate],[Tamount],[RequestID],[Active]";
                        string valueflow = "";
                        valueflow += "'" + newid.Split(',')[1] + "',";
                        valueflow += "'T',";
                        valueflow += "'" + station + "',";
                        valueflow += "'" + department + "',";
                        valueflow += "'" + hdOwner.Value.ToString() + "',";
                        valueflow += "'" + Request.Cookies.Get("eReimUserName").Value + "',";
                        valueflow += "'" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "',";
                        valueflow += hdSum.Value.ToString() == "" ? "null," : hdSum.Value.ToString() + ",";
                        valueflow += "'" + newid.Split(',')[0] + "'";
                        valueflow += ",1";
                        string sqlupdateEFlow = "insert into Eflow (" + wordflow + ") values(" + valueflow + ")";
                        string rows = dbc.UpdateData("eReimbursement", sqlupdateEFlow, "Update");
                        //
                        if (newid == "-1" || rows == "-1")
                        {
                            ErrorHandle("Data Error."); return;
                        }
                        else
                        {
                            hdTravelRequestID.Value = newid.Split(',')[0];//新增后记录ID
                            hdTravelRequestNo.Value = newid.Split(',')[1];//新增后记录No
                            if (!SaveDetail(detail, header0string, header1string, header2string, Cur, dept))
                            {
                                ErrorHandle("Data Error.");
                                return;
                            }
                            if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                            {
                                Panel3.Title = "差旅费申请单草稿: " + newid.Split(',')[1];
                                UpdateMSG("新增差旅费申请单草稿: " + newid.Split(',')[1] + "成功.");
                            }
                            else
                            {
                                Panel3.Title = "Travel Expense Draft: " + newid.Split(',')[1];
                                UpdateMSG("Added Travel Expense Draft: " + newid.Split(',')[1] + " successfully.");
                            }
                        }
                    }
                }
            }
        }
Пример #37
0
        protected void Search(object sender, DirectEventArgs e)
        {
            cs.DBCommand dbc = new cs.DBCommand();
            string sql = "";

            //string sql = "select * from V_Eflow_ETravel where [Active]=1 or [Active]=2 ";

            if (!string.IsNullOrEmpty(txtNo.Text))
            {
                string rem = dbc.ConvertString(txtNo.Text).IndexOf('\\') == -1 ? (dbc.ConvertString(txtNo.Text) + "%'") : (dbc.ConvertString(txtNo.Text) + @"%' escape '\'");
                sql += "and ([No] like '%" + rem + ") ";
            }
            if (!string.IsNullOrEmpty(cbxType.Text))
            {
                sql += "and [Type]='" + cbxType.Text + "' ";
            }
            if (!string.IsNullOrEmpty(txtAmount1.Text))
            {
                sql += "and [Tamount]>='" + txtAmount1.Text + "' ";
            }
            if (!string.IsNullOrEmpty(txtAmount2.Text))
            {
                sql += "and [Tamount]<='" + txtAmount2.Text + "' ";
            }
            if (!string.IsNullOrEmpty(txtRemark.Text))
            {
                string rem = dbc.ConvertString(txtRemark.Text).IndexOf('\\') == -1 ? (dbc.ConvertString(txtRemark.Text) + "%'") : (dbc.ConvertString(txtRemark.Text) + @"%' escape '\'");
                sql += "and ([Remark] like '%" + rem + ") ";
            }
            if (!string.IsNullOrEmpty(dfTDate1.RawText))
            {
                sql += "and convert(varchar(10),CreadedDate,111)>='" + dfTDate1.RawText + "' ";
            }
            if (!string.IsNullOrEmpty(dfTDate2.RawText))
            {
                sql += "and convert(varchar(10),CreadedDate,111)<='" + dfTDate2.RawText + "' ";
            }
            if (!string.IsNullOrEmpty(cbxSubType.Text))
            {
                sql += cbxSubType.Text == "0" ? "and [Step]!=0 " : "and [Step]=0 ";
            }
            if (!string.IsNullOrEmpty(cbxPerson.Text))
            {
                sql += "and PersonID='" + cbxPerson.Text + "' ";
            }
            if (!string.IsNullOrEmpty(cbxCreatedBy.Text))
            {
                sql += "and CreadedByID='" + cbxCreatedBy.Text + "' ";
            }
            if (!string.IsNullOrEmpty(cbxProcess.Text))
            {
                sql += "and Status='" + cbxProcess.Text + "' ";
                //switch (cbxProcess.Text)
                //{
                //    case "待批":
                //        sql += "and Status=1 ";
                //        break;
                //    case "Pending":
                //        sql += "and Status=1 ";
                //        break;
                //    case "已批":
                //        sql += "and Status=2 ";
                //        break;
                //    case "Approved":
                //        sql += "and Status=2 ";
                //        break;
                //    case "已拒绝":
                //        sql += "and Status=3 ";
                //        break;
                //    case "Rejected":
                //        sql += "and Status=3 ";
                //        break;
                //    case "待申请":
                //        sql += "and Status=0 ";
                //        break;
                //    case "Not Apply":
                //        sql += "and Status=0 ";
                //        break;
                //    default:
                //        break;
                //}
            }
            if (!string.IsNullOrEmpty(cbxStation.Text))
            {
                sql += "and Station='" + cbxStation.Text + "' ";
            }
            else
            {
                string getright = "select * from StationRole where UserID='" + Request.Cookies.Get("eReimUserID").Value + "'";
                DataTable dtright = dbc.GetData("eReimbursement", getright);
                DataTable dtStation = new DataTable();
                dtStation.Columns.Add("Text", System.Type.GetType("System.String"));
                dtStation.Columns.Add("Value", System.Type.GetType("System.String"));
                for (int j = 0; j < dtright.Rows.Count; j++)
                {
                    string[] dd = dtright.Rows[j]["Stations"].ToString().Split(',');
                    for (int i = 0; i < dd.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(dd[i].Trim()))
                        {
                            bool have = false;
                            for (int g = 0; g < dtStation.Rows.Count; g++)
                            {
                                if (dtStation.Rows[g]["Text"].ToString() == dd[i].Trim())
                                {
                                    have = true;
                                    break;
                                }
                            }
                            if (!have)
                            {
                                DataRow dr1 = dtStation.NewRow();
                                dr1["Text"] = dd[i];
                                dr1["Value"] = dd[i];
                                dtStation.Rows.Add(dr1);
                            }
                        }
                    }
                }
                //获取被授权站点下的所有申请人
                string station = "";
                for (int i = 0; i < dtStation.Rows.Count; i++)
                {
                    station += "'" + dtStation.Rows[i]["Text"].ToString() + "',";
                }
                if (!string.IsNullOrEmpty(station))
                {
                    station = " and Station in (" + station.Substring(0, station.Length - 1) + ") ";
                    sql += station;
                }
                else
                {
                    sql += " and FlowID is null ";
                }
            }
            string sql1 = "select t1.*";
            if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
            {
                sql1 += ",[Status1]=TDicStatus.CText,[Type1]=TDicMainType.CText,[Draft1]=TDicType.CText";
            }
            else
            {
                sql1 += ",[Status1]=TDicStatus.EText,[Type1]=TDicMainType.EText,[Draft1]=TDicType.EText";
            }
            sql1 += " from (select [Draft]=case when [Status]=0 then 1 else 0 end,* from V_Eflow_ETravel where FlowID>16097 and (Active=1 or Active=2) " + sql + ") t1";
            sql1 += " left join (select * from Edic where KeyValue='MainType') TDicMainType on TDicMainType.CValue=t1.Type";
            sql1 += " left join (select * from Edic where KeyValue='Status') TDicStatus on TDicStatus.CValue=t1.Status";
            sql1 += " left join (select * from Edic where KeyValue='Type') TDicType on TDicType.CValue=t1.Draft";

            
            DataTable dtdetail = new DataTable();
            dtdetail = dbc.GetData("eReimbursement", sql1);
            DataTable dtnew = new DataTable();
            dtnew.Columns.Add("FlowID", System.Type.GetType("System.String"));
            dtnew.Columns.Add("No", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Type", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Station", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Department", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Person", System.Type.GetType("System.String"));
            dtnew.Columns.Add("CreadedBy", System.Type.GetType("System.String"));
            dtnew.Columns.Add("CreadedDate", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Tamount", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Step", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Status", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Approver", System.Type.GetType("System.String"));
            dtnew.Columns.Add("ApproveDate", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Remark", System.Type.GetType("System.String"));
            dtnew.Columns.Add("ApproverID", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Draft", System.Type.GetType("System.String"));
            dtnew.Columns.Add("RequestID", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Status1", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Type1", System.Type.GetType("System.String"));
            dtnew.Columns.Add("Draft1", System.Type.GetType("System.String"));
            //151010,解析申请人Cost Center by Andy Kang
            dtnew.Columns.Add("PersonID", System.Type.GetType("System.String"));
            dtnew.Columns.Add("CostCenter", System.Type.GetType("System.String"));
            dtnew.Columns.Add("CostCenterNew", System.Type.GetType("System.String"));
            for (int i = 0; i < dtdetail.Rows.Count; i++)
            {
                DataRow dr = dtnew.NewRow();
                dr["FlowID"] = dtdetail.Rows[i]["FlowID"].ToString();
                dr["No"] = dtdetail.Rows[i]["No"].ToString();
                dr["Type"] = dtdetail.Rows[i]["Type"].ToString();
                dr["Station"] = dtdetail.Rows[i]["Station"].ToString();
                dr["Department"] = dtdetail.Rows[i]["Department"].ToString();
                dr["Person"] = dtdetail.Rows[i]["Person"].ToString();
                dr["CreadedBy"] = dtdetail.Rows[i]["CreadedBy"].ToString();
                dr["CreadedDate"] = dtdetail.Rows[i]["CreadedDate"].ToString() == "" ? "" : Convert.ToDateTime(dtdetail.Rows[i]["CreadedDate"].ToString()).ToString("yyyy/MM/dd");
                dr["Tamount"] = dtdetail.Rows[i]["Tamount"].ToString();
                dr["Step"] = dtdetail.Rows[i]["Step"].ToString();
                dr["Status"] = dtdetail.Rows[i]["Status"].ToString();
                dr["Approver"] = dtdetail.Rows[i]["Approver"].ToString();
                dr["ApproveDate"] = dtdetail.Rows[i]["ApproveDate"].ToString() == "" ? "" : Convert.ToDateTime(dtdetail.Rows[i]["ApproveDate"].ToString()).ToString("yyyy/MM/dd");
                dr["Remark"] = dtdetail.Rows[i]["Remark"].ToString();
                dr["ApproverID"] = dtdetail.Rows[i]["ApproverID"].ToString();
                dr["Draft"] = dtdetail.Rows[i]["Draft"].ToString();
                dr["RequestID"] = dtdetail.Rows[i]["RequestID"].ToString();
                dr["Status1"] = dtdetail.Rows[i]["Status1"].ToString();
                dr["Type1"] = dtdetail.Rows[i]["Type1"].ToString();
                dr["Draft1"] = dtdetail.Rows[i]["Draft1"].ToString();
                //151010,解析申请人Cost Center by Andy Kang
                dr["PersonID"] = dtdetail.Rows[i]["PersonID"].ToString();
                dr["CostCenter"] = dtdetail.Rows[i]["CostCenter"].ToString();
                DataSet ds1 = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(dtdetail.Rows[i]["PersonID"].ToString());
                if (ds1.Tables[0].Rows.Count == 1)
                {
                    DataTable dt1 = ds1.Tables[0];
                    dr["CostCenterNew"] = dt1.Rows[0]["CostCenter"].ToString();
                }
                else
                {
                    dr["CostCenterNew"] = "N/A";
                }

                dtnew.Rows.Add(dr);
            }
            Store1.DataSource = dtnew;
            Store1.DataBind();
        }
Пример #38
0
        protected bool SaveDetail(string detail, string header0string, string header1string, string header2string, string Cur, string dept)
        {
            cs.DBCommand dbc = new cs.DBCommand();
            //删除现有数据
            string deletesql = "delete from ETraveleDetail where [No]='" + hdTravelRequestID.Value.ToString() + "'";
            string newid1 = dbc.UpdateData("eReimbursement", deletesql, "Update");

            SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["eReimbursement"].ConnectionString);
            //如果出差站点为空,则不保存信息
            StoreSubmitDataEventArgs eSubmit = new StoreSubmitDataEventArgs(detail, null);
            XmlNode xml = eSubmit.Xml;
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml.InnerXml);
            int dtcol = doc.SelectNodes("records").Item(0).SelectNodes("record").Item(0).ChildNodes.Count;
            //doc.SelectNodes("records").Item(0).SelectNodes("record").Item(i).ChildNodes[j].InnerText;
            int dtrow = doc.SelectNodes("records").Item(0).SelectNodes("record").Count;
            int groupcount = (dtcol - 3) / 2;//多少个站点会被更新,如果站点为空则不更新
            decimal psum = 0, csum = 0;//记录该申请单的费用合计
            for (int i = 0; i < groupcount; i++)
            {
                if (header0string.Split(',')[i] != "NA")//站点为空则不更新
                {
                    DataSet ds2 = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(hdOwnerID.Value.ToString());
                    string station = "",Tstation="";
                    if (ds2.Tables[0].Rows.Count == 1)
                    {
                        DataTable dt1 = ds2.Tables[0];
                        station = dt1.Rows[0]["stationCode"].ToString();
                        DataTable dttemp = new DataTable();
                        string sqltemp = "select * from ESUSER where Userid='" + hdOwnerID.Value.ToString() + "'";
                        dttemp = dbc.GetData("eReimbursement", sqltemp);
                        if (dttemp.Rows.Count > 0)
                        {
                            station = dttemp.Rows[0]["Station"].ToString();
                        }
                    }
                    Tstation = header1string.Split(',')[i] == "NA" ? station : header1string.Split(',')[i];
                    double re = System.Math.Round(DIMERCO.SDK.Utilities.LSDK.GetLatestStationUSDConvertRate(station) / DIMERCO.SDK.Utilities.LSDK.GetLatestStationUSDConvertRate(Tstation), 4);
                    //共新增11行固定数据
                    for (int j = 0; j < 11; j++)
                    {
                        try
                        {
                            SqlCommand scdetail = sqlConn.CreateCommand();
                            scdetail.CommandText = "insert into ETraveleDetail ([No],[Tocity],[AccountCode],[Cur],[Pamount],[Camount],[TSation],[Createdby],[CreadedDate],[Tdate],[Department1],[DetailCode],[Tdate0],[CenterAmountP],[CenterAmountC]) values (@No,@Tocity,@AccountCode,@Cur,@Pamount,@Camount,@TSation,@Createdby,@CreadedDate,@Tdate,@Department1,@DetailCode,@Tdate0,@CenterAmountP,@CenterAmountC)";
                            SqlParameter spdetail = new SqlParameter("@No", SqlDbType.VarChar, 50);
                            spdetail.Value = hdTravelRequestID.Value.ToString();
                            scdetail.Parameters.Add(spdetail);

                            spdetail = new SqlParameter("@Tocity", SqlDbType.VarChar, 10);
                            spdetail.Value = header0string.Split(',')[i];
                            scdetail.Parameters.Add(spdetail);

                            spdetail = new SqlParameter("@AccountCode", SqlDbType.VarChar, 50);
                            switch (j)
                            {
                                case 4:
                                    spdetail.Value = "62010900";
                                    break;
                                case 5:
                                    spdetail.Value = "62011900";
                                    break;
                                case 6:
                                    spdetail.Value = "62010500";
                                    break;
                                default:
                                    spdetail.Value = "62012000";
                                    break;
                            }
                            scdetail.Parameters.Add(spdetail);

                            spdetail = new SqlParameter("@Cur", SqlDbType.VarChar, 50);
                            spdetail.Value = Cur;
                            scdetail.Parameters.Add(spdetail);

                            spdetail = new SqlParameter("@Pamount", SqlDbType.Decimal);
                            if (doc.SelectNodes("records").Item(0).SelectNodes("record").Item(j).ChildNodes[1 + i * 2].InnerText != "")
                            {
                                spdetail.Value = System.Math.Round(Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(j).ChildNodes[1 + i * 2].InnerText), 2);
                                psum += System.Math.Round(Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(j).ChildNodes[1 + i * 2].InnerText), 2);
                            }
                            else
                            {
                                spdetail.Value = DBNull.Value;
                            }
                            scdetail.Parameters.Add(spdetail);

                            spdetail = new SqlParameter("@CenterAmountP", SqlDbType.Decimal);
                            if (doc.SelectNodes("records").Item(0).SelectNodes("record").Item(j).ChildNodes[1 + i * 2].InnerText != "")
                            {
                                spdetail.Value = Convert.ToDecimal(System.Math.Round(Convert.ToDouble(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(j).ChildNodes[1 + i * 2].InnerText) * re, 2));
                                
                            }
                            else
                            {
                                spdetail.Value = DBNull.Value;
                            }
                            scdetail.Parameters.Add(spdetail);

                            spdetail = new SqlParameter("@Camount", SqlDbType.Decimal);
                            if (doc.SelectNodes("records").Item(0).SelectNodes("record").Item(j).ChildNodes[2 + i * 2].InnerText != "")
                            {
                                spdetail.Value = System.Math.Round(Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(j).ChildNodes[2 + i * 2].InnerText), 2);
                                csum += System.Math.Round(Convert.ToDecimal(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(j).ChildNodes[2 + i * 2].InnerText), 2);
                            }
                            else
                            {
                                spdetail.Value = DBNull.Value;
                            }
                            scdetail.Parameters.Add(spdetail);

                            spdetail = new SqlParameter("@CenterAmountC", SqlDbType.Decimal);
                            if (doc.SelectNodes("records").Item(0).SelectNodes("record").Item(j).ChildNodes[2 + i * 2].InnerText != "")
                            {
                                spdetail.Value = Convert.ToDecimal(System.Math.Round(Convert.ToDouble(doc.SelectNodes("records").Item(0).SelectNodes("record").Item(j).ChildNodes[2 + i * 2].InnerText) * re, 2));

                            }
                            else
                            {
                                spdetail.Value = DBNull.Value;
                            }
                            scdetail.Parameters.Add(spdetail);

                            spdetail = new SqlParameter("@TSation", SqlDbType.VarChar, 50);
                            spdetail.Value = header1string.Split(',')[i] == "NA" ? "" : header1string.Split(',')[i];
                            scdetail.Parameters.Add(spdetail);

                            spdetail = new SqlParameter("@Createdby", SqlDbType.VarChar, 50);
                            spdetail.Value = hdOwnerID.Value.ToString();
                            scdetail.Parameters.Add(spdetail);

                            spdetail = new SqlParameter("@CreadedDate", SqlDbType.DateTime);
                            spdetail.Value = DateTime.Now;
                            scdetail.Parameters.Add(spdetail);

                            spdetail = new SqlParameter("@Tdate", SqlDbType.DateTime);
                            if (header2string.Split(',')[i * 2 + 1] == "NA")
                            {
                                spdetail.Value = DBNull.Value;
                            }
                            else
                            {
                                spdetail.Value = Convert.ToDateTime(header2string.Split(',')[i * 2 + 1]);
                            }
                            scdetail.Parameters.Add(spdetail);

                            spdetail = new SqlParameter("@Tdate0", SqlDbType.DateTime);
                            if (header2string.Split(',')[i * 2] == "NA")
                            {
                                spdetail.Value = DBNull.Value;
                            }
                            else
                            {
                                spdetail.Value = Convert.ToDateTime(header2string.Split(',')[i * 2]);
                            }
                            scdetail.Parameters.Add(spdetail);

                            spdetail = new SqlParameter("@Department1", SqlDbType.VarChar, 50);
                            spdetail.Value = dept;
                            scdetail.Parameters.Add(spdetail);

                            spdetail = new SqlParameter("@DetailCode", SqlDbType.Int);
                            spdetail.Value = j;
                            scdetail.Parameters.Add(spdetail);

                            sqlConn.Open();
                            int row = scdetail.ExecuteNonQuery();
                            sqlConn.Close();
                        }
                        catch (Exception er)
                        {
                            throw er;
                        }
                    }
                }
            }
            try
            {
                SqlCommand scdetail = sqlConn.CreateCommand();
                scdetail.CommandText = "update ETravel set Pamout=@Pamout,Camount=@Camount,Tamount=@Tamount where [ID]=@ID";
                SqlParameter spdetail = new SqlParameter("@ID", SqlDbType.VarChar, 50);
                spdetail.Value = hdTravelRequestID.Value.ToString();
                scdetail.Parameters.Add(spdetail);

                spdetail = new SqlParameter("@Pamout", SqlDbType.Decimal);
                spdetail.Value = psum;
                scdetail.Parameters.Add(spdetail);

                spdetail = new SqlParameter("@Camount", SqlDbType.Decimal);
                spdetail.Value = csum;
                scdetail.Parameters.Add(spdetail);

                spdetail = new SqlParameter("@Tamount", SqlDbType.Decimal);
                spdetail.Value = psum + csum;
                scdetail.Parameters.Add(spdetail);

                sqlConn.Open();
                int row = scdetail.ExecuteNonQuery();
                sqlConn.Close();
            }
            catch (Exception)
            {

                throw;
            }

            return true;
        }
Пример #39
0
        protected void btnLogin_Click(object sender, DirectEventArgs e)
        {
            cs.DBCommand dbc = new cs.DBCommand();
            DataSet ds = new DataSet();
            bool user = DIMERCO.SDK.Utilities.ReSM.CheckUserInfo(tfUserID.Text.Trim(), tfPW.Text.Trim(), ref ds);
            if (ds.Tables[0].Rows.Count == 1)
            {
                DataTable dtuser = ds.Tables[0];
                Session["UserID"] = dtuser.Rows[0]["UserID"].ToString();
                if (Request.Cookies["eReimUserID"] != null)
                {
                    Response.Cookies["eReimUserID"].Value = dtuser.Rows[0]["UserID"].ToString();  //将值写入到客户端硬盘Cookie
                    Response.Cookies["eReimUserID"].Expires = DateTime.Now.AddHours(12);//设置Cookie过期时间
                }
                else
                {
                    HttpCookie cookie = new HttpCookie("eReimUserID", dtuser.Rows[0]["UserID"].ToString());
                    cookie.Expires = DateTime.Now.AddHours(12);
                    Response.Cookies.Add(cookie);
                }

                DataSet ds1 = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(dtuser.Rows[0]["UserID"].ToString());
                if (ds1.Tables[0].Rows.Count == 1)
                {
                    DataTable dt1 = ds1.Tables[0];
                    Session["UserName"] = dt1.Rows[0]["fullName"].ToString();
                    Session["Station"] = dt1.Rows[0]["stationCode"].ToString();
                    Session["Department"] = dt1.Rows[0]["CRPDepartmentName"].ToString();
                    Session["CostCenter"] = dt1.Rows[0]["CostCenter"].ToString();
                    if (Request.Cookies["eReimUserName"] != null)
                    {
                        Response.Cookies["eReimUserName"].Value = dt1.Rows[0]["fullName"].ToString();  //将值写入到客户端硬盘Cookie
                        Response.Cookies["eReimUserName"].Expires = DateTime.Now.AddHours(12);//设置Cookie过期时间
                    }
                    else
                    {
                        HttpCookie cookie = new HttpCookie("eReimUserName", dt1.Rows[0]["fullName"].ToString());
                        cookie.Expires = DateTime.Now.AddHours(12);
                        Response.Cookies.Add(cookie);
                    }
                    if (Request.Cookies["eReimStation"] != null)
                    {
                        Response.Cookies["eReimStation"].Value = dt1.Rows[0]["stationCode"].ToString();  //将值写入到客户端硬盘Cookie
                        Response.Cookies["eReimStation"].Expires = DateTime.Now.AddHours(12);//设置Cookie过期时间
                    }
                    else
                    {
                        HttpCookie cookie = new HttpCookie("eReimStation", dt1.Rows[0]["stationCode"].ToString());
                        cookie.Expires = DateTime.Now.AddHours(12);
                        Response.Cookies.Add(cookie);
                    }
                    if (Request.Cookies["eReimDepartment"] != null)
                    {
                        Response.Cookies["eReimDepartment"].Value = dt1.Rows[0]["CRPDepartmentName"].ToString();  //将值写入到客户端硬盘Cookie
                        Response.Cookies["eReimDepartment"].Expires = DateTime.Now.AddHours(12);//设置Cookie过期时间
                    }
                    else
                    {
                        HttpCookie cookie = new HttpCookie("eReimDepartment", dt1.Rows[0]["CRPDepartmentName"].ToString());
                        cookie.Expires = DateTime.Now.AddHours(12);
                        Response.Cookies.Add(cookie);
                    }
                    if (Request.Cookies["eReimCostCenter"] != null)
                    {
                        Response.Cookies["eReimCostCenter"].Value = dt1.Rows[0]["CostCenter"].ToString();  //将值写入到客户端硬盘Cookie
                        Response.Cookies["eReimCostCenter"].Expires = DateTime.Now.AddHours(12);//设置Cookie过期时间
                    }
                    else
                    {
                        HttpCookie cookie = new HttpCookie("eReimCostCenter", dt1.Rows[0]["CostCenter"].ToString());
                        cookie.Expires = DateTime.Now.AddHours(12);
                        Response.Cookies.Add(cookie);
                    }

                    //DataTable dttemp = new DataTable();
                    //string sqltemp = "select * from ESUSER where Userid='" + dtuser.Rows[0]["UserID"].ToString() + "'";
                    //dttemp = dbc.GetData("eReimbursement", sqltemp);
                    //if (dttemp.Rows.Count > 0)
                    //{
                    //    //Session["CostCenter"] = dttemp.Rows[0]["Station"].ToString();
                    //    if (Request.Cookies["eReimCostCenter"] != null)
                    //    {
                    //        Response.Cookies["eReimCostCenter"].Value = dttemp.Rows[0]["Station"].ToString();  //将值写入到客户端硬盘Cookie
                    //        Response.Cookies["eReimCostCenter"].Expires = DateTime.Now.AddHours(12);//设置Cookie过期时间
                    //    }
                    //    else
                    //    {
                    //        HttpCookie cookie = new HttpCookie("eReimCostCenter", dttemp.Rows[0]["Station"].ToString());
                    //        cookie.Expires = DateTime.Now.AddHours(12);
                    //        Response.Cookies.Add(cookie);
                    //    }
                    //}
                    X.AddScript("window.location.reload();");
                }
                else
                {
                    X.Msg.Alert("Message", "Data Error.").Show();
                    return;
                }
            }
            else
            {
                X.Msg.Alert("Message", "Please confirm your UserID and Password.").Show();
                return;
            }
            if (ds != null)
            {
                ds.Dispose();
            }
        }
Пример #40
0
 public void CheckEFlow()
 {
     cs.DBCommand dbc = new cs.DBCommand();
     //检查是否已经为该申请人设置过审批人
     string sqlCheckFlow = "";
     if (Radio1.Checked)//使用Budget审批流程
     {
         sqlCheckFlow = "select * from GroupFlow where [Type]!=2 and GID=(select GID from GroupUsers where UserID='" + hdOwnerID.Value.ToString() + "')";
     }
     else//使用unBudget审批流程
     {
         sqlCheckFlow = "select * from GroupFlow where [Type]=2 and GID=(select GID from GroupUsers where UserID='" + hdOwnerID.Value.ToString() + "')";
     }
     DataTable dtGroupFlowData = dbc.GetData("eReimbursement", sqlCheckFlow);
     if (dtGroupFlowData.Rows.Count < 1)
     {
         if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
         {
             ErrorHandle("请先设置审批人.");
         }
         else
         {
             ErrorHandle("Not set Approve flow,please contact with Local MIS.");
         }
         return;
     }
 }
Пример #41
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                //判断登录状态
                cs.DBCommand dbc = new cs.DBCommand();
                if (Request.Cookies.Get("eReimUserID") == null)
                {
                    X.AddScript("loginWindow.show();Panel1.disable();");
                    return;
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "", "$('div.gn_person ul.q-menubox li:eq(0) a').text('" + Request.Cookies.Get("eReimUserName").Value + "');", true); X.AddScript("loginWindow.hide();Panel1.enable();");
                }
                string sqltype    = "";
                string sqldraft   = "";
                string sqlProcess = "";
                if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
                {
                    PagingToolbar1.DisplayMsg = "显示 {0} - {1} of {2}";
                    ResourceManager1.Locale   = "zh-CN";
                    sqltype    += "select [Text]=CText,[Value]=CValue from Edic where KeyValue='MainType'";
                    sqldraft   += "select [Text]=CText,[Value]=CValue from Edic where KeyValue='Type'";
                    sqlProcess += "select [Text]=CText,[Value]=CValue from Edic where KeyValue='Status'";
                }
                else
                {
                    PagingToolbar1.DisplayMsg = "Displaying items {0} - {1} of {2}";
                    ResourceManager1.Locale   = "en-US";
                    sqltype    += "select [Text]=EText,[Value]=CValue from Edic where KeyValue='MainType'";
                    sqldraft   += "select [Text]=EText,[Value]=CValue from Edic where KeyValue='Type'";
                    sqlProcess += "select [Text]=EText,[Value]=CValue from Edic where KeyValue='Status'";
                }

                DataTable dttype = dbc.GetData("eReimbursement", sqltype);
                StoreType.DataSource = dttype;
                StoreType.DataBind();
                DataTable dtdraft = dbc.GetData("eReimbursement", sqldraft);
                StoreDraft.DataSource = dtdraft;
                StoreDraft.DataBind();
                DataTable dtProcess = dbc.GetData("eReimbursement", sqlProcess);
                StoreProcess.DataSource = dtProcess;
                StoreProcess.DataBind();
                //获取被授权站点
                string    getright  = "select * from StationRole where UserID='" + Request.Cookies.Get("eReimUserID").Value + "'";
                DataTable dtright   = dbc.GetData("eReimbursement", getright);
                DataTable dtStation = new DataTable();
                dtStation.Columns.Add("Text", System.Type.GetType("System.String"));
                dtStation.Columns.Add("Value", System.Type.GetType("System.String"));
                for (int j = 0; j < dtright.Rows.Count; j++)
                {
                    string[] dd = dtright.Rows[j]["Stations"].ToString().Split(',');
                    for (int i = 0; i < dd.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(dd[i].Trim()))
                        {
                            bool have = false;
                            for (int g = 0; g < dtStation.Rows.Count; g++)
                            {
                                if (dtStation.Rows[g]["Text"].ToString() == dd[i].Trim())
                                {
                                    have = true;
                                    break;
                                }
                            }
                            if (!have)
                            {
                                DataRow dr1 = dtStation.NewRow();
                                dr1["Text"]  = dd[i];
                                dr1["Value"] = dd[i];
                                dtStation.Rows.Add(dr1);
                            }
                        }
                    }
                }
                dtStation.DefaultView.Sort = "Text ASC";
                StoreStation.DataSource    = dtStation.DefaultView.ToTable();
                StoreStation.DataBind();
                //获取被授权站点下的所有申请人
                string station = "";
                for (int i = 0; i < dtStation.Rows.Count; i++)
                {
                    station += "'" + dtStation.Rows[i]["Text"].ToString() + "',";
                }
                if (!string.IsNullOrEmpty(station))
                {
                    station = " and Station in (" + station.Substring(0, station.Length - 1) + ") ";
                }
                string sqlgetPerson = "";
                if (station.Length > 0)
                {
                    sqlgetPerson = "select distinct [Text]=Person,[Value]=PersonID from V_Eflow_ETravel where (Active=1 or Active=2) and Person!='' " + station;
                }
                else
                {
                    sqlgetPerson = "select distinct [Text]=Person,[Value]=PersonID from V_Eflow_ETravel where (Active=1 or Active=2) and Person!='' and FlowID is null";
                }
                DataTable dtperson = dbc.GetData("eReimbursement", sqlgetPerson);
                dtperson.DefaultView.Sort = "Text ASC";
                StorePerson.DataSource    = dtperson.DefaultView.ToTable();
                StorePerson.DataBind();
                //获取被授权站点下的所有提单人
                string sqlgetCreatedBy = "";
                if (station.Length > 0)
                {
                    sqlgetCreatedBy = "select distinct [Text]=CreadedBy,[Value]=CreadedByID from V_Eflow_ETravel where (Active=1 or Active=2) and CreadedBy!='' " + station;
                }
                else
                {
                    sqlgetCreatedBy = "select distinct [Text]=CreadedBy,[Value]=CreadedByID from V_Eflow_ETravel where (Active=1 or Active=2) and CreadedBy!='' and FlowID is null";
                }
                DataTable dtcreatedby = dbc.GetData("eReimbursement", sqlgetCreatedBy);
                dtcreatedby.DefaultView.Sort = "Text ASC";
                StoreCreatedBy.DataSource    = dtcreatedby.DefaultView.ToTable();
                StoreCreatedBy.DataBind();
            }
        }
Пример #42
0
        protected void LoadData(DataTable dt, bool CheckCopy)
        {
            string ID = dt.Rows[0]["RequestID"].ToString();
            cs.DBCommand dbc = new cs.DBCommand();
            //cbxOwner.SelectedItem.Value = dt.Rows[0]["PersonID"].ToString();
            
            if (CheckCopy)//根据Copy判断是否需要判断Copy状态
            {
                if (Request.QueryString["Copy"] != null)
                {
                    if (Request.QueryString["Copy"].ToString() == "T")//Copy而已,作为新增
                    {
                        hdTravelRequestID.Value = "";
                        hdTravelRequestNo.Value = "";
                        if (Request.QueryString["CopyType"] != null)
                        {
                            if (Request.QueryString["CopyType"].ToString() == "A")
                            {
                                if (dt.Rows[0]["ReportFile"].ToString() != "")
                                {
                                    linkTravelReport.Text = dt.Rows[0]["ReportFile"].ToString();
                                    linkTravelReport.NavigateUrl = "./Upload/" + dt.Rows[0]["ReportFile"].ToString();
                                    hdReport.Value = dt.Rows[0]["ReportFile"].ToString();
                                }
                                if (dt.Rows[0]["Attach"].ToString() != "")
                                {
                                    linkScanFile.Text = dt.Rows[0]["Attach"].ToString();
                                    linkScanFile.NavigateUrl = "./Upload/" + dt.Rows[0]["Attach"].ToString();
                                    hdScanFile.Value = dt.Rows[0]["Attach"].ToString();
                                }
                            }
                        }
                    }
                    else
                    {
                        ErrorHandle("Data Error.");
                    }
                }
                else
                {
                    //labelOwner.Text = dt.Rows[0]["Person"].ToString();
                    //hdOwner.Value = dt.Rows[0]["Person"].ToString();
                    //hdOwnerID.Value = dt.Rows[0]["PersonID"].ToString();
                    //labelStation.Text = dt.Rows[0]["Station"].ToString();
                    //labelDepartment.Text = dt.Rows[0]["Department"].ToString();
                    //获取该人币种
                    //LabelCurrency.Text = DIMERCO.SDK.Utilities.LSDK.GetStationCurrencyByCode(dt.Rows[0]["Station"].ToString());
                    //hdCurrency.Value = System.Math.Round(1 / DIMERCO.SDK.Utilities.LSDK.GetLatestStationUSDConvertRate(dt.Rows[0]["Station"].ToString()), 3);

                    //DataSet ds1 = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(dt.Rows[0]["PersonID"].ToString());
                    //if (ds1.Tables[0].Rows.Count == 1)
                    //{
                    //    DataTable dt1 = ds1.Tables[0];
                    //    LabelCurrency.Text = DIMERCO.SDK.Utilities.LSDK.GetStationCurrencyByCode(dt1.Rows[0]["stationCode"].ToString());
                    //    hdCurrency.Value = System.Math.Round(1 / DIMERCO.SDK.Utilities.LSDK.GetLatestStationUSDConvertRate(dt1.Rows[0]["stationCode"].ToString()), 3);
                    //    DataTable dttemp = new DataTable();
                    //    string sqltemp = "select * from ESUSER where Userid='" + dt.Rows[0]["PersonID"].ToString() + "'";
                    //    dttemp = dbc.GetData("eReimbursement", sqltemp);
                    //    if (dttemp.Rows.Count > 0)
                    //    {
                    //        LabelCurrency.Text = DIMERCO.SDK.Utilities.LSDK.GetStationCurrencyByCode(dttemp.Rows[0]["Station"].ToString());
                    //        hdCurrency.Value = System.Math.Round(1 / DIMERCO.SDK.Utilities.LSDK.GetLatestStationUSDConvertRate(dttemp.Rows[0]["Station"].ToString()), 3);
                    //    }
                    //}
                    //else
                    //{
                    //    ErrorHandle("Data Error."); return;
                    //}

                    hdTravelRequestID.Value = ID;
                    hdTravelRequestNo.Value = dt.Rows[0]["No"].ToString();
                    if (dt.Rows[0]["ReportFile"].ToString() != "")
                    {
                        linkTravelReport.Text = dt.Rows[0]["ReportFile"].ToString();
                        linkTravelReport.NavigateUrl = "./Upload/" + dt.Rows[0]["ReportFile"].ToString();
                        hdReport.Value = dt.Rows[0]["ReportFile"].ToString();
                    }
                    if (dt.Rows[0]["Attach"].ToString() != "")
                    {
                        linkScanFile.Text = dt.Rows[0]["Attach"].ToString();
                        linkScanFile.NavigateUrl = "./Upload/" + dt.Rows[0]["Attach"].ToString();
                        hdScanFile.Value = dt.Rows[0]["Attach"].ToString();
                    }
                    X.AddScript("btnExport.enable();");
                }
            }
            else
            {
                //labelOwner.Text = dt.Rows[0]["Person"].ToString();
                //hdOwner.Value = dt.Rows[0]["Person"].ToString();
                //hdOwnerID.Value = dt.Rows[0]["PersonID"].ToString();
                //labelStation.Text = dt.Rows[0]["Station"].ToString();
                //labelDepartment.Text = dt.Rows[0]["Department"].ToString();
                //获取该人币种
                //LabelCurrency.Text = DIMERCO.SDK.Utilities.LSDK.GetStationCurrencyByCode(dt.Rows[0]["Station"].ToString());
                //hdCurrency.Value = System.Math.Round(1 / DIMERCO.SDK.Utilities.LSDK.GetLatestStationUSDConvertRate(dt.Rows[0]["Station"].ToString()), 3);

                //DataSet ds1 = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(dt.Rows[0]["PersonID"].ToString());
                //if (ds1.Tables[0].Rows.Count == 1)
                //{
                //    DataTable dt1 = ds1.Tables[0];
                //    LabelCurrency.Text = DIMERCO.SDK.Utilities.LSDK.GetStationCurrencyByCode(dt1.Rows[0]["stationCode"].ToString());
                //    hdCurrency.Value = System.Math.Round(1 / DIMERCO.SDK.Utilities.LSDK.GetLatestStationUSDConvertRate(dt1.Rows[0]["stationCode"].ToString()), 3);
                //    DataTable dttemp = new DataTable();
                //    string sqltemp = "select * from ESUSER where Userid='" + dt.Rows[0]["PersonID"].ToString() + "'";
                //    dttemp = dbc.GetData("eReimbursement", sqltemp);
                //    if (dttemp.Rows.Count > 0)
                //    {
                //        LabelCurrency.Text = DIMERCO.SDK.Utilities.LSDK.GetStationCurrencyByCode(dttemp.Rows[0]["Station"].ToString());
                //        hdCurrency.Value = System.Math.Round(1 / DIMERCO.SDK.Utilities.LSDK.GetLatestStationUSDConvertRate(dttemp.Rows[0]["Station"].ToString()), 3);
                //    }
                //}
                //else
                //{
                //    ErrorHandle("Data Error."); return;
                //}

                hdTravelRequestID.Value = ID;
                hdTravelRequestNo.Value = dt.Rows[0]["No"].ToString();
                if (dt.Rows[0]["ReportFile"].ToString() != "")
                {
                    linkTravelReport.Text = dt.Rows[0]["ReportFile"].ToString();
                    linkTravelReport.NavigateUrl = "./Upload/" + dt.Rows[0]["ReportFile"].ToString();
                    hdReport.Value = dt.Rows[0]["ReportFile"].ToString();
                }
                if (dt.Rows[0]["Attach"].ToString() != "")
                {
                    linkScanFile.Text = dt.Rows[0]["Attach"].ToString();
                    linkScanFile.NavigateUrl = "./Upload/" + dt.Rows[0]["Attach"].ToString();
                    hdScanFile.Value = dt.Rows[0]["Attach"].ToString();
                }
            }
            //Radio1.Checked = dt.Rows[0]["Budget"].ToString() == "1" ? true : false;
            //Radio2.Checked = dt.Rows[0]["Budget"].ToString() != "1" ? true : false;
            //cbxBudget.SelectedItem.Value = dt.Rows[0]["Budget"].ToString() == "1" ? "YES" : "NO";

            
            ////获取该人币种
            //DataSet ds1 = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(dt.Rows[0]["PersonID"].ToString());
            //if (ds1.Tables[0].Rows.Count == 1)
            //{
            //    DataTable dt1 = ds1.Tables[0];
            //    LabelCurrency.Text = DIMERCO.SDK.Utilities.LSDK.GetStationCurrencyByCode(dt1.Rows[0]["CostCenter"].ToString());

            //    DataTable dttemp = new DataTable();
            //    string sqltemp = "select * from ESUSER where Userid='" + dt.Rows[0]["PersonID"].ToString() + "'";
            //    dttemp = dbc.GetData("eReimbursement", sqltemp);
            //    if (dttemp.Rows.Count > 0)
            //    {
            //        LabelCurrency.Text = dttemp.Rows[0]["Currency"].ToString();
            //    }
            //}
            //else
            //{
            //    ErrorHandle("Data Error."); return;
            //}

            //载入已经保存的基本信息
            labelOwner.Text = dt.Rows[0]["Person"].ToString();
            hdOwner.Value = dt.Rows[0]["Person"].ToString();
            hdOwnerID.Value = dt.Rows[0]["PersonID"].ToString();
            labelStation.Text = dt.Rows[0]["Station"].ToString();
            labelDepartment.Text = dt.Rows[0]["Department"].ToString();

            //组合数据
            DataTable dtnew = new DataTable();
            Store2.Reader[0].Fields.Add("Category", RecordFieldType.String);
            dtnew.Columns.Add("Category", typeof(String));
            dtnew.Columns.Add("TotalP", typeof(String));
            dtnew.Columns.Add("TotalC", typeof(String));
            //默认12行
            for (int i = 0; i < 12; i++)
            {
                DataRow dr = dtnew.NewRow();
                dtnew.Rows.Add(dr);
            }
            //默认第一列是标题
            dtnew.Rows[0][0] = "1. Air Ticket - Int'l";
            dtnew.Rows[1][0] = "Air Ticket - Domestic";
            dtnew.Rows[2][0] = "2. Hotel Bill";
            dtnew.Rows[3][0] = "3. Meals";
            dtnew.Rows[4][0] = "4. Entertainment";
            dtnew.Rows[5][0] = "5. Car Rental/Transportation";
            dtnew.Rows[6][0] = "6. Communication";
            dtnew.Rows[7][0] = "7. Local Trip Allowance";
            dtnew.Rows[8][0] = "8. Overseas Trip Allowance";
            dtnew.Rows[9][0] = "9. Airport Tax/Travel Insurance";
            dtnew.Rows[10][0] = "10. Others";
            dtnew.Rows[11][0] = "Total";

            string sqlf = "select distinct Tocity from ETraveleDetail where [No]='" + ID + "'";
            DataTable dtf = dbc.GetData("eReimbursement", sqlf);
            string sqld = "select * from ETraveleDetail where [No]='" + ID + "' order by id";
            DataTable dtall = new DataTable();
            dtall = dbc.GetData("eReimbursement", sqld);
            LabelCurrency.Text = dtall.Rows[0]["Cur"].ToString();//读取费用明细中的本地币种显示
            //140226 显示预算
            DataTable dtbudget = new DataTable();
            dtbudget.Columns.Add("EName", typeof(System.String));
            dtbudget.Columns.Add("Type", typeof(System.String));
            dtbudget.Columns.Add("Current", typeof(System.Decimal));
            dtbudget.Columns.Add("PU", typeof(System.Decimal));
            dtbudget.Columns.Add("PB", typeof(System.Decimal));
            dtbudget.Columns.Add("PPercent", typeof(System.Decimal));
            dtbudget.Columns.Add("DU", typeof(System.Decimal));
            dtbudget.Columns.Add("DB", typeof(System.Decimal));
            dtbudget.Columns.Add("DPercent", typeof(System.Decimal));
            dtbudget.Columns.Add("SU", typeof(System.Decimal));
            dtbudget.Columns.Add("SB", typeof(System.Decimal));
            dtbudget.Columns.Add("SPercent", typeof(System.Decimal));
            //StoreBudget添加Field
            StoreBudget.Reader[0].Fields.Add("EName", RecordFieldType.String);
            StoreBudget.Reader[0].Fields.Add("Type", RecordFieldType.String);
            StoreBudget.Reader[0].Fields.Add("Current", RecordFieldType.String);
            StoreBudget.Reader[0].Fields.Add("PU", RecordFieldType.String);
            StoreBudget.Reader[0].Fields.Add("PB", RecordFieldType.String);
            StoreBudget.Reader[0].Fields.Add("PPercent", RecordFieldType.String);
            StoreBudget.Reader[0].Fields.Add("DU", RecordFieldType.String);
            StoreBudget.Reader[0].Fields.Add("DB", RecordFieldType.String);
            StoreBudget.Reader[0].Fields.Add("DPercent", RecordFieldType.String);
            StoreBudget.Reader[0].Fields.Add("SU", RecordFieldType.String);
            StoreBudget.Reader[0].Fields.Add("SB", RecordFieldType.String);
            StoreBudget.Reader[0].Fields.Add("SPercent", RecordFieldType.String);
            //取得预算日期
            string sqlA = "select convert(varchar(10),min(Tdate0),111) as BudgetDate from ETraveleDetail where No='" + ID + "'";
            DataTable dtA = dbc.GetData("eReimbursement", sqlA);
            //取得4大类合计
            //string sqlB = "select sum(T1) as T1,sum(T2) as T2,sum(T3) as T3,sum(T4) as T4 from (select case when AccountCode='62012000' then isnull(Pamount,0)+isnull(Camount,0) else 0 end as [T1],case when AccountCode='62010900' then isnull(Pamount,0)+isnull(Camount,0) else 0 end as [T2],case when AccountCode='62011900' then isnull(Pamount,0)+isnull(Camount,0) else 0 end as [T3],case when AccountCode='62010500' then isnull(Pamount,0)+isnull(Camount,0) else 0 end as [T4] from ETraveleDetail where No=" + ID + ") t";
            string sqlB = "select sum(isnull(Pamount,0)+isnull(Camount,0)) as Amount,'62010900' as Type from ETraveleDetail where No=" + ID + " and AccountCode='62012000' union all select sum(isnull(Pamount,0)+isnull(Camount,0)) as Amount,'62011900' as Type from ETraveleDetail where No=" + ID + " and AccountCode='62010900' union all select sum(isnull(Pamount,0)+isnull(Camount,0)) as Amount,'62010500' as Type from ETraveleDetail where No=" + ID + " and AccountCode='62011900' union all select sum(isnull(Pamount,0)+isnull(Camount,0)) as Amount,'62012000' as Type from ETraveleDetail where No=" + ID + " and AccountCode='62010500'";
            DataTable dtB = dbc.GetData("eReimbursement", sqlB);
            //取得传递预算的参数
            string userid = dt.Rows[0]["PersonID"].ToString();
            string dpt = dt.Rows[0]["Department"].ToString();
            string ostation = dt.Rows[0]["CostCenter"].ToString();//预算站点,与基本信息中的CostCenter一致(Station2)
            string tstation = ostation;//Etravel表中的Station2,目前与预算站点一致,不允许更改
            string year = Convert.ToDateTime(dtA.Rows[0]["BudgetDate"].ToString()).Year.ToString();
            string month = Convert.ToDateTime(dtA.Rows[0]["BudgetDate"].ToString()).Month.ToString();
            string accountcode = "";
            for (int g = 0; g < dtB.Rows.Count; g++)
            {
                if (Convert.ToDecimal(dtB.Rows[g]["Amount"].ToString()) != 0)
                {
                    DataRow dr = dtbudget.NewRow();
                    dr["Current"] = Convert.ToDecimal(dtB.Rows[g]["Amount"].ToString());
                    dr["Type"] = dtB.Rows[g]["Type"].ToString();
                    accountcode = dtB.Rows[g]["Type"].ToString();
                    DataTable dtC = new DataTable();
                    dtC = Comm.RtnEB(userid, dpt, ostation, tstation, accountcode, year, month);
                    for (int i = 0; i < dtC.Rows.Count; i++)
                    {
                        if (dtC.Rows[i]["Type"].ToString() == "全年个人")
                        {
                            dr["PU"] = Convert.ToDecimal(dtC.Rows[i]["Used"].ToString());
                            dr["PB"] = Convert.ToDecimal(dtC.Rows[i]["Budget"].ToString());
                        }
                        else if (dtC.Rows[i]["Type"].ToString() == "全年部门")
                        {
                            dr["DU"] = Convert.ToDecimal(dtC.Rows[i]["Used"].ToString());
                            dr["DB"] = Convert.ToDecimal(dtC.Rows[i]["Budget"].ToString());
                        }
                        else if (dtC.Rows[i]["Type"].ToString() == "全年站点")
                        {
                            dr["SU"] = Convert.ToDecimal(dtC.Rows[i]["Used"].ToString());
                            dr["SB"] = Convert.ToDecimal(dtC.Rows[i]["Budget"].ToString());
                        }
                    }
                    dtbudget.Rows.Add(dr);
                }
            }
            //计算%,取得名称
            for (int i = 0; i < dtbudget.Rows.Count; i++)
            {
                if (Convert.ToDecimal(dtbudget.Rows[i]["PB"].ToString()) != 0)//如果Budget不为0,则计算%
                {
                    dtbudget.Rows[i]["PPercent"] = System.Math.Round(Convert.ToDecimal(dtbudget.Rows[i]["PU"].ToString()) / Convert.ToDecimal(dtbudget.Rows[i]["PB"].ToString()), 4) * 100;
                }
                if (Convert.ToDecimal(dtbudget.Rows[i]["DB"].ToString()) != 0)//如果Budget不为0,则计算%
                {
                    dtbudget.Rows[i]["DPercent"] = System.Math.Round(Convert.ToDecimal(dtbudget.Rows[i]["DU"].ToString()) / Convert.ToDecimal(dtbudget.Rows[i]["DB"].ToString()), 4) * 100;
                }
                if (Convert.ToDecimal(dtbudget.Rows[i]["SB"].ToString()) != 0)//如果Budget不为0,则计算%
                {
                    dtbudget.Rows[i]["SPercent"] = System.Math.Round(Convert.ToDecimal(dtbudget.Rows[i]["SU"].ToString()) / Convert.ToDecimal(dtbudget.Rows[i]["SB"].ToString()), 4) * 100;
                }
                if (dtbudget.Rows[i]["Type"].ToString()=="62010900")
                {
                    dtbudget.Rows[i]["EName"] = "Travel expense";
                }
                else if (dtbudget.Rows[i]["Type"].ToString() == "62011900")
                {
                    dtbudget.Rows[i]["EName"] = "Entertainment";
                }
                else if (dtbudget.Rows[i]["Type"].ToString() == "62010500")
                {
                    dtbudget.Rows[i]["EName"] = "Transportation";
                }
                else if (dtbudget.Rows[i]["Type"].ToString() == "62012000")
                {
                    dtbudget.Rows[i]["EName"] = "Communication";
                }
            }
            
            bool PB = false, DB = false, SB = false;
            for (int i = 0; i < dtbudget.Rows.Count; i++)
            {
                if (Convert.ToDecimal(dtbudget.Rows[i]["PB"].ToString()) != 0)//是否显示个人预算列
                {
                    PB = true;
                }
                if (Convert.ToDecimal(dtbudget.Rows[i]["DB"].ToString()) != 0)//是否显示部门预算列
                {
                    DB = true;
                }
                if (Convert.ToDecimal(dtbudget.Rows[i]["SB"].ToString()) != 0)//是否显示站点预算列
                {
                    SB = true;
                }
            }
            //添加数据列
            var cm = GridPanelBudget.ColumnModel;
            cm.Columns.Add(new Column
            {
                DataIndex = "EName",
                Header = "Expense Item",
                Sortable = false,
                Resizable = false,
                MenuDisabled = true,
                Width = 100
            });
            cm.Columns.Add(new Column
            {
                DataIndex = "Current",
                Header = "Current",
                Renderer = new Renderer { Fn = "GetNumber" },
                Sortable = false,
                Resizable = false,
                MenuDisabled = true,
                Width = 100
            });
            //显示个人预算部分
            if (PB)
            {
                cm.Columns.Add(new Column
                {
                    DataIndex = "PU",
                    Header = "Personal Used",
                    Renderer = new Renderer { Fn = "GetNumber" },
                    Sortable = false,
                    Resizable = false,
                    MenuDisabled = true,
                    Width = 100
                });
                cm.Columns.Add(new Column
                {
                    DataIndex = "PB",
                    Header = "Personal Budget",
                    Renderer = new Renderer { Fn = "GetNumber" },
                    Sortable = false,
                    Resizable = false,
                    MenuDisabled = true,
                    Width = 100
                });
                cm.Columns.Add(new Column
                {
                    DataIndex = "PPercent",
                    Header = "%(Used/Budget)",
                    Renderer = new Renderer { Fn = "GetNumberPercent" },
                    Sortable = false,
                    Resizable = false,
                    MenuDisabled = true,
                    Width = 100
                });
            }
            if (DB)
            {
                cm.Columns.Add(new Column
                {
                    DataIndex = "DU",
                    Header = "Department Used",
                    Renderer = new Renderer { Fn = "GetNumber" },
                    Sortable = false,
                    Resizable = false,
                    MenuDisabled = true,
                    Width = 100
                });
                cm.Columns.Add(new Column
                {
                    DataIndex = "DB",
                    Header = "Department Budget",
                    Renderer = new Renderer { Fn = "GetNumber" },
                    Sortable = false,
                    Resizable = false,
                    MenuDisabled = true,
                    Width = 100
                });
                cm.Columns.Add(new Column
                {
                    DataIndex = "DPercent",
                    Header = "%(Used/Budget)",
                    Renderer = new Renderer { Fn = "GetNumberPercent" },
                    Sortable = false,
                    Resizable = false,
                    MenuDisabled = true,
                    Width = 100
                });
            }
            if (SB)
            {
                cm.Columns.Add(new Column
                {
                    DataIndex = "SU",
                    Header = "Unit Used",
                    Renderer = new Renderer { Fn = "GetNumber" },
                    Sortable = false,
                    Resizable = false,
                    MenuDisabled = true,
                    Width = 100
                });
                cm.Columns.Add(new Column
                {
                    DataIndex = "SB",
                    Header = "Unit Budget",
                    Renderer = new Renderer { Fn = "GetNumber" },
                    Sortable = false,
                    Resizable = false,
                    MenuDisabled = true,
                    Width = 100
                });
                cm.Columns.Add(new Column
                {
                    DataIndex = "SPercent",
                    Header = "%(Used/Budget)",
                    Renderer = new Renderer { Fn = "GetNumberPercent" },
                    Sortable = false,
                    Resizable = false,
                    MenuDisabled = true,
                    Width = 100
                });
            }
            StoreBudget.DataSource = dtbudget;
            StoreBudget.DataBind();
            //
            if (dtf.Rows.Count == 1)
            {
                
                for (int i = 0; i < dtall.Rows.Count; i++)
                {
                    if (i % 11 == 0)
                    {
                        string colname = "Station_" + (i / 11).ToString() + "_P";
                        Store2.Reader[0].Fields.Add(colname, RecordFieldType.String);
                        dtnew.Columns.Add(colname, typeof(String));
                        colname = "Station_" + (i / 11).ToString() + "_C";
                        Store2.Reader[0].Fields.Add(colname, RecordFieldType.String);
                        dtnew.Columns.Add(colname, typeof(String));
                    }
                    dtnew.Rows[i % 11][3 + i / 11 * 2] = dtall.Rows[i]["Pamount"].ToString();
                    dtnew.Rows[i % 11][3 + i / 11 * 2 + 1] = dtall.Rows[i]["Camount"].ToString();
                    //列合计
                    string df = dtnew.Rows[11][3 + i / 11 * 2].ToString() == "" ? "0" : dtnew.Rows[11][3 + i / 11 * 2].ToString();
                    string cf = dtall.Rows[i]["Pamount"].ToString() == "" ? "0" : dtall.Rows[i]["Pamount"].ToString();
                    dtnew.Rows[11][3 + i / 11 * 2] = Convert.ToDecimal(df) + Convert.ToDecimal(cf) == 0 ? "" : (Convert.ToDecimal(df) + Convert.ToDecimal(cf)).ToString();

                    string bf = dtnew.Rows[11][3 + i / 11 * 2 + 1].ToString() == "" ? "0" : dtnew.Rows[11][3 + i / 11 * 2 + 1].ToString();
                    string af = dtall.Rows[i]["Camount"].ToString() == "" ? "0" : dtall.Rows[i]["Camount"].ToString();
                    dtnew.Rows[11][3 + i / 11 * 2 + 1] = Convert.ToDecimal(bf) + Convert.ToDecimal(af) == 0 ? "" : (Convert.ToDecimal(bf) + Convert.ToDecimal(af)).ToString();
                    //行合计
                    string df1 = dtnew.Rows[i % 11][1].ToString() == "" ? "0" : dtnew.Rows[i % 11][1].ToString();
                    dtnew.Rows[i % 11][1] = Convert.ToDecimal(df1) + Convert.ToDecimal(cf) == 0 ? "" : (Convert.ToDecimal(df1) + Convert.ToDecimal(cf)).ToString();
                    string bf1 = dtnew.Rows[i % 11][2].ToString() == "" ? "0" : dtnew.Rows[i % 11][2].ToString();
                    dtnew.Rows[i % 11][2] = Convert.ToDecimal(bf1) + Convert.ToDecimal(af) == 0 ? "" : (Convert.ToDecimal(bf1) + Convert.ToDecimal(af)).ToString();
                    //总合计
                    string tf = dtnew.Rows[11][1].ToString() == "" ? "0" : dtnew.Rows[11][1].ToString();
                    dtnew.Rows[11][1] = Convert.ToDecimal(tf) + Convert.ToDecimal(cf) == 0 ? "" : (Convert.ToDecimal(tf) + Convert.ToDecimal(cf)).ToString();
                    string ff = dtnew.Rows[11][2].ToString() == "" ? "0" : dtnew.Rows[11][2].ToString();
                    dtnew.Rows[11][2] = Convert.ToDecimal(ff) + Convert.ToDecimal(af) == 0 ? "" : (Convert.ToDecimal(ff) + Convert.ToDecimal(af)).ToString();
                }
                dtnew.Columns.Add("Station_1_P", typeof(String));
                dtnew.Columns.Add("Station_1_C", typeof(String));
                Store2.Reader[0].Fields.Add("Station_1_P", RecordFieldType.String);
                Store2.Reader[0].Fields.Add("Station_1_C", RecordFieldType.String);
                Store2.Reader[0].Fields.Add("TotalP", RecordFieldType.String);
                Store2.Reader[0].Fields.Add("TotalC", RecordFieldType.String);

                Store2.DataSource = dtnew;
                Store2.DataBind();

                var TitleCol = new Column();
                TitleCol.DataIndex = "Category";
                TitleCol.Sortable = false;
                TitleCol.Resizable = false;
                TitleCol.MenuDisabled = true;
                TitleCol.Width = 180;
                this.GridPanel2.ColumnModel.Columns.Add(TitleCol);

                var Title1 = new Ext.Net.Label();
                Title1.Text = "Destination:";
                HeaderColumn hcTitle1 = new HeaderColumn();
                hcTitle1.Component.Add(Title1);
                this.GridPanel2.GetView().HeaderRows[0].Columns.Add(hcTitle1);

                var Title2 = new Ext.Net.Label();
                Title2.Text = "Cost Center:";
                HeaderColumn hcTitle2 = new HeaderColumn();
                hcTitle2.Component.Add(Title2);
                this.GridPanel2.GetView().HeaderRows[1].Columns.Add(hcTitle2);

                var Title3 = new Ext.Net.Label();
                Title3.Text = "Travel Period:";
                HeaderColumn hcTitle3 = new HeaderColumn();
                hcTitle3.Component.Add(Title3);
                this.GridPanel2.GetView().HeaderRows[2].Columns.Add(hcTitle3);

                int colc = dtall.Rows.Count / 11;
                for (int i = 0; i < colc; i++)//准备复制已有信息
                {
                    string fieldPName = "Station_" + i.ToString() + "_P";
                    string fieldCName = "Station_" + i.ToString() + "_C";

                    var txtP = new Ext.Net.NumberField();
                    //txtP.Listeners.Blur.Fn = "Cal";
                    var colP = new Column();
                    colP.Header = "Person Pay";
                    colP.DataIndex = fieldPName;
                    colP.Sortable = false;
                    colP.Resizable = false;
                    colP.MenuDisabled = true;
                    colP.Width = 110;
                    colP.Editor.Add(txtP);
                    this.GridPanel2.ColumnModel.Columns.Add(colP);

                    var txtC = new Ext.Net.NumberField();
                    //txtC.Listeners.Blur.Fn = "Cal";
                    var colC = new Column();
                    colC.Header = "Company Pay";
                    colC.DataIndex = fieldCName;
                    colC.Sortable = false;
                    colC.Resizable = false;
                    colC.MenuDisabled = true;
                    colC.Width = 110;
                    colC.Editor.Add(txtC);
                    this.GridPanel2.ColumnModel.Columns.Add(colC);

                    var Station = new Ext.Net.TextField();
                    Station.Text = dtall.Rows[i * 11]["Tocity"].ToString();
                    HeaderColumn hcStation = new HeaderColumn();
                    hcStation.Component.Add(Station);
                    this.GridPanel2.GetView().HeaderRows[0].Columns.Add(hcStation);

                    var Button = new Ext.Net.Button();
                    Button.Text = "Remove";
                    Button.Listeners.Click.Handler = "removecol(this," + i.ToString() + ");";
                    Button.Listeners.Click.Delay = 50;
                    HeaderColumn hcButton = new HeaderColumn();
                    hcButton.Component.Add(Button);
                    this.GridPanel2.GetView().HeaderRows[0].Columns.Add(hcButton);

                    var CostCenter = new Ext.Net.TextField();
                    CostCenter.Disabled = true;
                    CostCenter.EmptyText = "Station Code";
                    CostCenter.Text = dtall.Rows[i * 11]["TSation"].ToString();
                    HeaderColumn hcCostCenter = new HeaderColumn();
                    hcCostCenter.Component.Add(CostCenter);
                    this.GridPanel2.GetView().HeaderRows[1].Columns.Add(hcCostCenter);

                    //HeaderColumn hcCostCenter1 = new HeaderColumn();
                    //this.GridPanel2.GetView().HeaderRows[1].Columns.Add(hcCostCenter1);
                    var ButtonGetSum = new Ext.Net.Button();
                    ButtonGetSum.Text = "Calculate";
                    ButtonGetSum.Listeners.Click.Handler = "GetSum();";
                    ButtonGetSum.Listeners.Click.Delay = 50;
                    HeaderColumn hcButtonGetSum = new HeaderColumn();
                    hcButtonGetSum.Component.Add(ButtonGetSum);
                    this.GridPanel2.GetView().HeaderRows[1].Columns.Add(hcButtonGetSum);

                    var datefrom = new DateField();
                    string dtfroms = dtall.Rows[i * 11]["Tdate0"].ToString() == "" ? "" : Convert.ToDateTime(dtall.Rows[i * 11]["Tdate0"].ToString()).ToString("yyyy/MM/dd");
                    datefrom.SetValue(dtfroms);
                    datefrom.EmptyText = "yyyy/MM/dd";
                    datefrom.Format = "yyyy/MM/dd";
                    HeaderColumn Date1 = new HeaderColumn();
                    Date1.Component.Add(datefrom);
                    this.GridPanel2.GetView().HeaderRows[2].Columns.Add(Date1);

                    var dateto = new DateField();
                    string datetos = dtall.Rows[i * 11]["Tdate"].ToString() == "" ? "" : Convert.ToDateTime(dtall.Rows[i * 11]["Tdate"].ToString()).ToString("yyyy/MM/dd");
                    dateto.SetValue(datetos);
                    dateto.EmptyText = "yyyy/MM/dd";
                    dateto.Format = "yyyy/MM/dd";
                    HeaderColumn Date2 = new HeaderColumn();
                    Date2.Component.Add(dateto);
                    this.GridPanel2.GetView().HeaderRows[2].Columns.Add(Date2);
                }

                var txtP1 = new Ext.Net.NumberField();
                //txtP1.Listeners.Blur.Fn = "Cal";
                //txtP1.Listeners.Blur.Delay = 50;
                var colP1 = new Column();
                colP1.Header = "Person Pay";
                colP1.DataIndex = "Station_1_P";
                colP1.Sortable = false;
                colP1.Resizable = false;
                colP1.MenuDisabled = true;
                colP1.Width = 110;
                colP1.Locked = true;
                colP1.Editor.Add(txtP1);
                colP1.Hidden = true;
                this.GridPanel2.ColumnModel.Columns.Add(colP1);

                var txtC1 = new Ext.Net.NumberField();
                //txtC1.Listeners.Blur.Fn = "Cal";
                //txtC1.Listeners.Blur.Delay = 50;
                var colC1 = new Column();
                colC1.Header = "Company Pay";
                colC1.DataIndex = "Station_1_C";
                colC1.Sortable = false;
                colC1.Resizable = false;
                colC1.MenuDisabled = true;
                colC1.Width = 110;
                colC1.Locked = true;
                colC1.Editor.Add(txtC1);
                colC1.Hidden = true;
                this.GridPanel2.ColumnModel.Columns.Add(colC1);

                var TotalP = new Ext.Net.TextField();
                TotalP.ReadOnly = true;
                TotalP.Cls = "custom-row";
                var colTotalP = new Column();
                colTotalP.DataIndex = "TotalP";
                colTotalP.Sortable = false;
                colTotalP.Resizable = false;
                colTotalP.MenuDisabled = true;
                colTotalP.Width = 110;
                colTotalP.Locked = true;
                colTotalP.Editor.Add(TotalP);
                this.GridPanel2.ColumnModel.Columns.Add(colTotalP);

                var TotalC = new Ext.Net.TextField();
                TotalC.ReadOnly = true;
                TotalC.Cls = "custom-row";
                var colTotalC = new Column();
                colTotalC.DataIndex = "TotalC";
                colTotalC.Sortable = false;
                colTotalC.Resizable = false;
                colTotalC.MenuDisabled = true;
                colTotalC.Width = 110;
                colTotalC.Locked = true;
                colTotalC.Editor.Add(TotalC);
                this.GridPanel2.ColumnModel.Columns.Add(colTotalC);

                var Station1 = new Ext.Net.TextField();
                HeaderColumn hcStation1 = new HeaderColumn();
                hcStation1.Component.Add(Station1);
                this.GridPanel2.GetView().HeaderRows[0].Columns.Add(hcStation1);

                var CostCenter0 = new Ext.Net.TextField();
                CostCenter0.Disabled = true;
                CostCenter0.EmptyText = "Station Code";
                HeaderColumn hcCostCenter0 = new HeaderColumn();
                hcCostCenter0.Component.Add(CostCenter0);
                this.GridPanel2.GetView().HeaderRows[1].Columns.Add(hcCostCenter0);

                HeaderColumn hcDate3 = new HeaderColumn();
                var Date3 = new DateField();
                Date3.EmptyText = "yyyy/MM/dd";
                Date3.Format = "yyyy/MM/dd";
                //Date3.SetValue("2013/11/1");
                hcDate3.Component.Add(Date3);
                this.GridPanel2.GetView().HeaderRows[2].Columns.Add(hcDate3);


                var Button1 = new Ext.Net.Button();
                Button1.Text = "Remove";
                Button1.Listeners.Click.Handler = "removecol(this,1);";
                Button1.Listeners.Click.Delay = 50;
                HeaderColumn hcButton1 = new HeaderColumn();
                hcButton1.Component.Add(Button1);
                this.GridPanel2.GetView().HeaderRows[0].Columns.Add(hcButton1);

                var ButtonGetSum1 = new Ext.Net.Button();
                ButtonGetSum1.Text = "Calculate";
                ButtonGetSum1.Listeners.Click.Handler = "GetSum();";
                ButtonGetSum1.Listeners.Click.Delay = 50;
                HeaderColumn hcButtonGetSum1 = new HeaderColumn();
                hcButtonGetSum1.Component.Add(ButtonGetSum1);
                this.GridPanel2.GetView().HeaderRows[1].Columns.Add(hcButtonGetSum1);

                HeaderColumn hcDate4 = new HeaderColumn();
                var Date4 = new DateField();
                Date4.EmptyText = "yyyy/MM/dd";
                Date4.Format = "yyyy/MM/dd";
                //Date4.SetValue("2013/11/2");
                hcDate4.Component.Add(Date4);
                this.GridPanel2.GetView().HeaderRows[2].Columns.Add(hcDate4);

                HeaderColumn hcTotal1 = new HeaderColumn();
                this.GridPanel2.GetView().HeaderRows[0].Columns.Add(hcTotal1);

                HeaderColumn hcTotal3 = new HeaderColumn();
                this.GridPanel2.GetView().HeaderRows[1].Columns.Add(hcTotal3);

                var TitleTotalP = new Ext.Net.Label();
                TitleTotalP.Text = "Total(Person)";
                TitleTotalP.Cls = "custom-row";
                HeaderColumn hcTitleTotalP = new HeaderColumn();
                hcTitleTotalP.Component.Add(TitleTotalP);
                this.GridPanel2.GetView().HeaderRows[2].Columns.Add(hcTitleTotalP);

                HeaderColumn hcTotal2 = new HeaderColumn();
                this.GridPanel2.GetView().HeaderRows[0].Columns.Add(hcTotal2);

                HeaderColumn hcTotal4 = new HeaderColumn();
                this.GridPanel2.GetView().HeaderRows[1].Columns.Add(hcTotal4);

                var TitleTotalC = new Ext.Net.Label();
                TitleTotalC.Text = "Total(Comp)";
                TitleTotalC.Cls = "custom-row";
                HeaderColumn hcTitleTotalC = new HeaderColumn();
                hcTitleTotalC.Component.Add(TitleTotalC);
                this.GridPanel2.GetView().HeaderRows[2].Columns.Add(hcTitleTotalC);

                X.AddScript("GridPanel2.colModel.setHidden(3, true);GridPanel2.colModel.setHidden(4, true);Store2.removeField('Station_1_P');Store2.removeField('Station_1_C');");
            }
            else
            {
                //string sqld = "select * from ETraveleDetail where [No]='" + ID + "' order by id";
                //DataTable dtall = new DataTable();
                //dtall = dbc.GetData("eReimbursement", sqld);
                for (int i = 0; i < dtall.Rows.Count; i++)
                {
                    if (i % 11 == 0)
                    {
                        string colname = "Station_" + (i / 11).ToString() + "_P";
                        Store2.Reader[0].Fields.Add(colname, RecordFieldType.String);
                        dtnew.Columns.Add(colname, typeof(String));
                        colname = "Station_" + (i / 11).ToString() + "_C";
                        Store2.Reader[0].Fields.Add(colname, RecordFieldType.String);
                        dtnew.Columns.Add(colname, typeof(String));
                    }
                    dtnew.Rows[i % 11][3 + i / 11 * 2] = dtall.Rows[i]["Pamount"].ToString();
                    dtnew.Rows[i % 11][3 + i / 11 * 2 + 1] = dtall.Rows[i]["Camount"].ToString();
                    //列合计
                    string df = dtnew.Rows[11][3 + i / 11 * 2].ToString() == "" ? "0" : dtnew.Rows[11][3 + i / 11 * 2].ToString();
                    string cf = dtall.Rows[i]["Pamount"].ToString() == "" ? "0" : dtall.Rows[i]["Pamount"].ToString();
                    dtnew.Rows[11][3 + i / 11 * 2] = Convert.ToDecimal(df) + Convert.ToDecimal(cf) == 0 ? "" : (Convert.ToDecimal(df) + Convert.ToDecimal(cf)).ToString();

                    string bf = dtnew.Rows[11][3 + i / 11 * 2 + 1].ToString() == "" ? "0" : dtnew.Rows[11][3 + i / 11 * 2 + 1].ToString();
                    string af = dtall.Rows[i]["Camount"].ToString() == "" ? "0" : dtall.Rows[i]["Camount"].ToString();
                    dtnew.Rows[11][3 + i / 11 * 2 + 1] = Convert.ToDecimal(bf) + Convert.ToDecimal(af) == 0 ? "" : (Convert.ToDecimal(bf) + Convert.ToDecimal(af)).ToString();
                    //行合计
                    string df1 = dtnew.Rows[i % 11][1].ToString() == "" ? "0" : dtnew.Rows[i % 11][1].ToString();
                    dtnew.Rows[i % 11][1] = Convert.ToDecimal(df1) + Convert.ToDecimal(cf) == 0 ? "" : (Convert.ToDecimal(df1) + Convert.ToDecimal(cf)).ToString();
                    string bf1 = dtnew.Rows[i % 11][2].ToString() == "" ? "0" : dtnew.Rows[i % 11][2].ToString();
                    dtnew.Rows[i % 11][2] = Convert.ToDecimal(bf1) + Convert.ToDecimal(af) == 0 ? "" : (Convert.ToDecimal(bf1) + Convert.ToDecimal(af)).ToString();
                    //总合计
                    string tf = dtnew.Rows[11][1].ToString() == "" ? "0" : dtnew.Rows[11][1].ToString();
                    dtnew.Rows[11][1] = Convert.ToDecimal(tf) + Convert.ToDecimal(cf) == 0 ? "" : (Convert.ToDecimal(tf) + Convert.ToDecimal(cf)).ToString();
                    string ff = dtnew.Rows[11][2].ToString() == "" ? "0" : dtnew.Rows[11][2].ToString();
                    dtnew.Rows[11][2] = Convert.ToDecimal(ff) + Convert.ToDecimal(af) == 0 ? "" : (Convert.ToDecimal(ff) + Convert.ToDecimal(af)).ToString();
                }
                Store2.Reader[0].Fields.Add("TotalP", RecordFieldType.String);
                Store2.Reader[0].Fields.Add("TotalC", RecordFieldType.String);

                Store2.DataSource = dtnew;
                Store2.DataBind();

                var TitleCol = new Column();
                TitleCol.DataIndex = "Category";
                TitleCol.Sortable = false;
                TitleCol.Resizable = false;
                TitleCol.MenuDisabled = true;
                TitleCol.Width = 180;
                this.GridPanel2.ColumnModel.Columns.Add(TitleCol);

                var Title1 = new Ext.Net.Label();
                Title1.Text = "Destination:";
                HeaderColumn hcTitle1 = new HeaderColumn();
                hcTitle1.Component.Add(Title1);
                this.GridPanel2.GetView().HeaderRows[0].Columns.Add(hcTitle1);

                var Title2 = new Ext.Net.Label();
                Title2.Text = "Cost Center:";
                HeaderColumn hcTitle2 = new HeaderColumn();
                hcTitle2.Component.Add(Title2);
                this.GridPanel2.GetView().HeaderRows[1].Columns.Add(hcTitle2);

                var Title3 = new Ext.Net.Label();
                Title3.Text = "Travel Period:";
                HeaderColumn hcTitle3 = new HeaderColumn();
                hcTitle3.Component.Add(Title3);
                this.GridPanel2.GetView().HeaderRows[2].Columns.Add(hcTitle3);

                int colc = dtall.Rows.Count / 11;
                for (int i = 0; i < colc; i++)//准备复制已有信息
                {
                    string fieldPName = "Station_" + i.ToString() + "_P";
                    //RecordField field1 = new RecordField(fieldAName, RecordFieldType.Float);
                    //Store2.Reader[0].Fields.Add(fieldPName, RecordFieldType.Float);
                    //this.Store2.AddField(field1, columncount);
                    string fieldCName = "Station_" + i.ToString() + "_C";
                    //RecordField field1 = new RecordField(fieldAName, RecordFieldType.Float);
                    //Store2.Reader[0].Fields.Add(fieldCName, RecordFieldType.Float);

                    var txtP = new Ext.Net.NumberField();
                    //txtP.Listeners.Blur.Fn = "Cal";
                    var colP = new Column();
                    colP.Header = "Person Pay";
                    colP.DataIndex = fieldPName;
                    colP.Sortable = false;
                    colP.Resizable = false;
                    colP.MenuDisabled = true;
                    colP.Width = 110;
                    colP.Editor.Add(txtP);
                    this.GridPanel2.ColumnModel.Columns.Add(colP);

                    var txtC = new Ext.Net.NumberField();
                    //txtC.Listeners.Blur.Fn = "Cal";
                    var colC = new Column();
                    colC.Header = "Company Pay";
                    colC.DataIndex = fieldCName;
                    colC.Sortable = false;
                    colC.Resizable = false;
                    colC.MenuDisabled = true;
                    colC.Width = 110;
                    colC.Editor.Add(txtC);
                    this.GridPanel2.ColumnModel.Columns.Add(colC);

                    var Station = new Ext.Net.TextField();
                    Station.Text = dtall.Rows[i * 11]["Tocity"].ToString();
                    HeaderColumn hcStation = new HeaderColumn();
                    hcStation.Component.Add(Station);
                    this.GridPanel2.GetView().HeaderRows[0].Columns.Add(hcStation);

                    var Button = new Ext.Net.Button();
                    Button.Text = "Remove";
                    Button.Listeners.Click.Handler = "removecol(this," + i.ToString() + ");";
                    Button.Listeners.Click.Delay = 50;
                    HeaderColumn hcButton = new HeaderColumn();
                    hcButton.Component.Add(Button);
                    this.GridPanel2.GetView().HeaderRows[0].Columns.Add(hcButton);

                    var CostCenter = new Ext.Net.TextField();
                    CostCenter.Disabled = true;
                    CostCenter.EmptyText = "Station Code";
                    CostCenter.Text = dtall.Rows[i * 11]["TSation"].ToString();
                    HeaderColumn hcCostCenter = new HeaderColumn();
                    hcCostCenter.Component.Add(CostCenter);
                    this.GridPanel2.GetView().HeaderRows[1].Columns.Add(hcCostCenter);

                    //HeaderColumn hcCostCenter1 = new HeaderColumn();
                    //this.GridPanel2.GetView().HeaderRows[1].Columns.Add(hcCostCenter1);
                    var ButtonGetSum = new Ext.Net.Button();
                    ButtonGetSum.Text = "Calculate";
                    ButtonGetSum.Listeners.Click.Handler = "GetSum();";
                    ButtonGetSum.Listeners.Click.Delay = 50;
                    HeaderColumn hcButtonGetSum = new HeaderColumn();
                    hcButtonGetSum.Component.Add(ButtonGetSum);
                    this.GridPanel2.GetView().HeaderRows[1].Columns.Add(hcButtonGetSum);

                    var datefrom = new DateField();
                    string dtfroms = dtall.Rows[i * 11]["Tdate0"].ToString() == "" ? "" : Convert.ToDateTime(dtall.Rows[i * 11]["Tdate0"].ToString()).ToString("yyyy/MM/dd");
                    datefrom.SetValue(dtfroms);
                    datefrom.EmptyText = "yyyy/MM/dd";
                    datefrom.Format = "yyyy/MM/dd";
                    HeaderColumn Date1 = new HeaderColumn();
                    Date1.Component.Add(datefrom);
                    this.GridPanel2.GetView().HeaderRows[2].Columns.Add(Date1);

                    var dateto = new DateField();
                    string datetos = dtall.Rows[i * 11]["Tdate"].ToString() == "" ? "" : Convert.ToDateTime(dtall.Rows[i * 11]["Tdate"].ToString()).ToString("yyyy/MM/dd");
                    dateto.SetValue(datetos);
                    dateto.EmptyText = "yyyy/MM/dd";
                    dateto.Format = "yyyy/MM/dd";
                    HeaderColumn Date2 = new HeaderColumn();
                    Date2.Component.Add(dateto);
                    this.GridPanel2.GetView().HeaderRows[2].Columns.Add(Date2);
                }

                var TotalP = new Ext.Net.TextField();
                TotalP.ReadOnly = true;
                TotalP.Cls = "custom-row";
                var colTotalP = new Column();
                colTotalP.DataIndex = "TotalP";
                colTotalP.Sortable = false;
                colTotalP.Resizable = false;
                colTotalP.MenuDisabled = true;
                colTotalP.Width = 110;
                colTotalP.Locked = true;
                colTotalP.Editor.Add(TotalP);
                this.GridPanel2.ColumnModel.Columns.Add(colTotalP);

                var TotalC = new Ext.Net.TextField();
                TotalC.ReadOnly = true;
                TotalC.Cls = "custom-row";
                var colTotalC = new Column();
                colTotalC.DataIndex = "TotalC";
                colTotalC.Sortable = false;
                colTotalC.Resizable = false;
                colTotalC.MenuDisabled = true;
                colTotalC.Width = 110;
                colTotalC.Locked = true;
                colTotalC.Editor.Add(TotalC);
                this.GridPanel2.ColumnModel.Columns.Add(colTotalC);

                HeaderColumn hcTotal1 = new HeaderColumn();
                this.GridPanel2.GetView().HeaderRows[0].Columns.Add(hcTotal1);

                HeaderColumn hcTotal2 = new HeaderColumn();
                this.GridPanel2.GetView().HeaderRows[0].Columns.Add(hcTotal2);

                HeaderColumn hcTotal3 = new HeaderColumn();
                this.GridPanel2.GetView().HeaderRows[1].Columns.Add(hcTotal3);

                HeaderColumn hcTotal4 = new HeaderColumn();
                this.GridPanel2.GetView().HeaderRows[1].Columns.Add(hcTotal4);

                var TitleTotalP = new Ext.Net.Label();
                TitleTotalP.Text = "Total(Person)";
                TitleTotalP.Cls = "custom-row";
                HeaderColumn hcTitleTotalP = new HeaderColumn();
                hcTitleTotalP.Component.Add(TitleTotalP);
                this.GridPanel2.GetView().HeaderRows[2].Columns.Add(hcTitleTotalP);

                var TitleTotalC = new Ext.Net.Label();
                TitleTotalC.Text = "Total(Comp)";
                TitleTotalC.Cls = "custom-row";
                HeaderColumn hcTitleTotalC = new HeaderColumn();
                hcTitleTotalC.Component.Add(TitleTotalC);
                this.GridPanel2.GetView().HeaderRows[2].Columns.Add(hcTitleTotalC);
            }
            //根据语言设置
            //string sqlp = "";
            //if (Request.Cookies["lang"] != null && Request.Cookies["lang"].Value.ToLower() == "zh-cn")
            //{
            //    sqlp += ",[COAName]=t2.ADes";
            //}
            //else
            //{
            //    sqlp += ",[COAName]=t2.SAccountName";
            //}

            //string detailsql = "select t1.* from ETraveleDetail t1 where t1.No='" + ID + "' order by DetailCode";
            //DataTable dtdetail = new DataTable();
            //dtdetail = dbc.GetData("eReimbursement", detailsql);
            //DataTable dtnew = new DataTable();
            //dtnew.Columns.Add("DetailID", System.Type.GetType("System.String"));
            //dtnew.Columns.Add("Tocity", System.Type.GetType("System.String"));
            //dtnew.Columns.Add("AccountCode", System.Type.GetType("System.String"));
            //dtnew.Columns.Add("Cur", System.Type.GetType("System.String"));
            //dtnew.Columns.Add("Pamount", System.Type.GetType("System.String"));
            //dtnew.Columns.Add("Camount", System.Type.GetType("System.String"));
            //dtnew.Columns.Add("TSation", System.Type.GetType("System.String"));
            //dtnew.Columns.Add("Tdate", System.Type.GetType("System.String"));
            //dtnew.Columns.Add("Tdate0", System.Type.GetType("System.String"));
            //dtnew.Columns.Add("Type", System.Type.GetType("System.String"));
            //dtnew.Columns.Add("Department1", System.Type.GetType("System.String"));
            //for (int i = 0; i < dtdetail.Rows.Count; i++)
            //{
            //    DataRow dr = dtnew.NewRow();
            //    dr["DetailID"] = dtdetail.Rows[i]["ID"].ToString();
            //    dr["Tocity"] = dtdetail.Rows[i]["Tocity"].ToString();
            //    dr["AccountCode"] = dtdetail.Rows[i]["AccountCode"].ToString();
            //    dr["Cur"] = dtdetail.Rows[i]["Cur"].ToString();
            //    dr["Pamount"] = dtdetail.Rows[i]["Pamount"].ToString();
            //    dr["Camount"] = dtdetail.Rows[i]["Camount"].ToString();
            //    dr["TSation"] = dtdetail.Rows[i]["TSation"].ToString();
            //    dr["Tdate"] = dtdetail.Rows[i]["Tdate"].ToString() == "" ? "" : Convert.ToDateTime(dtdetail.Rows[i]["Tdate"].ToString()).ToString("yyyy/MM/dd");
            //    dr["Tdate0"] = dtdetail.Rows[i]["Tdate0"].ToString() == "" ? "" : Convert.ToDateTime(dtdetail.Rows[i]["Tdate0"].ToString()).ToString("yyyy/MM/dd");
            //    dr["Type"] = hdStatus.Value.ToString();//传递给子页面以判断按钮状态 0:允许修改,允许上传;1:不允许修改,允许上传;2:全不允许
            //    dr["Department1"] = dtdetail.Rows[i]["Department1"].ToString();
            //    dtnew.Rows.Add(dr);
            //}
            //Store3.DataSource = dtnew;
            //Store3.DataBind();
            ////txtSum.Text = (psum + csum).ToString("#,##0.00"); hdSum.Value = (psum + csum).ToString();
            ////txtPersonalSum.Text = psum.ToString("#,##0.00"); hdPamountSum.Value = psum.ToString();
            ////txtCompanySum.Text = csum.ToString("#,##0.00"); hdCamountSum.Value = csum.ToString();
            //txtRemark.Text = dt.Rows[0]["Remark"].ToString();
            //if (dt.Rows[0]["CCMailList"].ToString() != "")
            //{
            //    ToolTipCC.Html = dt.Rows[0]["CCMailList"].ToString().Replace(",", "<br />");
            //    DataTable dtCCMailList = new DataTable();
            //    dtCCMailList.Columns.Add("Email", typeof(String));
            //    for (int i = 0; i < dt.Rows[0]["CCMailList"].ToString().Split(',').Length; i++)
            //    {
            //        DataRow dr = dtCCMailList.NewRow();
            //        dr["Email"] = dt.Rows[0]["CCMailList"].ToString().Split(',')[i];
            //        dtCCMailList.Rows.Add(dr);
            //    }
            //    StoreCCList.DataSource = dtCCMailList;
            //    StoreCCList.DataBind();
            //}
        }
Пример #43
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                //cs.ZipFloClass zip = new cs.ZipFloClass();
                //string filename = "TR20151111110108.xlsx";
                //string filepath = System.Web.HttpContext.Current.Request.MapPath("Upload/") + "TR20151111110108.xlsx";
                //string zipfilepath = System.Web.HttpContext.Current.Request.MapPath("Upload/") + "TR20151111110108.zip";
                //zip.ZipSingleFile(filename, filepath, zipfilepath);
                if (Request.Cookies.Get("eReimUserID") == null)
                {
                    X.AddScript("loginWindow.show();Panel1.disable();");
                    return;
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "", "$('div.gn_person ul.q-menubox li:eq(0) a').text('" + Request.Cookies.Get("eReimUserName").Value + "');", true);
                    X.AddScript("loginWindow.hide();Panel1.enable();");

                    cs.DBCommand dbc = new cs.DBCommand();

                    //获取被授权站点
                    string    getright  = "select * from StationRole where UserID='" + Request.Cookies.Get("eReimUserID").Value + "'";
                    DataTable dtright   = dbc.GetData("eReimbursement", getright);
                    DataTable dtStation = new DataTable();
                    dtStation.Columns.Add("Text", System.Type.GetType("System.String"));
                    dtStation.Columns.Add("Value", System.Type.GetType("System.String"));
                    for (int j = 0; j < dtright.Rows.Count; j++)
                    {
                        string[] dd = dtright.Rows[j]["Stations"].ToString().Split(',');
                        for (int i = 0; i < dd.Length; i++)
                        {
                            if (!string.IsNullOrEmpty(dd[i].Trim()))
                            {
                                bool have = false;
                                for (int g = 0; g < dtStation.Rows.Count; g++)
                                {
                                    if (dtStation.Rows[g]["Text"].ToString() == dd[i].Trim())
                                    {
                                        have = true;
                                        break;
                                    }
                                }
                                if (!have)
                                {
                                    DataRow dr1 = dtStation.NewRow();
                                    dr1["Text"]  = dd[i];
                                    dr1["Value"] = dd[i];
                                    dtStation.Rows.Add(dr1);
                                }
                            }
                        }
                    }
                    dtStation.DefaultView.Sort = "Text ASC";
                    StoreStation.DataSource    = dtStation.DefaultView.ToTable();
                    StoreStation.DataBind();
                    cbxStation.Text = Request.Cookies.Get("eReimStation").Value.ToString();

                    //获取站点文件后缀列表
                    RefreshList(Request.Cookies.Get("eReimStation").Value.ToString());
                    //string getpostfix = "select * from FileRule where StationCode='" + Request.Cookies.Get("eReimStation").Value.ToString() + "'";
                    //DataTable dtPostfix = dbc.GetData("eReimbursement", getpostfix);
                    //dtPostfix.Columns.Add("Allow1");
                    //for (int i = 0; i < dtPostfix.Rows.Count; i++)
                    //{
                    //    dtPostfix.Rows[i]["Allow1"] = dtPostfix.Rows[i]["Allow"].ToString() == "0" ? "NO" : "YES";
                    //}
                    //StoreCCList.DataSource = dtPostfix;
                    //StoreCCList.DataBind();

                    //string sql = "select MailList as Email from MailSetting where UserID='" + Request.Cookies.Get("eReimUserID").Value + "' and MailList!=''";
                    //DataTable dtdetail = new DataTable();
                    //dtdetail = dbc.GetData("eReimbursement", sql);
                    //if (dtdetail != null && dtdetail.Rows.Count == 1)
                    //{
                    //    string[] mc = dtdetail.Rows[0]["Email"].ToString().Split(',');
                    //    DataTable dt = new DataTable();
                    //    dt.Columns.Add("Email");
                    //    for (int i = 0; i < mc.Length; i++)
                    //    {
                    //        DataRow dr = dt.NewRow();
                    //        dr["Email"] = mc[i];
                    //        dt.Rows.Add(dr);
                    //    }
                    //    StoreCCList.DataSource = dt;
                    //    StoreCCList.DataBind();
                    //}
                    //DataTable dt = new DataTable();
                    //dt.Columns.Add("Postfix");
                    //dt.Columns.Add("Station");
                    //DataRow dr = dt.NewRow();
                    //dr[0] = "xls";
                    //dr[1] = "ZJDTSN";
                    //dt.Rows.Add(dr);

                    //dr = dt.NewRow();
                    //dr[0] = "xlsx";
                    //dr[1] = "ZJDTSN";
                    //dt.Rows.Add(dr);

                    //dr = dt.NewRow();
                    //dr[0] = "doc";
                    //dr[1] = "ZJDTSN";
                    //dt.Rows.Add(dr);

                    //dr = dt.NewRow();
                    //dr[0] = "docx";
                    //dr[1] = "ZJDTSN";
                    //dt.Rows.Add(dr);

                    //dr = dt.NewRow();
                    //dr[0] = "zip";
                    //dr[1] = "ZJDTSN";
                    //dt.Rows.Add(dr);

                    //dr = dt.NewRow();
                    //dr[0] = "rar";
                    //dr[1] = "ZJDTSN";
                    //dt.Rows.Add(dr);

                    //dr = dt.NewRow();
                    //dr[0] = "txt";
                    //dr[1] = "ZJDTSN";
                    //dt.Rows.Add(dr);

                    //dr = dt.NewRow();
                    //dr[0] = "pdf";
                    //dr[1] = "ZJDTSN";
                    //dt.Rows.Add(dr);

                    //dr = dt.NewRow();
                    //dr[0] = "#exe";
                    //dr[1] = "ZJDTSN";
                    //dt.Rows.Add(dr);

                    //dr = dt.NewRow();
                    //dr[0] = "#";
                    //dr[1] = "ZJDTSN";
                    //dt.Rows.Add(dr);

                    //StoreCCList.DataSource = dt;
                    //StoreCCList.DataBind();
                }
            }
        }
Пример #44
0
        protected void btnExport_Click(object sender, EventArgs e)
        {
            XlsDocument xls = new XlsDocument();//新建一个xls文档
            xls.FileName = DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";

            string MainID = Request.QueryString["ID"].ToString();
            cs.DBCommand dbc = new cs.DBCommand();
            string sqlmain = "select * from ETravel where ID=" + MainID;
            DataTable dtMain = dbc.GetData("eReimbursement", sqlmain);
            if (dtMain.Rows.Count != 1)
            {
                ErrorHandle("Data Error.");
                return;
            }
            string sqlTocity = "select (ROW_NUMBER() OVER (ORDER BY Tocity)-1) % 4 AS SubRow,(ROW_NUMBER() OVER (ORDER BY Tocity) - 1) / 4 AS Row,Tocity from (select distinct Tocity from ETraveleDetail where [No]='" + MainID + "') t1";
            DataTable dtTocity = dbc.GetData("eReimbursement", sqlTocity);
            int pagecount = 0;
            for (int i = 0; i < dtTocity.Rows.Count; i++)
            {
                if (Convert.ToInt32(dtTocity.Rows[i]["Row"].ToString())>pagecount)
                {
                    pagecount = Convert.ToInt32(dtTocity.Rows[i]["Row"].ToString());
                }
            }
            for (int j = 0; j < pagecount + 1; j++)
            {
                Worksheet sheet;
                sheet = xls.Workbook.Worksheets.Add(DateTime.Now.ToString("yyyyMMddHHmmss" + j.ToString()));
                //首行空白行
                XF titleXF = xls.NewXF(); // 为xls生成一个XF实例,XF是单元格格式对象
                titleXF.HorizontalAlignment = HorizontalAlignments.Left; // 设定文字居中
                titleXF.VerticalAlignment = VerticalAlignments.Centered; // 垂直居中
                titleXF.UseBorder = false; // 使用边框
                titleXF.Font.Height = 12 * 20; // 字大小(字体大小是以 1/20 point 为单位的)
                //第二行
                XF titleXF1 = xls.NewXF(); // 为xls生成一个XF实例,XF是单元格格式对象
                titleXF1.HorizontalAlignment = HorizontalAlignments.Centered; // 设定文字居中
                titleXF1.VerticalAlignment = VerticalAlignments.Centered; // 垂直居中
                titleXF1.UseBorder = false; // 使用边框
                titleXF1.Font.Underline = UnderlineTypes.Single;
                titleXF1.Font.Height = 18 * 20;

                XF columnTitleXF41 = xls.NewXF();

                XF columnTitleXF42 = xls.NewXF();
                columnTitleXF42.HorizontalAlignment = HorizontalAlignments.Centered;
                columnTitleXF42.VerticalAlignment = VerticalAlignments.Centered;
                columnTitleXF42.Font.Height = 12 * 20;

                XF columnTitleXF43 = xls.NewXF();
                columnTitleXF43.HorizontalAlignment = HorizontalAlignments.Centered;
                columnTitleXF43.VerticalAlignment = VerticalAlignments.Centered;
                columnTitleXF43.Font.Height = 12 * 20;
                columnTitleXF43.UseBorder = true;
                columnTitleXF43.LeftLineStyle = 2;
                columnTitleXF43.TopLineStyle = 2;
                columnTitleXF43.RightLineStyle = 2;
                columnTitleXF43.BottomLineStyle = 2;

                XF columnTitleXF44 = xls.NewXF();
                columnTitleXF44.HorizontalAlignment = HorizontalAlignments.Centered;
                columnTitleXF44.VerticalAlignment = VerticalAlignments.Centered;
                columnTitleXF44.Font.Height = 12 * 20;
                columnTitleXF44.UseBorder = true;
                columnTitleXF44.TopLineStyle = 2;
                columnTitleXF44.BottomLineStyle = 2;

                XF columnTitleXF46 = xls.NewXF();
                columnTitleXF46.HorizontalAlignment = HorizontalAlignments.Centered;
                columnTitleXF46.VerticalAlignment = VerticalAlignments.Centered;
                columnTitleXF46.Font.Height = 12 * 20;
                columnTitleXF46.UseBorder = true;
                columnTitleXF46.TopLineStyle = 2;
                columnTitleXF46.BottomLineStyle = 2;
                columnTitleXF46.RightLineStyle = 2;

                XF columnTitleXF412 = xls.NewXF();
                columnTitleXF412.HorizontalAlignment = HorizontalAlignments.Centered;
                columnTitleXF412.VerticalAlignment = VerticalAlignments.Centered;
                columnTitleXF412.Font.Height = 12 * 20;
                columnTitleXF412.UseBorder = true;
                columnTitleXF412.TopLineStyle = 2;
                columnTitleXF412.BottomLineStyle = 2;
                columnTitleXF412.RightLineStyle = 2;

                XF columnTitleXF62 = xls.NewXF();
                columnTitleXF62.HorizontalAlignment = HorizontalAlignments.Centered;
                columnTitleXF62.VerticalAlignment = VerticalAlignments.Centered;
                columnTitleXF62.Font.Height = 10 * 20;
                columnTitleXF62.Font.Bold = true;
                columnTitleXF62.UseBorder = true;
                columnTitleXF62.LeftLineStyle = 2;
                columnTitleXF62.TopLineStyle = 2;
                columnTitleXF62.RightLineStyle = 2;
                columnTitleXF62.BottomLineStyle = 2;

                XF columnTitleXF63 = xls.NewXF();
                columnTitleXF63.HorizontalAlignment = HorizontalAlignments.Centered;
                columnTitleXF63.VerticalAlignment = VerticalAlignments.Centered;
                columnTitleXF63.Font.Height = 10 * 20;
                columnTitleXF63.UseBorder = true;
                columnTitleXF63.TopLineStyle = 2;
                columnTitleXF63.LeftLineStyle = 1;

                XF columnTitleXF64 = xls.NewXF();
                columnTitleXF64.HorizontalAlignment = HorizontalAlignments.Centered;
                columnTitleXF64.VerticalAlignment = VerticalAlignments.Centered;
                columnTitleXF64.Font.Height = 10 * 20;
                columnTitleXF64.UseBorder = true;
                columnTitleXF64.TopLineStyle = 2;
                columnTitleXF64.RightLineStyle = 1;

                XF columnTitleXF66 = xls.NewXF();
                columnTitleXF66.HorizontalAlignment = HorizontalAlignments.Centered;
                columnTitleXF66.VerticalAlignment = VerticalAlignments.Centered;
                columnTitleXF66.Font.Height = 10 * 20;
                columnTitleXF66.UseBorder = true;
                columnTitleXF66.TopLineStyle = 2;

                XF columnTitleXF67 = xls.NewXF();
                columnTitleXF67.HorizontalAlignment = HorizontalAlignments.Centered;
                columnTitleXF67.VerticalAlignment = VerticalAlignments.Centered;
                columnTitleXF67.Font.Height = 10 * 20;
                columnTitleXF67.Font.Bold = true;
                columnTitleXF67.UseBorder = true;
                columnTitleXF67.LeftLineStyle = 2;
                columnTitleXF67.TopLineStyle = 2;
                columnTitleXF67.BottomLineStyle = 1;

                XF columnTitleXF68 = xls.NewXF();
                columnTitleXF68.HorizontalAlignment = HorizontalAlignments.Centered;
                columnTitleXF68.VerticalAlignment = VerticalAlignments.Centered;
                columnTitleXF68.Font.Height = 10 * 20;
                columnTitleXF68.UseBorder = true;
                columnTitleXF68.TopLineStyle = 2;
                columnTitleXF68.RightLineStyle = 2;

                XF columnTitleXF72 = xls.NewXF();
                columnTitleXF72.HorizontalAlignment = HorizontalAlignments.Centered;
                columnTitleXF72.VerticalAlignment = VerticalAlignments.Centered;
                columnTitleXF72.Font.Height = 10 * 20;
                columnTitleXF72.Font.Bold = true;
                columnTitleXF72.UseBorder = true;
                columnTitleXF72.LeftLineStyle = 2;
                columnTitleXF72.RightLineStyle = 2;
                columnTitleXF72.BottomLineStyle = 2;

                XF columnTitleXF73 = xls.NewXF();
                columnTitleXF73.HorizontalAlignment = HorizontalAlignments.Centered;
                columnTitleXF73.VerticalAlignment = VerticalAlignments.Centered;
                columnTitleXF73.Font.Height = 10 * 20;
                columnTitleXF73.UseBorder = true;
                columnTitleXF73.LeftLineStyle = 1;
                columnTitleXF73.TopLineStyle = 1;
                columnTitleXF73.RightLineStyle = 1;
                columnTitleXF73.BottomLineStyle = 2;

                XF columnTitleXF77 = xls.NewXF();
                columnTitleXF77.HorizontalAlignment = HorizontalAlignments.Centered;
                columnTitleXF77.VerticalAlignment = VerticalAlignments.Centered;
                columnTitleXF77.Font.Height = 10 * 20;
                columnTitleXF77.Font.Bold = true;
                columnTitleXF77.UseBorder = true;
                columnTitleXF77.LeftLineStyle = 2;
                columnTitleXF77.TopLineStyle = 1;
                columnTitleXF77.RightLineStyle = 1;
                columnTitleXF77.BottomLineStyle = 2;

                XF columnTitleXF78 = xls.NewXF();
                columnTitleXF78.HorizontalAlignment = HorizontalAlignments.Centered;
                columnTitleXF78.VerticalAlignment = VerticalAlignments.Centered;
                columnTitleXF78.Font.Height = 10 * 20;
                columnTitleXF78.Font.Bold = true;
                columnTitleXF78.UseBorder = true;
                columnTitleXF78.TopLineStyle = 1;
                columnTitleXF78.RightLineStyle = 2;
                columnTitleXF78.BottomLineStyle = 2;

                XF columnTitleXF82 = xls.NewXF();
                columnTitleXF82.HorizontalAlignment = HorizontalAlignments.Left;
                columnTitleXF82.VerticalAlignment = VerticalAlignments.Centered;
                columnTitleXF82.Font.Height = 10 * 20;
                columnTitleXF82.UseBorder = true;
                columnTitleXF82.LeftLineStyle = 2;
                columnTitleXF82.TopLineStyle = 2;
                columnTitleXF82.RightLineStyle = 2;
                columnTitleXF82.BottomLineStyle = 1;

                XF columnTitleXF83 = xls.NewXF();
                columnTitleXF83.HorizontalAlignment = HorizontalAlignments.Right;
                columnTitleXF83.VerticalAlignment = VerticalAlignments.Centered;
                columnTitleXF83.Font.Height = 10 * 20;
                columnTitleXF83.UseBorder = true;
                columnTitleXF83.LeftLineStyle = 1;
                columnTitleXF83.TopLineStyle = 1;
                columnTitleXF83.RightLineStyle = 1;
                columnTitleXF83.BottomLineStyle = 1;

                XF columnTitleXF812 = xls.NewXF();
                columnTitleXF812.HorizontalAlignment = HorizontalAlignments.Right;
                columnTitleXF812.VerticalAlignment = VerticalAlignments.Centered;
                columnTitleXF812.Font.Height = 10 * 20;
                columnTitleXF812.UseBorder = true;
                columnTitleXF812.LeftLineStyle = 1;
                columnTitleXF812.TopLineStyle = 1;
                columnTitleXF812.RightLineStyle = 2;
                columnTitleXF812.BottomLineStyle = 1;

                XF columnTitleXF92 = xls.NewXF();
                columnTitleXF92.HorizontalAlignment = HorizontalAlignments.Left;
                columnTitleXF92.VerticalAlignment = VerticalAlignments.Centered;
                columnTitleXF92.Font.Height = 10 * 20;
                columnTitleXF92.UseBorder = true;
                columnTitleXF92.LeftLineStyle = 2;
                columnTitleXF92.TopLineStyle = 1;
                columnTitleXF92.RightLineStyle = 2;
                columnTitleXF92.BottomLineStyle = 1;

                XF columnTitleXF93 = xls.NewXF();
                columnTitleXF93.HorizontalAlignment = HorizontalAlignments.Left;
                columnTitleXF93.VerticalAlignment = VerticalAlignments.Centered;
                columnTitleXF93.Font.Height = 10 * 20;
                columnTitleXF93.UseBorder = true;
                columnTitleXF93.LeftLineStyle = 1;
                columnTitleXF93.TopLineStyle = 1;

                XF columnTitleXF192 = xls.NewXF();
                columnTitleXF192.HorizontalAlignment = HorizontalAlignments.Left;
                columnTitleXF192.VerticalAlignment = VerticalAlignments.Centered;
                columnTitleXF192.Font.Height = 10 * 20;
                columnTitleXF192.UseBorder = true;
                columnTitleXF192.LeftLineStyle = 2;
                columnTitleXF192.TopLineStyle = 1;
                columnTitleXF192.RightLineStyle = 2;
                columnTitleXF192.BottomLineStyle = 2;

                XF columnTitleXF202 = xls.NewXF();
                columnTitleXF202.HorizontalAlignment = HorizontalAlignments.Left;
                columnTitleXF202.VerticalAlignment = VerticalAlignments.Centered;
                columnTitleXF202.Font.Height = 10 * 20;
                columnTitleXF202.UseBorder = true;
                columnTitleXF202.LeftLineStyle = 2;
                columnTitleXF202.TopLineStyle = 2;

                XF columnTitleXF208 = xls.NewXF();
                columnTitleXF208.HorizontalAlignment = HorizontalAlignments.Centered;
                columnTitleXF208.VerticalAlignment = VerticalAlignments.Centered;
                columnTitleXF208.Font.Height = 10 * 20;
                columnTitleXF208.UseBorder = true;
                columnTitleXF208.LeftLineStyle = 1;

                XF columnTitleXF215 = xls.NewXF();
                columnTitleXF215.HorizontalAlignment = HorizontalAlignments.Left;
                columnTitleXF215.VerticalAlignment = VerticalAlignments.Centered;
                columnTitleXF215.Font.Height = 10 * 20;
                columnTitleXF215.UseBorder = true;
                columnTitleXF215.LeftLineStyle = 1;

                // 列标题行
                ColumnInfo col1 = new ColumnInfo(xls, sheet); // 列对象
                col1.ColumnIndexStart = 0; // 起始列为第1列,索引从0开始
                col1.ColumnIndexEnd = 0; // 终止列为第1列,索引从0开始
                col1.Width = 256; // 列的宽度计量单位为 1/256 字符宽
                sheet.AddColumnInfo(col1); // 把格式附加到sheet页上

                ColumnInfo col2 = new ColumnInfo(xls, sheet);
                col2 = new ColumnInfo(xls, sheet); // 列对象
                col2.ColumnIndexStart = 1;
                col2.ColumnIndexEnd = 1;
                col2.Width = 7680;
                sheet.AddColumnInfo(col2);

                ColumnInfo col3 = new ColumnInfo(xls, sheet);
                col3 = new ColumnInfo(xls, sheet); // 列对象
                col3.ColumnIndexStart = 2;
                col3.ColumnIndexEnd = 9;
                col3.Width = 1800;
                sheet.AddColumnInfo(col3);

                ColumnInfo col4 = new ColumnInfo(xls, sheet);
                col4 = new ColumnInfo(xls, sheet); // 列对象
                col4.ColumnIndexStart = 10;
                col4.ColumnIndexEnd = 11;
                col4.Width = 3900;
                sheet.AddColumnInfo(col4);

                //行
                RowInfo rol1 = new RowInfo();
                rol1.RowHeight = 10 * 20;
                rol1.RowIndexStart = 1;
                rol1.RowIndexEnd = 1;
                sheet.AddRowInfo(rol1);

                rol1 = new RowInfo();
                rol1.RowHeight = 20 * 20;
                rol1.RowIndexStart = 2;
                rol1.RowIndexEnd = 2;
                sheet.AddRowInfo(rol1);

                rol1 = new RowInfo();
                rol1.RowHeight = 5 * 20;
                rol1.RowIndexStart = 3;
                rol1.RowIndexEnd = 3;
                sheet.AddRowInfo(rol1);

                rol1 = new RowInfo();
                rol1.RowHeight = 5 * 20;
                rol1.RowIndexStart = 5;
                rol1.RowIndexEnd = 5;
                sheet.AddRowInfo(rol1);

                rol1 = new RowInfo();
                rol1.RowHeight = 18 * 20;
                rol1.RowIndexStart = 6;
                rol1.RowIndexEnd = 23;
                sheet.AddRowInfo(rol1);

                // 数据单元格样式
                XF dataXF = xls.NewXF(); // 为xls生成一个XF实例,XF是单元格格式对象
                dataXF.HorizontalAlignment = HorizontalAlignments.Centered; // 设定文字居中
                dataXF.VerticalAlignment = VerticalAlignments.Centered; // 垂直居中
                dataXF.UseBorder = true; // 使用边框
                dataXF.LeftLineStyle = 1; // 左边框样式
                dataXF.LeftLineColor = Colors.Black; // 左边框颜色
                dataXF.BottomLineStyle = 1;  // 下边框样式
                dataXF.BottomLineColor = Colors.Black;  // 下边框颜色
                dataXF.Font.FontName = "宋体";
                dataXF.Font.Height = 9 * 20; // 设定字大小(字体大小是以 1/20 point 为单位的)
                dataXF.UseProtection = false; // 默认的就是受保护的,导出后需要启用编辑才可修改
                dataXF.TextWrapRight = true; // 自动换行

                // 合并单元格
                MergeArea titleArea = new MergeArea(1, 1, 1, 12);
                sheet.AddMergeArea(titleArea);
                titleArea = new MergeArea(2, 2, 1, 12);
                sheet.AddMergeArea(titleArea);
                titleArea = new MergeArea(3, 3, 1, 12);
                sheet.AddMergeArea(titleArea);
                titleArea = new MergeArea(4, 4, 3, 6);
                sheet.AddMergeArea(titleArea);
                titleArea = new MergeArea(4, 4, 7, 10);
                sheet.AddMergeArea(titleArea);
                titleArea = new MergeArea(4, 4, 11, 12);
                sheet.AddMergeArea(titleArea);
                titleArea = new MergeArea(6, 6, 11, 12);
                sheet.AddMergeArea(titleArea);
                titleArea = new MergeArea(6, 6, 3, 4);
                sheet.AddMergeArea(titleArea);
                titleArea = new MergeArea(6, 6, 5, 6);
                sheet.AddMergeArea(titleArea);
                titleArea = new MergeArea(6, 6, 7, 8);
                sheet.AddMergeArea(titleArea);
                titleArea = new MergeArea(6, 6, 9, 10);
                sheet.AddMergeArea(titleArea);
                titleArea = new MergeArea(6, 7, 2, 2);
                sheet.AddMergeArea(titleArea);
                // 开始填充数据到单元格
                org.in2bits.MyXls.Cells cells = sheet.Cells;
                cells.Add(1, 1, "", titleXF);
                cells.Add(2, 1, "Travel Expense Report", titleXF1);
                cells.Add(3, 1, "", titleXF);
                cells.Add(4, 1, "", columnTitleXF41);
                cells.Add(4, 2, "Applicant:", columnTitleXF42);
                cells.Add(4, 3, dtMain.Rows[0]["Person"].ToString(), columnTitleXF43);
                cells.Add(4, 4, "", columnTitleXF44);
                cells.Add(4, 5, "", columnTitleXF44);
                cells.Add(4, 6, "", columnTitleXF46);

                cells.Add(4, 7, "Travel Period:", columnTitleXF42);
                string bb = "";
                if (dtMain.Rows[0]["Bdate"].ToString()!="")
                {
                    bb += Convert.ToDateTime(dtMain.Rows[0]["Bdate"].ToString()).ToString("yyyy/MM/dd");
                }
                if (dtMain.Rows[0]["Edate"].ToString() != "")
                {
                    bb += " - " + Convert.ToDateTime(dtMain.Rows[0]["Edate"].ToString()).ToString("yyyy/MM/dd");
                }
                cells.Add(4, 11, bb, columnTitleXF43);
                cells.Add(4, 12, "", columnTitleXF412);
                cells.Add(5, 1, "", columnTitleXF41);
                cells.Add(6, 1, "", columnTitleXF41);
                cells.Add(6, 2, "Travel Destination", columnTitleXF62);
                cells.Add(6, 3, "", columnTitleXF63);
                cells.Add(6, 4, "", columnTitleXF64);
                cells.Add(6, 5, "", columnTitleXF63);
                cells.Add(6, 6, "", columnTitleXF64);
                cells.Add(6, 7, "", columnTitleXF63);
                cells.Add(6, 8, "", columnTitleXF64);
                cells.Add(6, 9, "", columnTitleXF63);
                cells.Add(6, 10, "", columnTitleXF64);
                cells.Add(6, 11, "Total Expenses", columnTitleXF67);
                cells.Add(6, 12, "", columnTitleXF68);
                cells.Add(7, 1, "", columnTitleXF41);
                cells.Add(7, 2, "", columnTitleXF72);
                cells.Add(7, 3, "", columnTitleXF73);
                cells.Add(7, 4, "", columnTitleXF73);
                cells.Add(7, 5, "", columnTitleXF73);
                cells.Add(7, 6, "", columnTitleXF73);
                cells.Add(7, 7, "", columnTitleXF73);
                cells.Add(7, 8, "", columnTitleXF73);
                cells.Add(7, 9, "", columnTitleXF73);
                cells.Add(7, 10, "", columnTitleXF73);
                cells.Add(7, 11, "Reimbursement", columnTitleXF77);
                cells.Add(7, 12, "Company Paid", columnTitleXF78);
                cells.Add(8, 1, "", columnTitleXF41);
                cells.Add(8, 2, "1. Air Ticket - Int'l", columnTitleXF82);
                cells.Add(9, 1, "", columnTitleXF41);
                cells.Add(9, 2, "Domestic", columnTitleXF92);
                cells.Add(10, 1, "", columnTitleXF41);
                cells.Add(10, 2, "2. Hotel Bill", columnTitleXF92);
                cells.Add(11, 1, "", columnTitleXF41);
                cells.Add(11, 2, "3. Meals", columnTitleXF92);
                cells.Add(12, 1, "", columnTitleXF41);
                cells.Add(12, 2, "4. Entertainment", columnTitleXF92);
                cells.Add(13, 1, "", columnTitleXF41);
                cells.Add(13, 2, "5. Car Rental/Transportation", columnTitleXF92);
                cells.Add(14, 1, "", columnTitleXF41);
                cells.Add(14, 2, "6. Communication", columnTitleXF92);
                cells.Add(15, 1, "", columnTitleXF41);
                cells.Add(15, 2, "7. Local Trip NTD800(CNY60)/day", columnTitleXF92);
                cells.Add(16, 1, "", columnTitleXF41);
                cells.Add(16, 2, "8. Overseas Trip USD15/day", columnTitleXF92);
                cells.Add(17, 1, "", columnTitleXF41);
                cells.Add(17, 2, "9. Airport Tax/Travel Insurance", columnTitleXF92);
                cells.Add(18, 1, "", columnTitleXF41);
                cells.Add(18, 2, "10. Others", columnTitleXF92);
                cells.Add(19, 1, "", columnTitleXF41);
                cells.Add(19, 2, "Total", columnTitleXF192);
                cells.Add(20, 1, "", columnTitleXF41);
                cells.Add(20, 2, "Remarks:          USD: NTD =", columnTitleXF202);
                cells.Add(20, 12, "Total Trip Expense", columnTitleXF208);
                cells.Add(21, 7, "Less: Advance", columnTitleXF215);
                cells.Add(22, 7, "Bal Due to Company", columnTitleXF215);
                cells.Add(23, 7, "Bal. Due to Employee", columnTitleXF215);
                for (int i = 0; i < 12; i++)
                {
                    for (int ii = 0; ii < 9; ii++)
                    {
                        cells.Add(8 + i, 3 + ii, "", columnTitleXF83);
                    }
                }
                for (int i = 0; i < 12; i++)
                {
                    cells.Add(8 + i, 12, "", columnTitleXF812);
                }
                string sqlDetail = "select * from ETraveleDetail where [No]='" + MainID + "'";
                DataTable dtDetail = dbc.GetData("eReimbursement", sqlDetail);
                decimal row1TC = 0M;
                decimal row1TP = 0M;
                decimal row2TC = 0M;
                decimal row2TP = 0M;
                decimal row3TC = 0M;
                decimal row3TP = 0M;
                decimal row4TC = 0M;
                decimal row4TP = 0M;

                decimal row5TC = 0M;
                decimal row5TP = 0M;
                decimal row6TC = 0M;
                decimal row6TP = 0M;
                decimal row7TC = 0M;
                decimal row7TP = 0M;
                decimal row8TC = 0M;
                decimal row8TP = 0M;
                decimal row9TC = 0M;
                decimal row9TP = 0M;
                decimal row10TC = 0M;
                decimal row10TP = 0M;
                decimal row11TC = 0M;
                decimal row11TP = 0M;
                for (int p = 0; p < dtTocity.Rows.Count; p++)
                {
                    if (Convert.ToInt32(dtTocity.Rows[p]["Row"].ToString()) == j)
                    {
                        decimal row1Pamount = 0M;
                        decimal row1Camount = 0M;
                        decimal row2Pamount = 0M;
                        decimal row2Camount = 0M;
                        decimal row3Pamount = 0M;
                        decimal row3Camount = 0M;
                        decimal row4Pamount = 0M;
                        decimal row4Camount = 0M;

                        decimal row5Pamount = 0M;
                        decimal row5Camount = 0M;
                        decimal row6Pamount = 0M;
                        decimal row6Camount = 0M;
                        decimal row7Pamount = 0M;
                        decimal row7Camount = 0M;
                        decimal row8Pamount = 0M;
                        decimal row8Camount = 0M;
                        decimal row9Pamount = 0M;
                        decimal row9Camount = 0M;
                        decimal row10Pamount = 0M;
                        decimal row10Camount = 0M;
                        decimal row11Pamount = 0M;
                        decimal row11Camount = 0M;


                        decimal column0TC = 0M;
                        decimal column1TP = 0M;
                        
                        for (int i = 0; i < dtDetail.Rows.Count; i++)
                        {
                            if (dtDetail.Rows[i]["Tocity"].ToString() == dtTocity.Rows[p]["Tocity"].ToString())
                            {
                                if (dtDetail.Rows[i]["AccountCode"].ToString() == "62012023")//Air Ticket - Int'l
                                {
                                    row1Pamount += dtDetail.Rows[i]["Pamount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Pamount"].ToString());
                                    row1Camount += dtDetail.Rows[i]["Camount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Camount"].ToString());

                                    row1TC += dtDetail.Rows[i]["Pamount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Pamount"].ToString());
                                    row1TP += dtDetail.Rows[i]["Camount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Camount"].ToString());
                                }
                                else if (dtDetail.Rows[i]["AccountCode"].ToString() == "62012011" || dtDetail.Rows[i]["AccountCode"].ToString() == "62012021")//Hotel Bill
                                {
                                    row3Pamount += dtDetail.Rows[i]["Pamount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Pamount"].ToString());
                                    row3Camount += dtDetail.Rows[i]["Camount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Camount"].ToString());

                                    row3TC += dtDetail.Rows[i]["Pamount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Pamount"].ToString());
                                    row3TP += dtDetail.Rows[i]["Camount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Camount"].ToString());
                                }
                                else if (dtDetail.Rows[i]["AccountCode"].ToString() == "62010901" || dtDetail.Rows[i]["AccountCode"].ToString() == "62010910" || dtDetail.Rows[i]["AccountCode"].ToString() == "62010920")//Enter
                                {
                                    row5Pamount += dtDetail.Rows[i]["Pamount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Pamount"].ToString());
                                    row5Camount += dtDetail.Rows[i]["Camount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Camount"].ToString());

                                    row5TC += dtDetail.Rows[i]["Pamount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Pamount"].ToString());
                                    row5TP += dtDetail.Rows[i]["Camount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Camount"].ToString());
                                }
                                else if (dtDetail.Rows[i]["AccountCode"].ToString() == "62011901" || dtDetail.Rows[i]["AccountCode"].ToString() == "62011910" || dtDetail.Rows[i]["AccountCode"].ToString() == "62011920" || dtDetail.Rows[i]["AccountCode"].ToString() == "62011930" || dtDetail.Rows[i]["AccountCode"].ToString() == "62011940" || dtDetail.Rows[i]["AccountCode"].ToString() == "62012013")//Car
                                {
                                    row6Pamount += dtDetail.Rows[i]["Pamount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Pamount"].ToString());
                                    row6Camount += dtDetail.Rows[i]["Camount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Camount"].ToString());

                                    row6TC += dtDetail.Rows[i]["Pamount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Pamount"].ToString());
                                    row6TP += dtDetail.Rows[i]["Camount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Camount"].ToString());
                                }
                                else if (dtDetail.Rows[i]["AccountCode"].ToString() == "62010501" || dtDetail.Rows[i]["AccountCode"].ToString() == "62010510" || dtDetail.Rows[i]["AccountCode"].ToString() == "62010520" || dtDetail.Rows[i]["AccountCode"].ToString() == "62010530" || dtDetail.Rows[i]["AccountCode"].ToString() == "62010540" || dtDetail.Rows[i]["AccountCode"].ToString() == "62010550" || dtDetail.Rows[i]["AccountCode"].ToString() == "62010560")//Commu
                                {
                                    row7Pamount += dtDetail.Rows[i]["Pamount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Pamount"].ToString());
                                    row6Camount += dtDetail.Rows[i]["Camount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Camount"].ToString());

                                    row7TC += dtDetail.Rows[i]["Pamount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Pamount"].ToString());
                                    row7TP += dtDetail.Rows[i]["Camount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Camount"].ToString());
                                }
                                else if (dtDetail.Rows[i]["AccountCode"].ToString() == "62012012")//Local
                                {
                                    row8Pamount += dtDetail.Rows[i]["Pamount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Pamount"].ToString());
                                    row8Camount += dtDetail.Rows[i]["Camount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Camount"].ToString());

                                    row8TC += dtDetail.Rows[i]["Pamount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Pamount"].ToString());
                                    row8TP += dtDetail.Rows[i]["Camount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Camount"].ToString());
                                }
                                else if (dtDetail.Rows[i]["AccountCode"].ToString() == "62012022")//Oversea
                                {
                                    row9Pamount += dtDetail.Rows[i]["Pamount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Pamount"].ToString());
                                    row9Camount += dtDetail.Rows[i]["Camount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Camount"].ToString());

                                    row9TC += dtDetail.Rows[i]["Pamount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Pamount"].ToString());
                                    row9TP += dtDetail.Rows[i]["Camount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Camount"].ToString());
                                }
                                else if (dtDetail.Rows[i]["AccountCode"].ToString() == "62020630")//Airport
                                {
                                    row10Pamount += dtDetail.Rows[i]["Pamount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Pamount"].ToString());
                                    row10Camount += dtDetail.Rows[i]["Camount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Camount"].ToString());

                                    row10TC += dtDetail.Rows[i]["Pamount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Pamount"].ToString());
                                    row10TP += dtDetail.Rows[i]["Camount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Camount"].ToString());
                                }
                                else if (dtDetail.Rows[i]["AccountCode"].ToString() == "62012014" || dtDetail.Rows[i]["AccountCode"].ToString() == "62012024")//Others
                                {
                                    row11Pamount += dtDetail.Rows[i]["Pamount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Pamount"].ToString());
                                    row11Camount += dtDetail.Rows[i]["Camount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Camount"].ToString());

                                    row11TC += dtDetail.Rows[i]["Pamount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Pamount"].ToString());
                                    row11TP += dtDetail.Rows[i]["Camount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Camount"].ToString());
                                }
                                else
                                {
                                    row11Pamount += dtDetail.Rows[i]["Pamount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Pamount"].ToString());
                                    row11Camount += dtDetail.Rows[i]["Camount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Camount"].ToString());

                                    row11TC += dtDetail.Rows[i]["Pamount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Pamount"].ToString());
                                    row11TP += dtDetail.Rows[i]["Camount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Camount"].ToString());
                                }
                                column0TC += dtDetail.Rows[i]["Pamount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Pamount"].ToString());
                                column1TP += dtDetail.Rows[i]["Camount"].ToString() == "" ? 0 : Convert.ToDecimal(dtDetail.Rows[i]["Camount"].ToString());
                            }
                        }

                        cells.Add(6, Convert.ToInt32(dtTocity.Rows[p]["SubRow"].ToString()) * 2 + 3, dtTocity.Rows[p]["Tocity"].ToString(), columnTitleXF63);
                        cells.Add(7, Convert.ToInt32(dtTocity.Rows[p]["SubRow"].ToString()) * 2 + 3, "Reim", columnTitleXF73);
                        cells.Add(7, Convert.ToInt32(dtTocity.Rows[p]["SubRow"].ToString()) * 2 + 4, "Comp", columnTitleXF73);
                        if (row1Pamount != 0M)
                        {
                            cells.Add(8, Convert.ToInt32(dtTocity.Rows[p]["SubRow"].ToString()) * 2 + 3, row1Pamount, columnTitleXF83);
                        }
                        if (row1Camount != 0M)
                        {
                            cells.Add(8, Convert.ToInt32(dtTocity.Rows[p]["SubRow"].ToString()) * 2 + 4, row1Camount, columnTitleXF83);
                        }
                        if (row2Pamount != 0M)
                        {
                            cells.Add(9, Convert.ToInt32(dtTocity.Rows[p]["SubRow"].ToString()) * 2 + 3, row2Pamount, columnTitleXF83);
                        }
                        if (row2Camount != 0M)
                        {
                            cells.Add(9, Convert.ToInt32(dtTocity.Rows[p]["SubRow"].ToString()) * 2 + 4, row2Camount, columnTitleXF83);
                        }
                        if (row3Pamount != 0M)
                        {
                            cells.Add(10, Convert.ToInt32(dtTocity.Rows[p]["SubRow"].ToString()) * 2 + 3, row3Pamount, columnTitleXF83);
                        }
                        if (row3Camount != 0M)
                        {
                            cells.Add(10, Convert.ToInt32(dtTocity.Rows[p]["SubRow"].ToString()) * 2 + 4, row3Camount, columnTitleXF83);
                        }
                        if (row4Pamount != 0M)
                        {
                            cells.Add(11, Convert.ToInt32(dtTocity.Rows[p]["SubRow"].ToString()) * 2 + 3, row4Pamount, columnTitleXF83);
                        }
                        if (row4Camount != 0M)
                        {
                            cells.Add(11, Convert.ToInt32(dtTocity.Rows[p]["SubRow"].ToString()) * 2 + 4, row4Camount, columnTitleXF83);
                        }
                        if (row5Pamount != 0M)
                        {
                            cells.Add(12, Convert.ToInt32(dtTocity.Rows[p]["SubRow"].ToString()) * 2 + 3, row5Pamount, columnTitleXF83);
                        }
                        if (row5Camount != 0M)
                        {
                            cells.Add(12, Convert.ToInt32(dtTocity.Rows[p]["SubRow"].ToString()) * 2 + 4, row5Camount, columnTitleXF83);
                        }
                        if (row6Pamount != 0M)
                        {
                            cells.Add(13, Convert.ToInt32(dtTocity.Rows[p]["SubRow"].ToString()) * 2 + 3, row6Pamount, columnTitleXF83);
                        }
                        if (row6Camount != 0M)
                        {
                            cells.Add(13, Convert.ToInt32(dtTocity.Rows[p]["SubRow"].ToString()) * 2 + 4, row6Camount, columnTitleXF83);
                        }
                        if (row7Pamount != 0M)
                        {
                            cells.Add(14, Convert.ToInt32(dtTocity.Rows[p]["SubRow"].ToString()) * 2 + 3, row7Pamount, columnTitleXF83);
                        }
                        if (row7Camount != 0M)
                        {
                            cells.Add(14, Convert.ToInt32(dtTocity.Rows[p]["SubRow"].ToString()) * 2 + 4, row7Camount, columnTitleXF83);
                        }
                        if (row8Pamount != 0M)
                        {
                            cells.Add(15, Convert.ToInt32(dtTocity.Rows[p]["SubRow"].ToString()) * 2 + 3, row8Pamount, columnTitleXF83);
                        }
                        if (row8Camount != 0M)
                        {
                            cells.Add(15, Convert.ToInt32(dtTocity.Rows[p]["SubRow"].ToString()) * 2 + 4, row8Camount, columnTitleXF83);
                        }
                        if (row9Pamount != 0M)
                        {
                            cells.Add(16, Convert.ToInt32(dtTocity.Rows[p]["SubRow"].ToString()) * 2 + 3, row9Pamount, columnTitleXF83);
                        }
                        if (row9Camount != 0M)
                        {
                            cells.Add(16, Convert.ToInt32(dtTocity.Rows[p]["SubRow"].ToString()) * 2 + 4, row9Camount, columnTitleXF83);
                        }
                        if (row10Pamount != 0M)
                        {
                            cells.Add(17, Convert.ToInt32(dtTocity.Rows[p]["SubRow"].ToString()) * 2 + 3, row10Pamount, columnTitleXF83);
                        }
                        if (row10Camount != 0M)
                        {
                            cells.Add(17, Convert.ToInt32(dtTocity.Rows[p]["SubRow"].ToString()) * 2 + 4, row10Camount, columnTitleXF83);
                        }
                        if (row11Pamount != 0M)
                        {
                            cells.Add(18, Convert.ToInt32(dtTocity.Rows[p]["SubRow"].ToString()) * 2 + 3, row11Pamount, columnTitleXF83);
                        }
                        if (row11Camount != 0M)
                        {
                            cells.Add(18, Convert.ToInt32(dtTocity.Rows[p]["SubRow"].ToString()) * 2 + 4, row11Camount, columnTitleXF83);
                        }

                        if (column0TC != 0M)
                        {
                            cells.Add(19, Convert.ToInt32(dtTocity.Rows[p]["SubRow"].ToString()) * 2 + 3, column0TC, columnTitleXF83);
                        }
                        if (column1TP != 0M)
                        {
                            cells.Add(19, Convert.ToInt32(dtTocity.Rows[p]["SubRow"].ToString()) * 2 + 4, column1TP, columnTitleXF83);
                        }
                    }
                }
                if (row1TC != 0M)
                {
                    cells.Add(8, 11, row1TC, columnTitleXF83);
                }
                if (row1TP != 0M)
                {
                    cells.Add(8, 12, row1TP, columnTitleXF812);
                }
                if (row2TC != 0M)
                {
                    cells.Add(9, 11, row2TC, columnTitleXF83);
                }
                if (row2TP != 0M)
                {
                    cells.Add(9, 12, row2TP, columnTitleXF812);
                }
                if (row3TC != 0M)
                {
                    cells.Add(10, 11, row3TC, columnTitleXF83);
                }
                if (row3TP != 0M)
                {
                    cells.Add(10, 12, row3TP, columnTitleXF812);
                }
                if (row4TC != 0M)
                {
                    cells.Add(11, 11, row4TC, columnTitleXF83);
                }
                if (row4TP != 0M)
                {
                    cells.Add(11, 12, row4TP, columnTitleXF812);
                }
                if (row5TC != 0M)
                {
                    cells.Add(12, 11, row5TC, columnTitleXF83);
                }
                if (row5TP != 0M)
                {
                    cells.Add(12, 12, row5TP, columnTitleXF812);
                }
                if (row6TC != 0M)
                {
                    cells.Add(13, 11, row6TC, columnTitleXF83);
                }
                if (row6TP != 0M)
                {
                    cells.Add(13, 12, row6TP, columnTitleXF812);
                }
                if (row7TC != 0M)
                {
                    cells.Add(14, 11, row7TC, columnTitleXF83);
                }
                if (row7TP != 0M)
                {
                    cells.Add(14, 12, row7TP, columnTitleXF812);
                }
                if (row8TC != 0M)
                {
                    cells.Add(15, 11, row8TC, columnTitleXF83);
                }
                if (row8TP != 0M)
                {
                    cells.Add(15, 12, row8TP, columnTitleXF812);
                }
                if (row9TC != 0M)
                {
                    cells.Add(16, 11, row9TC, columnTitleXF83);
                }
                if (row9TP != 0M)
                {
                    cells.Add(16, 12, row9TP, columnTitleXF812);
                }
                if (row10TC != 0M)
                {
                    cells.Add(17, 11, row10TC, columnTitleXF83);
                }
                if (row10TP != 0M)
                {
                    cells.Add(17, 12, row10TP, columnTitleXF812);
                }
                if (row11TC != 0M)
                {
                    cells.Add(18, 11, row11TC, columnTitleXF83);
                }
                if (row11TP != 0M)
                {
                    cells.Add(18, 12, row11TP, columnTitleXF812);
                }
                decimal tc = row1TC + row2TC + row3TC + row4TC + row5TC + row6TC + row7TC + row8TC + row9TC + row10TC + row11TC;
                if (tc!=0M)
                {
                    cells.Add(19, 11, tc, columnTitleXF83);
                }
                decimal tp = row1TP + row2TP + row3TP + row4TP + row5TP + row6TP + row7TP + row8TP + row9TP + row11TP;
                if (tp != 0M)
                {
                    cells.Add(19, 12, tp, columnTitleXF812);
                }
            }
            xls.Send();
        }
Пример #45
0
        protected void btnLogin_Click(object sender, DirectEventArgs e)
        {
            cs.DBCommand dbc  = new cs.DBCommand();
            DataSet      ds   = new DataSet();
            bool         user = DIMERCO.SDK.Utilities.ReSM.CheckUserInfo(tfUserID.Text.Trim(), tfPW.Text.Trim(), ref ds);

            if (ds.Tables[0].Rows.Count == 1)
            {
                DataTable dtuser = ds.Tables[0];
                Session["UserID"] = dtuser.Rows[0]["UserID"].ToString();
                if (Request.Cookies["eReimUserID"] != null)
                {
                    Response.Cookies["eReimUserID"].Value   = dtuser.Rows[0]["UserID"].ToString(); //将值写入到客户端硬盘Cookie
                    Response.Cookies["eReimUserID"].Expires = DateTime.Now.AddHours(12);           //设置Cookie过期时间
                }
                else
                {
                    HttpCookie cookie = new HttpCookie("eReimUserID", dtuser.Rows[0]["UserID"].ToString());
                    cookie.Expires = DateTime.Now.AddHours(12);
                    Response.Cookies.Add(cookie);
                }

                DataSet ds1 = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(dtuser.Rows[0]["UserID"].ToString());
                if (ds1.Tables[0].Rows.Count == 1)
                {
                    DataTable dt1 = ds1.Tables[0];
                    Session["UserName"]   = dt1.Rows[0]["fullName"].ToString();
                    Session["Station"]    = dt1.Rows[0]["stationCode"].ToString();
                    Session["Department"] = dt1.Rows[0]["CRPDepartmentName"].ToString();
                    Session["CostCenter"] = dt1.Rows[0]["CostCenter"].ToString();
                    if (Request.Cookies["eReimUserName"] != null)
                    {
                        Response.Cookies["eReimUserName"].Value   = dt1.Rows[0]["fullName"].ToString(); //将值写入到客户端硬盘Cookie
                        Response.Cookies["eReimUserName"].Expires = DateTime.Now.AddHours(12);          //设置Cookie过期时间
                    }
                    else
                    {
                        HttpCookie cookie = new HttpCookie("eReimUserName", dt1.Rows[0]["fullName"].ToString());
                        cookie.Expires = DateTime.Now.AddHours(12);
                        Response.Cookies.Add(cookie);
                    }
                    if (Request.Cookies["eReimStation"] != null)
                    {
                        Response.Cookies["eReimStation"].Value   = dt1.Rows[0]["stationCode"].ToString(); //将值写入到客户端硬盘Cookie
                        Response.Cookies["eReimStation"].Expires = DateTime.Now.AddHours(12);             //设置Cookie过期时间
                    }
                    else
                    {
                        HttpCookie cookie = new HttpCookie("eReimStation", dt1.Rows[0]["stationCode"].ToString());
                        cookie.Expires = DateTime.Now.AddHours(12);
                        Response.Cookies.Add(cookie);
                    }
                    if (Request.Cookies["eReimDepartment"] != null)
                    {
                        Response.Cookies["eReimDepartment"].Value   = dt1.Rows[0]["CRPDepartmentName"].ToString(); //将值写入到客户端硬盘Cookie
                        Response.Cookies["eReimDepartment"].Expires = DateTime.Now.AddHours(12);                   //设置Cookie过期时间
                    }
                    else
                    {
                        HttpCookie cookie = new HttpCookie("eReimDepartment", dt1.Rows[0]["CRPDepartmentName"].ToString());
                        cookie.Expires = DateTime.Now.AddHours(12);
                        Response.Cookies.Add(cookie);
                    }
                    if (Request.Cookies["eReimCostCenter"] != null)
                    {
                        Response.Cookies["eReimCostCenter"].Value   = dt1.Rows[0]["CostCenter"].ToString(); //将值写入到客户端硬盘Cookie
                        Response.Cookies["eReimCostCenter"].Expires = DateTime.Now.AddHours(12);            //设置Cookie过期时间
                    }
                    else
                    {
                        HttpCookie cookie = new HttpCookie("eReimCostCenter", dt1.Rows[0]["CostCenter"].ToString());
                        cookie.Expires = DateTime.Now.AddHours(12);
                        Response.Cookies.Add(cookie);
                    }

                    //DataTable dttemp = new DataTable();
                    //string sqltemp = "select * from ESUSER where Userid='" + dtuser.Rows[0]["UserID"].ToString() + "'";
                    //dttemp = dbc.GetData("eReimbursement", sqltemp);
                    //if (dttemp.Rows.Count > 0)
                    //{
                    //    //Session["CostCenter"] = dttemp.Rows[0]["Station"].ToString();
                    //    if (Request.Cookies["eReimCostCenter"] != null)
                    //    {
                    //        Response.Cookies["eReimCostCenter"].Value = dttemp.Rows[0][3].ToString();  //将值写入到客户端硬盘Cookie
                    //        Response.Cookies["eReimCostCenter"].Expires = DateTime.Now.AddHours(12);//设置Cookie过期时间
                    //    }
                    //    else
                    //    {
                    //        HttpCookie cookie = new HttpCookie("eReimCostCenter", dttemp.Rows[0]["Station"].ToString());
                    //        cookie.Expires = DateTime.Now.AddHours(12);
                    //        Response.Cookies.Add(cookie);
                    //    }
                    //}
                    X.AddScript("window.location.reload();");
                }
                else
                {
                    X.Msg.Alert("Message", "Data Error.").Show();
                    return;
                }
            }
            else
            {
                X.Msg.Alert("Message", "Please confirm your UserID and Password.").Show();
                return;
            }
            if (ds != null)
            {
                ds.Dispose();
            }
        }
Пример #46
0
        protected bool SaveDetail(string detailjson)
        {
            JavaScriptSerializer ser = new JavaScriptSerializer();
            List<DetailExpense> Details = ser.Deserialize<List<DetailExpense>>(detailjson);

            DateTime dtnull = new DateTime(1, 1, 1, 0, 0, 0);
            cs.DBCommand dbc = new cs.DBCommand();
            //删除现有数据
            string deletesql = "delete from ETraveleDetail where [No]='" + hdTravelRequestID.Value.ToString() + "'";
            string newid1 = dbc.UpdateData("eReimbursement", deletesql, "Update");
            foreach (DetailExpense detail in Details)
            {
                if (newid1 == "-1")
                {
                    ErrorHandle("Data Error.");
                    return false;
                }
                //新增
                string word = "[No],[Tocity],[AccountName],[AccountCode],[AccountDes],[Cur],[Pamount],[Camount],[TSation],[Createdby],[CreadedDate],[Tdate],[Department1]";
                string value = "";
                value += "'" + hdTravelRequestID.Value.ToString() + "',";
                value += "'" + detail.Tocity + "',";
                value += "'" + detail.AccountName + "',";
                value += "'" + detail.AccountCode + "',";
                value += "'" + detail.AccountDes.Replace("'", "''") + "',";
                value += "'" + detail.Cur + "',";
                value += detail.Pamount == "" ? "null," : detail.Pamount + ",";
                value += detail.Camount == "" ? "null," : detail.Camount + ",";
                value += "'" + detail.TSation + "',";
                value += "'" + cbxOwner.Value.ToString() + "',";//edit
                value += "'" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "',";
                value += detail.Tdate == "" ? "null" : "'" + detail.Tdate + "',";
                value += "'" + detail.Department1 + "'";

                string updatesql = "insert into ETraveleDetail (" + word + ") values(" + value + ");select [ID]=@@IDENTITY from ETraveleDetail";

                string newid = dbc.UpdateData("eReimbursement", updatesql, "Insert");
                if (newid == "-1")
                {
                    ErrorHandle("Data Error."); return false;
                }
            }
            return true;
        }