private void ButtonPay_Click(object sender, RoutedEventArgs e)
 {
     if (dataContext == null)
     {
         dataContext = new DataClassesProjectClassifyDataContext();
     }
     try
     {
         Prizes prizes = new Prizes
         {
             //ProjectID = ProjectId,
             Department    = ((Department)ListBoxDepartment.SelectedItem).Name,
             Name          = ((Employee)ListBoxEmployee.SelectedItem).Name,
             PrizeClassify = ((PrizeClassify)ListBoxPrizeClassify.SelectedItem).PrizeClassifyName,
             AccountName   = ((Employee)ListBoxEmployee.SelectedItem).AccountName,
             AwardName     = TextBoxAwardName.Text.Trim(),
             Prize         = Convert.ToDecimal(TextBoxPrize.Text.Trim()),
             PayYear       = TextBoxYear.Text.Trim()
         };
         dataContext.Prizes.InsertOnSubmit(prizes);
         dataContext.SubmitChanges();
         //DataGridPrizes.ItemsSource = dataContext.Prizes.Where(p => p.ProjectID.Equals(ProjectId));
     }
     catch (Exception)
     { }
 }
Пример #2
0
        private void ButtonUpdate_Click(object sender, RoutedEventArgs e)
        {
            if (dataContext == null)
            {
                dataContext = new DataClassesProjectClassifyDataContext();
            }
            Prizes prizes = dataContext.Prizes.FirstOrDefault(p => p.ID.Equals(_currentPrizeID));

            if (prizes != null)
            {
                var prizeses =
                    dataContext.Prizes.Where(
                        p =>
                        p.Name.Equals(prizes.Name) && p.AccountName.Equals(prizes.AccountName) && p.PayYear.Equals(prizes.PayYear) &&
                        p.Department.Equals(prizes.Department) && p.PrizeClassify.Equals(prizes.PrizeClassify) &&
                        p.Project.Equals(prizes.Project) && p.AwardName.Equals(prizes.AwardName));
                try
                {
                    foreach (var pr in prizeses)
                    {
                        pr.Prize = Convert.ToDecimal(TextBoxPrize.Text);
                    }
                    dataContext.SubmitChanges();
                    FreshData();
                }
                catch (Exception error)
                {
                    MessageBox.Show(error.Message);
                }
            }
        }
Пример #3
0
        private void buttonSumbit_Click(object sender, RoutedEventArgs e)
        {
            if (listboxContractType.SelectedItem == null)
            {
                MessageBox.Show("请选择合同类型!", "错误");
                return;
            }
            if (ContractDate.SelectedDate == null)
            {
                MessageBox.Show("请选择签订日期!", "错误");
                return;
            }
            if (dataContext == null)
            {
                dataContext = new DataClassesProjectClassifyDataContext();
            }
            var pn = dataContext.ProjectContracts.Where(p => p.ContractNo.Trim().Equals(textboxContractNo.Text.Trim()) && p.ContractNo.Trim() != "");

            if (pn.Count() > 0)
            {
                MessageBox.Show("合同编号重复,已经录入该合同?", "错误");
                return;
            }
            ProjectContracts projectContract = new ProjectContracts();

            projectContract.ProjectID  = projectID;
            projectContract.TypeID     = ((ContractTypes)(listboxContractType.SelectedItem)).TypeID;
            projectContract.ContractNo = textboxContractNo.Text;
            try
            {
                projectContract.SumMoney = (Decimal)Double.Parse(textboxSumMoney.Text);
            }
            catch (FormatException)
            {
                MessageBox.Show("金额格式不对!", "错误");
                return;
            }
            projectContract.ProjectName    = textboxProjectName.Text.Trim();
            projectContract.FirstParty     = textboxFirstParty.Text.Trim();
            projectContract.SecondParty    = textboxSecondParty.Text.Trim();
            projectContract.ContractPeriod = textboxContractPeriod.Text.Trim();
            projectContract.Principal      = textboxPrincipal.Text.Trim();
            projectContract.ContractDate   = ContractDate.SelectedDate;
            projectContract.Note           = textboxNote.Text;

            dataContext.ProjectContracts.InsertOnSubmit(projectContract);
            dataContext.SubmitChanges();
            datagridContracts.DataContext         = dataContext.ProjectContracts.Where(pc => pc.ProjectID.Equals(projectID));
            listboxContractType.DisplayMemberPath = "ContractType";
            listboxContractType.SelectedValuePath = "TypeID";
            listboxContractType.DataContext       = dataContext.ContractTypes;
            listboxContractType.SelectedIndex     = 0;
            ((MainWindow)(this.Owner)).DialogR    = true;
        }
        private void buttonSubmit_Click(object sender, RoutedEventArgs e)
        {
            if (RateClassifys.SelectedItem == null)
            {
                MessageBox.Show("请选择鉴定结论!", "错误");
                return;
            }
            if (RateDate.SelectedDate == null)
            {
                MessageBox.Show("请选择日期!", "错误");
                return;
            }
            RateResults rateResults = new RateResults();

            rateResults.ProjectID      = projectID;
            rateResults.RateDepartment = RateDepartment.Text.Trim();
            rateResults.RateClassifyID = ((RateClassify)(RateClassifys.SelectedItem)).RateClassifyId;
            rateResults.RateDate       = RateDate.SelectedDate;
            rateResults.Note           = Note.Text.Trim();
            dataContent = new DataClassesProjectClassifyDataContext();
            dataContent.RateResults.InsertOnSubmit(rateResults);
            dataContent.SubmitChanges();
            dataGridRate.DataContext           = dataContent.RateResults.Where(r => r.ProjectID.Equals(projectID));
            ((MainWindow)(this.Owner)).DialogR = true;
        }
