Esempio n. 1
0
        private void listView_Contract_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ct = (ContractNameT)listView_Contract.SelectedItem;
            if (ct == null)
            {
                listView_Contract.SelectedIndex = 0;
                ct = (ContractNameT)listView_Contract.SelectedItem;
            }
            ocd = SqlQuery.ContractDataQuery(ct.ID);
            ListViewSerices.ItemsSource = ocd;
            MClass mc = new MClass();

            aac               = SqlQuery.AccountantQuery(ct.ID);
            mc.ac             = aac;
            mc.oac            = SqlQuery.AccountantLogQuery(ct.ID);
            oac               = mc.oac;
            wwh               = SqlQuery.WarehouseQuery(ct.ID);
            mc.wh             = wwh;
            ocw               = SqlQuery.WarehouseLogQuery(ct.ID);
            mc.ocw            = ocw;
            ppr               = SqlQuery.ProductionerQuery(ct.ID);
            mc.pr             = ppr;
            opr               = SqlQuery.ProductionerLogQuery(ct.ID);
            mc.opr            = opr;
            ppt               = SqlQuery.Project_dataQuery(ct.ID);
            mc.pt             = ppt;
            opt               = mc.opt = SqlQuery.ProjectLogQuery(ct.ID);
            ssl               = SqlQuery.SalesQuery(ct.ID);
            mc.sl             = ssl;
            osl               = mc.osl = SqlQuery.SalesLogQuery(ct.ID);
            mc.ct             = SqlQuery.ContractVQuery(ct.ID)[0];
            MGrid.DataContext = mc;
        }
Esempio n. 2
0
 public static void Contractinsert(ContractNameT ct, Accountant ac, Productioner pr, Project pj, Sales sa, Warehouse wh)
 {
     using (var conn = new SqlConnection(@string))
     {
         string sql0 = String.Format(@"insert into ContractNameT (ID,Customer,Contract_Type,Contract_Amount,Count,Contract_Number,Contract_Date,ContractName) values('{7}','{0}','{1}',{2},{3},'{4}','{5}','{6}');", ct.Customer, ct.Contract_Type, ct.Contract_Amount, ct.Count, ct.Contract_Number, ct.Contract_Date, ct.ContractName, ct.ID);
         //string sql1 = String.Format(@"insert into Contract_Data (ID,Service,Contract_ID) values('{0}','{1}','{2}');", cd.ID,cd.Service, cd.Contract_ID);
         string   sql2 = String.Format(@"insert into Accountant (ID,ContractID,AffirmIncomeGist,SubAffirmIncomeAmount,SubInvoiceCount,SubInvoiceAmount,SubCost,SubMaterial,Subworker,SubManufacturing_Costs,AvgGrossrofitMargin,NoAffirmIncomeAmount,Subtotal) values('{0}','{1}','{2}',{3},{4},{5},{6},{7},{8},{9},{10},{11},{12});", ac.ID, ac.ContractID, ac.AffirmIncomeGist, ac.SubAffirmIncomeAmount, ac.SubInvoiceCount, ac.SubInvoiceAmount, ac.SubCost, ac.SubMaterial, ac.Subworker, ac.SubManufacturing_Costs, ac.AvgGrossrofitMargin, ac.NoAffirmIncomeAmount, ac.Subtotal);
         string   sql3 = String.Format(@"insert into Productioner (ID,ContractID,TotalProduct,NoTotalProduct) values('{0}','{1}',{2},{3});", pr.ID, pr.ContractID, pr.TotalProduct, pr.NoTotalProduct);
         string   sql4 = String.Format(@"insert into Project (ID,ContractID,DompletedDate,DompletedAcceptanceDate) values('{0}','{1}','{2}','{3}');", pj.ID, pj.ContractID, pj.DompletedDate, pj.DompletedAcceptanceDate);
         string   sql5 = String.Format(@"insert into Sales (ID,ContractID,AmountCollection,NoAmountCollection,SubAffirmIncomeAmount,SubInvoiceCount,SubInvoiceAmount) values('{0}','{1}',{2},'{3}',{4},{5},{6});", sa.ID, sa.ContractID, sa.AmountCollection, sa.NoAmountCollection, sa.SubAffirmIncomeAmount, sa.SubInvoiceCount, sa.SubInvoiceAmount);
         string   sql6 = String.Format(@"insert into Warehouse (ID,ContractID,Reserves,ShippedCount,NoShippedCount) values('{0}','{1}',{2},{3},{4});", wh.ID, wh.ContractID, wh.Reserves, wh.ShippedCount, wh.NoShippedCount);
         string[] sqls = { sql0, sql2, sql3, sql4, sql5, sql6 };
         string   s    = string.Concat(sqls);
         conn.Open();
         SqlCommand cmd = new SqlCommand(s, conn);
         cmd.ExecuteNonQuery();
     }
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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("合同金额和数量只能为正数");
            }
        }