예제 #1
0
        private void errormailfuc(Exception ex)
        {
            DIMERCO.SDK.MailMsg mail = new DIMERCO.SDK.MailMsg();

            mail.FromDispName = "eReim";
            mail.From         = "*****@*****.**";
            mail.To           = ConfigurationManager.AppSettings["errormailto"];
            mail.Title        = "eReim Bug" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:dd");
            mail.Body         = ex.Message + "<br/>" + (ex.InnerException == null ? "" : ex.InnerException.ToString()) + "</div>";
            mail.Send();
        }
예제 #2
0
        public DataTable GetData(string sqlcon, string command)
        {
            try
            {
                string         sConnection = ConfigurationManager.ConnectionStrings[sqlcon].ConnectionString;
                DataSet        dsSet       = new DataSet();
                SqlDataAdapter sdaAdapter  = null;
                //SqlCommandBuilder scbBuilder = null;
                //建立Connection
                SqlConnection scConnection = new SqlConnection(sConnection);
                scConnection.Open();
                //建立Command
                SqlCommand scCommand = scConnection.CreateCommand();
                scCommand.CommandText = command;
                //建立Adapter
                sdaAdapter = new SqlDataAdapter(scCommand);

                //该对象负责生成用于更新数据库的SQL语句,不必自己创建这些语句
                //scbBuilder = new SqlCommandBuilder(sdaAdapter);

                //得到数据
                sdaAdapter.Fill(dsSet, "Request");
                sdaAdapter.Dispose();
                scCommand.Dispose();
                scConnection.Close();
                scConnection.Dispose();
                return(dsSet.Tables[0]);
            }
            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/></div>";
                mail.Send();
            }
            return(null);
        }
예제 #3
0
        protected void btnLogin_Click(object sender, DirectEventArgs e)
        {
            try
            {
                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][3].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();
                }
            }
            
            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();
            }
        }
예제 #4
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();
            }
        }
예제 #5
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);
            }
        }
예제 #6
0
        protected void btnLogin_Click(object sender, DirectEventArgs e)
        {
            try
            {
                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][3].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();
                }
            }

            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();
            }
        }
예제 #7
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();
            }
        }
예제 #8
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);
            }
        }
예제 #9
0
        public DataTable GetData(string sqlcon, string command)
        {
            try
            {
                string sConnection = ConfigurationManager.ConnectionStrings[sqlcon].ConnectionString;
                DataSet dsSet = new DataSet();
                SqlDataAdapter sdaAdapter = null;
                //SqlCommandBuilder scbBuilder = null;
                //建立Connection
                SqlConnection scConnection = new SqlConnection(sConnection);
                scConnection.Open();
                //建立Command
                SqlCommand scCommand = scConnection.CreateCommand();
                scCommand.CommandText = command;
                //建立Adapter
                sdaAdapter = new SqlDataAdapter(scCommand);

                //该对象负责生成用于更新数据库的SQL语句,不必自己创建这些语句
                //scbBuilder = new SqlCommandBuilder(sdaAdapter);

                //得到数据
                sdaAdapter.Fill(dsSet, "Request");
                sdaAdapter.Dispose();
                scCommand.Dispose();
                scConnection.Close();
                scConnection.Dispose();
                return dsSet.Tables[0];
            }
            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/></div>";
                mail.Send();
            }
            return null;
        }
예제 #10
0
        public string UpdateData(string sqlcon, string command, string type)
        {
            if (type == "Insert")
            {
                try
                {

                    string sConnection = ConfigurationManager.ConnectionStrings[sqlcon].ConnectionString;
                    DataSet dsSet = new DataSet();
                    SqlDataAdapter sdaAdapter = null;
                    SqlConnection scConnection = new SqlConnection(sConnection);
                    
                    SqlCommand scCommand = scConnection.CreateCommand();
                    scCommand.CommandText = command;
                    scConnection.Open();
                    sdaAdapter = new SqlDataAdapter(scCommand);
                    sdaAdapter.Fill(dsSet, "Request");
                    sdaAdapter.Dispose();
                    scCommand.Dispose();
                    scConnection.Close();
                    scConnection.Dispose();
                    return dsSet.Tables[0].Rows[0][0].ToString();
                }
                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 = "<div>SQL Command: " + command + "<br /><br />" + ex.Message + "</div>";
                    mail.Send();
                    return "-1";
                }

            }
            else if (type == "Update")
            {
                try
                {
                    string sConnection = ConfigurationManager.ConnectionStrings[sqlcon].ConnectionString;
                    DataSet dsSet = new DataSet();
                    SqlConnection scConnection = new SqlConnection(sConnection);
                    scConnection.Open();
                    SqlCommand scCommand = scConnection.CreateCommand();
                    scCommand.CommandText = command;
                    int row = scCommand.ExecuteNonQuery();
                    scCommand.Dispose();
                    scConnection.Close();
                    scConnection.Dispose();
                    return "1";
                }
                catch (Exception ex)
                {
                    DIMERCO.SDK.MailMsg mail = new DIMERCO.SDK.MailMsg();

                    mail.FromDispName = "eReimbursement Bug";
                    mail.From = "*****@*****.**";
                    mail.To = "*****@*****.**";
                    mail.Title = "eReimbursement Bug";
                    mail.Body = "<div>SQL Command: " + command + "<br /><br />" + ex.Message + "</div>";
                    mail.Send();
                    return "-1";
                }
            }
            return "0";
        }
예제 #11
0
        private void errormailfuc(Exception ex)
        {
            DIMERCO.SDK.MailMsg mail = new DIMERCO.SDK.MailMsg();

            mail.FromDispName = "eReim";
            mail.From = "*****@*****.**";
            mail.To = ConfigurationManager.AppSettings["errormailto"];
            mail.Title = "eReim Bug" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:dd");
            mail.Body = ex.Message + "<br/>" + (ex.InnerException == null ? "" : ex.InnerException.ToString()) + "</div>";
            mail.Send();
        }