Пример #5
0
        private void buttonSubmit_Click(object sender, RoutedEventArgs e)
        {
            if (PatentClassifies.SelectedItem == null)
            {
                MessageBox.Show("请选择知识产权项类别!", "错误");
                return;
            }
            if (PatentDate.SelectedDate == null)
            {
                MessageBox.Show("请选择颁布时间!", "错误");
                return;
            }
            Patents patents = new Patents();

            patents.ProjectID        = projectID;
            patents.PatentClassifyID = ((PatentClassify)PatentClassifies.SelectedItem).PatentClassifyID;
            patents.PatentNo         = PatentNo.Text.Trim();
            patents.PatentName       = PatentName.Text.Trim();
            patents.PatendDepartment = PatentDepartment.Text.Trim();
            patents.PatentDate       = PatentDate.SelectedDate;
            patents.Note             = Note.Text.Trim();
            dataContext = new DataClassesProjectClassifyDataContext();
            dataContext.Patents.InsertOnSubmit(patents);
            dataContext.SubmitChanges();
            dataGridPatents.DataContext        = dataContext.Patents.Where(p => p.ProjectID.Equals(projectID));
            ((MainWindow)(this.Owner)).DialogR = true;
        }
        private void buttonUpdate_Click(object sender, RoutedEventArgs e)
        {
            if (fundID == 0)
            {
                return;
            }
            if (FundClassifys.SelectedItem == null)
            {
                MessageBox.Show("请选择经费类型!", "错误");
                return;
            }
            if (FundDate.SelectedDate == null)
            {
                MessageBox.Show("请选择日期!", "错误");
                return;
            }
            if (dataContent == null)
            {
                dataContent = new DataClassesProjectClassifyDataContext();
            }
            var fund = dataContent.Funds.Single(f => f.Id.Equals(fundID));

            fund.FundClassifyID = ((FundClassify)FundClassifys.SelectedItem).FandClassifyId;
            fund.ContractNo     = textBoxContractNo.Text.Trim();
            fund.Source         = FundSource.Text.Trim();
            try
            {
                fund.Money = (decimal)double.Parse(Money.Text);
            }
            catch (FormatException)
            {
                MessageBox.Show("金额格式不对!", "错误");
                return;
            }
            fund.Date         = FundDate.SelectedDate;
            fund.Handled      = Handled.Text.Trim();
            fund.SubPrincipal = SubPrincipal.Text.Trim();
            dataContent.SubmitChanges();
            dataContent = new DataClassesProjectClassifyDataContext();
            dataGridFund.DataContext = dataContent.Funds.Where(f => f.ProjectID.Equals(ProjectID)).OrderBy(f => f.Date);
            SetTotalMoney();
        }
