Ejemplo n.º 1
0
 public static ObservableCollection <Productioner> ProductionerGet(ProductionerLog pl, ObservableCollection <Productioner> op, ObservableCollection <Warehouse> w)
 {
     SqlQuery.insert(pl);
     //var a = opl.Sum(x => x.ProductionCount);
     op[0].TotalProduct   += pl.ProductionCount;
     op[0].NoTotalProduct -= pl.ProductionCount;
     w[0].Reserves         = op[0].TotalProduct - w[0].ShippedCount;
     SqlQuery.updata(op[0]);
     return(op);
 }
Ejemplo n.º 2
0
        private void btn_Save_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string logName            = tb_LogName.Text.ToString().Trim();
                string productionQuantity = tb_ProductionQuantity.Text.ToString().Trim();
                string productionDate;
                if (string.IsNullOrEmpty(tb_ProductionDate.ToString()))
                {
                    productionDate = "";
                }
                else
                {
                    productionDate = DateTime.Parse(tb_ProductionDate.ToString().Trim()).ToShortDateString();
                }

                if (string.IsNullOrEmpty(logName) || string.IsNullOrEmpty(productionQuantity) || string.IsNullOrEmpty(productionDate))
                {
                    MessageBox.Show("所有值皆不能为空");
                }
                else if (double.Parse(productionQuantity) < 0)
                {
                    MessageBox.Show("生产数量不能为负数");
                }
                else if (double.Parse(productionQuantity) % 1 != 0)
                {
                    MessageBox.Show("生产数量不能为小数");
                }
                else
                {
                    ProductionerLog pl = new ProductionerLog();
                    pl.ID              = Guid.NewGuid();
                    pl.ContractID      = mw.ct.ID;
                    pl.DepartmentID    = mw.ppr[0].ID;
                    pl.ProductionCount = Convert.ToDouble(productionQuantity);

                    pl.ProductionDate = productionDate;
                    pl.LogDate        = DateTime.Now.ToString();
                    pl.LogName        = logName;
                    mw.opr.Add(pl);
                    mw.ppr[0] = GetData.ProductionerGet(pl, mw.ppr, mw.wwh)[0];
                    MessageBox.Show("操作成功!");
                    this.Close();
                }
            }
            catch (FormatException)
            {
                MessageBox.Show("生产数量只能为正整数");
            }
        }
Ejemplo n.º 3
0
 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();
         }
     }
 }