Esempio n. 1
0
        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();
                }
            }
        }
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);
        }