Beispiel #1
0
        public static ObservableCollection <Project_data> ProjectGet(ProjectLog pjl, Project_data pd, ObservableCollection <Project_data> opj)
        {
            SqlQuery.insert(pjl);
            //int a = opj.IndexOf(mw.ppt.FirstOrDefault<Project_data>(x => x.ID == item.ID));
            //pds = SqlQuery.Project_dataQueryByService(mw.ct.ID, item.ID);
            //opj.Add(pd);

            //Project_data a =opj.FirstOrDefault<Project_data>(x => x.ServiceID == pd.ServiceID);
            //opj[opj.IndexOf(a)] = pd;
            //int i = opj.IndexOf(a);
            //Boolean bb = (i >= 0);
            //if (bb)
            //{
            //    opj.Move(opj.IndexOf(pd), opj.IndexOf(a));
            //    opj.Remove(a);
            //    ObservableCollection < Project_data > ppp= SqlQuery.Project_dataQueryByService(pd.ContractID, pd.ServiceID);
            //    //p
            //}
            SqlQuery.insert(pd);
            return(opj);
        }
Beispiel #2
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();
         }
     }
 }
Beispiel #3
0
        private void btn_Save_Click(object sender, RoutedEventArgs e)//******
        {
            string        logName   = tb_LogName.Text.ToString().Trim();
            Contract_Data item      = (Contract_Data)cb_Service.SelectedItem;
            string        service   = item.Service;
            ComboBoxItem  item_Type = (ComboBoxItem)cb_Type.SelectedItem;
            string        type      = item_Type.Content.ToString();
            ObservableCollection <Project_data> pds = null;
            string typeDate;

            if (string.IsNullOrEmpty(tb_TypeDate.ToString()))
            {
                typeDate = "";
            }
            else
            {
                typeDate = DateTime.Parse(tb_TypeDate.ToString().Trim()).ToShortDateString();
            }
            string constructionDate        = "";
            string dompletedDate           = "";
            string dompletedAcceptanceDate = "";


            if (string.IsNullOrEmpty(logName) || string.IsNullOrEmpty(service))
            {
                MessageBox.Show("日志名和服务款项不能为空");
            }
            else
            {
                var aaa = mw.ppt.FirstOrDefault <Project_data>(x => x.ServiceID == item.ID);
                if (mw.ppt.FirstOrDefault <Project_data>(x => x.ServiceID == item.ID) != null)
                {
                    int a = mw.ppt.IndexOf(mw.ppt.FirstOrDefault <Project_data>(x => x.ServiceID == item.ID));
                    pds = SqlQuery.Project_dataQueryByService(mw.ct.ID, item.ID);

                    if (type.Equals("施工日期"))
                    {
                        lbl_Date.Text       = "施工日期";
                        constructionDate    = typeDate;
                        pds[0].ProjectStart = constructionDate;
                    }
                    else if (type.Equals("竣工日期"))
                    {
                        lbl_Date.Text        = "竣工日期";
                        dompletedDate        = typeDate;
                        pds[0].DompletedDate = dompletedDate;
                    }
                    else if (type.Equals("取得竣工验收单日期"))
                    {
                        lbl_Date.Text                  = "取得竣工验收单日期";
                        dompletedAcceptanceDate        = typeDate;
                        pds[0].DompletedAcceptanceDate = dompletedAcceptanceDate;
                    }
                    pds[0].Service = service;
                    ProjectLog p = new ProjectLog();
                    p.ID         = Guid.NewGuid();
                    p.ContractID = mw.ct.ID;
                    // p.DepartmentID = mw.ppt[0].ID;
                    p.ProjectStart            = constructionDate;
                    p.DompletedDate           = dompletedDate;
                    p.DompletedAcceptanceDate = dompletedAcceptanceDate;
                    p.LogDate   = DateTime.Now.ToString();
                    p.LogName   = logName;
                    p.Service   = service;
                    p.ServiceID = item.ID;
                    mw.ppt[a]   = pds[0];
                    mw.opt.Add(p);
                    GetData.ProjectGet(p, pds[0], mw.ppt);
                }
                else
                {
                    if (type.Equals("施工日期"))
                    {
                        lbl_Date.Text    = "施工日期";
                        constructionDate = typeDate;
                    }
                    else if (type.Equals("竣工日期"))
                    {
                        lbl_Date.Text = "竣工日期";
                        dompletedDate = typeDate;
                    }
                    else if (type.Equals("取得竣工验收单日期"))
                    {
                        lbl_Date.Text           = "取得竣工验收单日期";
                        dompletedAcceptanceDate = typeDate;
                    }
                    Project_data pdd = new Project_data();
                    pdd.ID                      = Guid.NewGuid();
                    pdd.ContractID              = mw.ct.ID;
                    pdd.ProjectStart            = constructionDate;
                    pdd.Service                 = item.Service;
                    pdd.DompletedDate           = dompletedDate;
                    pdd.DompletedAcceptanceDate = dompletedAcceptanceDate;
                    pdd.ServiceID               = item.ID;


                    ProjectLog p = new ProjectLog();
                    p.ID         = Guid.NewGuid();
                    p.ContractID = mw.ct.ID;
                    // p.DepartmentID = mw.ppt[0].ID;
                    p.ProjectStart            = constructionDate;
                    p.DompletedDate           = dompletedDate;
                    p.DompletedAcceptanceDate = dompletedAcceptanceDate;
                    p.LogDate   = DateTime.Now.ToString();
                    p.LogName   = logName;
                    p.Service   = service;
                    p.ServiceID = item.ID;
                    mw.ppt.Add(pdd);
                    mw.opt.Add(p);
                    GetData.ProjectGet(p, pdd, mw.ppt);
                }

                //GetData.ProjectGet(p, pds[0], mw.ppt);
                MessageBox.Show("操作成功!");
                this.Close();
            }
        }