private void ButtonShift_Click(object sender, RoutedEventArgs e) { if (FundClassifys.SelectedItem == null) { return; } var fundClassify = (FundClassify)FundClassifys.SelectedItem; if ((fundClassify.FundClassify1 != "到账") && (fundClassify.FundClassify1 != "支付外协")) { return; } if (dataGridFund.SelectedItem == null) { return; } if (string.IsNullOrWhiteSpace(textBoxContractNo.Text)) { MessageBox.Show("请输入合同编号!", "错误"); return; } if (dataContent == null) { dataContent = new DataClassesProjectClassifyDataContext(); } try { var funds = (Funds)dataGridFund.SelectedItem; var contract = dataContent.ProjectContracts.FirstOrDefault(c => c.ContractNo.Equals(funds.ContractNo)); if (contract == null) { return; } var contractFunds = new ContractFunds { ContractNo = funds.ContractNo, ContractID = contract.ID, FundClassifyID = funds.FundClassifyID, Date = funds.Date, Handled = funds.Handled, Money = funds.Money, Source = funds.Source, SubPrincipal = funds.SubPrincipal }; dataContent.ContractFunds.InsertOnSubmit(contractFunds); dataContent.Funds.DeleteOnSubmit(funds); dataContent.SubmitChanges(); dataContent = new DataClassesProjectClassifyDataContext(); dataGridFund.DataContext = dataContent.Funds.Where(f => f.ProjectID.Equals(ProjectID)).OrderBy(f => f.Date); SetTotalMoney(); } catch (Exception) { throw; } }
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(); }