private void bt_ThemXe_Click(object sender, EventArgs e)
 {
     if (rd_KhachHangCu.Checked)
     {
         if (KhachHang == null)
         {
             MessageBox.Show("Cần cung cấp thông tin Khách Hàng trước khi chọn xe", "Yêu Cầu Thông Tin", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
     }
     else
     {
         if (txt_HoTen.Text == "" || txt_DiaChi.Text == "" || txt_CMND.Text == "")
         {
             MessageBox.Show("Cần cung cấp thông tin trước khi chọn xe", "Yêu Cầu Thông Tin", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
     }
     TimXe.ShowDialog(this);
     if (TimXe.Xe != null)
     {
         Xe    = TimXe.Xe;
         MauXe = TimXe.MauXe;
         grid_DanhSachXeDat.Rows.Add(1);
     }
 }
 private void bt_Tim_Click(object sender, EventArgs e)
 {
     Xe = null;
     if (txt_TuKhoa.Text == "")
     {
         MessageBox.Show("Chưa nhập từ khoá", "Thiếu Thông Tin", MessageBoxButtons.OK, MessageBoxIcon.Error);
         txt_TuKhoa.Focus();
         return;
     }
     if (rd_MaXe.Checked)
     {
         int Ma = 0;
         try
         {
             Ma = int.Parse(txt_TuKhoa.Text);
         }
         catch (System.Exception ex)
         {
             MessageBox.Show("Mã Xe phải là số nguyên dương", "Lỗi Dữ Liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
             txt_TuKhoa.SelectAll();
             txt_TuKhoa.Focus();
             return;
         }
         Xe = new XE_BUS().Select(Ma);
     }
     else
     {
         Xe = new XE_BUS().SelectByTenXe(txt_TuKhoa.Text);
     }
     if (Xe != null)
     {
         txt_ro_MaXe.Text           = Xe.Ma.ToString();
         txt_ro_TenXe.Text          = Xe.TenXe;
         txt_ro_LoaiDiaHinh.Text    = Xe.LoaiDiaHinh;
         txt_ro_KieuXe.Text         = Xe.TenKieuXe;
         txt_ro_HangSanXuat.Text    = Xe.TenHangXe;
         txt_ro_DoiXe.Text          = Xe.DoiXe.ToString();
         txt_ro_SoLuong.Text        = Xe.SoLuong.ToString();
         txt_ro_ChiSoNhienLieu.Text = Xe.ChiSoNhienLieu.ToString();
         txt_ro_LoaiDiaHinh.Text    = Xe.LoaiDiaHinh;
         txt_ro_TocDoToiDa.Text     = Xe.MaxSpeed.ToString();
         txt_ro_SoLuong.Text        = Xe.SoLuong.ToString();
         combo_Mau.DataSource       = new MAUXE_BUS().SelectAllByMaXe(Xe.Ma);
         if (combo_Mau.DataSource != null)
         {
             combo_Mau.Enabled          = true;
             txt_ro_SoLuongTheoMau.Text = MauXe.SoLuong.ToString();
             bt_XacNhan.Enabled         = true;
             updown_SoLuong.Enabled     = true;
         }
         else
         {
             combo_Mau.Enabled          = false;
             txt_ro_SoLuongTheoMau.Text = "0";
             bt_XacNhan.Enabled         = false;
             updown_SoLuong.Items.Clear();
             updown_SoLuong.Enabled = false;
         }
     }
 }
        //[DataRow("Lead", "Vanggggggggggggggggggggg", "77H7-77777")]
        //[DataRow("Lead", "Vang", "77H7-7777777777777777777")]
        public void Update_NSX_With_MaxSize(String Name, String Color, String License_Plate)
        {
            Login();

            driver.Navigate().GoToUrl(homeURL + "/app/admin/xe-group11");
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(15);
            Thread.Sleep(8000);
            //Act
            Random rnd    = new Random();
            int    number = rnd.Next(1, 5);

            IWebElement         ele      = driver.FindElement(By.XPath("/html/body/app-root/ng-component/div/div/div[2]/ng-component/div[2]/div/div/div/div/div/p-table/div/div/div/div[2]/table/tbody/tr[" + number + "]/td[2]"));
            IJavaScriptExecutor executor = (IJavaScriptExecutor)driver;

            executor.ExecuteScript("arguments[0].click();", ele);
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(7);


            IWebElement         eleEdit      = driver.FindElement(By.XPath("/html/body/app-root/ng-component/div/div/div[2]/ng-component/div[1]/ul/li[3]"));
            IJavaScriptExecutor executorEdit = (IJavaScriptExecutor)driver;

            executorEdit.ExecuteScript("arguments[0].click();", eleEdit);
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30);

            //Act;

            driver.FindElement(By.Name("xE_NAME")).Clear();
            driver.FindElement(By.Name("xE_NAME")).SendKeys(Name);
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(7);

            driver.FindElement(By.Name("xE_COLOR")).Clear();
            driver.FindElement(By.Name("xE_COLOR")).SendKeys(Color);
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(7);

            driver.FindElement(By.Name("xE_LICENSE_PLATE")).Clear();
            driver.FindElement(By.Name("xE_LICENSE_PLATE")).SendKeys(License_Plate);
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(7);


            String Code = driver.FindElement(By.Name("xE_CODE")).GetAttribute("value");


            //wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.Id("btnSaveNTX")));
            IWebElement         eleUpdate      = driver.FindElement(By.XPath("/html/body/app-root/ng-component/div/div/div[2]/ng-component/form/ul/li[1]/i"));
            IJavaScriptExecutor executorUpdate = (IJavaScriptExecutor)driver;

            executorUpdate.ExecuteScript("arguments[0].click();", eleUpdate);
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30);


            //Check with value of DB
            XE_DTO finalRow = DataProvider.Instance.GetData <XE_DTO>("XE_SEARCH", new { XE_CODE = Code }).ToList().FirstOrDefault();

            //Assert
            Assert.AreNotEqual(Name, finalRow.XE_NAME);


            driver.Close();
        }
Beispiel #4
0
        public void Create_XE_With_DuplicateCode(String Code, String Name, String Color, int Seats, string Model, string License, int Price, int Consumption, string Notes, int Mspeed, string Manufacturer, int Manufacture_year)
        {
            Login();

            driver.Navigate().GoToUrl(homeURL + "/app/admin/xe-group11-add");
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(7);
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60));

            wait.Until(e => e.FindElement(By.Name("xE_CODE")));
            Thread.Sleep(8000);

            //Act
            driver.FindElement(By.Name("xE_CODE")).SendKeys(Code);
            driver.FindElement(By.Name("xE_NAME")).SendKeys(Name);
            driver.FindElement(By.Name("xE_COLOR")).SendKeys(Color);
            driver.FindElement(By.Name("xE_SEATS")).SendKeys(Seats.ToString());
            driver.FindElement(By.Name("xE_MODEL")).SendKeys(Model);
            driver.FindElement(By.Name("xE_LICENSE_PLATE")).SendKeys(License);
            driver.FindElement(By.Name("xE_PRICE")).SendKeys(Price.ToString());
            driver.FindElement(By.Name("xE_CONSUMPTION")).SendKeys(Consumption.ToString());
            driver.FindElement(By.Name("xE_NOTES")).SendKeys(Notes);
            driver.FindElement(By.Name("xE_MAX_SPEED")).SendKeys(Mspeed.ToString());
            driver.FindElement(By.Name("xE_MANUFACTURER")).SendKeys(Manufacturer);
            driver.FindElement(By.Name("xE_MANUFACTURE_YEAR")).SendKeys(Manufacture_year.ToString());

            IWebElement   comboBox      = driver.FindElement(By.Name("xE_STATUS"));
            SelectElement selectedValue = new SelectElement(comboBox);

            selectedValue.SelectByIndex(1);

            String Status = (string)((IJavaScriptExecutor)driver).ExecuteScript("return arguments[0].options[arguments[0].selectedIndex].text;", selectedValue);

            IWebElement         ele      = driver.FindElement(By.XPath("/html/body/app-root/ng-component/div/div/div[2]/ng-component/form/ul/li[1]"));
            IJavaScriptExecutor executor = (IJavaScriptExecutor)driver;

            executor.ExecuteScript("arguments[0].click();", ele);

            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(7);

            //Assert.IsTrue(driver.FindElement(By.XPath("/html/body")).GetAttribute("class").Contains("swal-icon swal-icon--error"));
            XE_DTO finalRow = DataProvider.Instance.GetData <XE_DTO>("XE_SEARCH", new { XE_CODE = Code }).ToList().FirstOrDefault();

            //Assert
            Assert.AreNotEqual(Name, finalRow.XE_NAME);

            /*Assert.AreEqual(Color, finalRow.XE_COLOR);
             * Assert.AreEqual(Seats, finalRow.XE_SEATS);
             * Assert.AreEqual(Model, finalRow.XE_MODEL);
             * Assert.AreEqual(License, finalRow.XE_LICENSE_PLATE);
             * Assert.AreEqual(Price, finalRow.XE_PRICE);
             * Assert.AreEqual(Consumption, finalRow.XE_CONSUMPTION);
             * Assert.AreEqual(Notes, finalRow.XE_NOTES);
             * Assert.AreEqual(Mspeed, finalRow.XE_MAX_SPEED);
             * Assert.AreEqual(Manufacturer, finalRow.XE_MANUFACTURER);
             * Assert.AreEqual(Manufacture_year, finalRow.XE_MANUFACTURE_YEAR);
             * Assert.AreEqual(Status, finalRow.XE_STATUS);*/

            driver.Close();
        }
Beispiel #5
0
 private void bt_ThemXe_Click(object sender, EventArgs e)
 {
     TimXe.ShowDialog(this);
     if (TimXe.Xe != null)
     {
         Xe    = TimXe.Xe;
         MauXe = TimXe.MauXe;
         grid_DanhSachXeMua.Rows.Add(1);
     }
 }
Beispiel #6
0
        /// <summary>
        /// Selects all records from the XE table.
        /// </summary>
        public List <XE_DTO> SelectAll()
        {
            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(m_ConnectionString, CommandType.StoredProcedure, "PROC_Xe_SelectAll"))
            {
                List <XE_DTO> XeList = new List <XE_DTO>();
                while (dataReader.Read())
                {
                    XE_DTO Xe = MakeXE_DTO(dataReader);
                    XeList.Add(Xe);
                }

                return(XeList);
            }
        }
        public void Delete_XE_CT_With_OK_Status()
        {
            Login();

            driver.Navigate().GoToUrl(homeURL + "/app/admin/xe-group11");
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(15);
            Thread.Sleep(8000);
            //Act
            Random rnd    = new Random();
            int    number = rnd.Next(1, 5);

            IWebElement         ele      = driver.FindElement(By.XPath("/html/body/app-root/ng-component/div/div/div[2]/ng-component/div[3]/div/div/div/div/div/p-table/div/div/div/div[2]/table/tbody/tr[" + number + "]/td[2]"));
            IJavaScriptExecutor executor = (IJavaScriptExecutor)driver;

            executor.ExecuteScript("arguments[0].click();", ele);
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(7);



            IWebElement         eleXem      = driver.FindElement(By.XPath("/html/body/app-root/ng-component/div/div/div[2]/ng-component/div[1]/ul/li[3]"));
            IJavaScriptExecutor executorXem = (IJavaScriptExecutor)driver;

            executorXem.ExecuteScript("arguments[0].click();", eleXem);
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(7);

            String Code = driver.FindElement(By.Name("xE_CODE")).GetAttribute("value");

            IWebElement         eleDel      = driver.FindElement(By.XPath("/html/body/app-root/ng-component/div/div/div[2]/ng-component/form/ul/li[2]"));
            IJavaScriptExecutor executorDel = (IJavaScriptExecutor)driver;

            executorDel.ExecuteScript("arguments[0].click();", eleDel);
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(7);

            IWebElement         eleYes      = driver.FindElement(By.XPath("/html/body/div/div/div[4]/div[2]/button"));
            IJavaScriptExecutor executorYes = (IJavaScriptExecutor)driver;

            executorYes.ExecuteScript("arguments[0].click();", eleYes);
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30);


            //Check with value of DB
            XE_DTO finalRow = DataProvider.Instance.GetData <XE_DTO>("XE_SEARCH", new { XE_CODE = Code }).ToList().FirstOrDefault();

            //Assert
            //Assert.AreEqual("0", finalRow.RECORD_STATUS);
            Assert.IsNull(finalRow);

            driver.Close();
        }