예제 #12
0
        protected bool SendMail(string RequestID)
        {
            //发送提醒邮件
            cs.DBCommand dbc = new cs.DBCommand();
            string sql = "select * from V_Eflow_ETravel where [Type]='G' and Step!=0 and RequestID=" + RequestID + " 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><br />");
                //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=\"14\" " + tdstyle + ">Expense Detail</th></tr><tr>");
                sb.Append("<th " + tdstyle + "></th>");
                sb.Append("<th " + tdstyle + ">Type</th>");
                sb.Append("<th " + tdstyle + ">Date</th>");
                sb.Append("<th " + tdstyle + ">Expense Type</th>");
                sb.Append("<th " + tdstyle + ">Currency</th>");
                sb.Append("<th " + tdstyle + ">Amounts</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 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;
                string sqldetail = "select [StationBudget]='',[DepartmentBudget]='',[PersonBudget]='',[StationYTD]='',[DepartmentYTD]='',[PersonYTD]='',t3.EText,case when t1.Type='O' then t2.SAccountName else '' end as SAccountName,t1.* from EeommonDetail t1 left join AccoundCode t2 on t2.SAccountCode=t1.AccountCode left join (select * from Edic where KeyValue='SubType') t3 on t3.CValue=t1.[Type] where t1.[No]='" + RequestID + "'";
                //string sqldetail = "select 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 = "";
                    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 accountcode = "";
                    if (dtdetail.Rows[i]["Type"].ToString() == "O")
                    {
                        string newr = "select BAccountCode from AccoundCode where SAccountCode='" + dtdetail.Rows[i]["AccountCode"].ToString() + "'";
                        DataTable den = new DataTable();
                        den = dbc.GetData("eReimbursement", newr);
                        accountcode = den.Rows[0]["BAccountCode"].ToString();
                    }
                    else
                    {
                        accountcode = dtdetail.Rows[i]["AccountCode"].ToString();
                    }
                    string Years = "";
                    string month = "";

                    if (dtdetail.Rows[i]["Type"].ToString() == "C")
                    {
                        if (dtdetail.Rows[i]["EffectTime"].ToString() != "")
                        {
                            Years = Convert.ToDateTime(dtdetail.Rows[i]["EffectTime"].ToString()).Year.ToString();
                            month = Convert.ToDateTime(dtdetail.Rows[i]["EffectTime"].ToString()).Month.ToString();
                        }
                    }
                    else
                    {
                        if (dtdetail.Rows[i]["Tdate"].ToString() != "")
                        {

                            Years = Convert.ToDateTime(dtdetail.Rows[i]["Tdate"].ToString()).Year.ToString();
                            month = Convert.ToDateTime(dtdetail.Rows[i]["Tdate"].ToString()).Month.ToString();
                        }
                    }
                    if (Years != "" && month != "")
                    {
                        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 + ">" + dtdetail.Rows[i]["EText"].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]["Amount"].ToString() == "" ? "" : Convert.ToDecimal(dtdetail.Rows[i]["Amount"].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]["StationYTD"].ToString() + "</td>");
                    sb.Append("<td " + tdstyle + ">" + dtdetail.Rows[i]["DepartmentYTD"].ToString() + "</td>");
                    sb.Append("<td " + tdstyle + ">" + dtdetail.Rows[i]["PersonYTD"].ToString() + "</td></tr>");
                    ptotal += dtdetail.Rows[i]["Amount"].ToString() == "" ? 0 : Convert.ToDecimal(dtdetail.Rows[i]["Amount"].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 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://61.218.73.79:88/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;
        }
