public static void UpdataService(Contract_Data a) { string s = String.Format(@"update Contract_Data set Service='{0}'where ID='{1}'", a.Service, a.Contract_ID); using (var conn = new SqlConnection(@string)) { gongong(conn, s); } }
public static void updata(object ob) { using (var conn = new SqlConnection(@string)) { if (ob is Accountant) { Accountant c = (Accountant)ob; string sql0 = String.Format(@"update Accountant set ID='{0}',ContractID='{1}',AffirmIncomeGist='{2}', SubAffirmIncomeAmount={3}, SubInvoiceCount={4},SubInvoiceAmount={5},SubCost={6},SubMaterial={7},Subworker={8},SubManufacturing_Costs={9},Subtotal={10},AvgGrossrofitMargin={11},NoAffirmIncomeAmount={12} where ID='{0}'", c.ID, c.ContractID, c.AffirmIncomeGist, c.SubAffirmIncomeAmount, c.SubInvoiceCount, c.SubInvoiceAmount, c.SubCost, c.SubMaterial, c.Subworker, c.SubManufacturing_Costs, c.Subtotal, c.AvgGrossrofitMargin, c.NoAffirmIncomeAmount); conn.Open(); SqlCommand cmd = new SqlCommand(sql0, conn); cmd.ExecuteNonQuery(); } if (ob is Productioner) { Productioner c = (Productioner)ob; string sql0 = String.Format(@"update Productioner set ID='{0}',ContractID='{1}',TotalProduct={2}, NoTotalProduct={3} where ID='{0}'", c.ID, c.ContractID, c.TotalProduct, c.NoTotalProduct); conn.Open(); SqlCommand cmd = new SqlCommand(sql0, conn); cmd.ExecuteNonQuery(); } if (ob is Sales) { Sales c = (Sales)ob; string sql0 = String.Format(@"update Sales set ID='{0}',ContractID='{1}',AmountCollection={2}, NoAmountCollection={3}, SubAffirmIncomeAmount={4},SubInvoiceCount={5},SubInvoiceAmount={6} where ID='{0}'", c.ID, c.ContractID, c.AmountCollection, c.NoAmountCollection, c.SubAffirmIncomeAmount, c.SubInvoiceCount, c.SubInvoiceAmount); conn.Open(); SqlCommand cmd = new SqlCommand(sql0, conn); cmd.ExecuteNonQuery(); } if (ob is Warehouse) { Warehouse c = (Warehouse)ob; string sql0 = String.Format(@"update Warehouse set ID='{0}',ContractID='{1}',Reserves={2},ShippedCount={3}, NoShippedCount={4} where ID='{0}'", c.ID, c.ContractID, c.Reserves, c.ShippedCount, c.NoShippedCount); conn.Open(); SqlCommand cmd = new SqlCommand(sql0, conn); cmd.ExecuteNonQuery(); } if (ob is Project) { Project c = (Project)ob; string sql0 = String.Format(@"update Project set ID='{0}',ContractID='{1}',DompletedDate='{2}',DompletedAcceptanceDate='{3}',ProjectStart='{4}' where ID='{0}'", c.ID, c.ContractID, c.DompletedDate, c.DompletedAcceptanceDate, c.ProjectStart); conn.Open(); SqlCommand cmd = new SqlCommand(sql0, conn); cmd.ExecuteNonQuery(); } if (ob is Contract_Data) { Contract_Data a = (Contract_Data)ob; string sql0 = String.Format(@"update Contract_Data set ID='{0}',Contract_ID='{1}',Service='{2}' where ID='{0}'", a.ID, a.Contract_ID, a.Service); conn.Open(); SqlCommand cmd = new SqlCommand(sql0, conn); cmd.ExecuteNonQuery(); } } }
private void btn_Save_Click(object sender, RoutedEventArgs e) { string logName = tb_LogName.Text.ToString().Trim(); Contract_Data item = (Contract_Data)cb_Service.SelectedItem; string service = item.Service; string affirmIncomeGist; try { ComboBoxItem cbi = cb_AffirmIncomeGist.SelectedItem as ComboBoxItem; affirmIncomeGist = cbi.Content.ToString().Trim(); } catch (NullReferenceException) { affirmIncomeGist = ""; } string affirmIncomeAmount = tb_AffirmIncomeAmount.Text.ToString().Trim(); string invoiceCount = tb_InvoiceCount.Text.ToString().Trim(); string invoiceAmount = tb_InvoiceAmount.Text.ToString().Trim(); string cost = tb_Cost.Text.ToString().Trim(); string material = tb_Material.Text.ToString().Trim(); string subtotal = tb_Subtotal.Text.ToString().Trim(); string grossrofitMargin = tb_GrossrofitMargin.Text.ToString().Trim(); string name = tb_Name.Text.ToString().Trim();; if (string.IsNullOrEmpty(logName) || string.IsNullOrEmpty(service)) { MessageBox.Show("日志名和服务条款不能为空"); } else { AccountantLog al = new AccountantLog(); al.ID = Guid.NewGuid(); al.LogName = logName; al.LogDate = DateTime.Now.ToString(); // al.ServiceID= al.Name = name; al.Service = service; al.AffirmIncomeGist = affirmIncomeAmount; al.AffirmIncomeAmount = Convert.ToDecimal(affirmIncomeAmount); al.InvoiceCount = Convert.ToDouble(invoiceCount); al.InvoiceAmount = Convert.ToDecimal(invoiceAmount); al.Cost = Convert.ToDouble(cost); al.Material = Convert.ToDecimal(material); al.GrossrofitMargin = Convert.ToDouble(grossrofitMargin); al.Subtotal = Convert.ToDecimal(subtotal); al.ContractID = mw.ct.ID; al.DepartmentID = mw.aac[0].ID; al.ServiceID = item.ID; mw.oac.Add(al); mw.aac[0] = GetData.AccountantGet(al, mw.aac)[0]; MessageBox.Show("操作成功!"); this.Close(); } }
private void btn_DeleteService3_Click(object sender, RoutedEventArgs e) { Contract_Data cd = (Contract_Data)ListViewSerices.SelectedItem; ocd.Remove(cd); SqlQuery.DeleteService(cd.ID); int a = opt.Count; int b = ppt.Count; int c = osl.Count; int ee = oac.Count; for (int i = a - 1; i >= 0; i--) { if (opt[i].ServiceID == cd.ID) { opt.Remove(opt[i]); } } for (int i = b - 1; i >= 0; i--) { if (ppt[i].ServiceID == cd.ID) { ppt.Remove(ppt[i]); } } for (int i = c - 1; i >= 0; i--) { if (osl[i].ServiceID == cd.ID) { osl.Remove(osl[i]); } } for (int i = ee - 1; i >= 0; i--) { if (oac[i].ServiceID == cd.ID) { oac.Remove(oac[i]); } } //opt.Remove((opt.FirstOrDefault<ProjectLog>(x => x.ServiceID == cd.ID))); //osl.Remove((osl.FirstOrDefault<SalesLog>(x => x.ServiceID == cd.ID))); //oac.Remove((oac.FirstOrDefault<AccountantLog>(x => x.ServiceID == cd.ID))); }
public static void UpdataD(Contract_Data a) { string s0 = String.Format(@"update AccountantLog set Service='{0}'where ServiceID='{1}';", a.Service, a.ID); string s1 = String.Format(@"update ProjectLog set Service='{0}'where ServiceID='{1}';", a.Service, a.ID); string s2 = String.Format(@"update Project_data set Service='{0}'where ServiceID='{1}';", a.Service, a.ID); string s4 = String.Format(@"update SalesLog set Service='{0}'where ServiceID='{1}';", a.Service, a.ID); StringBuilder sb = new StringBuilder(); sb.Append(s0); sb.Append(s1); sb.Append(s2); sb.Append(s4); //string s = string.Concat(s0,s1,s2,s4); using (var conn = new SqlConnection(@string)) { gongong(conn, sb.ToString()); } }
public static void first(ContractNameT ct, Contract_Data cd) { Accountant ac = new Accountant(); ac.ID = Guid.NewGuid(); ac.ContractID = ct.ID; ac.NoAffirmIncomeAmount = ct.Contract_Amount; ac.SubAffirmIncomeAmount = 0; ac.SubInvoiceAmount = 0; ac.SubInvoiceCount = 0; ac.SubManufacturing_Costs = 0; ac.SubMaterial = 0; ac.Subtotal = 0; ac.Subworker = 0; ac.SubCost = 0; Productioner pr = new Productioner(); pr.ContractID = ct.ID; pr.NoTotalProduct = ct.Count; pr.TotalProduct = 0; pr.ID = Guid.NewGuid(); Project pt = new Project(); pt.ID = Guid.NewGuid(); pt.ContractID = ct.ID; Sales sl = new Sales(); sl.ID = Guid.NewGuid(); sl.ContractID = ct.ID; sl.AmountCollection = 0; sl.NoAmountCollection = ct.Contract_Amount; sl.SubAffirmIncomeAmount = 0; sl.SubInvoiceCount = 0; sl.SubInvoiceAmount = 0; Warehouse wh = new Warehouse(); wh.ID = Guid.NewGuid(); wh.ContractID = ct.ID; wh.NoShippedCount = ct.Count; wh.Reserves = 0; wh.ShippedCount = 0; SqlQuery.Contractinsert(ct, ac, pr, pt, sl, wh); }
private void btn_Save_Click(object sender, RoutedEventArgs e) { try { string logName = tb_LogName.Text.ToString().Trim(); Contract_Data item = (Contract_Data)cb_Service.SelectedItem; string service = item.Service; string amount = tb_Amount.Text.ToString().Trim(); if (string.IsNullOrEmpty(logName) || string.IsNullOrEmpty(service) || string.IsNullOrEmpty(amount)) { MessageBox.Show("所有值皆不能为空"); } else if (double.Parse(amount) < 0) { MessageBox.Show("收款金额不能为负数"); } else { SalesLog sl = new SalesLog(); sl.DepartmentID = mw.ssl[0].ID; sl.ID = Guid.NewGuid(); sl.ContractID = mw.ct.ID; sl.Service = service; sl.ServiceID = item.ID; sl.AffirmIncomeAmount = Convert.ToDecimal(amount); sl.LogDate = DateTime.Now.ToString(); sl.LogName = logName; mw.osl.Add(sl); mw.ssl[0] = GetData.SalesGet(sl, mw.ssl)[0]; MessageBox.Show("操作成功!"); this.Close(); } } catch (FormatException) { MessageBox.Show("收款金额只能为正数"); } }
public static void insert(object ob) { using (var conn = new SqlConnection(@string)) { if (ob is ProjectLog) { ProjectLog a = (ProjectLog)ob; string sql0 = String.Format("insert into ProjectLog(ID,DepartmentID,DompletedDate,DompletedAcceptanceDate,LogDate,Name,ContractID,LogName,ServiceID,ProjectStart,Service) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}')", a.ID, a.DepartmentID, a.DompletedDate, a.DompletedAcceptanceDate, a.LogDate, a.Name, a.ContractID, a.LogName, a.ServiceID, a.ProjectStart, a.Service); string s = string.Concat(sql0); conn.Open(); SqlCommand cmd = new SqlCommand(s, conn); cmd.ExecuteNonQuery(); } if (ob is Project_data) { Project_data a = (Project_data)ob; string sql0 = String.Format(@"UPDATE Project_data SET DompletedDate='{1}',DompletedAcceptanceDate='{2}',ServiceID='{3}',Service='{4}',ProjectStart='{5}',ContractID='{6}' WHERE ServiceID = '{3}';IF(@@ROWCOUNT = 0) BEGIN INSERT INTO Project_data(ID, DompletedDate,DompletedAcceptanceDate,ServiceID,Service,ProjectStart,ContractID)VALUES('{0}','{1}','{2}','{3}','{4}','{5}','{6}')END;", a.ID, a.DompletedDate, a.DompletedAcceptanceDate, a.ServiceID, a.Service, a.ProjectStart, a.ContractID); string s = string.Concat(sql0); conn.Open(); SqlCommand cmd = new SqlCommand(s, conn); cmd.ExecuteNonQuery(); } if (ob is AccountantLog) { AccountantLog a = (AccountantLog)ob; string sql0 = String.Format("insert into AccountantLog(ID,DepartmentID,AffirmIncomeGist,AffirmIncomeAmount,InvoiceCount,InvoiceAmount,Cost,Material,worker,Manufacturing_Costs,Subtotal,GrossrofitMargin,ContractID,LogDate,LogName,ServiceID,Name) values('{0}','{1}','{2}',{3},{4},{5},{6},{7},{8},{9},{10},{11},'{12}','{13}','{14}','{15}','{16}')", a.ID, a.DepartmentID, a.AffirmIncomeGist, a.AffirmIncomeAmount, a.InvoiceCount, a.InvoiceAmount, a.Cost, a.Material, a.worker, a.Manufacturing_Costs, a.Subtotal, a.GrossrofitMargin, a.ContractID, a.LogDate, a.LogName, a.ServiceID, a.Name); string s = string.Concat(sql0); conn.Open(); SqlCommand cmd = new SqlCommand(s, conn); cmd.ExecuteNonQuery(); } if (ob is ProductionerLog) { ProductionerLog a = (ProductionerLog)ob; string sql0 = String.Format("insert into ProductionerLog(ID,DepartmentID,ProductionCount,ProductionDate,LogDate,ContractID,LogName,Name) values('{0}','{1}',{2},'{3}','{4}','{5}','{6}','{7}')", a.ID, a.DepartmentID, a.ProductionCount, a.ProductionDate, a.LogDate, a.ContractID, a.LogName, a.Name); string s = string.Concat(sql0); conn.Open(); SqlCommand cmd = new SqlCommand(s, conn); cmd.ExecuteNonQuery(); } if (ob is WarehouseLog) { WarehouseLog a = (WarehouseLog)ob; string sql0 = String.Format("insert into WarehouseLog(ID,DepartmentID,Shipments,ShippedDate,LogDate,ContractID,LogName,Name) values('{0}','{1}',{2},'{3}','{4}','{5}','{6}','{7}')", a.ID, a.DepartmentID, a.Shipments, a.ShippedDate, a.LogDate, a.ContractID, a.LogName, a.Name); string s = string.Concat(sql0); conn.Open(); SqlCommand cmd = new SqlCommand(s, conn); cmd.ExecuteNonQuery(); } if (ob is SalesLog) { SalesLog a = (SalesLog)ob; string sql0 = String.Format("insert into SalesLog(ID,DepartmentID,ReturnDate,InvoiceDate,AffirmIncomeDate,AffirmIncomeAmount,InvoiceCount,InvoiceAmount,AmountCollection,AffirmIncomeGist,ContractID,LogDate,LogName,ServiceID,Name) values('{0}','{1}','{2}','{3}','{4}',{5},{6},{7},{8},'{9}','{10}','{11}','{12}','{13}','{14}')", a.ID, a.DepartmentID, a.ReturnDate, a.InvoiceDate, a.AffirmIncomeDate, a.AffirmIncomeAmount, a.InvoiceCount, a.InvoiceAmount, a.AmountCollection, a.AffirmIncomeGist, a.ContractID, a.LogDate, a.LogName, a.ServiceID, a.Name); string s = string.Concat(sql0); conn.Open(); SqlCommand cmd = new SqlCommand(s, conn); cmd.ExecuteNonQuery(); } if (ob is Contract_Data) { Contract_Data a = (Contract_Data)ob; string sql0 = String.Format("insert into Contract_Data(ID,Service,Contract_ID) values('{0}','{1}','{2}')", a.ID, a.Service, a.Contract_ID); string s = string.Concat(sql0); conn.Open(); SqlCommand cmd = new SqlCommand(s, conn); cmd.ExecuteNonQuery(); } } }
private void btn_Save_Click(object sender, RoutedEventArgs e) { try { string contractName = tb_ContractName.Text.ToString().Trim(); string customer = tb_Customer.Text.ToString().Trim(); ComboBoxItem item = cb_Contract_Type.SelectedItem as ComboBoxItem; string contract_Type = item.Content.ToString().Trim(); string contract_Amount = tb_Contract_Amount.Text.ToString().Trim(); string count = tb_Count.Text.ToString().Trim(); string contract_Number = tb_Contract_Number.Text.ToString().Trim(); string contract_Date; if (string.IsNullOrEmpty(tb_Contract_Date.ToString())) { contract_Date = ""; } else { contract_Date = DateTime.Parse(tb_Contract_Date.ToString().Trim()).ToShortDateString(); } if (string.IsNullOrEmpty(contractName) || string.IsNullOrEmpty(customer) || string.IsNullOrEmpty(contract_Type) || string.IsNullOrEmpty(contract_Amount) || string.IsNullOrEmpty(count) || string.IsNullOrEmpty(contract_Number) || string.IsNullOrEmpty(contract_Date)) { MessageBox.Show("所有值皆不能为空"); } else if (decimal.Parse(contract_Amount) < 0) { MessageBox.Show("合同金额不能为负数"); } else if (double.Parse(count) < 0) { MessageBox.Show("数量不能为负数"); } else if (double.Parse(count) % 1 != 0) { MessageBox.Show("数量不能为小数"); } else { ContractNameT ct = new ContractNameT(); ct.ID = Guid.NewGuid(); ct.Customer = customer; ct.ContractName = contractName; ct.Contract_Type = contract_Type; ct.Contract_Amount = Convert.ToDecimal(contract_Amount); ct.Contract_Date = contract_Date; ct.Contract_Number = contract_Number; ct.Count = Convert.ToDouble(count); Contract_Data cd = new Contract_Data(); cd.ID = Guid.NewGuid(); cd.Contract_ID = ct.ID; //cd.Service = "总服务"; GetData.first(ct, cd); //oct = new ObservableCollection<ContractNameT>(); var a = mw.oct; mw.oct.Add(ct); mw.oct = new ObservableCollection <ContractNameT>(mw.oct.OrderByDescending(x => DateTime.Parse(x.Contract_Date))); mw.listView_Contract.ItemsSource = mw.oct; mw.listView_Contract.Items.Refresh(); MessageBox.Show("操作成功!"); mw.listView_Contract.SelectedItem = ct; //立即创建一个服务 InsertService ins = new InsertService(); ins.mw = this.mw; ins.ShowDialog(); this.Close(); } } catch (FormatException) { MessageBox.Show("合同金额和数量只能为正数"); } }
private void btn_Save_Click(object sender, RoutedEventArgs e) { Contract_Data cd = (Contract_Data)mw.ListViewSerices.SelectedItem; string service = tb_Service.Text.ToString().Trim(); if (string.IsNullOrEmpty(service)) { MessageBox.Show("输入值不能为空"); } else { if (type.Equals("edit")) { cd.Service = service; //mw.ocd.Add(cd); //if ((mw.ocd.IndexOf(mw.ocd.FirstOrDefault<Contract_Data>(x => x.ID == cd.ID))) >= 0) //{ // int a=mw.ocd.IndexOf(cd); // int b=mw.ocd.IndexOf(mw.ocd.FirstOrDefault<Contract_Data>(x => x.ID == cd.ID)); // Contract_Data cpp = mw.ocd[b]; // mw.ocd[b]=mw.ocd[a]; // mw.ocd[a] = cpp; // // mw.ocd.Remove(mw.ocd.FirstOrDefault<Contract_Data>(x => x.ID == cd.ID)); //} SqlQuery.updata(cd); SqlQuery.UpdataD(cd); foreach (ProjectLog pg in mw.opt) { if (pg.ServiceID == cd.ID) { pg.Service = cd.Service; } } foreach (Project_data pd in mw.ppt) { if (pd.ServiceID == cd.ID) { pd.Service = cd.Service; } } foreach (SalesLog pg in mw.osl) { if (pg.ServiceID == cd.ID) { pg.Service = cd.Service; } } foreach (AccountantLog pg in mw.oac) { if (pg.ServiceID == cd.ID) { pg.Service = cd.Service; } } } else if (type.Equals("f")) { Contract_Data contract_Data = new Contract_Data(); contract_Data.Contract_ID = mw.ct.ID; contract_Data.ID = Guid.NewGuid(); contract_Data.Service = service; mw.ocd.Add(contract_Data); SqlQuery.insert(contract_Data); } //for (ProjectLog p in mw.opt) //{ //} MessageBox.Show("操作成功!"); this.Close(); } }
private void btn_Save_Click(object sender, RoutedEventArgs e)//****** { string logName = tb_LogName.Text.ToString().Trim(); Contract_Data item = (Contract_Data)cb_Service.SelectedItem; string service = item.Service; ComboBoxItem item_Type = (ComboBoxItem)cb_Type.SelectedItem; string type = item_Type.Content.ToString(); ObservableCollection <Project_data> pds = null; string typeDate; if (string.IsNullOrEmpty(tb_TypeDate.ToString())) { typeDate = ""; } else { typeDate = DateTime.Parse(tb_TypeDate.ToString().Trim()).ToShortDateString(); } string constructionDate = ""; string dompletedDate = ""; string dompletedAcceptanceDate = ""; if (string.IsNullOrEmpty(logName) || string.IsNullOrEmpty(service)) { MessageBox.Show("日志名和服务款项不能为空"); } else { var aaa = mw.ppt.FirstOrDefault <Project_data>(x => x.ServiceID == item.ID); if (mw.ppt.FirstOrDefault <Project_data>(x => x.ServiceID == item.ID) != null) { int a = mw.ppt.IndexOf(mw.ppt.FirstOrDefault <Project_data>(x => x.ServiceID == item.ID)); pds = SqlQuery.Project_dataQueryByService(mw.ct.ID, item.ID); if (type.Equals("施工日期")) { lbl_Date.Text = "施工日期"; constructionDate = typeDate; pds[0].ProjectStart = constructionDate; } else if (type.Equals("竣工日期")) { lbl_Date.Text = "竣工日期"; dompletedDate = typeDate; pds[0].DompletedDate = dompletedDate; } else if (type.Equals("取得竣工验收单日期")) { lbl_Date.Text = "取得竣工验收单日期"; dompletedAcceptanceDate = typeDate; pds[0].DompletedAcceptanceDate = dompletedAcceptanceDate; } pds[0].Service = service; ProjectLog p = new ProjectLog(); p.ID = Guid.NewGuid(); p.ContractID = mw.ct.ID; // p.DepartmentID = mw.ppt[0].ID; p.ProjectStart = constructionDate; p.DompletedDate = dompletedDate; p.DompletedAcceptanceDate = dompletedAcceptanceDate; p.LogDate = DateTime.Now.ToString(); p.LogName = logName; p.Service = service; p.ServiceID = item.ID; mw.ppt[a] = pds[0]; mw.opt.Add(p); GetData.ProjectGet(p, pds[0], mw.ppt); } else { if (type.Equals("施工日期")) { lbl_Date.Text = "施工日期"; constructionDate = typeDate; } else if (type.Equals("竣工日期")) { lbl_Date.Text = "竣工日期"; dompletedDate = typeDate; } else if (type.Equals("取得竣工验收单日期")) { lbl_Date.Text = "取得竣工验收单日期"; dompletedAcceptanceDate = typeDate; } Project_data pdd = new Project_data(); pdd.ID = Guid.NewGuid(); pdd.ContractID = mw.ct.ID; pdd.ProjectStart = constructionDate; pdd.Service = item.Service; pdd.DompletedDate = dompletedDate; pdd.DompletedAcceptanceDate = dompletedAcceptanceDate; pdd.ServiceID = item.ID; ProjectLog p = new ProjectLog(); p.ID = Guid.NewGuid(); p.ContractID = mw.ct.ID; // p.DepartmentID = mw.ppt[0].ID; p.ProjectStart = constructionDate; p.DompletedDate = dompletedDate; p.DompletedAcceptanceDate = dompletedAcceptanceDate; p.LogDate = DateTime.Now.ToString(); p.LogName = logName; p.Service = service; p.ServiceID = item.ID; mw.ppt.Add(pdd); mw.opt.Add(p); GetData.ProjectGet(p, pdd, mw.ppt); } //GetData.ProjectGet(p, pds[0], mw.ppt); MessageBox.Show("操作成功!"); this.Close(); } }