Пример #7
0
        private void buttonSubmit_Click(object sender, RoutedEventArgs e)
        {
            if (FundClassifys.SelectedItem == null)
            {
                MessageBox.Show("请选择经费类型!", "错误");
                return;
            }
            var fundClassify = (FundClassify)FundClassifys.SelectedItem;

            if ((fundClassify.FundClassify1 == "课题组报支") || (fundClassify.FundClassify1 == "管理费"))
            {
                MessageBox.Show("经费类型属于项目经费,请到项目经费管理模块处理!", "错误");
                return;
            }
            if (FundDate.SelectedDate == null)
            {
                MessageBox.Show("请选择日期!", "错误");
                return;
            }
            if (contractID <= 0)
            {
                MessageBox.Show("请选择合同!", "错误");
                return;
            }
            var funds = new ContractFunds();

            funds.ContractID = contractID;
            if (!string.IsNullOrWhiteSpace(textBoxContractNo.Text))
            {
                funds.ContractNo = textBoxContractNo.Text.Trim();
            }
            funds.Source         = FundSource.Text;
            funds.FundClassifyID = ((FundClassify)FundClassifys.SelectedItem).FandClassifyId;
            try
            {
                funds.Money = (decimal)double.Parse(Money.Text);
            }
            catch (FormatException)
            {
                MessageBox.Show("金额格式不对!", "错误");
                return;
            }
            funds.Date         = FundDate.SelectedDate;
            funds.Handled      = Handled.Text.Trim();
            funds.SubPrincipal = SubPrincipal.Text.Trim();
            dataContent        = new DataClassesProjectClassifyDataContext();
            dataContent.ContractFunds.InsertOnSubmit(funds);
            dataContent.SubmitChanges();
            dataGridFund.DataContext    = dataContent.Funds.Where(f => f.ProjectID.Equals(ProjectID)).OrderBy(f => f.Date);
            ((MainWindow)Owner).DialogR = true;
            SetTotalMoney();
        }
 private void buttonSubmit_Click(object sender, RoutedEventArgs e)
 {
     if (RewardClasses.SelectedItem == null)
     {
         MessageBox.Show("请选择奖项级别!", "错误");
         return;
     }
     if (RewardClassifies.SelectedItem == null)
     {
         MessageBox.Show("请选择奖项等别!", "错误");
         return;
     }
     //if(RewardDate.SelectedDate == null)
     //{
     //    MessageBox.Show("请选择授奖日期!", "错误");
     //    return;
     //}
     if (String.IsNullOrEmpty(RewardDepartment.Text))
     {
         MessageBox.Show("请填写授奖机构!", "错误");
         return;
     }
     if (String.IsNullOrEmpty(RewardName.Text))
     {
         MessageBox.Show("请填写奖项名称!", "错误");
         return;
     }
     dataContext = new DataClassesProjectClassifyDataContext();
     Reward rw = new Reward();
     rw.ProjectID = projectID;
     rw.RewardClassID = ((RewardClass)RewardClasses.SelectedItem).RewardClassId;
     rw.RewardClassifyID = ((RewardClassify)RewardClassifies.SelectedItem).RewardClassifyID;
     rw.RewardName = RewardName.Text.Trim();
     rw.ReawardYear = RewardYear.Text.Trim();
     if (RewardDate.SelectedDate != null)
     {
         rw.RewardDate = RewardDate.SelectedDate;
     }
     rw.RewardDepartment = RewardDepartment.Text.Trim();
     rw.Department = Department.Text.Trim();
     rw.Workers = Workers.Text.Trim();
     rw.Note = Note.Text.Trim();
     dataContext.Reward.InsertOnSubmit(rw);
     dataContext.SubmitChanges();
     dataGridRewards.DataContext = dataContext.Reward.Where(r => r.ProjectID.Equals(projectID));
     ((MainWindow)(this.Owner)).DialogR = true;
 }
Пример #9
0
        private void buttonDelete_Click(object sender, RoutedEventArgs e)
        {
            if (ID == 0)
            {
                MessageBox.Show("请选择成果登记项!", "错误");
                return;
            }
            dataContent = new DataClassesProjectClassifyDataContext();
            var re = dataContent.Results.Single(r => r.Id.Equals(ID));

            dataContent.Results.DeleteOnSubmit(re);
            dataContent.SubmitChanges();
            dataContent = new DataClassesProjectClassifyDataContext();
            dataGridResults.DataContext        = dataContent.Results.Where(r => r.ProjectID.Equals(projectID));
            ((MainWindow)(this.Owner)).DialogR = true;
            Clear();
        }
Пример #10
0
        private void buttonAdd_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(Worker.Text))
            {
                MessageBox.Show("请输入团队成员姓名!", "错误");
                return;
            }
            dataContext = new DataClassesProjectClassifyDataContext();
            TeamWorkers teamWorkers = new TeamWorkers();

            teamWorkers.ProjectID  = projectID;
            teamWorkers.WorkerName = Worker.Text;
            dataContext.TeamWorkers.InsertOnSubmit(teamWorkers);
            dataContext.SubmitChanges();
            Workers.DataContext = dataContext.TeamWorkers.Where(t => t.ProjectID.Equals(projectID));
            ((MainWindow)(this.Owner)).DialogR = true;
        }
Пример #11
0
        private void DeleteProject()
        {
            if (projectID == 0)
            {
                MessageBox.Show("请选择项目!", "错误");
                return;
            }
            var pb = dataContext.ProjectBase.Single(p => p.ProjectId.Equals(projectID));

            if (MessageBox.Show("确认删除项目 " + pb.ProjectName + " ?! 删除后将不能恢复!", "警告", MessageBoxButton.YesNoCancel) != MessageBoxResult.Yes)
            {
                return;
            }
            dataContext.ProjectBase.DeleteOnSubmit(pb);
            dataContext.SubmitChanges();
            projectID = 0;
            DialogR   = true;
            RefreshData();
        }
 private void buttonDelete_Click(object sender, RoutedEventArgs e)
 {
     if (ID == 0)
     {
         MessageBox.Show("请选择奖项!", "错误");
         return;
     }
     if (MessageBox.Show("该项奖项将被删除!确认要删除该项奖项信息?", "警告", MessageBoxButton.YesNo) == MessageBoxResult.No)
     {
         return;
     }
     dataContext = new DataClassesProjectClassifyDataContext();
     var rw = dataContext.Reward.Single(r => r.Id.Equals(ID));
     dataContext.Reward.DeleteOnSubmit(rw);
     dataContext.SubmitChanges();
     dataContext = new DataClassesProjectClassifyDataContext();
     dataGridRewards.DataContext = dataContext.Reward.Where(r => r.ProjectID.Equals(projectID));
     ((MainWindow)(this.Owner)).DialogR = true;
     Clear();
 }