Beispiel #8
0
        public PagedResultDto <XE_DTO> XE_Search(XE_DTO filterInput)
        {
            var list = procedureHelper.GetData <XE_DTO>("XE_SEARCH", new XE_DTO
            {
                XE_CODE  = filterInput.XE_CODE,
                XE_NAME  = filterInput.XE_NAME,
                XE_COLOR = filterInput.XE_COLOR,
            });

            var totalCount = list.Count();

            return(new PagedResultDto <XE_DTO> {
                TotalCount = totalCount, Items = list
            });
        }
Beispiel #9
0
        /// <summary>
        /// Selects all records from the XE table by a foreign key.
        /// </summary>
        public List <XE_DTO> SelectAllByMaKieuXe(int MaKieuXe)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@MA_KIEU_XE", MaKieuXe)
            };

            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(m_ConnectionString, CommandType.StoredProcedure, "PROC_XeSelectAllByMaKieuXe", parameters))
            {
                List <XE_DTO> XeList = new List <XE_DTO>();
                while (dataReader.Read())
                {
                    XE_DTO Xe = MakeXE_DTO(dataReader);
                    XeList.Add(Xe);
                }

                return(XeList);
            }
        }
Beispiel #10
0
        /// <summary>
        /// Saves a record to the XE table.
        /// </summary>
        public void Insert(XE_DTO Xe)
        {
            ValidationUtility.ValidateArgument("Xe", Xe);

            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@TEN_XE", Xe.TenXe),
                new SqlParameter("@MA_KIEU_XE", Xe.MaKieuXe),
                new SqlParameter("@MA_HANG_XE", Xe.MaHangXe),
                new SqlParameter("@DOI_XE", Xe.DoiXe),
                new SqlParameter("@CHI_SO_NHIEN_LIEU", Xe.ChiSoNhienLieu),
                new SqlParameter("@MAX_SPEED", Xe.MaxSpeed),
                new SqlParameter("@LOAI_DIA_HINH", Xe.LoaiDiaHinh),
                new SqlParameter("@SO_CHO_NGOI", Xe.SoChoNgoi),
                new SqlParameter("@GIA_TIEN_BAN", Xe.GiaTienBan),
                new SqlParameter("@GIA_TIEN_MUA", Xe.GiaTienMua),
                new SqlParameter("@SO_LUONG", Xe.SoLuong)
            };

            Xe.Ma = (int)SqlClientUtility.ExecuteScalar(m_ConnectionString, CommandType.StoredProcedure, "PROC_Xe_Insert", parameters);
        }