예제 #13
0
        protected bool SendMailNew(DataTable dtPar)
        {
            //发送提醒邮件
            cs.DBCommand dbc = new cs.DBCommand();
            string sql = "select * from V_Eflow_ETravel where [Type]='G' 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 if (dtMail.Rows[0]["FlowFn"].ToString().ToLower() == "confirm")
                {
                    msg = "Seek For Your Confirmation.";
                }
                else
                {
                    msg = "Seek For Your Approval.";
                }
                //string budget = dtMail.Rows[0]["Budget"].ToString() == "1" ? "(Budgeted)" : "(UnBudgeted)";
                //14/10/24
                string budget = "";
                if (dtMail.Rows[0]["Budget"].ToString() == "1")
                {
                    budget = "(Budgeted)";
                }
                else if (dtMail.Rows[0]["Budget"].ToString() == "0")
                {
                    budget = "(UnBudgeted)";
                }
                else if (dtMail.Rows[0]["Budget"].ToString() == "-1")
                {
                    budget = "(Over-Budgeted)";
                }
                else if (dtMail.Rows[0]["Budget"].ToString() == "-2")
                {
                    budget = "(UnBudgeted & Over-Budgeted)";
                }
                DIMERCO.SDK.MailMsg mail = new DIMERCO.SDK.MailMsg();
                
                //16090007E 
                if (dtMail.Rows[0]["OnBehalfPersonID"].ToString()!="")
                {
                    mail.Title = "Dimerco eReimbursement on behalf of " + dtMail.Rows[0]["OnBehalfPersonName"].ToString() + " " + budget + " " + dtMail.Rows[0]["Person"].ToString() + " - " + msg;
                }
                else
                {
                    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 != null && dsTo.Tables.Count >= 1 && dsTo.Tables[0].Rows.Count == 1)
                {
                    mailto += dsTo.Tables[0].Rows[0]["eMail"].ToString() + ",";
                }
                //else
                //{
                //    ErrorHandle("Error mail address."); return false;
                //}
                //DataSet dsCC1 = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList("A0001");
                //DataTable dt13 = dsCC1.Tables[0];
                string mailcc = "";
                DataSet dsCC = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(dtMail.Rows[0]["PersonID"].ToString());
                if (dsCC != null && dsCC.Tables.Count >= 1 && 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() + ",";
                    string mcc = dsCC.Tables[0].Rows[0]["eMail"].ToString().Trim();
                    if (mcc != "" && mailcc.ToLower().IndexOf(mcc) == -1)
                    {
                        mailcc += mcc + ",";
                    }
                }
                if (dtMail.Rows[0]["CCMailList"].ToString() != "")
                {
                    //mailcc += dtMail.Rows[0]["CCMailList"].ToString();
                    string mcc = dtMail.Rows[0]["CCMailList"].ToString().Trim();
                    string[] mcclist = mcc.Split(',');
                    for (int i = 0; i < mcclist.Length; i++)
                    {
                        if (mcclist[i] != "" && mailcc.ToLower().IndexOf(mcclist[i]) == -1)
                        {
                            mailcc += mcclist[i] + ",";
                        }
                    }
                }
                //固定抄送人
                string sqlmc = "select * from MailSetting where UserID='" + dtMail.Rows[0]["PersonID"].ToString() + "' and MailList!=''";
                DataTable dtmc = new DataTable();
                dtmc = dbc.GetData("eReimbursement", sqlmc);
                if (dtmc != null && dtmc.Rows.Count == 1)
                {
                    string mcc = dtmc.Rows[0]["MailList"].ToString().Trim();
                    string[] mcclist = mcc.Split(',');
                    for (int i = 0; i < mcclist.Length; i++)
                    {
                        if (mcclist[i] != "" && mailcc.ToLower().IndexOf(mcclist[i]) == -1)
                        {
                            mailcc += mcclist[i] + ",";
                        }
                    }
                }


                //160127 Shanshan提出邮件测试
                string mailtestword = "";
                mailtestword += "<br />Mail to: " + mailto + "<br />";
                mailtestword += "Mail CC: " + mailcc + "<br />";
                DataSet dsowner = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(dtMail.Rows[0]["PersonID"].ToString());
                if (dsowner != null && dsowner.Tables.Count >= 1 && dsowner.Tables[0].Rows.Count == 1)
                {
                    mail.To = dsowner.Tables[0].Rows[0]["eMail"].ToString();
                }
                //mail.To = mailto;
                //mail.Cc = mailcc;



                string divstyle = "style='font-size:small;'";
                string divstyleCurrent = "style='font-size:small;color:blue;'";
                string divstyleR = "style='font-size:small;color:red;'";
                string divstyleReject = "style='font-size:small;color:red;'";
                string divstylered = "style='border:silver 1px ridge; font-size:small;background-color: #FFFFFF;empty-cells:show;color:red;' width='110px' align='right'";
                string tdstyle = "style='border:silver 1px ridge; font-size:small;background-color: #FFFFFF;empty-cells:show;' width='110px'align='right'";
                StringBuilder sb = new StringBuilder();


                //160127 Shanshan提出邮件测试
                sb.Append("<div " + divstyleReject + ">THIS IS A TEST MAIL." + mailtestword + "</div><br />");
                sb.Append("<div>");



                sb.Append("<div " + divstyle + "> Dear " + dtMail.Rows[0]["Approver"].ToString() + ",</div><br />");
                //160115 垫付
                if (hdOnBehalf.Value == null || hdOnBehalf.Value.ToString() == "")
                {
                    sb.Append("<div " + divstyle + ">The following eReimbursement application: " + msg + "</div><br /><br />");
                }
                else
                {
                    sb.Append("<div " + divstyle + ">The following eReimbursement application on behalf of " + dtMail.Rows[0]["OnBehalfPersonUnit"].ToString() + " " + dtMail.Rows[0]["OnBehalfPersonName"].ToString() + ": " + msg + "</div><br /><br />");
                }

                sb.Append("<div " + divstyle + ">No#:" + dtMail.Rows[0]["No"].ToString() + budget + "</div>");
                //sb.Append("<div style='font-size:small;'><div style='float:left'>No#:" + dtMail.Rows[0]["No"].ToString() + "</div><a style='color:Red;'>" + budget + "</a></div>");
                //sb.Append("<div style='font-size:small;'><a>No#:" + dtMail.Rows[0]["No"].ToString() + "</a><a style='color:Red;'>" + budget + "</a></div>");
                //sb.Append("<div><table><tr style='font-size:small;'><td width='200px'>No#:" + dtMail.Rows[0]["No"].ToString() + "</td><td style='color:Red;'>" + budget + "</td></tr></table></div>");
                //sb.Append("<div><div style='font-size:small;float: left;'>No#:" + dtMail.Rows[0]["No"].ToString() + "</div><div style='font-size:small;color:red;'>" + budget + "</div></div>");
                sb.Append("<div " + divstyle + ">Applicant:" + dtMail.Rows[0]["Person"].ToString() + "</div>");
                sb.Append("<div " + divstyle + ">Unit:" + dtMail.Rows[0]["Station"].ToString() + "</div>");
                sb.Append("<div " + divstyle + ">Department:" + dtMail.Rows[0]["Department"].ToString() + "</div><br />");
                //140312
                //如果只有一个年份,则不显示Year列
                DataTable dtpar1 = dtPar.DefaultView.ToTable(true, "Year");
                bool YearOrNot = dtpar1.Rows.Count == 1 ? false : true;
                //160115 垫付
                if (hdOnBehalf.Value == null || hdOnBehalf.Value.ToString() == "")
                {
                    if (dtMail.Rows[0]["Budget"].ToString() == "1")//预算内
                    {
                        DataTable dtPerson = new DataTable();
                        dtPerson.Columns.Add("Year", typeof(System.String));
                        dtPerson.Columns.Add("EName", typeof(System.String));
                        dtPerson.Columns.Add("Currency", typeof(System.String));
                        dtPerson.Columns.Add("Current", typeof(System.Decimal));
                        dtPerson.Columns.Add("PU", typeof(System.Decimal));
                        dtPerson.Columns.Add("PB", typeof(System.Decimal));
                        dtPerson.Columns.Add("PPercent", typeof(System.String));//%(Current+Used) / Budget

                        DataTable dtDepartment = new DataTable();
                        dtDepartment.Columns.Add("Year", typeof(System.String));
                        dtDepartment.Columns.Add("EName", typeof(System.String));
                        dtDepartment.Columns.Add("Currency", typeof(System.String));
                        dtDepartment.Columns.Add("Current", typeof(System.Decimal));
                        dtDepartment.Columns.Add("DU", typeof(System.Decimal));
                        dtDepartment.Columns.Add("DB", typeof(System.Decimal));
                        dtDepartment.Columns.Add("DPercent", typeof(System.String));//%(Current+Used) / Budget

                        DataTable dtStation = new DataTable();
                        dtStation.Columns.Add("Year", typeof(System.String));
                        dtStation.Columns.Add("EName", typeof(System.String));
                        dtStation.Columns.Add("Currency", typeof(System.String));
                        dtStation.Columns.Add("Current", typeof(System.Decimal));
                        dtStation.Columns.Add("SU", typeof(System.Decimal));
                        dtStation.Columns.Add("SB", typeof(System.Decimal));
                        dtStation.Columns.Add("SPercent", typeof(System.String));//%(Current+Used) / Budget

                        for (int i = 0; i < dtPar.Rows.Count; i++)
                        {
                            if (Convert.ToDecimal(dtPar.Rows[i]["PB"].ToString()) != 0)//按照个人分配了预算
                            {
                                DataRow dr = dtPerson.NewRow();
                                dr["Year"] = dtPar.Rows[i]["Year"].ToString();
                                dr["EName"] = dtPar.Rows[i]["EName"].ToString();
                                dr["Currency"] = dtPar.Rows[i]["Currency"].ToString();
                                dr["Current"] = dtPar.Rows[i]["Current"];
                                dr["PU"] = dtPar.Rows[i]["PU"];
                                dr["PB"] = dtPar.Rows[i]["PB"];
                                //dr["PPercent"] = dtPar.Rows[i]["PPercent"].ToString() + "%";
                                decimal per = System.Math.Round(100 * (Convert.ToDecimal(dtPar.Rows[i]["Current"].ToString()) + Convert.ToDecimal(dtPar.Rows[i]["PU"].ToString())) / Convert.ToDecimal(dtPar.Rows[i]["PB"].ToString()), 2);
                                dr["PPercent"] = per.ToString() + "%";
                                dtPerson.Rows.Add(dr);
                            }
                            if (Convert.ToDecimal(dtPar.Rows[i]["PB"].ToString()) == 0 && Convert.ToDecimal(dtPar.Rows[i]["DB"].ToString()) != 0)//按照部门分配了预算
                            {
                                DataRow dr = dtDepartment.NewRow();
                                dr["Year"] = dtPar.Rows[i]["Year"].ToString();
                                dr["EName"] = dtPar.Rows[i]["EName"].ToString();
                                dr["Currency"] = dtPar.Rows[i]["Currency"].ToString();
                                dr["Current"] = dtPar.Rows[i]["Current"];
                                dr["DU"] = dtPar.Rows[i]["DU"];
                                dr["DB"] = dtPar.Rows[i]["DB"];
                                //dr["DPercent"] = dtPar.Rows[i]["DPercent"].ToString() + "%";
                                decimal per = System.Math.Round(100 * (Convert.ToDecimal(dtPar.Rows[i]["Current"].ToString()) + Convert.ToDecimal(dtPar.Rows[i]["DU"].ToString())) / Convert.ToDecimal(dtPar.Rows[i]["DB"].ToString()), 2);
                                dr["DPercent"] = per.ToString() + "%";
                                dtDepartment.Rows.Add(dr);
                            }
                            if (Convert.ToDecimal(dtPar.Rows[i]["PB"].ToString()) == 0 && Convert.ToDecimal(dtPar.Rows[i]["DB"].ToString()) == 0 && Convert.ToDecimal(dtPar.Rows[i]["SB"].ToString()) != 0)//按照站点分配了预算
                            {
                                DataRow dr = dtStation.NewRow();
                                dr["Year"] = dtPar.Rows[i]["Year"].ToString();
                                dr["EName"] = dtPar.Rows[i]["EName"].ToString();
                                dr["Currency"] = dtPar.Rows[i]["Currency"].ToString();
                                dr["Current"] = dtPar.Rows[i]["Current"];
                                dr["SU"] = dtPar.Rows[i]["SU"];
                                dr["SB"] = dtPar.Rows[i]["SB"];
                                //dr["SPercent"] = dtPar.Rows[i]["SPercent"].ToString() + "%";
                                decimal per = System.Math.Round(100 * (Convert.ToDecimal(dtPar.Rows[i]["Current"].ToString()) + Convert.ToDecimal(dtPar.Rows[i]["SU"].ToString())) / Convert.ToDecimal(dtPar.Rows[i]["SB"].ToString()), 2);
                                dr["SPercent"] = per.ToString() + "%";
                                dtStation.Rows.Add(dr);
                            }
                        }
                        if (dtPerson.Rows.Count > 0)//如果有个人分配,则显示个人表格
                        {
                            dtPerson.DefaultView.Sort = "Year ASC";
                            DataTable dtPersonNew = dtPerson.DefaultView.ToTable();
                            for (int i = 0; i < dtPersonNew.Rows.Count; i++)
                            {
                                if (i == 0 || dtPersonNew.Rows[i]["Year"].ToString() != dtPersonNew.Rows[i - 1]["Year"].ToString())//每个单独Year的第一行
                                {
                                    if (YearOrNot)
                                    {
                                        sb.Append("<div " + divstyleR + ">Budget Year:" + dtPersonNew.Rows[i]["Year"].ToString() + "</div><div><table><tr>");
                                    }
                                    else
                                    {
                                        sb.Append("<div><table><tr>");
                                    }
                                    sb.Append("<td " + tdstyle + ">Expense Item</td>");
                                    sb.Append("<td " + tdstyle + ">Currency</td>");
                                    sb.Append("<td " + tdstyle + ">current</td>");
                                    sb.Append("<td " + tdstyle + ">Personal<br />Used</td>");
                                    sb.Append("<td " + tdstyle + ">Personal<br />Budget</td>");
                                    sb.Append("<td " + tdstyle + ">%<br />(Current+Used) / Budget</td></tr>");

                                    sb.Append("<tr><td " + tdstyle + ">" + dtPersonNew.Rows[i]["EName"].ToString() + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + dtPersonNew.Rows[i]["Currency"].ToString() + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtPersonNew.Rows[i]["Current"].ToString())) + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtPersonNew.Rows[i]["PU"].ToString())) + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtPersonNew.Rows[i]["PB"].ToString())) + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + dtPersonNew.Rows[i]["PPercent"].ToString() + "</td></tr>");
                                }
                                else
                                {
                                    sb.Append("<tr><td " + tdstyle + ">" + dtPersonNew.Rows[i]["EName"].ToString() + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + dtPersonNew.Rows[i]["Currency"].ToString() + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtPersonNew.Rows[i]["Current"].ToString())) + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtPersonNew.Rows[i]["PU"].ToString())) + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtPersonNew.Rows[i]["PB"].ToString())) + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + dtPersonNew.Rows[i]["PPercent"].ToString() + "</td></tr>");
                                }
                                if (i == dtPersonNew.Rows.Count - 1 || dtPersonNew.Rows[i]["Year"].ToString() != dtPersonNew.Rows[i + 1]["Year"].ToString())//每个单独Year的最后一行
                                {
                                    sb.Append("<tr><td " + tdstyle + ">Sub Total</td>");
                                    sb.Append("<td " + tdstyle + ">" + dtPersonNew.Rows[i]["Currency"].ToString() + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtPersonNew.Compute("Sum(Current)", "Year = " + dtPersonNew.Rows[i]["Year"].ToString()))) + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtPersonNew.Compute("Sum(PU)", "Year = " + dtPersonNew.Rows[i]["Year"].ToString()))) + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtPersonNew.Compute("Sum(PB)", "Year = " + dtPersonNew.Rows[i]["Year"].ToString()))) + "</td>");
                                    sb.Append("<td " + tdstyle + ">&nbsp;</td></tr>");

                                    sb.Append("</table></div><br />");

                                }
                            }
                            //sb.Append("<div><table><tr>");
                            //sb.Append("<td " + tdstyle + ">Expense Item</td>");
                            //sb.Append("<td " + tdstyle + ">Currency</td>");
                            //sb.Append("<td " + tdstyle + ">current</td>");
                            //if (YearOrNot)
                            //{
                            //    sb.Append("<td " + tdstyle + ">Budget Year</td>");
                            //}

                            //sb.Append("<td " + tdstyle + ">Personal<br />Used</td>");
                            //sb.Append("<td " + tdstyle + ">Personal<br />Budget</td>");
                            //sb.Append("<td " + tdstyle + ">%<br />(Current+Used) / Budget</td></tr>");
                            //DataRow dr = dtPerson.NewRow();
                            //dr["EName"] = "Sub Total";
                            //dr["Currency"] = dtPerson.Rows[0]["Currency"].ToString();
                            //dr["Current"] = dtPerson.Compute("Sum(Current)", "");
                            //dr["PU"] = dtPerson.Compute("Sum(PU)", "");
                            //dr["PB"] = dtPerson.Compute("Sum(PB)", "");
                            //dr["PPercent"] = "&nbsp;";
                            //dr["Year"] = "&nbsp;";
                            //dtPerson.Rows.Add(dr);
                            //for (int i = 0; i < dtPerson.Rows.Count; i++)
                            //{
                            //    sb.Append("<tr><td " + tdstyle + ">" + dtPerson.Rows[i]["EName"].ToString() + "</td>");
                            //    sb.Append("<td " + tdstyle + ">" + dtPerson.Rows[i]["Currency"].ToString() + "</td>");
                            //    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtPerson.Rows[i]["Current"].ToString())) + "</td>");
                            //    if (YearOrNot)
                            //    {
                            //        sb.Append("<td " + tdstyle + ">" + dtPerson.Rows[i]["Year"].ToString() + "</td>");
                            //    }

                            //    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtPerson.Rows[i]["PU"].ToString())) + "</td>");
                            //    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtPerson.Rows[i]["PB"].ToString())) + "</td>");
                            //    sb.Append("<td " + tdstyle + ">" + dtPerson.Rows[i]["PPercent"].ToString() + "</td></tr>");
                            //}
                            //sb.Append("</table></div><br />");
                        }
                        if (dtDepartment.Rows.Count > 0)//如果有部门分配,则显示部门表格
                        {
                            dtDepartment.DefaultView.Sort = "Year ASC";
                            DataTable dtDepartmentNew = dtDepartment.DefaultView.ToTable();
                            for (int i = 0; i < dtDepartmentNew.Rows.Count; i++)
                            {
                                if (i == 0 || dtDepartmentNew.Rows[i]["Year"].ToString() != dtDepartmentNew.Rows[i - 1]["Year"].ToString())//每个单独Year的第一行
                                {
                                    if (YearOrNot)
                                    {
                                        sb.Append("<div " + divstyleR + ">Budget Year:" + dtDepartmentNew.Rows[i]["Year"].ToString() + "</div><div><table><tr>");
                                    }
                                    else
                                    {
                                        sb.Append("<div><table><tr>");
                                    }
                                    sb.Append("<td " + tdstyle + ">Expense Item</td>");
                                    sb.Append("<td " + tdstyle + ">Currency</td>");
                                    sb.Append("<td " + tdstyle + ">current</td>");
                                    sb.Append("<td " + tdstyle + ">Department<br />Used</td>");
                                    sb.Append("<td " + tdstyle + ">Department<br />Budget</td>");
                                    sb.Append("<td " + tdstyle + ">%<br />(Current+Used) / Budget</td></tr>");

                                    sb.Append("<tr><td " + tdstyle + ">" + dtDepartmentNew.Rows[i]["EName"].ToString() + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + dtDepartmentNew.Rows[i]["Currency"].ToString() + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtDepartmentNew.Rows[i]["Current"].ToString())) + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtDepartmentNew.Rows[i]["DU"].ToString())) + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtDepartmentNew.Rows[i]["DB"].ToString())) + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + dtDepartmentNew.Rows[i]["DPercent"].ToString() + "</td></tr>");
                                }
                                else
                                {
                                    sb.Append("<tr><td " + tdstyle + ">" + dtDepartmentNew.Rows[i]["EName"].ToString() + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + dtDepartmentNew.Rows[i]["Currency"].ToString() + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtDepartmentNew.Rows[i]["Current"].ToString())) + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtDepartmentNew.Rows[i]["DU"].ToString())) + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtDepartmentNew.Rows[i]["DB"].ToString())) + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + dtDepartmentNew.Rows[i]["DPercent"].ToString() + "</td></tr>");
                                }
                                if (i == dtDepartmentNew.Rows.Count - 1 || dtDepartmentNew.Rows[i]["Year"].ToString() != dtDepartmentNew.Rows[i + 1]["Year"].ToString())//每个单独Year的最后一行
                                {
                                    sb.Append("<tr><td " + tdstyle + ">Sub Total</td>");
                                    sb.Append("<td " + tdstyle + ">" + dtDepartmentNew.Rows[i]["Currency"].ToString() + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtDepartmentNew.Compute("Sum(Current)", "Year = " + dtDepartmentNew.Rows[i]["Year"].ToString()))) + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtDepartmentNew.Compute("Sum(DU)", "Year = " + dtDepartmentNew.Rows[i]["Year"].ToString()))) + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtDepartmentNew.Compute("Sum(DB)", "Year = " + dtDepartmentNew.Rows[i]["Year"].ToString()))) + "</td>");
                                    sb.Append("<td " + tdstyle + ">&nbsp;</td></tr>");

                                    sb.Append("</table></div><br />");

                                }
                            }
                            //sb.Append("<div><table><tr>");
                            //sb.Append("<td " + tdstyle + ">Expense Item</td>");
                            //sb.Append("<td " + tdstyle + ">Currency</td>");
                            //sb.Append("<td " + tdstyle + ">current</td>");
                            //if (YearOrNot)
                            //{
                            //    sb.Append("<td " + tdstyle + ">Budget Year</td>");
                            //}
                            //sb.Append("<td " + tdstyle + ">Department<br />Used</td>");
                            //sb.Append("<td " + tdstyle + ">Department<br />Budget</td>");
                            //sb.Append("<td " + tdstyle + ">%<br />(Current+Used) / Budget</td></tr>");
                            //DataRow dr = dtDepartment.NewRow();
                            //dr["EName"] = "Sub Total";
                            //dr["Currency"] = dtDepartment.Rows[0]["Currency"].ToString();
                            //dr["Current"] = dtDepartment.Compute("Sum(Current)", "");
                            //dr["DU"] = dtDepartment.Compute("Sum(DU)", "");
                            //dr["DB"] = dtDepartment.Compute("Sum(DB)", "");
                            //dr["DPercent"] = "&nbsp;";
                            //dr["Year"] = "&nbsp;";
                            //dtDepartment.Rows.Add(dr);
                            //for (int i = 0; i < dtDepartment.Rows.Count; i++)
                            //{
                            //    sb.Append("<tr><td " + tdstyle + ">" + dtDepartment.Rows[i]["EName"].ToString() + "</td>");
                            //    sb.Append("<td " + tdstyle + ">" + dtDepartment.Rows[i]["Currency"].ToString() + "</td>");
                            //    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtDepartment.Rows[i]["Current"].ToString())) + "</td>");
                            //    if (YearOrNot)
                            //    {
                            //        sb.Append("<td " + tdstyle + ">" + dtDepartment.Rows[i]["Year"].ToString() + "</td>");
                            //    }
                            //    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtDepartment.Rows[i]["DU"].ToString())) + "</td>");
                            //    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtDepartment.Rows[i]["DB"].ToString())) + "</td>");
                            //    sb.Append("<td " + tdstyle + ">" + dtDepartment.Rows[i]["DPercent"].ToString() + "</td></tr>");
                            //}
                            //sb.Append("</table></div><br />");
                        }
                        if (dtStation.Rows.Count > 0)//如果有部门分配,则显示个人表格
                        {
                            dtStation.DefaultView.Sort = "Year ASC";
                            DataTable dtStationNew = dtStation.DefaultView.ToTable();
                            for (int i = 0; i < dtStationNew.Rows.Count; i++)
                            {
                                if (i == 0 || dtStationNew.Rows[i]["Year"].ToString() != dtStationNew.Rows[i - 1]["Year"].ToString())//每个单独Year的第一行
                                {
                                    if (YearOrNot)
                                    {
                                        sb.Append("<div " + divstyleR + ">Budget Year:" + dtStationNew.Rows[i]["Year"].ToString() + "</div><div><table><tr>");
                                    }
                                    else
                                    {
                                        sb.Append("<div><table><tr>");
                                    }

                                    sb.Append("<td " + tdstyle + ">Expense Item</td>");
                                    sb.Append("<td " + tdstyle + ">Currency</td>");
                                    sb.Append("<td " + tdstyle + ">current</td>");
                                    sb.Append("<td " + tdstyle + ">Unit<br />Used</td>");
                                    sb.Append("<td " + tdstyle + ">Unit<br />Budget</td>");
                                    sb.Append("<td " + tdstyle + ">%<br />(Current+Used) / Budget</td></tr>");

                                    sb.Append("<tr><td " + tdstyle + ">" + dtStationNew.Rows[i]["EName"].ToString() + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + dtStationNew.Rows[i]["Currency"].ToString() + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtStationNew.Rows[i]["Current"].ToString())) + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtStationNew.Rows[i]["SU"].ToString())) + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtStationNew.Rows[i]["SB"].ToString())) + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + dtStationNew.Rows[i]["SPercent"].ToString() + "</td></tr>");
                                }
                                else
                                {
                                    sb.Append("<tr><td " + tdstyle + ">" + dtStationNew.Rows[i]["EName"].ToString() + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + dtStationNew.Rows[i]["Currency"].ToString() + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtStationNew.Rows[i]["Current"].ToString())) + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtStationNew.Rows[i]["SU"].ToString())) + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtStationNew.Rows[i]["SB"].ToString())) + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + dtStationNew.Rows[i]["SPercent"].ToString() + "</td></tr>");
                                }
                                if (i == dtStationNew.Rows.Count - 1 || dtStationNew.Rows[i]["Year"].ToString() != dtStationNew.Rows[i + 1]["Year"].ToString())//每个单独Year的最后一行
                                {
                                    sb.Append("<tr><td " + tdstyle + ">Sub Total</td>");
                                    sb.Append("<td " + tdstyle + ">" + dtStationNew.Rows[i]["Currency"].ToString() + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtStationNew.Compute("Sum(Current)", "Year = " + dtStationNew.Rows[i]["Year"].ToString()))) + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtStationNew.Compute("Sum(SU)", "Year = " + dtStationNew.Rows[i]["Year"].ToString()))) + "</td>");
                                    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtStationNew.Compute("Sum(SB)", "Year = " + dtStationNew.Rows[i]["Year"].ToString()))) + "</td>");
                                    sb.Append("<td " + tdstyle + ">&nbsp;</td></tr>");

                                    sb.Append("</table></div><br />");

                                }
                            }
                            //sb.Append("<div><table><tr>");
                            //sb.Append("<td " + tdstyle + ">Expense Item</td>");
                            //sb.Append("<td " + tdstyle + ">Currency</td>");
                            //sb.Append("<td " + tdstyle + ">current</td>");
                            //if (YearOrNot)
                            //{
                            //    sb.Append("<td " + tdstyle + ">Budget Year</td>");
                            //}
                            //sb.Append("<td " + tdstyle + ">Unit<br />Used</td>");
                            //sb.Append("<td " + tdstyle + ">Unit<br />Budget</td>");
                            //sb.Append("<td " + tdstyle + ">%<br />(Current+Used) / Budget</td></tr>");
                            //DataRow dr = dtStation.NewRow();
                            //dr["EName"] = "Sub Total";
                            //dr["Currency"] = dtStation.Rows[0]["Currency"].ToString();
                            //dr["Current"] = dtStation.Compute("Sum(Current)", "");
                            //dr["SU"] = dtStation.Compute("Sum(SU)", "");
                            //dr["SB"] = dtStation.Compute("Sum(SB)", "");
                            //dr["SPercent"] = "&nbsp;";
                            //dr["Year"] = "&nbsp;";
                            //dtStation.Rows.Add(dr);
                            //for (int i = 0; i < dtStation.Rows.Count; i++)
                            //{
                            //    sb.Append("<tr><td " + tdstyle + ">" + dtStation.Rows[i]["EName"].ToString() + "</td>");
                            //    sb.Append("<td " + tdstyle + ">" + dtStation.Rows[i]["Currency"].ToString() + "</td>");
                            //    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtStation.Rows[i]["Current"].ToString())) + "</td>");
                            //    if (YearOrNot)
                            //    {
                            //        sb.Append("<td " + tdstyle + ">" + dtStation.Rows[i]["Year"].ToString() + "</td>");
                            //    }
                            //    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtStation.Rows[i]["SU"].ToString())) + "</td>");
                            //    sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtStation.Rows[i]["SB"].ToString())) + "</td>");
                            //    sb.Append("<td " + tdstyle + ">" + dtStation.Rows[i]["SPercent"].ToString() + "</td></tr>");
                            //}
                            //sb.Append("</table></div><br />");
                        }
                    }
                    else
                    {

                        dtPar.DefaultView.Sort = "Year ASC";
                        DataTable dtStationNew = dtPar.DefaultView.ToTable();
                        for (int i = 0; i < dtStationNew.Rows.Count; i++)
                        {
                            if (i == 0 || dtStationNew.Rows[i]["Year"].ToString() != dtStationNew.Rows[i - 1]["Year"].ToString())//每个单独Year的第一行
                            {
                                if (YearOrNot)
                                {
                                    sb.Append("<div " + divstyleR + ">Budget Year:" + dtStationNew.Rows[i]["Year"].ToString() + "</div><div><table><tr>");
                                }
                                else
                                {
                                    sb.Append("<div><table><tr>");
                                }
                                sb.Append("<td " + tdstyle + ">Expense Item</td>");
                                sb.Append("<td " + tdstyle + ">Currency</td>");
                                sb.Append("<td " + tdstyle + ">current</td>");
                                sb.Append("<td " + tdstyle + ">Personal<br />Used</td>");
                                sb.Append("<td " + tdstyle + ">Personal<br />Budget</td>");
                                sb.Append("<td " + tdstyle + ">%<br />(Current+Used) /<br />Budget</td>");
                                sb.Append("<td " + tdstyle + ">Department<br />Used</td>");
                                sb.Append("<td " + tdstyle + ">Department<br />Budget</td>");
                                sb.Append("<td " + tdstyle + ">%<br />(Current+Used) /<br />Budget</td>");
                                sb.Append("<td " + tdstyle + ">Unit<br />Used</td>");
                                sb.Append("<td " + tdstyle + ">Unit<br />Budget</td>");
                                sb.Append("<td " + tdstyle + ">%<br />(Current+Used) /<br />Budget</td></tr>");

                                sb.Append("<tr><td " + tdstyle + ">" + dtStationNew.Rows[i]["EName"].ToString() + "</td>");
                                sb.Append("<td " + tdstyle + ">" + dtStationNew.Rows[i]["Currency"].ToString() + "</td>");
                                sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtStationNew.Rows[i]["Current"].ToString())) + "</td>");

                                string PB = ""; string PP = ""; string DB = ""; string DP = ""; string SB = ""; string SP = "";
                                if (Convert.ToDecimal(dtStationNew.Rows[i]["PB"].ToString()) != 0)
                                {
                                    PB = string.Format("{0:N2}", dtStationNew.Rows[i]["PB"]);
                                    PP = string.Format("{0:P2}", (Convert.ToDecimal(dtStationNew.Rows[i]["Current"].ToString()) + Convert.ToDecimal(dtStationNew.Rows[i]["PU"].ToString())) / Convert.ToDecimal(dtStationNew.Rows[i]["PB"].ToString()));
                                }
                                else
                                {
                                    PB = "--";
                                    PP = "--";
                                }
                                if (Convert.ToDecimal(dtStationNew.Rows[i]["DB"].ToString()) != 0)
                                {
                                    DB = string.Format("{0:N2}", dtStationNew.Rows[i]["DB"]);
                                    DP = string.Format("{0:P2}", (Convert.ToDecimal(dtStationNew.Rows[i]["Current"].ToString()) + Convert.ToDecimal(dtStationNew.Rows[i]["DU"].ToString())) / Convert.ToDecimal(dtStationNew.Rows[i]["DB"].ToString()));
                                }
                                else
                                {
                                    DB = "--";
                                    DP = "--";
                                }
                                if (Convert.ToDecimal(dtStationNew.Rows[i]["SB"].ToString()) != 0)
                                {
                                    SB = string.Format("{0:N2}", dtStationNew.Rows[i]["SB"]);
                                    SP = string.Format("{0:P2}", (Convert.ToDecimal(dtStationNew.Rows[i]["Current"].ToString()) + Convert.ToDecimal(dtStationNew.Rows[i]["SU"].ToString())) / Convert.ToDecimal(dtStationNew.Rows[i]["SB"].ToString()));
                                }
                                else
                                {
                                    SB = "--";
                                    SP = "--";
                                }

                                if (Convert.ToDecimal(dtStationNew.Rows[i]["PB"].ToString()) == 0 && Convert.ToDecimal(dtStationNew.Rows[i]["DB"].ToString()) == 0 && Convert.ToDecimal(dtStationNew.Rows[i]["SB"].ToString()) == 0)
                                {
                                    PP = "Unbudget Item";
                                    DP = "Unbudget Item";
                                    SP = "Unbudget Item";
                                }
                                decimal PPercent, DPercent, SPercent;
                                //Person
                                sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtStationNew.Rows[i]["PU"].ToString())) + "</td>");
                                sb.Append("<td " + tdstyle + ">" + PB + "</td>");
                                if (PP == "Unbudget Item")
                                {
                                    sb.Append("<td " + divstylered + ">" + PP + "</td>");
                                }
                                else if (PP == "--" || PP == "&nbsp;")
                                {
                                    sb.Append("<td " + tdstyle + ">" + PP + "</td>");
                                }
                                else if (decimal.TryParse(PP.Substring(0, PP.Length - 1), out PPercent))
                                {
                                    if (PPercent > 100)
                                    {
                                        sb.Append("<td " + divstylered + ">" + PP + "</td>");
                                    }
                                    else
                                    {
                                        sb.Append("<td " + tdstyle + ">" + PP + "</td>");
                                    }
                                }
                                //Department
                                sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtStationNew.Rows[i]["DU"].ToString())) + "</td>");
                                sb.Append("<td " + tdstyle + ">" + DB + "</td>");
                                if (DP == "Unbudget Item")
                                {
                                    sb.Append("<td " + divstylered + ">" + DP + "</td>");
                                }
                                else if (DP == "--" || DP == "&nbsp;")
                                {
                                    sb.Append("<td " + tdstyle + ">" + DP + "</td>");
                                }
                                else if (decimal.TryParse(DP.Substring(0, DP.Length - 1), out DPercent))
                                {
                                    if (DPercent > 100)
                                    {
                                        sb.Append("<td " + divstylered + ">" + DP + "</td>");
                                    }
                                    else
                                    {
                                        sb.Append("<td " + tdstyle + ">" + DP + "</td>");
                                    }
                                }
                                //Station
                                sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtStationNew.Rows[i]["SU"].ToString())) + "</td>");
                                sb.Append("<td " + tdstyle + ">" + SB + "</td>");
                                if (SP == "Unbudget Item")
                                {
                                    sb.Append("<td " + divstylered + ">" + SP + "</td>");
                                }
                                else if (SP == "--" || SP == "&nbsp;")
                                {
                                    sb.Append("<td " + tdstyle + ">" + SP + "</td>");
                                }
                                else if (decimal.TryParse(SP.Substring(0, SP.Length - 1), out SPercent))
                                {
                                    if (SPercent > 100)
                                    {
                                        sb.Append("<td " + divstylered + ">" + SP + "</td>");
                                    }
                                    else
                                    {
                                        sb.Append("<td " + tdstyle + ">" + SP + "</td>");
                                    }
                                }
                            }
                            else
                            {
                                sb.Append("<tr><td " + tdstyle + ">" + dtStationNew.Rows[i]["EName"].ToString() + "</td>");
                                sb.Append("<td " + tdstyle + ">" + dtStationNew.Rows[i]["Currency"].ToString() + "</td>");
                                sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtStationNew.Rows[i]["Current"].ToString())) + "</td>");

                                string PB = ""; string PP = ""; string DB = ""; string DP = ""; string SB = ""; string SP = "";
                                if (Convert.ToDecimal(dtStationNew.Rows[i]["PB"].ToString()) != 0)
                                {
                                    PB = string.Format("{0:N2}", dtStationNew.Rows[i]["PB"]);
                                    PP = string.Format("{0:P2}", (Convert.ToDecimal(dtStationNew.Rows[i]["Current"].ToString()) + Convert.ToDecimal(dtStationNew.Rows[i]["PU"].ToString())) / Convert.ToDecimal(dtStationNew.Rows[i]["PB"].ToString()));
                                }
                                else
                                {
                                    PB = "--";
                                    PP = "--";
                                }
                                if (Convert.ToDecimal(dtStationNew.Rows[i]["DB"].ToString()) != 0)
                                {
                                    DB = string.Format("{0:N2}", dtStationNew.Rows[i]["DB"]);
                                    DP = string.Format("{0:P2}", (Convert.ToDecimal(dtStationNew.Rows[i]["Current"].ToString()) + Convert.ToDecimal(dtStationNew.Rows[i]["DU"].ToString())) / Convert.ToDecimal(dtStationNew.Rows[i]["DB"].ToString()));
                                }
                                else
                                {
                                    DB = "--";
                                    DP = "--";
                                }
                                if (Convert.ToDecimal(dtStationNew.Rows[i]["SB"].ToString()) != 0)
                                {
                                    SB = string.Format("{0:N2}", dtStationNew.Rows[i]["SB"]);
                                    SP = string.Format("{0:P2}", (Convert.ToDecimal(dtStationNew.Rows[i]["Current"].ToString()) + Convert.ToDecimal(dtStationNew.Rows[i]["SU"].ToString())) / Convert.ToDecimal(dtStationNew.Rows[i]["SB"].ToString()));
                                }
                                else
                                {
                                    SB = "--";
                                    SP = "--";
                                }

                                if (Convert.ToDecimal(dtStationNew.Rows[i]["PB"].ToString()) == 0 && Convert.ToDecimal(dtStationNew.Rows[i]["DB"].ToString()) == 0 && Convert.ToDecimal(dtStationNew.Rows[i]["SB"].ToString()) == 0)
                                {
                                    PP = "Unbudget Item";
                                    DP = "Unbudget Item";
                                    SP = "Unbudget Item";
                                }
                                decimal PPercent, DPercent, SPercent;
                                //Person
                                sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtStationNew.Rows[i]["PU"].ToString())) + "</td>");
                                sb.Append("<td " + tdstyle + ">" + PB + "</td>");
                                if (PP == "Unbudget Item")
                                {
                                    sb.Append("<td " + divstylered + ">" + PP + "</td>");
                                }
                                else if (PP == "--" || PP == "&nbsp;")
                                {
                                    sb.Append("<td " + tdstyle + ">" + PP + "</td>");
                                }
                                else if (decimal.TryParse(PP.Substring(0, PP.Length - 1), out PPercent))
                                {
                                    if (PPercent > 100)
                                    {
                                        sb.Append("<td " + divstylered + ">" + PP + "</td>");
                                    }
                                    else
                                    {
                                        sb.Append("<td " + tdstyle + ">" + PP + "</td>");
                                    }
                                }
                                //Department
                                sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtStationNew.Rows[i]["DU"].ToString())) + "</td>");
                                sb.Append("<td " + tdstyle + ">" + DB + "</td>");
                                if (DP == "Unbudget Item")
                                {
                                    sb.Append("<td " + divstylered + ">" + DP + "</td>");
                                }
                                else if (DP == "--" || DP == "&nbsp;")
                                {
                                    sb.Append("<td " + tdstyle + ">" + DP + "</td>");
                                }
                                else if (decimal.TryParse(DP.Substring(0, DP.Length - 1), out DPercent))
                                {
                                    if (DPercent > 100)
                                    {
                                        sb.Append("<td " + divstylered + ">" + DP + "</td>");
                                    }
                                    else
                                    {
                                        sb.Append("<td " + tdstyle + ">" + DP + "</td>");
                                    }
                                }
                                //Station
                                sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtStationNew.Rows[i]["SU"].ToString())) + "</td>");
                                sb.Append("<td " + tdstyle + ">" + SB + "</td>");
                                if (SP == "Unbudget Item")
                                {
                                    sb.Append("<td " + divstylered + ">" + SP + "</td>");
                                }
                                else if (SP == "--" || SP == "&nbsp;")
                                {
                                    sb.Append("<td " + tdstyle + ">" + SP + "</td>");
                                }
                                else if (decimal.TryParse(SP.Substring(0, SP.Length - 1), out SPercent))
                                {
                                    if (SPercent > 100)
                                    {
                                        sb.Append("<td " + divstylered + ">" + SP + "</td>");
                                    }
                                    else
                                    {
                                        sb.Append("<td " + tdstyle + ">" + SP + "</td>");
                                    }
                                }
                            }
                            if (i == dtStationNew.Rows.Count - 1 || dtStationNew.Rows[i]["Year"].ToString() != dtStationNew.Rows[i + 1]["Year"].ToString())//每个单独Year的最后一行
                            {
                                sb.Append("<tr><td " + tdstyle + ">Sub Total</td>");
                                sb.Append("<td " + tdstyle + ">" + dtStationNew.Rows[i]["Currency"].ToString() + "</td>");
                                sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtStationNew.Compute("Sum(Current)", "Year = " + dtStationNew.Rows[i]["Year"].ToString()))) + "</td>");
                                sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtStationNew.Compute("Sum(PU)", "Year = " + dtStationNew.Rows[i]["Year"].ToString()))) + "</td>");
                                sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtStationNew.Compute("Sum(PB)", "Year = " + dtStationNew.Rows[i]["Year"].ToString()))) + "</td>");
                                sb.Append("<td " + tdstyle + ">&nbsp;</td>");
                                sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtStationNew.Compute("Sum(DU)", "Year = " + dtStationNew.Rows[i]["Year"].ToString()))) + "</td>");
                                sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtStationNew.Compute("Sum(DB)", "Year = " + dtStationNew.Rows[i]["Year"].ToString()))) + "</td>");
                                sb.Append("<td " + tdstyle + ">&nbsp;</td>");
                                sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtStationNew.Compute("Sum(SU)", "Year = " + dtStationNew.Rows[i]["Year"].ToString()))) + "</td>");
                                sb.Append("<td " + tdstyle + ">" + string.Format("{0:N2}", Convert.ToDecimal(dtStationNew.Compute("Sum(SB)", "Year = " + dtStationNew.Rows[i]["Year"].ToString()))) + "</td>");
                                sb.Append("<td " + tdstyle + ">&nbsp;</td></tr>");
                                sb.Append("</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 if (dtMail.Rows[i]["FlowFn"].ToString().ToLower() == "confirm")
                    {
                        msg1 = ". Waiting for Confirmation: " + 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://61.218.73.79:88/eReimbursement/Approve.aspx";
                    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;
        }
예제 #14
0
        public string UpdateData(string sqlcon, string command, string type)
        {
            if (type == "Insert")
            {
                try
                {
                    string         sConnection  = ConfigurationManager.ConnectionStrings[sqlcon].ConnectionString;
                    DataSet        dsSet        = new DataSet();
                    SqlDataAdapter sdaAdapter   = null;
                    SqlConnection  scConnection = new SqlConnection(sConnection);

                    SqlCommand scCommand = scConnection.CreateCommand();
                    scCommand.CommandText = command;
                    scConnection.Open();
                    sdaAdapter = new SqlDataAdapter(scCommand);
                    sdaAdapter.Fill(dsSet, "Request");
                    sdaAdapter.Dispose();
                    scCommand.Dispose();
                    scConnection.Close();
                    scConnection.Dispose();
                    return(dsSet.Tables[0].Rows[0][0].ToString());
                }
                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         = "<div>SQL Command: " + command + "<br /><br />" + ex.Message + "</div>";
                    mail.Send();
                    return("-1");
                }
            }
            else if (type == "Update")
            {
                try
                {
                    string        sConnection  = ConfigurationManager.ConnectionStrings[sqlcon].ConnectionString;
                    DataSet       dsSet        = new DataSet();
                    SqlConnection scConnection = new SqlConnection(sConnection);
                    scConnection.Open();
                    SqlCommand scCommand = scConnection.CreateCommand();
                    scCommand.CommandText = command;
                    int row = scCommand.ExecuteNonQuery();
                    scCommand.Dispose();
                    scConnection.Close();
                    scConnection.Dispose();
                    return("1");
                }
                catch (Exception ex)
                {
                    DIMERCO.SDK.MailMsg mail = new DIMERCO.SDK.MailMsg();

                    mail.FromDispName = "eReimbursement Bug";
                    mail.From         = "*****@*****.**";
                    mail.To           = "*****@*****.**";
                    mail.Title        = "eReimbursement Bug";
                    mail.Body         = "<div>SQL Command: " + command + "<br /><br />" + ex.Message + "</div>";
                    mail.Send();
                    return("-1");
                }
            }
            return("0");
        }