Пример #13
0
        private void buttonDelete_Click(object sender, RoutedEventArgs e)
        {
            if (contractID == 0)
            {
                MessageBox.Show("请选择合同项!", "错误");
                return;
            }
            if (MessageBox.Show("该项合同将被删除!确认要删除该项合同信息?", "警告", MessageBoxButton.YesNo) == MessageBoxResult.No)
            {
                return;
            }
            dataContext = new DataClassesProjectClassifyDataContext();
            var pc = dataContext.ProjectContracts.Single(p => p.ID.Equals(contractID));

            dataContext.ProjectContracts.DeleteOnSubmit(pc);
            dataContext.SubmitChanges();
            dataContext = new DataClassesProjectClassifyDataContext();
            datagridContracts.DataContext      = dataContext.ProjectContracts.Where(p => p.ProjectID.Equals(projectID));
            ((MainWindow)(this.Owner)).DialogR = true;
            Clear();
        }
Пример #14
0
        private void buttonRemove_Click(object sender, RoutedEventArgs e)
        {
            if (ID == 0)
            {
                MessageBox.Show("请选择团队成员!", "错误");
                return;
            }
            if (MessageBox.Show("该团队成员将被删除!确认要删除该团队成员信息?", "警告", MessageBoxButton.YesNo) == MessageBoxResult.No)
            {
                return;
            }
            dataContext = new DataClassesProjectClassifyDataContext();
            TeamWorkers teamWorkers = (TeamWorkers)Workers.SelectedItem;

            dataContext.TeamWorkers.DeleteOnSubmit(teamWorkers);
            dataContext.SubmitChanges();
            dataContext         = new DataClassesProjectClassifyDataContext();
            Workers.DataContext = dataContext.TeamWorkers.Where(t => t.ProjectID.Equals(projectID));
            ((MainWindow)(this.Owner)).DialogR = true;
            Clear();
        }
        private void buttonDelete_Click(object sender, RoutedEventArgs e)
        {
            if (fundID == 0)
            {
                MessageBox.Show("请选择经费项!", "错误");
                return;
            }
            if (MessageBox.Show("该项经费将被删除!确认要删除该项经费信息?", "警告", MessageBoxButton.YesNo) == MessageBoxResult.No)
            {
                return;
            }
            dataContent = new DataClassesProjectClassifyDataContext();
            var fd = dataContent.Funds.Single(f => f.Id.Equals(fundID));

            dataContent.Funds.DeleteOnSubmit(fd);
            dataContent.SubmitChanges();
            dataContent = new DataClassesProjectClassifyDataContext();
            dataGridFund.DataContext    = dataContent.Funds.Where(f => f.ProjectID.Equals(ProjectID));
            ((MainWindow)Owner).DialogR = true;
            Clear();
            SetTotalMoney();
        }
 private void buttonAdd_Click(object sender, RoutedEventArgs e)
 {
     if (String.IsNullOrEmpty(ClassifyName.Text))
     {
         MessageBox.Show("请输入知识产权类别名称", "错误");
         return;
     }
     else
     {
         var pc = dataContext.PatentClassify.Count(p => p.PatentClassify1.Equals(ClassifyName.Text.Trim()));
         if (pc > 0)
         {
             MessageBox.Show("已存在相同知识产权类别", "错误");
             return;
         }
         PatentClassify patentClassify = new PatentClassify();
         patentClassify.PatentClassify1 = ClassifyName.Text.Trim();
         dataContext.PatentClassify.InsertOnSubmit(patentClassify);
         dataContext.SubmitChanges();
         dataContext            = new DataClassesProjectClassifyDataContext();
         Classifies.DataContext = dataContext.PatentClassify;
     }
 }
Пример #17
0
        private void buttonSubmit_Click(object sender, RoutedEventArgs e)
        {
            if (RegistDate.SelectedDate == null)
            {
                MessageBox.Show("请选择日期!", "错误");
                return;
            }
            if (String.IsNullOrEmpty(RegistNo.Text))
            {
                MessageBox.Show("请输入成果登记号!", "错误");
                return;
            }
            Results rs = new Results();

            rs.ProjectID  = projectID;
            rs.RegistDate = RegistDate.SelectedDate;
            rs.RegistNo   = RegistNo.Text.Trim();
            dataContent   = new DataClassesProjectClassifyDataContext();
            dataContent.Results.InsertOnSubmit(rs);
            dataContent.SubmitChanges();
            dataGridResults.DataContext        = dataContent.Results.Where(r => r.ProjectID.Equals(projectID));
            ((MainWindow)(this.Owner)).DialogR = true;
        }
 private void buttonAdd_Click(object sender, RoutedEventArgs e)
 {
     if (String.IsNullOrEmpty(ClassifyName.Text))
     {
         MessageBox.Show("请输入奖项级别", "错误");
         return;
     }
     else
     {
         var pc = dataContext.RewardClass.Count(p => p.RewardClass1.Equals(ClassifyName.Text.Trim()));
         if (pc > 0)
         {
             MessageBox.Show("已存在相同奖项级别", "错误");
             return;
         }
         RewardClass rewardClass = new RewardClass();
         rewardClass.RewardClass1 = ClassifyName.Text.Trim();
         dataContext.RewardClass.InsertOnSubmit(rewardClass);
         dataContext.SubmitChanges();
         dataContext            = new DataClassesProjectClassifyDataContext();
         Classifies.DataContext = dataContext.RewardClass;
     }
 }