Beispiel #11
0
        /// <summary>
        /// Creates a new instance of the XE class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private XE_DTO MakeXE_DTO(SqlDataReader dataReader)
        {
            XE_DTO Xe = new XE_DTO();

            Xe.Ma             = SqlClientUtility.GetInt32(dataReader, "MA", 0);
            Xe.TenXe          = SqlClientUtility.GetString(dataReader, "TEN_XE", String.Empty);
            Xe.MaKieuXe       = SqlClientUtility.GetInt32(dataReader, "MA_KIEU_XE", 0);
            Xe.MaHangXe       = SqlClientUtility.GetInt32(dataReader, "MA_HANG_XE", 0);
            Xe.TenHangXe      = SqlClientUtility.GetString(dataReader, "TEN_HANG_XE", String.Empty);
            Xe.DoiXe          = SqlClientUtility.GetInt32(dataReader, "DOI_XE", 0);
            Xe.TenKieuXe      = SqlClientUtility.GetString(dataReader, "TEN_KIEU_XE", String.Empty);
            Xe.ChiSoNhienLieu = SqlClientUtility.GetDecimal(dataReader, "CHI_SO_NHIEN_LIEU", Decimal.Zero);
            Xe.MaxSpeed       = SqlClientUtility.GetInt32(dataReader, "MAX_SPEED", 0);
            Xe.LoaiDiaHinh    = SqlClientUtility.GetString(dataReader, "LOAI_DIA_HINH", String.Empty);
            Xe.SoChoNgoi      = SqlClientUtility.GetInt32(dataReader, "SO_CHO_NGOI", 0);
            Xe.GiaTienBan     = SqlClientUtility.GetDecimal(dataReader, "GIA_TIEN_BAN", Decimal.Zero);
            Xe.GiaTienMua     = SqlClientUtility.GetDecimal(dataReader, "GIA_TIEN_MUA", Decimal.Zero);
            Xe.SoLuong        = SqlClientUtility.GetInt32(dataReader, "SO_LUONG", 0);

            return(Xe);
        }
