Beispiel #1
0
        public List <ReadableSale> GetSpecificWordGroup(string customer, string manufacturer, string keywords, int staff_Id, string helper,
                                                        DateTime salesOrderStartDate, DateTime salesOrderEndDate, DateTime salesStartDate,
                                                        DateTime salesEndDate)
        {
            using (DefaultConnection db = new DefaultConnection())
            {
                SQLWhereString whereString = new SQLWhereString();
                string where = whereString.SearchKeyWhere <ReadableSale>(db, keywords);
                int openCustomer_Id               = BusinessPartnerData.NameToId(db, customer)[0];
                int closeCustomer_Id              = BusinessPartnerData.NameToId(db, customer)[1];
                int openManufacturer_Id           = ManufacturerData.NameToId(db, manufacturer)[0];
                int closeManufacturer_Id          = ManufacturerData.NameToId(db, manufacturer)[1];
                int openStaff_Id                  = StaffData.GetIdRange(db, staff_Id)[0];
                int closeStaff_Id                 = StaffData.GetIdRange(db, staff_Id)[1];
                int openHelper_Id                 = HelperData.NameToId(db, helper)[0];
                int closeHelper_Id                = HelperData.NameToId(db, helper)[1];
                List <ReadableSale> readableSales = new List <ReadableSale>();
                if (!String.IsNullOrEmpty(keywords))
                {
                    readableSales = db.Database
                                    .SqlQuery <ReadableSale>(where)
                                    .ToList();
                    return(readableSales
                           .Where(rs => rs.Customer_Id >= openCustomer_Id &&
                                  rs.Customer_Id <= closeCustomer_Id &&
                                  rs.Manufacturer_Id >= openManufacturer_Id &&
                                  rs.Manufacturer_Id <= closeManufacturer_Id &&
                                  rs.ResponsibleStaff_Id >= openStaff_Id &&
                                  rs.ResponsibleStaff_Id <= closeStaff_Id &&
                                  rs.Helper_Id >= openHelper_Id &&
                                  rs.Helper_Id <= closeHelper_Id &&
                                  rs.SalesOrderDate >= salesOrderStartDate &&
                                  rs.SalesOrderDate <= salesOrderEndDate &&
                                  rs.SalesDate >= salesStartDate &&
                                  rs.SalesDate <= salesEndDate)
                           .ToList());
                }
                else
                {
                    readableSales = db.ReadableSales
                                    .Where(rs => rs.Customer_Id >= openCustomer_Id &&
                                           rs.Customer_Id <= closeCustomer_Id &&
                                           rs.Manufacturer_Id >= openManufacturer_Id &&
                                           rs.Manufacturer_Id <= closeManufacturer_Id &&
                                           rs.ResponsibleStaff_Id >= openStaff_Id &&
                                           rs.ResponsibleStaff_Id <= closeStaff_Id &&
                                           rs.Helper_Id >= openHelper_Id &&
                                           rs.Helper_Id <= closeHelper_Id &&
                                           rs.SalesOrderDate >= salesOrderStartDate &&
                                           rs.SalesOrderDate <= salesOrderEndDate &&
                                           rs.SalesDate >= salesStartDate &&
                                           rs.SalesDate <= salesEndDate)
                                    .ToList();

                    return(readableSales);
                }
            }
        }
 //見積データの追加
 public void Create(string customer, string helper, string staff, string[] products_Id)
 {
     using (DefaultConnection db = new DefaultConnection())
     {
         int[] customer_Ids = BusinessPartnerData.NameToId(db, customer);
         int[] helper_Ids   = HelperData.NameToId(db, helper);
         int   customer_Id  = customer_Ids[0];
         int   helper_Id    = helper_Ids[0];
         int   product_Id   = 0;
         int   staff_Id     = StaffData.EmailToId(db, staff);
         foreach (var item in products_Id)
         {
             product_Id = int.Parse(item);
             Quotation quotation = new Quotation(customer_Id, helper_Id, product_Id, staff_Id);
             db.Quotations.Add(quotation);
             db.SaveChanges();
         }
     }
 }