Пример #19
0
 private void buttonAdd_Click(object sender, RoutedEventArgs e)
 {
     if (String.IsNullOrEmpty(ClassifyName.Text))
     {
         MessageBox.Show("请输入经费类别", "错误");
         return;
     }
     else
     {
         var pc = dataContext.FundClassify.Count(p => p.FundClassify1.Equals(ClassifyName.Text.Trim()));
         if (pc > 0)
         {
             MessageBox.Show("已存在相同经费类别", "错误");
             return;
         }
         FundClassify fundClassify = new FundClassify();
         fundClassify.FundClassify1 = ClassifyName.Text.Trim();
         fundClassify.IncomeOrPay   = IsInCome.IsChecked;
         dataContext.FundClassify.InsertOnSubmit(fundClassify);
         dataContext.SubmitChanges();
         dataContext            = new DataClassesProjectClassifyDataContext();
         Classifies.DataContext = dataContext.FundClassify;
     }
 }
Пример #20
0
 private void buttonAdd_Click(object sender, RoutedEventArgs e)
 {
     if (String.IsNullOrEmpty(ClassifyName.Text))
     {
         MessageBox.Show("请输入项目类别名称", "错误");
         return;
     }
     else
     {
         var pc = dataContext.ProjectClassify.Count(p => p.ProjectClassify1.Equals(ClassifyName.Text.Trim()));
         if (pc > 0)
         {
             MessageBox.Show("已存在相同项目类别名称", "错误");
             return;
         }
         ProjectClassify projectClassify = new ProjectClassify();
         projectClassify.ProjectClassify1 = ClassifyName.Text.Trim();
         dataContext.ProjectClassify.InsertOnSubmit(projectClassify);
         dataContext.SubmitChanges();
         dataContext                        = new DataClassesProjectClassifyDataContext();
         Classifies.DataContext             = dataContext.ProjectClassify;
         ((MainWindow)(this.Owner)).DialogR = true;
     }
 }
