private void myBtn_Click(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;
            btn.IsEnabled = false;
            if (DaGr.SelectedItems == null)
            {
                ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("TIPS"), Utility.GetResourceStr("SELECTERROR", "OPERATION"), Utility.GetResourceStr("CONFIRMBUTTON"), MessageIcon.Exclamation);
                return;
            }

            if (DaGr.SelectedItems.Count == 0)
            {
                ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("TIPS"), Utility.GetResourceStr("SELECTERROR", "OPERATION"), Utility.GetResourceStr("CONFIRMBUTTON"), MessageIcon.Exclamation);
                return;
            }

            ///luojie 20120808
            ///未报销按钮的权限控制,同修改按钮
            V_Travelmanagement entrb = new V_Travelmanagement();
            entrb = DaGr.SelectedItems[0] as V_Travelmanagement;
            if (SMT.SaaS.FrameworkUI.Common.Utility.ToolBarButtonOperationPermission(entrb, "T_OA_BUSINESSTRIP", OperationType.Edit, Common.CurrentLoginUserInfo.EmployeeID))
            {
                for (int i = 0; i < DaGr.SelectedItems.Count; i++)
                {
                    V_Travelmanagement ent = new V_Travelmanagement();
                    ent = (DaGr.SelectedItems[i] as V_Travelmanagement);

                    reportid = ent.ReportId;
                    businesstrID = ent.Travelmanagement.BUSINESSTRIPID;
                    travelreimbursementId = ent.TrId;
                    Tdetail = ent.Tdetail;
                }

                if (!string.IsNullOrEmpty(travelreimbursementId) && travelreimbursementId != "空" && Tdetail > 0)//如果已生成报销单,直接打开表单提交
                {
                    WhetherReimbursement = false;
                    BusinessApplicationsForm AddWin = new BusinessApplicationsForm(FormTypes.Edit, businesstrID, WhetherReimbursement);
                    EntityBrowser browser = new EntityBrowser(AddWin);
                    browser.RemoveSMTLoading();
                    browser.FormType = FormTypes.Edit;
                    browser.EntityBrowseToolBar.MaxHeight = 0;
                    browser.MinWidth = 980;
                    browser.MinHeight = 445;
                    browser.TitleContent = "出差申请";
                    browser.ReloadDataEvent += new EntityBrowser.refreshGridView(browser_ReloadDataEvent);
                    browser.Show<string>(DialogMode.Default, Common.ParentLayoutRoot, "", (result) => { });
                }
                else
                {
                    ReimbursementSwitch = true;//出差报销开关
                    Travelmanagement.GetTravelmanagementByIdAsync(businesstrID, btn);
                }
            }
            else
            {
                Utility.ShowCustomMessage(MessageTypes.Caution, Utility.GetResourceStr("CAUTION"), Utility.GetResourceStr("对不起,您没有修改该用户报销的权限"));
            }
        }
        private void alterTravelBusiness(V_Travelmanagement ent)
        {
            BusinessApplicationsForm AddWin = new BusinessApplicationsForm(FormTypes.Resubmit, ent.Travelmanagement.BUSINESSTRIPID);
            AddWin.isAlterTrave = true;
            EntityBrowser browser = new EntityBrowser(AddWin);
            browser.RemoveSMTLoading();
            browser.EntityBrowseToolBar.MaxHeight = 0;
            browser.FormType = FormTypes.Resubmit;
            browser.MinWidth = 980;
            browser.MinHeight = 445;
            browser.TitleContent = "出差申请修改行程";
            browser.ReloadDataEvent += new EntityBrowser.refreshGridView(browser_ReloadDataEvent);
            browser.EntityEditor = AddWin;
            browser.Show<string>(DialogMode.Default, SMT.SAAS.Main.CurrentContext.Common.ParentLayoutRoot, "", (result) => { });

        }
 void TrC_GetTravelReimbursementByIdCompleted(object sender, GetTravelReimbursementByIdCompletedEventArgs e)
 {
     try
     {
         if (e.Error != null && !string.IsNullOrEmpty(e.Error.Message))
         {
             ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("TIPS"), Utility.GetResourceStr("ERRORINFO"), Utility.GetResourceStr("CONFIRM"), MessageIcon.Exclamation);
         }
         else
         {
             if (e.Result == null)
             {
                 ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("TIPS"), Utility.GetResourceStr("ERRORINFO"), Utility.GetResourceStr("CONFIRM"), MessageIcon.Exclamation);
                 return;
             }
             travelReimbursement = e.Result;
             if (!string.IsNullOrEmpty(travelReimbursement.TRAVELREIMBURSEMENTID))
             {
                 BusinessApplicationsForm AddWin = new BusinessApplicationsForm(FormTypes.Edit, businesstrID);
                 EntityBrowser browser = new EntityBrowser(AddWin);
                 browser.RemoveSMTLoading();
                 browser.FormType = FormTypes.Edit;
                 browser.MinWidth = 980;
                 browser.MinHeight = 445;
                 browser.TitleContent = "出差申请";
                 browser.ReloadDataEvent += new EntityBrowser.refreshGridView(browser_ReloadDataEvent);
                 browser.Show<string>(DialogMode.Default, Common.ParentLayoutRoot, "", (result) => { });
             }
             LoadData();//重新加载数据(主要用于刷新"是否报销"按钮的状态)
             ReimbursementSwitch = false;//关闭开关
         }
     }
     catch (Exception ex)
     {
         Logger.Current.Log(ex.Message, Category.Debug, Priority.Low);
         ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("TIPS"), Utility.GetResourceStr("ERRORINFO"), Utility.GetResourceStr("CONFIRM"), MessageIcon.Exclamation);
     }
 }
        void btnAudit_Click(object sender, RoutedEventArgs e)
        {
            if (DaGr.SelectedItems == null)
            {
                ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("TIPS"), Utility.GetResourceStr("SELECTERROR", "AUDIT"), Utility.GetResourceStr("CONFIRMBUTTON"), MessageIcon.Exclamation);
                return;
            }

            if (DaGr.SelectedItems.Count == 0)
            {
                ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("TIPS"), Utility.GetResourceStr("SELECTERROR", "AUDIT"), Utility.GetResourceStr("CONFIRMBUTTON"), MessageIcon.Exclamation);
                return;
            }
            V_Travelmanagement ent = new V_Travelmanagement();
            ent = (DaGr.SelectedItems[0] as V_Travelmanagement);

            BusinessApplicationsForm AddWin = new BusinessApplicationsForm(FormTypes.Audit, ent.Travelmanagement.BUSINESSTRIPID);
            EntityBrowser browser = new EntityBrowser(AddWin);
            browser.RemoveSMTLoading();
            browser.EntityBrowseToolBar.MaxHeight = 0;
            browser.FormType = FormTypes.Audit;
            browser.MinWidth = 728;
            browser.MinHeight = 445;
            browser.TitleContent = "出差申请";
            browser.ReloadDataEvent += new EntityBrowser.refreshGridView(browser_ReloadDataEvent);
            browser.Show<string>(DialogMode.Default, Common.ParentLayoutRoot, "", (result) => { });
        }
        void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            if (DaGr.SelectedItems == null)
            {
                ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("TIPS"), Utility.GetResourceStr("SELECTDATAALERT"), Utility.GetResourceStr("CONFIRMBUTTON"), MessageIcon.Exclamation);
                return;
            }

            if (DaGr.SelectedItems.Count == 0)
            {
                ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("TIPS"), Utility.GetResourceStr("SELECTDATAALERT"), Utility.GetResourceStr("CONFIRMBUTTON"), MessageIcon.Exclamation);
                return;
            }

            V_Travelmanagement ent = new V_Travelmanagement();
            ent = (DaGr.SelectedItems[0] as V_Travelmanagement);

            if (SMT.SaaS.FrameworkUI.Common.Utility.ToolBarButtonOperationPermission(ent, "T_OA_BUSINESSTRIP", OperationType.Edit, Common.CurrentLoginUserInfo.EmployeeID))
            {
                BusinessApplicationsForm AddWin = new BusinessApplicationsForm(FormTypes.Edit, ent.Travelmanagement.BUSINESSTRIPID);
                EntityBrowser browser = new EntityBrowser(AddWin);
                AddWin.ParentEntityBrowser = browser;
                browser.RemoveSMTLoading();
                browser.EntityBrowseToolBar.MaxHeight = 0;
                browser.FormType = FormTypes.Edit;
                browser.MinWidth = 980;
                browser.MinHeight = 445;
                browser.TitleContent = "出差申请";
                browser.ReloadDataEvent += new EntityBrowser.refreshGridView(browser_ReloadDataEvent);
                browser.Show<string>(DialogMode.Default, Common.ParentLayoutRoot, "", (result) => { });
            }
            else
            {
                Utility.ShowCustomMessage(MessageTypes.Caution, Utility.GetResourceStr("TIPS"), Utility.GetResourceStr("YOUDONOTHAVEPERMISSIONTOOPERATETHEDATA"));
            }
        }
        void btnNew_Click(object sender, RoutedEventArgs e)
        {
            //Utility.CreateFormFromMVC("113a24a8-1125-4209-be64-ce21915930a7"
            //   , "SMT.SaaS.OA.UI.UserControls.BusinessApplicationsForm", "Edit");

            //Utility.CreateFormFromEngine("1f49fd17-3f1c-442b-9cb1-aecddb82a62c"
            //    , "SMT.SaaS.OA.UI.UserControls.BusinessApplicationsForm", "Edit");
            //return;
            //Utility.CreateFormFromEngine("a7eb1928-c4a9-442d-82a0-2d57ee4cd87a", "SMT.SaaS.OA.UI.UserControls.BusinessApplicationsForm", "VIEW"); return;
            BusinessApplicationsForm AddWin = new BusinessApplicationsForm(FormTypes.New, "");
            EntityBrowser browser = new EntityBrowser(AddWin);
            browser.EntityBrowseToolBar.MaxHeight = 0;
            AddWin.ParentEntityBrowser = browser;
            browser.RemoveSMTLoading();
            browser.MinWidth = 980;
            browser.MinHeight = 445;
            browser.TitleContent = "出差申请";
            browser.ReloadDataEvent += new EntityBrowser.refreshGridView(browser_ReloadDataEvent);
            browser.Show<string>(DialogMode.Default, Common.ParentLayoutRoot, "", (result) => { }, true);
        }
        ///// <summary>
        ///// 加载字典
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //void DictManager_OnDictionaryLoadCompleted(object sender, OnDictionaryLoadArgs e)
        //{
        //    if (e.Error == null && e.Result)
        //    {
        //        SearchUserID = Common.CurrentLoginUserInfo.EmployeeID;

        //        string Name = "";
        //        Name = Common.CurrentLoginUserInfo.EmployeeName + "-" + Common.CurrentLoginUserInfo.UserPosts[0].PostName + "-" + Common.CurrentLoginUserInfo.UserPosts[0].DepartmentName + "-" + Common.CurrentLoginUserInfo.UserPosts[0].CompanyName;
        //        txtSearchID.Text = Name;
        //        ToolTipService.SetToolTip(txtSearchID, Name);
        //    }
        //    else
        //    {
        //        ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("ERROR"), "字典加载错误,请联系管理员",
        //            Utility.GetResourceStr("CONFIRM"), MessageIcon.Exclamation);
        //        return;
        //    }
        //}
        #endregion

        #region 重新提交
        void btnReSubmit_Click(object sender, RoutedEventArgs e)
        {
            if (DaGr.SelectedItems == null)
            {
                ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("TIPS"), Utility.GetResourceStr("SELECTERROR", "ReSubmit"), Utility.GetResourceStr("CONFIRMBUTTON"), MessageIcon.Exclamation);
                return;
            }

            if (DaGr.SelectedItems.Count == 0)
            {
                ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("TIPS"), Utility.GetResourceStr("SELECTERROR", "ReSubmit"), Utility.GetResourceStr("CONFIRMBUTTON"), MessageIcon.Exclamation);
                return;
            }

            V_Travelmanagement ent = new V_Travelmanagement();
            ent = (DaGr.SelectedItems[0] as V_Travelmanagement);

            ///luojie
            ///增加重新提交的判断,审核通过的不允许重新提交
            if (ent.TraveAppCheckState == "2" && ent.TrCheckState == "2")
            {
                ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("CAUTION"), Utility.GetResourceStr("已审核通过的出差报销不能重新提交"), Utility.GetResourceStr("确定"), MessageIcon.Exclamation);
                return;
            }
            if (ent.TraveAppCheckState == "2" && ent.TrCheckState != "3")
            {
                ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("CAUTION"), Utility.GetResourceStr("已审核通过的出差申请不能重新提交"), Utility.GetResourceStr("确定"), MessageIcon.Exclamation);
                return;
            }
            BusinessApplicationsForm AddWin = new BusinessApplicationsForm(FormTypes.Resubmit, ent.Travelmanagement.BUSINESSTRIPID);
            EntityBrowser browser = new EntityBrowser(AddWin);
            browser.RemoveSMTLoading();
            browser.EntityBrowseToolBar.MaxHeight = 0;
            browser.FormType = FormTypes.Resubmit;
            browser.MinWidth = 980;
            browser.MinHeight = 445;
            browser.TitleContent = "出差申请";
            browser.ReloadDataEvent += new EntityBrowser.refreshGridView(browser_ReloadDataEvent);
            browser.EntityEditor = AddWin;
            browser.Show<string>(DialogMode.Default, SMT.SAAS.Main.CurrentContext.Common.ParentLayoutRoot, "", (result) => { });
        }