예제 #1
0
        private void btn_Save_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string logName   = tb_LogName.Text.ToString().Trim();
                string shipments = tb_Shipments.Text.ToString().Trim();
                string shippedDate;
                if (string.IsNullOrEmpty(tb_ShippedDate.ToString()))
                {
                    shippedDate = "";
                }
                else
                {
                    shippedDate = DateTime.Parse(tb_ShippedDate.ToString().Trim()).ToShortDateString();
                }

                if (string.IsNullOrEmpty(logName) || string.IsNullOrEmpty(shipments) || string.IsNullOrEmpty(shippedDate))
                {
                    MessageBox.Show("所有值皆不能为空");
                }
                else if (double.Parse(shipments) < 0)
                {
                    MessageBox.Show("发货数量不能为负数");
                }
                else if (double.Parse(shipments) % 1 != 0)
                {
                    MessageBox.Show("发货数量不能为小数");
                }
                else
                {
                    WarehouseLog w = new WarehouseLog();
                    w.ID           = Guid.NewGuid();
                    w.LogName      = logName;
                    w.Shipments    = Convert.ToDouble(shipments);
                    w.ShippedDate  = shippedDate;
                    w.LogDate      = DateTime.Now.ToString();
                    w.ContractID   = mw.ct.ID;
                    w.DepartmentID = mw.wwh[0].ID;
                    mw.wwh[0]      = GetData.WarehouseGet(w, mw.wwh)[0];
                    mw.ocw.Add(w);
                    MessageBox.Show("操作成功!");
                    this.Close();
                }
            }
            catch (FormatException)
            {
                MessageBox.Show("发货数量只能为正整数");
            }
        }
예제 #2
0
파일: GetData.cs 프로젝트: huajiayi/CSMS
        public static ObservableCollection <Warehouse> WarehouseGet(WarehouseLog w, ObservableCollection <Warehouse> ow)
        {
            SqlQuery.insert(w);
            //ObservableCollection <WarehouseLog> owl= SqlQuery.WarehouseLogQuery(w.ContractID);
            ObservableCollection <ProductionerLog> op = SqlQuery.ProductionerLogQuery(w.ContractID);
            //ObservableCollection<Warehouse> ow =  SqlQuery.WarehouseQuery(w.ContractID);
            //var a = owl.Sum(x => x.Shipments);
            var b = op.Sum(x => x.ProductionCount);

            //Warehouse wah = new Warehouse();
            //wah.ContractID = w.ContractID;
            //wah.ID = ow[0].ID;
            ow[0].ShippedCount   += w.Shipments;
            ow[0].Reserves       -= w.Shipments;
            ow[0].NoShippedCount -= w.Shipments;
            SqlQuery.updata(ow[0]);
            //ObservableCollection<object> ob = new ObservableCollection<object>();
            //ob.Add(owl);
            //ob.Add();
            return(ow);
        }
예제 #3
0
파일: SqlQuery.cs 프로젝트: huajiayi/CSMS
 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();
         }
     }
 }