Exemplo n.º 1
0
 public static ObservableCollection <Sales> SalesGet(SalesLog sl, ObservableCollection <Sales> os)
 {
     SqlQuery.insert(sl);
     os[0].AmountCollection      += sl.AmountCollection;
     os[0].NoAmountCollection    -= sl.AffirmIncomeAmount;
     os[0].SubAffirmIncomeAmount += sl.AffirmIncomeAmount;
     os[0].SubInvoiceAmount      += sl.InvoiceAmount;
     os[0].SubInvoiceCount       += sl.InvoiceCount;
     SqlQuery.updata(os[0]);
     return(os);
 }
Exemplo n.º 2
0
        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("收款金额只能为正数");
            }
        }
Exemplo 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();
         }
     }
 }