Пример #21
0
        private void buttonSubmit_Click(object sender, RoutedEventArgs e)
        {
            if (!validDate())
            {
                MessageBox.Show("日期或数字格式不对!", "警告");
                return;
            }

            if (isCreate)
            {
                if (MessageBox.Show("确认新建项目?", "温馨提示", MessageBoxButton.OKCancel) != MessageBoxResult.OK)
                {
                    return;
                }
                //新建项目
                if (!isSubProject)
                {
                    //非子项目
                    dataContent = new DataClassesProjectClassifyDataContext();
                    var pb = dataContent.ProjectBase.Where(p => p.ProjectNo.Trim().Equals(ProjectNo.Text.Trim()) && p.ProjectNo.Trim() != "");
                    if (pb.Count() > 0)
                    {
                        MessageBox.Show("院编号重复,已经录入该项目?", "错误");
                        return;
                    }
                    ProjectBase projectBase = new ProjectBase();
                    projectBase.ProjectClassifyID = projectClassifyID;
                    projectBase.ProjectNo         = ProjectNo.Text.Trim();
                    projectBase.ContractNo        = ContractNo.Text.Trim();
                    projectBase.FirstParty        = FirstParty.Text.Trim();
                    projectBase.SecondParty       = SecondParty.Text.Trim();
                    projectBase.SetupYear         = SetupYear.Text.Trim();
                    projectBase.ProjectName       = ProjectName.Text.Trim();
                    if (!String.IsNullOrEmpty(StartDate.Text.Trim()))
                    {
                        projectBase.StartDate = DateTime.Parse(StartDate.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(PlanFinishDate.Text.Trim()))
                    {
                        projectBase.PlanFinishDate = DateTime.Parse(PlanFinishDate.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(FinishDate.Text.Trim()))
                    {
                        projectBase.FinishDate = DateTime.Parse(FinishDate.Text.Trim());
                    }
                    projectBase.Principal = Principal.Text.Trim();
                    if (!String.IsNullOrEmpty(SumMoney.Text.Trim()))
                    {
                        projectBase.SumMoney = Convert.ToDecimal(SumMoney.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(Ministry.Text.Trim()))
                    {
                        projectBase.Ministry = Convert.ToDecimal(Ministry.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(Transportation.Text))
                    {
                        projectBase.Transportation = Convert.ToDecimal(Transportation.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(Science.Text.Trim()))
                    {
                        projectBase.Science = Convert.ToDecimal(Science.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(SupportEngineering.Text.Trim()))
                    {
                        projectBase.SupportEngineering = Convert.ToDecimal(SupportEngineering.Text);
                    }
                    if (!String.IsNullOrEmpty(Other.Text.Trim()))
                    {
                        projectBase.Other = Convert.ToDecimal(Other.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(AuthrizeMoney.Text.Trim()))
                    {
                        projectBase.AuthorizeMoney = Convert.ToDecimal(AuthrizeMoney.Text.Trim());
                    }
                    projectBase.AnchoredDepartment = AnchoredDepartment.Text.Trim();
                    if ((bool)(IsKnot1.IsChecked))
                    {
                        projectBase.IsKnot = "验收";
                    }
                    if ((bool)(IsKnot2.IsChecked))
                    {
                        projectBase.IsKnot = "鉴定";
                    }
                    if ((bool)(IsKnot3.IsChecked))
                    {
                        projectBase.IsKnot = "尚未结题";
                    }
                    if ((bool)(IsKnot5.IsChecked))
                    {
                        projectBase.IsKnot = "结清";
                    }
                    projectBase.IsMainResearch = IsMainSearch.IsChecked;
                    projectBase.IsFiled        = IsFiled.IsChecked;
                    projectBase.Note           = Note.Text.Trim();
                    dataContent.ProjectBase.InsertOnSubmit(projectBase);
                    dataContent.SubmitChanges();
                    ProjectID = projectBase.ProjectId;
                    ((MainWindow)(this.Owner)).ProjectID = projectID;
                }
                else
                {
                    //子项目
                    dataContent = new DataClassesProjectClassifyDataContext();
                    var pb = dataContent.ProjectBase.Where(p => p.ProjectNo.Trim().Equals(ProjectNo.Text.Trim()) && p.ProjectNo.Trim() != "");
                    if (pb.Count() > 0)
                    {
                        MessageBox.Show("院编号重复,已经录入该项目?", "错误");
                        return;
                    }
                    ProjectBase projectBase = new ProjectBase();
                    projectBase.ParentID    = ParentID;
                    projectBase.ProjectNo   = ProjectNo.Text.Trim();
                    projectBase.ContractNo  = ContractNo.Text.Trim();
                    projectBase.FirstParty  = FirstParty.Text.Trim();
                    projectBase.SecondParty = SecondParty.Text.Trim();
                    projectBase.SetupYear   = SetupYear.Text.Trim();
                    projectBase.ProjectName = ProjectName.Text.Trim();
                    if (!String.IsNullOrEmpty(StartDate.Text.Trim()))
                    {
                        projectBase.StartDate = DateTime.Parse(StartDate.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(PlanFinishDate.Text.Trim()))
                    {
                        projectBase.PlanFinishDate = DateTime.Parse(PlanFinishDate.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(FinishDate.Text.Trim()))
                    {
                        projectBase.FinishDate = DateTime.Parse(FinishDate.Text.Trim());
                    }
                    projectBase.Principal = Principal.Text.Trim();
                    if (!String.IsNullOrEmpty(SumMoney.Text.Trim()))
                    {
                        projectBase.SumMoney = Convert.ToDecimal(SumMoney.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(Ministry.Text.Trim()))
                    {
                        projectBase.Ministry = Convert.ToDecimal(Ministry.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(Transportation.Text))
                    {
                        projectBase.Transportation = Convert.ToDecimal(Transportation.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(Science.Text.Trim()))
                    {
                        projectBase.Science = Convert.ToDecimal(Science.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(SupportEngineering.Text.Trim()))
                    {
                        projectBase.SupportEngineering = Convert.ToDecimal(SupportEngineering.Text);
                    }
                    if (!String.IsNullOrEmpty(Other.Text.Trim()))
                    {
                        projectBase.Other = Convert.ToDecimal(Other.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(AuthrizeMoney.Text.Trim()))
                    {
                        projectBase.AuthorizeMoney = Convert.ToDecimal(AuthrizeMoney.Text.Trim());
                    }
                    projectBase.AnchoredDepartment = AnchoredDepartment.Text.Trim();
                    if ((bool)(IsKnot1.IsChecked))
                    {
                        projectBase.IsKnot = "验收";
                    }
                    if ((bool)(IsKnot2.IsChecked))
                    {
                        projectBase.IsKnot = "鉴定";
                    }
                    if ((bool)(IsKnot3.IsChecked))
                    {
                        projectBase.IsKnot = "尚未结题";
                    }
                    if ((bool)(IsKnot5.IsChecked))
                    {
                        projectBase.IsKnot = "结清";
                    }
                    projectBase.IsMainResearch = IsMainSearch.IsChecked;
                    projectBase.IsFiled        = IsFiled.IsChecked;
                    projectBase.Note           = Note.Text.Trim();
                    dataContent.ProjectBase.InsertOnSubmit(projectBase);
                    dataContent.SubmitChanges();
                    ProjectID = projectBase.ProjectId;
                    ((MainWindow)(this.Owner)).ProjectID = projectID;
                }
            }
            else
            {
                //修改项目
                if (dataContent == null)
                {
                    dataContent = new DataClassesProjectClassifyDataContext();
                }
                var pb = dataContent.ProjectBase.Where(p => p.ProjectNo.Trim().Equals(ProjectNo.Text.Trim()) && p.ProjectNo.Trim() != "" && p.ProjectId != projectID);
                if (pb.Count() > 0)
                {
                    MessageBox.Show("项目编号重复!", "错误");
                    return;
                }
                ProjectBase projectBase = dataContent.ProjectBase.Single(p => p.ProjectId.Equals(ProjectID));
                projectBase.ProjectNo   = ProjectNo.Text.Trim();
                projectBase.ContractNo  = ContractNo.Text.Trim();
                projectBase.FirstParty  = FirstParty.Text.Trim();
                projectBase.SecondParty = SecondParty.Text.Trim();
                projectBase.SetupYear   = SetupYear.Text.Trim();
                projectBase.ProjectName = ProjectName.Text.Trim();
                if (!String.IsNullOrEmpty(StartDate.Text.Trim()))
                {
                    projectBase.StartDate = DateTime.Parse(StartDate.Text.Trim());
                }
                if (!String.IsNullOrEmpty(PlanFinishDate.Text.Trim()))
                {
                    projectBase.PlanFinishDate = DateTime.Parse(PlanFinishDate.Text.Trim());
                }
                if (!String.IsNullOrEmpty(FinishDate.Text.Trim()))
                {
                    projectBase.FinishDate = DateTime.Parse(FinishDate.Text.Trim());
                }
                projectBase.Principal = Principal.Text.Trim();
                if (!String.IsNullOrEmpty(SumMoney.Text.Trim()))
                {
                    projectBase.SumMoney = Convert.ToDecimal(SumMoney.Text.Trim());
                }
                if (!String.IsNullOrEmpty(Ministry.Text.Trim()))
                {
                    projectBase.Ministry = Convert.ToDecimal(Ministry.Text.Trim());
                }
                if (!String.IsNullOrEmpty(Transportation.Text))
                {
                    projectBase.Transportation = Convert.ToDecimal(Transportation.Text.Trim());
                }
                if (!String.IsNullOrEmpty(Science.Text.Trim()))
                {
                    projectBase.Science = Convert.ToDecimal(Science.Text.Trim());
                }
                if (!String.IsNullOrEmpty(SupportEngineering.Text.Trim()))
                {
                    projectBase.SupportEngineering = Convert.ToDecimal(SupportEngineering.Text);
                }
                if (!String.IsNullOrEmpty(Other.Text.Trim()))
                {
                    projectBase.Other = Convert.ToDecimal(Other.Text.Trim());
                }
                if (!String.IsNullOrEmpty(AuthrizeMoney.Text.Trim()))
                {
                    projectBase.AuthorizeMoney = Convert.ToDecimal(AuthrizeMoney.Text.Trim());
                }
                projectBase.AnchoredDepartment = AnchoredDepartment.Text.Trim();
                if ((bool)(IsKnot1.IsChecked))
                {
                    projectBase.IsKnot = "验收";
                }
                if ((bool)(IsKnot2.IsChecked))
                {
                    projectBase.IsKnot = "鉴定";
                }
                if ((bool)(IsKnot3.IsChecked))
                {
                    projectBase.IsKnot = "尚未结题";
                }
                if ((bool)(IsKnot5.IsChecked))
                {
                    projectBase.IsKnot = "结清";
                }
                projectBase.IsMainResearch = IsMainSearch.IsChecked;
                projectBase.IsFiled        = IsFiled.IsChecked;
                projectBase.Note           = Note.Text.Trim();
                dataContent.SubmitChanges();
            }
            ((MainWindow)(this.Owner)).DialogR = true;
            this.Close();
        }
        /// <summary>
        /// 读取奖金数据
        /// </summary>
        private void ReadData()
        {
            var ws = _wb.Worksheets.FirstOrDefault();

            if (ws != null)
            {
                List <string> logins = new List <string>();
                _doo       = new DomainOperate("hncdi");
                _totalRows = ws.Rows().Count();
                int currentRow = 5;
                _listPrizeses = new List <Prizes>();
                while (currentRow <= _totalRows)
                {
                    var row = ws.Row(currentRow);
                    if (row.Cell(1).IsEmpty())
                    {
                        currentRow++;
                        continue;
                    }
                    string temp = row.Cell(1).GetString();
                    temp = temp.Replace(" ", "").Trim();
                    if (temp == "合计" || temp == "小计" || temp == "总计" || temp == "共计")
                    {
                        break;
                    }
                    //if (row.Cell(2).IsEmpty() && row.Cell(1).GetString().Contains("计")) break;
                    var dataRow    = row.RowUsed();
                    int totalCol   = dataRow.CellCount();
                    int currentCol = 1;
                    if (dataRow.Cell(currentCol).IsEmpty())
                    {
                        currentRow++;
                        continue;
                    }
                    string userName = dataRow.Cell(currentCol).GetString();
                    userName = userName.Replace(" ", "").Trim();
                    if (IsNumber(userName))
                    {
                        currentRow++;
                        continue;
                    }
                    GetUserAccount(userName, out logins);

                    if (!logins.Any())
                    {
                        CurrentEmployee = new Employee
                        {
                            Name        = userName,
                            AccountName = "",
                            Department  = _declareDepartment
                        };
                    }
                    else
                    {
                        if (logins.Count() > 1)
                        {
                            SelectPrizeEmployee selectPrizeEmployee = new SelectPrizeEmployee();
                            selectPrizeEmployee.EmployeeName = userName;
                            selectPrizeEmployee.ShowDialog();
                            CurrentEmployeeName        = selectPrizeEmployee.EmployeeName;
                            CurrentEmployeeAccountName = selectPrizeEmployee.SelectedAccountName;
                            CurrentEmployeeDepartment  = selectPrizeEmployee.SelectedDepartment;
                            if (string.IsNullOrWhiteSpace(CurrentEmployeeName))
                            {
                                CurrentEmployee = null;
                            }
                            else
                            {
                                CurrentEmployee = new Employee
                                {
                                    Name        = CurrentEmployeeName,
                                    AccountName = CurrentEmployeeAccountName,
                                    Department  = CurrentEmployeeDepartment
                                };
                            }
                        }
                        else
                        {
                            CurrentEmployee = new Employee
                            {
                                Name        = userName,
                                AccountName = logins[0],
                                Department  = _doo.GetOuByLoginID(logins[0])
                            };
                        }
                    }
                    if (CurrentEmployee == null)
                    {
                        currentRow++;
                        continue;
                    }
                    currentCol = 4;
                    while (currentCol <= totalCol)
                    {
                        if (string.IsNullOrWhiteSpace(_dictionaryProject[currentCol]) || dataRow.Cell(currentCol).IsEmpty())
                        {
                            currentCol++;
                            continue;
                        }
                        try
                        {
                            decimal prize = Convert.ToDecimal(dataRow.Cell(currentCol).Value);
                            if (prize <= 0.0M)
                            {
                                currentCol++;
                                continue;
                            }
                            if (currentCol > _lastCategoryColNo)
                            {
                                _dictionaryCategory.Add(currentCol, "");
                                _lastCategoryColNo++;
                            }
                            if (currentCol > _lastProjectColNo)
                            {
                                _dictionaryProject.Add(currentCol, _dictionaryProject[_lastProjectColNo]);
                                _lastProjectColNo++;
                            }
                            if (currentCol > _lastClassifyColNo)
                            {
                                _dictionaryPrizeClassify.Add(currentCol, _dictionaryPrizeClassify[_lastClassifyColNo]);
                                _lastClassifyColNo++;
                            }

                            Prizes prizes = new Prizes
                            {
                                Department        = CurrentEmployee.Department,
                                DeclareDepartment = _declareDepartment,
                                Name          = CurrentEmployee.Name,
                                AccountName   = CurrentEmployee.AccountName,
                                Project       = _dictionaryProject[currentCol],
                                PrizeClassify = _dictionaryPrizeClassify[currentCol],
                                AwardName     = _dictionaryCategory[currentCol],
                                Prize         = prize,
                                PayYear       = _year
                            };
                            //检查重复项
                            var pr =
                                dataContext.Prizes.FirstOrDefault(
                                    p =>
                                    p.Department.Equals(prizes.Department) &&
                                    //p.DeclareDepartment.Equals(prizes.DeclareDepartment) &&
                                    p.Name.Equals(prizes.Name) && p.AccountName.Equals(prizes.AccountName) &&
                                    p.Project.Equals(prizes.Project) && p.PrizeClassify.Equals(prizes.PrizeClassify) &&
                                    p.PayYear.Equals(prizes.PayYear) &&
                                    p.AwardName.Equals(prizes.AwardName));

                            if (pr != null)
                            {
                                if (pr.Prize != prizes.Prize)
                                {
                                    pr.Prize = prizes.Prize;
                                    dataContext.SubmitChanges();
                                }
                            }
                            else
                            {
                                dataContext.Prizes.InsertOnSubmit(prizes);
                                dataContext.SubmitChanges();
                            }
                            currentCol++;
                        }
                        catch (Exception error)
                        {
                            MessageBox.Show(error.Message + "当前行" + currentRow.ToString());
                            currentCol++;
                        }
                    }
                    currentRow++;
                }
            }
        }