Example #1
0
        public async Task setup(testItem test)
        {
            try
            {
                if (File.Exists(path + test.script_Actual))
                {
                    string query = path + test.script_Actual;
                    dbConn con;
                    if (File.Exists(query))
                    {
                        con = new dbConn(server, "dbmSemanticAnalytics");
                        StreamReader fileText = new StreamReader(query);
                        query = cleanStreamReader(fileText);
                        var acS = await con.Read(query);

                        DataTable dtbl = acS.test;
                        test.MessageErrorActual = acS.message;
                        if (dtbl != null)
                        {
                            test.staus = 1;
                        }
                    }
                }
            }

            catch
            {
                test.staus = 0;
            }
        }
 public ActionResult GetPerson()
 {
     using (dbConn ef = new dbConn())
     {
         List <Person> list = (from tabla in ef.Person orderby tabla.BusinessEntityID descending select tabla).Take(100).ToList();
         return(Json(new { data = list }, JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult GetContactType()
 {
     using (dbConn ef = new dbConn())
     {
         List <ContactType> list = ef.ContactType.ToList();
         return(Json(new { data = list }, JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult GetProductCategory()
 {
     using (dbConn ef = new dbConn())
     {
         List <ProductCategory> list = ef.ProductCategory.ToList();
         return(Json(new { data = list }, JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult GetShipMethod()
 {
     using (dbConn ef = new dbConn())
     {
         List <ShipMethod> list = ef.ShipMethod.ToList();
         return(Json(new { data = list }, JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult GetCreditCard()
 {
     using (dbConn ef = new dbConn())
     {
         List <CreditCard> list = (from tabla in ef.CreditCard orderby tabla.CreditCardID descending select tabla).Take(100).ToList();
         return(Json(new { data = list }, JsonRequestBehavior.AllowGet));
     }
 }
Example #7
0
 public ActionResult GetEmployee()
 {
     using (dbConn ef = new dbConn())
     {
         List <Employee> list = ef.Employee.ToList();
         return(Json(new { data = list }, JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult GetLocation()
 {
     using (dbConn ef = new dbConn())
     {
         List <Location> list = ef.Location.ToList();
         return(Json(new { data = list }, JsonRequestBehavior.AllowGet));
     }
 }
Example #9
0
 public ActionResult GetDepartment()
 {
     using (dbConn ef = new dbConn())
     {
         List <Department> list = ef.Department.ToList();
         return(Json(new { data = list }, JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult GetAddress()
 {
     using (dbConn ef = new dbConn())
     {
         List <Address> list = new List <Address>();
         list = (from tabla in ef.Address orderby tabla.AddressID descending select tabla).Take(100).ToList();
         return(Json(new { data = list }, JsonRequestBehavior.AllowGet));
     }
 }
        public ActionResult PostProductVendor(ProductVendor PV)
        {
            try
            {
                using (dbConn ef = new dbConn())
                {
                    ProductVendor pv = new ProductVendor();

                    if (PV.OperationType == "Save")
                    {
                        int id = Convert.ToInt32(ef.ProductVendor.Max(field => (int?)field.ProductID) + 1 ?? 1);
                        pv.ProductID        = id;
                        pv.BusinessEntityID = PV.BusinessEntityID;
                        pv.AverageLeadTime  = PV.AverageLeadTime;
                        pv.StandardPrice    = PV.StandardPrice;
                        pv.LastReceiptCost  = PV.LastReceiptCost;
                        pv.LastReceiptDate  = PV.LastReceiptDate;
                        pv.MinOrderQty      = PV.MinOrderQty;
                        pv.MaxOrderQty      = PV.MaxOrderQty;
                        pv.OnOrderQty       = PV.OnOrderQty;
                        pv.UnitMeasureCode  = PV.UnitMeasureCode;
                        pv.ModifiedDate     = DateTime.Now;
                        ef.ProductVendor.Add(pv);
                        ef.SaveChanges();
                    }

                    if (PV.OperationType == "Update")
                    {
                        pv = ef.ProductVendor.First(row => row.ProductID == PV.ProductID);
                        pv.BusinessEntityID = PV.BusinessEntityID;
                        pv.AverageLeadTime  = PV.AverageLeadTime;
                        pv.StandardPrice    = PV.StandardPrice;
                        pv.LastReceiptCost  = PV.LastReceiptCost;
                        pv.LastReceiptDate  = PV.LastReceiptDate;
                        pv.MinOrderQty      = PV.MinOrderQty;
                        pv.MaxOrderQty      = PV.MaxOrderQty;
                        pv.OnOrderQty       = PV.OnOrderQty;
                        pv.UnitMeasureCode  = PV.UnitMeasureCode;
                        pv.ModifiedDate     = DateTime.Now;
                        ef.SaveChanges();
                    }

                    if (PV.OperationType == "Delete")
                    {
                        pv = ef.ProductVendor.FirstOrDefault(row => row.ProductID == PV.ProductID);
                        ef.ProductVendor.Remove(pv);
                        ef.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(500, " :( Something bad happened: " + ex.Message));
            }
            return(Json(new { success = true, Message = "Successful", JsonRequestBehavior.AllowGet }));
        }
        public ActionResult PostSalesPerson(SalesPerson SP)
        {
            try
            {
                using (dbConn ef = new dbConn())
                {
                    SalesPerson sp = new SalesPerson();

                    if (SP.OperationType == "Save")
                    {
                        int id = Convert.ToInt32(ef.SalesPerson.Max(field => (int?)field.BusinessEntityID) + 1 ?? 1);
                        sp.BusinessEntityID = id;
                        sp.TerritoryID      = SP.TerritoryID;
                        sp.SalesQuota       = SP.SalesQuota;
                        sp.Bonus            = SP.Bonus;
                        sp.CommissionPct    = SP.CommissionPct;
                        sp.SalesYTD         = SP.SalesYTD;
                        sp.SalesLastYear    = SP.SalesLastYear;
                        sp.rowguid          = SP.rowguid;
                        sp.ModifiedDate     = DateTime.Now;
                        ef.SalesPerson.Add(sp);
                        ef.SaveChanges();
                    }

                    if (SP.OperationType == "Update")
                    {
                        sp               = ef.SalesPerson.First(row => row.BusinessEntityID == SP.BusinessEntityID);
                        sp.TerritoryID   = SP.TerritoryID;
                        sp.SalesQuota    = SP.SalesQuota;
                        sp.Bonus         = SP.Bonus;
                        sp.CommissionPct = SP.CommissionPct;
                        sp.SalesYTD      = SP.SalesYTD;
                        sp.SalesLastYear = SP.SalesLastYear;
                        sp.rowguid       = SP.rowguid;
                        sp.ModifiedDate  = DateTime.Now;
                        ef.SaveChanges();
                    }

                    if (SP.OperationType == "Delete")
                    {
                        sp = ef.SalesPerson.FirstOrDefault(row => row.BusinessEntityID == SP.BusinessEntityID);
                        ef.SalesPerson.Remove(sp);
                        ef.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(500, " :( Something bad happened: " + ex.Message));
            }
            return(Json(new { success = true, Message = "Successful", JsonRequestBehavior.AllowGet }));
        }
        public ActionResult PostProductReview(ProductReview PR)
        {
            try
            {
                using (dbConn ef = new dbConn())
                {
                    ProductReview pr = new ProductReview();

                    if (PR.OperationType == "Save")
                    {
                        int id = Convert.ToInt32(ef.ProductReview.Max(field => (int?)field.ProductReviewID) + 1 ?? 1);
                        pr.ProductReviewID = id;
                        pr.ProductID       = PR.ProductID;
                        pr.ReviewerName    = PR.ReviewerName;
                        pr.ReviewDate      = PR.ReviewDate;
                        pr.EmailAddress    = PR.EmailAddress;
                        pr.Rating          = PR.Rating;
                        pr.Comments        = PR.Comments;
                        pr.ModifiedDate    = DateTime.Now;
                        ef.ProductReview.Add(pr);
                        ef.SaveChanges();
                    }

                    if (PR.OperationType == "Update")
                    {
                        pr = ef.ProductReview.First(row => row.ProductReviewID == PR.ProductReviewID);
                        pr.ProductReviewID = PR.ProductReviewID;
                        pr.ProductID       = PR.ProductID;
                        pr.ReviewerName    = PR.ReviewerName;
                        pr.ReviewDate      = PR.ReviewDate;
                        pr.EmailAddress    = PR.EmailAddress;
                        pr.Rating          = PR.Rating;
                        pr.Comments        = PR.Comments;
                        pr.ModifiedDate    = DateTime.Now;
                        ef.SaveChanges();
                    }

                    if (PR.OperationType == "Delete")
                    {
                        pr = ef.ProductReview.FirstOrDefault(row => row.ProductReviewID == PR.ProductReviewID);
                        ef.ProductReview.Remove(pr);
                        ef.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(500, " :( Something bad happened: " + ex.Message));
            }
            return(Json(new { success = true, Message = "Successful", JsonRequestBehavior.AllowGet }));
        }
        public ActionResult PostAddress(Address AD)
        {
            try
            {
                using (dbConn ef = new dbConn())
                {
                    Address addr = new Address();

                    if (AD.OperationType == "Save")
                    {
                        int Id = Convert.ToInt32(ef.Address.Max(field => (int?)field.AddressID) + 1 ?? 1);
                        addr.AddressID       = Id;
                        addr.AddressLine1    = AD.AddressLine1;
                        addr.AddressLine2    = AD.AddressLine2;
                        addr.City            = AD.City;
                        addr.StateProvinceID = AD.StateProvinceID;
                        addr.PostalCode      = AD.PostalCode;
                        addr.rowguid         = AD.rowguid;
                        addr.ModifiedDate    = DateTime.Now;
                        ef.Address.Add(addr);
                        ef.SaveChanges();
                    }

                    if (AD.OperationType == "Update")
                    {
                        addr = ef.Address.First(row => row.AddressID == AD.AddressID);
                        addr.AddressLine1 = AD.AddressLine1;
                        addr.AddressLine2 = AD.AddressLine2;
                        addr.City         = AD.City;
                        addr.PostalCode   = AD.PostalCode;
                        addr.rowguid      = AD.rowguid;
                        addr.ModifiedDate = DateTime.Now;
                        ef.SaveChanges();
                    }

                    if (AD.OperationType == "Delete")
                    {
                        addr = ef.Address.FirstOrDefault(row => row.AddressID == AD.AddressID);
                        ef.Address.Remove(addr);
                        ef.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(500, " :( Something bad happened: " + ex.Message));
            }
            return(Json(new { success = true, Message = "Successful", JsonRequestBehavior.AllowGet }));
        }
        public ActionResult PostShipMethod(ShipMethod SM)
        {
            try
            {
                using (dbConn ef = new dbConn())
                {
                    ShipMethod sm = new ShipMethod();

                    if (SM.OperationType == "Save")
                    {
                        int id = Convert.ToInt32(ef.ShipMethod.Max(field => (int?)field.ShipMethodID) + 1 ?? 1);
                        sm.ShipMethodID = id;
                        sm.Name         = SM.Name;
                        sm.ShipBase     = SM.ShipBase;
                        sm.ShipRate     = SM.ShipRate;
                        sm.rowguid      = SM.rowguid;
                        sm.ModifiedDate = DateTime.Now;
                        ef.ShipMethod.Add(sm);
                        ef.SaveChanges();
                    }

                    if (SM.OperationType == "Update")
                    {
                        sm              = ef.ShipMethod.First(row => row.ShipMethodID == SM.ShipMethodID);
                        sm.Name         = SM.Name;
                        sm.ShipBase     = SM.ShipBase;
                        sm.ShipRate     = SM.ShipRate;
                        sm.rowguid      = SM.rowguid;
                        sm.ModifiedDate = DateTime.Now;
                        ef.SaveChanges();
                    }

                    if (SM.OperationType == "Delete")
                    {
                        sm = ef.ShipMethod.FirstOrDefault(row => row.ShipMethodID == SM.ShipMethodID);
                        ef.ShipMethod.Remove(sm);
                        ef.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(500, " :( Something bad happened: " + ex.Message));
            }
            return(Json(new { success = true, Message = "Successful", JsonRequestBehavior.AllowGet }));
        }
        public ActionResult PostCreditCard(CreditCard CC)
        {
            try
            {
                using (dbConn ef = new dbConn())
                {
                    CreditCard cc = new CreditCard();

                    if (CC.OperationType == "Save")
                    {
                        int id = Convert.ToInt32(ef.CreditCard.Max(field => (int?)field.CreditCardID) + 1 ?? 1);
                        cc.CreditCardID = id;
                        cc.CardType     = CC.CardType;
                        cc.CardNumber   = CC.CardNumber;
                        cc.ExpMonth     = CC.ExpMonth;
                        cc.ExpYear      = CC.ExpYear;
                        cc.ModifiedDate = DateTime.Now;
                        ef.CreditCard.Add(cc);
                        ef.SaveChanges();
                    }

                    if (CC.OperationType == "Update")
                    {
                        cc              = ef.CreditCard.First(row => row.CreditCardID == CC.CreditCardID);
                        cc.CardType     = CC.CardType;
                        cc.CardNumber   = CC.CardNumber;
                        cc.ExpMonth     = CC.ExpMonth;
                        cc.ExpYear      = CC.ExpYear;
                        cc.ModifiedDate = DateTime.Now;
                        ef.SaveChanges();
                    }

                    if (CC.OperationType == "Delete")
                    {
                        cc = ef.CreditCard.FirstOrDefault(row => row.CreditCardID == CC.CreditCardID);
                        ef.CreditCard.Remove(cc);
                        ef.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(500, " :( Something bad happened: " + ex.Message));
            }
            return(Json(new { success = true, Message = "Successful", JsonRequestBehavior.AllowGet }));
        }
Example #17
0
        public ActionResult PostEmployeePayHis(EmployeePayHistory EPH)
        {
            try
            {
                using (dbConn ef = new dbConn())
                {
                    EmployeePayHistory eph = new EmployeePayHistory();

                    if (EPH.OperationType == "Save")
                    {
                        int Id = Convert.ToInt32(ef.EmployeePayHistory.Max(field => (int?)field.BusinessEntityID) + 1 ?? 1);
                        eph.BusinessEntityID = Id;
                        eph.RateChangeDate   = EPH.RateChangeDate;
                        eph.Rate             = EPH.Rate;
                        eph.PayFrequency     = EPH.PayFrequency;
                        eph.ModifiedDate     = DateTime.Now;

                        ef.EmployeePayHistory.Add(eph);
                        ef.SaveChanges();
                    }

                    if (EPH.OperationType == "Update")
                    {
                        eph = ef.EmployeePayHistory.First(row => row.BusinessEntityID == EPH.BusinessEntityID);
                        eph.RateChangeDate = EPH.RateChangeDate;
                        eph.Rate           = EPH.Rate;
                        eph.PayFrequency   = EPH.PayFrequency;
                        eph.ModifiedDate   = DateTime.Now;
                        ef.SaveChanges();
                    }

                    if (EPH.OperationType == "Delete")
                    {
                        eph = ef.EmployeePayHistory.FirstOrDefault(row => row.BusinessEntityID == EPH.BusinessEntityID);
                        ef.EmployeePayHistory.Remove(eph);
                        ef.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(500, " :( Something bad happened: " + ex.Message));
            }
            return(Json(new { success = true, Message = "Successful", JsonRequestBehavior.AllowGet }));
        }
Example #18
0
        public ActionResult PostShift(Shift SH)
        {
            try
            {
                using (dbConn ef = new dbConn())
                {
                    Shift sh = new Shift();

                    if (SH.OperationType == "Save")
                    {
                        byte Id = Convert.ToByte(ef.Shift.Max(field => (byte?)field.ShiftID) + 1 ?? 1);
                        sh.ShiftID      = Id;
                        sh.Name         = SH.Name;
                        sh.StartTime    = SH.StartTime;
                        sh.EndTime      = SH.EndTime;
                        sh.ModifiedDate = DateTime.Now;

                        ef.Shift.Add(sh);
                        ef.SaveChanges();
                    }

                    if (SH.OperationType == "Update")
                    {
                        sh              = ef.Shift.First(row => row.ShiftID == SH.ShiftID);
                        sh.Name         = SH.Name;
                        sh.StartTime    = SH.StartTime;
                        sh.EndTime      = SH.EndTime;
                        sh.ModifiedDate = DateTime.Now;
                        ef.SaveChanges();
                    }

                    if (SH.OperationType == "Delete")
                    {
                        sh = ef.Shift.FirstOrDefault(row => row.ShiftID == SH.ShiftID);
                        ef.Shift.Remove(sh);
                        ef.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(500, " :( Something bad happened: " + ex.Message));
            }
            return(Json(new { success = true, Message = "Successful", JsonRequestBehavior.AllowGet }));
        }
        public ActionResult PostLocation(Location LC)
        {
            try
            {
                using (dbConn ef = new dbConn())
                {
                    Location lc = new Location();

                    if (LC.OperationType == "Save")
                    {
                        short id = Convert.ToInt16(ef.Location.Max(field => (short?)field.LocationID) + 1 ?? 1);
                        lc.LocationID   = id;
                        lc.Name         = LC.Name;
                        lc.CostRate     = LC.CostRate;
                        lc.Availability = LC.Availability;
                        lc.ModifiedDate = DateTime.Now;
                        ef.Location.Add(lc);
                        ef.SaveChanges();
                    }

                    if (LC.OperationType == "Update")
                    {
                        lc              = ef.Location.First(row => row.LocationID == LC.LocationID);
                        lc.Name         = LC.Name;
                        lc.CostRate     = LC.CostRate;
                        lc.Availability = LC.Availability;
                        lc.ModifiedDate = DateTime.Now;
                        ef.SaveChanges();
                    }

                    if (LC.OperationType == "Delete")
                    {
                        lc = ef.Location.FirstOrDefault(row => row.LocationID == LC.LocationID);
                        ef.Location.Remove(lc);
                        ef.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(500, " :( Something bad happened: " + ex.Message));
            }
            return(Json(new { success = true, Message = "Successful", JsonRequestBehavior.AllowGet }));
        }
Example #20
0
        public ActionResult PostDepartment(Department DM)
        {
            try
            {
                using (dbConn ef = new dbConn())
                {
                    Department dept = new Department();

                    if (DM.OperationType == "Save")
                    {
                        short Id = Convert.ToInt16(ef.Department.Max(field => (short?)field.DepartmentID) + 1 ?? 1);
                        dept.DepartmentID = Id;
                        dept.Name         = DM.Name;
                        dept.GroupName    = DM.GroupName;
                        dept.ModifiedDate = DateTime.Now;
                        ef.Department.Add(dept);
                        ef.SaveChanges();
                    }

                    if (DM.OperationType == "Update")
                    {
                        dept              = ef.Department.First(row => row.DepartmentID == DM.DepartmentID);
                        dept.Name         = DM.Name;
                        dept.GroupName    = DM.GroupName;
                        dept.ModifiedDate = DateTime.Now;
                        ef.SaveChanges();
                    }

                    if (DM.OperationType == "Delete")
                    {
                        dept = ef.Department.FirstOrDefault(row => row.DepartmentID == DM.DepartmentID);
                        ef.Department.Remove(dept);
                        ef.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(500, " :( Something bad happened: " + ex.Message));
            }
            return(Json(new { success = true, Message = "Successful", JsonRequestBehavior.AllowGet }));
        }
        public ActionResult PostProductCategory(ProductCategory PC)
        {
            try
            {
                using (dbConn ef = new dbConn())
                {
                    ProductCategory pc = new ProductCategory();

                    if (PC.OperationType == "Save")
                    {
                        int id = Convert.ToInt32(ef.ProductCategory.Max(field => (int?)field.ProductCategoryID) + 1 ?? 1);
                        pc.ProductCategoryID = id;
                        pc.Name         = PC.Name;
                        pc.rowguid      = PC.rowguid;
                        pc.ModifiedDate = DateTime.Now;
                        ef.ProductCategory.Add(pc);
                        ef.SaveChanges();
                    }

                    if (PC.OperationType == "Update")
                    {
                        pc              = ef.ProductCategory.First(row => row.ProductCategoryID == PC.ProductCategoryID);
                        pc.Name         = PC.Name;
                        pc.rowguid      = PC.rowguid;
                        pc.ModifiedDate = DateTime.Now;
                        ef.SaveChanges();
                    }

                    if (PC.OperationType == "Delete")
                    {
                        pc = ef.ProductCategory.FirstOrDefault(row => row.ProductCategoryID == PC.ProductCategoryID);
                        ef.ProductCategory.Remove(pc);
                        ef.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(500, " :( Something bad happened: " + ex.Message));
            }
            return(Json(new { success = true, Message = "Successful", JsonRequestBehavior.AllowGet }));
        }
        public ActionResult PostContactType(ContactType CT)
        {
            try
            {
                using (dbConn ef = new dbConn())
                {
                    ContactType ct = new ContactType();

                    if (CT.OperationType == "Save")
                    {
                        int Id = Convert.ToInt32(ef.ContactType.Max(field => (int?)field.ContactTypeID) + 1 ?? 1);
                        ct.ContactTypeID = Id;
                        ct.Name          = CT.Name;
                        ct.ModifiedDate  = DateTime.Now;
                        ef.ContactType.Add(ct);
                        ef.SaveChanges();
                    }

                    if (CT.OperationType == "Update")
                    {
                        ct              = ef.ContactType.First(row => row.ContactTypeID == CT.ContactTypeID);
                        ct.Name         = CT.Name;
                        ct.ModifiedDate = DateTime.Now;
                        ef.SaveChanges();
                    }

                    if (CT.OperationType == "Delete")
                    {
                        ct = ef.ContactType.FirstOrDefault(row => row.ContactTypeID == CT.ContactTypeID);
                        ef.ContactType.Remove(ct);
                        ef.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(500, " :( Something bad happened: " + ex.Message));
            }
            return(Json(new { success = true, Message = "Successful", JsonRequestBehavior.AllowGet }));
        }
Example #23
0
        public ActionResult PostEmployee(Employee EM)
        {
            try
            {
                using (dbConn ef = new dbConn())
                {
                    Employee emp = new Employee();

                    if (EM.OperationType == "Save")
                    {
                        int Id = Convert.ToInt32(ef.Employee.Max(field => (int?)field.BusinessEntityID) + 1 ?? 1);
                        emp.BusinessEntityID = Id;
                        emp.NationalIDNumber = EM.NationalIDNumber;
                        emp.LoginID          = EM.LoginID;
                        //emp.OrganizationLevel = EM.OrganizationLevel;
                        emp.JobTitle       = EM.JobTitle;
                        emp.BirthDate      = EM.BirthDate;
                        emp.MaritalStatus  = EM.MaritalStatus;
                        emp.Gender         = EM.Gender;
                        emp.HireDate       = EM.HireDate;
                        emp.SalariedFlag   = EM.SalariedFlag;
                        emp.VacationHours  = EM.VacationHours;
                        emp.SickLeaveHours = EM.SickLeaveHours;
                        emp.CurrentFlag    = EM.CurrentFlag;
                        emp.rowguid        = EM.rowguid;
                        emp.ModifiedDate   = DateTime.Now;

                        ef.Employee.Add(emp);
                        ef.SaveChanges();
                    }

                    if (EM.OperationType == "Update")
                    {
                        emp = ef.Employee.First(row => row.BusinessEntityID == EM.BusinessEntityID);
                        emp.NationalIDNumber = EM.NationalIDNumber;
                        emp.LoginID          = EM.LoginID;
                        //emp.OrganizationLevel = Convert.ToInt16(EM.OrganizationLevel);
                        emp.JobTitle       = EM.JobTitle;
                        emp.BirthDate      = EM.BirthDate;
                        emp.MaritalStatus  = EM.MaritalStatus;
                        emp.Gender         = EM.Gender;
                        emp.HireDate       = EM.HireDate;
                        emp.SalariedFlag   = EM.SalariedFlag;
                        emp.VacationHours  = EM.VacationHours;
                        emp.SickLeaveHours = EM.SickLeaveHours;
                        emp.CurrentFlag    = EM.CurrentFlag;
                        emp.rowguid        = EM.rowguid;
                        emp.ModifiedDate   = DateTime.Now;
                        ef.SaveChanges();
                    }

                    if (EM.OperationType == "Delete")
                    {
                        emp = ef.Employee.FirstOrDefault(row => row.BusinessEntityID == EM.BusinessEntityID);
                        ef.Employee.Remove(emp);
                        ef.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(500, " :( Something bad happened: " + ex.Message));
            }
            return(Json(new { success = true, Message = "Successful", JsonRequestBehavior.AllowGet }));
        }
        public ActionResult PostPerson(Person PE)
        {
            try
            {
                using (dbConn ef = new dbConn())
                {
                    Person         per = new Person();
                    BusinessEntity bss = new BusinessEntity();

                    if (PE.OperationType == "Save")
                    {
                        int Id = Convert.ToInt32(ef.Person.Max(field => (int?)field.BusinessEntityID) + 1 ?? 1);
                        per.BusinessEntityID = Id;
                        bss.BusinessEntityID = Id;
                        per.PersonType       = PE.PersonType;
                        per.NameStyle        = PE.NameStyle;
                        per.Title            = PE.Title;
                        per.FirstName        = PE.FirstName;
                        per.MiddleName       = PE.MiddleName;
                        per.LastName         = PE.LastName;
                        per.Suffix           = PE.Suffix;
                        per.EmailPromotion   = PE.EmailPromotion;
                        per.rowguid          = PE.rowguid;
                        bss.rowguid          = PE.rowguid;
                        per.ModifiedDate     = DateTime.Now;
                        bss.ModifiedDate     = DateTime.Now;
                        ef.BusinessEntity.Add(bss);
                        ef.Person.Add(per);
                        ef.SaveChanges();
                    }

                    if (PE.OperationType == "Update")
                    {
                        per                = ef.Person.First(row => row.BusinessEntityID == PE.BusinessEntityID);
                        per.PersonType     = PE.PersonType;
                        per.NameStyle      = PE.NameStyle;
                        per.Title          = PE.Title;
                        per.FirstName      = PE.FirstName;
                        per.MiddleName     = PE.MiddleName;
                        per.LastName       = PE.LastName;
                        per.Suffix         = PE.Suffix;
                        per.EmailPromotion = PE.EmailPromotion;
                        per.rowguid        = PE.rowguid;
                        per.ModifiedDate   = DateTime.Now;
                        ef.SaveChanges();
                    }

                    if (PE.OperationType == "Delete")
                    {
                        per = ef.Person.FirstOrDefault(row => row.BusinessEntityID == PE.BusinessEntityID);
                        ef.Person.Remove(per);
                        ef.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(500, " :( Something bad happened: " + ex.Message));
            }
            return(Json(new { success = true, Message = "Successful", JsonRequestBehavior.AllowGet }));
        }
Example #25
0
        public void setup(string db, string query)
        {
            dbConn con = new dbConn(server, db);

            con.Read(query);
        }
Example #26
0
        private async void querySubmittedZoek(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
        {
            Debug.WriteLine("querysubmittedzoek; " + args.QueryText);
            string input = args.QueryText;
            List <SearchResult> listResults = new List <SearchResult>();

            //Search in Database
            bool        availableInDb = false;
            Task <bool> searchInDb    = Task <bool> .Factory.StartNew(() =>
            {
                List <string> output = new List <string>();
                bool succeeded       = false;

                dbConn dbConnection = new dbConn();

                try
                {
                    MySqlCommand cmd = dbConnection.selectQuery("SELECT * FROM video WHERE title LIKE '%" + input + "%' ORDER BY id DESC LIMIT 0,4");

                    MySqlDataReader reader = cmd.ExecuteReader();

                    string urlx;
                    string titlex;
                    string descriptionx;
                    string genrex;
                    string thumbx;

                    while (reader.Read())
                    {
                        urlx         = (string)reader["url"];
                        titlex       = (string)reader["title"];
                        descriptionx = (string)reader["description"];
                        genrex       = (string)reader["genre"];
                        thumbx       = (string)reader["thumbnail"];
                        urlx        += ";" + titlex + ";" + thumbx;

                        listResults.Add(new SearchResult {
                            url         = urlx,
                            title       = titlex,
                            description = descriptionx,
                            genre       = genrex,
                            thumb       = thumbx
                        });
                        succeeded = true;
                    }

                    reader.Close();
                }
                catch (MySqlException ex)
                {
                    Debug.WriteLine(ex.Message);
                }

                dbConnection.dbClose();
                return(succeeded);
            });

            searchInDb.Wait();
            SearchWordResults.ItemsSource = listResults;
            availableInDb = await searchInDb;
            if (!availableInDb)
            {
                //Cannot be found in database.
                await Search.crawlerSearchterm(input);

                ErrorDialog.showMessage("Crawler is aan het zoeken, probeer het zo weer");
            }
        }
Example #27
0
        public async Task Test(testItem test)
        {
            dbConn conn           = null;
            string ActualQuery    = null;
            string ExcpectedQuery = null;

            try
            {
                if (File.Exists(path + test.script_Actual))
                {
                    string pathActual   = path + test.script_Actual;
                    string pathExpected = path + test.script_Expected;
                    conn = new dbConn(server, "dbmSemanticAnalytics");
                    StreamReader fileA = new StreamReader(pathActual);
                    ActualQuery = cleanStreamReader(fileA);
                    fileA.Close();
                    //ActualQuery = ActualQuery.Replace(@"/n", " ");
                    //ActualQuery = ActualQuery.Replace("GO", " ");
                    var acA = await conn.Read(ActualQuery);

                    test.Actual_DT          = acA.test;
                    test.MessageErrorActual = acA.message;

                    if (test.type == "Dynamic")
                    {
                        StreamReader fileE = new StreamReader(pathExpected);
                        ExcpectedQuery = cleanStreamReader(fileE);
                        fileE.Close();
                        //ExcpectedQuery = ExcpectedQuery.Replace(@"/n", " ");
                        //ExcpectedQuery = ExcpectedQuery.Replace("GO", " ");
                        var acE = await conn.Read(ExcpectedQuery);

                        test.Expected_DT          = acE.test;
                        test.MessageErrorExpected = acA.message;
                    }
                    else
                    {
                        //StreamReader csvFile = new StreamReader(path + @"expected\" + test.Items[0].name_Expected);
                        test.Expected_DT = new DataTable();
                        string[] columns = null;

                        var lines = File.ReadAllLines(path + @"\..\expected\" + test.script_Expected);

                        if (lines.Count() > 0)
                        {
                            columns = lines[0].Split(new char[] { ',' });

                            foreach (var column in columns)
                            {
                                test.Expected_DT.Columns.Add(column);
                            }
                        }
                        for (int i = 1; i < lines.Count(); i++)
                        {
                            DataRow  dr     = test.Expected_DT.NewRow();
                            string[] values = lines[i].Split(new char[] { ',' });

                            for (int j = 0; j < values.Count() && j < columns.Count(); j++)
                            {
                                dr[j] = values[j];
                            }

                            test.Expected_DT.Rows.Add(dr);
                        }
                    }

                    //test.ResultCompare = ct.getDifferentRecords(test.Actual_DT, test.Expected_DT);
                    Compare(test);
                }
            }
            catch
            {
                test.staus = 0;
            }
        }