Beispiel #12
0
 public List <XE_DTO> XE_Insert(XE_DTO filterInput)
 {
     return(procedureHelper.GetData <XE_DTO>("XE_INSERT", filterInput));
 }
Beispiel #13
0
        public void Create_XE_With_OK_Status(String Name, String Color, int Seats, String Model, String License, int Price, int Consumption, String Notes, int Mspeed, String Manufacturer, int Manufacture_year)
        {
            String Code = (new Random().Next(1, 99999999)).ToString();


            Login();

            driver.Navigate().GoToUrl(homeURL + "/app/admin/xe-group11-add");
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(7);
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60));

            wait.Until(e => e.FindElement(By.Name("xE_CODE")));
            Thread.Sleep(8000);

            //Act;
            driver.FindElement(By.Name("xE_CODE")).SendKeys(Code);
            driver.FindElement(By.Name("xE_NAME")).SendKeys(Name);
            driver.FindElement(By.Name("xE_COLOR")).SendKeys(Color);
            driver.FindElement(By.Name("xE_SEATS")).SendKeys(Seats.ToString());
            driver.FindElement(By.Name("xE_MODEL")).SendKeys(Model);
            driver.FindElement(By.Name("xE_LICENSE_PLATE")).SendKeys(License);
            driver.FindElement(By.Name("xE_PRICE")).SendKeys(Price.ToString());
            driver.FindElement(By.Name("xE_CONSUMPTION")).SendKeys(Consumption.ToString());
            driver.FindElement(By.Name("xE_NOTES")).SendKeys(Notes);
            driver.FindElement(By.Name("xE_MAX_SPEED")).SendKeys(Mspeed.ToString());
            driver.FindElement(By.Name("xE_MANUFACTURER")).SendKeys(Manufacturer);
            driver.FindElement(By.Name("xE_MANUFACTURE_YEAR")).SendKeys(Manufacture_year.ToString());
            //driver.FindElement(By.Name("xE_STATUS")).SendKeys(Status);

            Random rnd    = new Random();
            int    number = rnd.Next(0, 3);

            IWebElement   comboBox      = driver.FindElement(By.Name("xE_STATUS"));
            SelectElement selectedValue = new SelectElement(comboBox);

            selectedValue.SelectByIndex(number);

            String Status = (string)((IJavaScriptExecutor)driver).ExecuteScript("return arguments[0].options[arguments[0].selectedIndex].text;", selectedValue);

            //String Status = selectedValue.SelectByIndex(0).value;

            //get value of select element



            IWebElement         ele      = driver.FindElement(By.XPath("/html/body/app-root/ng-component/div/div/div[2]/ng-component/form/ul/li[1]"));
            IJavaScriptExecutor executor = (IJavaScriptExecutor)driver;

            executor.ExecuteScript("arguments[0].click();", ele);


            //Check with value of DB
            //CM_XE_DTO input = new CM_XE_DTO(Code, Name, Origin);
            XE_DTO finalRow = DataProvider.Instance.GetData <XE_DTO>("XE_SEARCH", new { XE_CODE = Code }).ToList().FirstOrDefault();

            //Assert
            Assert.AreEqual(Code, finalRow.XE_CODE);
            Assert.AreEqual(Name, finalRow.XE_NAME);
            Assert.AreEqual(Color, finalRow.XE_COLOR);
            Assert.AreEqual(Seats, finalRow.XE_SEATS);
            Assert.AreEqual(Model, finalRow.XE_MODEL);
            Assert.AreEqual(License, finalRow.XE_LICENSE_PLATE);
            Assert.AreEqual(Price, finalRow.XE_PRICE);
            Assert.AreEqual(Consumption, finalRow.XE_CONSUMPTION);
            Assert.AreEqual(Notes, finalRow.XE_NOTES);
            Assert.AreEqual(Mspeed, finalRow.XE_MAX_SPEED);
            Assert.AreEqual(Manufacturer, finalRow.XE_MANUFACTURER);
            Assert.AreEqual(Manufacture_year, finalRow.XE_MANUFACTURE_YEAR);
            Assert.AreEqual(Status, finalRow.XE_STATUS);

            driver.Close();
        }
Beispiel #14
0
 public List <XE_DTO> XE_Update(XE_DTO filterInput)
 {
     return(procedureHelper.GetData <XE_DTO>("XE_UPDATE", filterInput));
 }
 public PagedResultDto <XE_DTO> XE_Search([FromBody] XE_DTO filterInput)
 {
     return(xeService.XE_Search(filterInput));
 }
 /// <summary>
 /// Updates a record in the XE table.
 /// </summary>
 public void Update(XE_DTO Xe)
 {
     ValidationUtility.ValidateArgument("Xe", Xe);
     new XE_DAO().Update(Xe);
 }
 /// <summary>
 /// Saves a record to the XE table.
 /// </summary>
 public void Insert(XE_DTO Xe)
 {
     ValidationUtility.ValidateArgument("Xe", Xe);
     new XE_DAO().Insert(Xe);
 }
 public List <XE_DTO> XE_Insert([FromBody] XE_DTO input)
 {
     return(xeService.XE_Insert(input));
 }
 public List <XE_DTO> XE_Update([FromBody] XE_DTO input)
 {
     return(xeService.XE_Update(input));
 }