示例#1
0
        public JsonResult GetCustomers(Customers item)
        {
            try
            {
                IList <Customers> listData = new List <Customers>();
                CustomersData     data     = new CustomersData();
                listData = data.Get(item);


                var jsonResult = Json(new
                {
                    data    = listData,
                    success = true
                }, JsonRequestBehavior.AllowGet);

                jsonResult.MaxJsonLength = int.MaxValue;
                return(jsonResult);
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    success = false,
                    errMsg = ex.Message
                }, JsonRequestBehavior.AllowGet));
            }
        }
示例#2
0
        // GET: /Customers/GetCustomerID/:id

        public JsonResult GetCustomerID(int id)
        {
            Customers     cus_info = new Customers();
            CustomersData data3    = new CustomersData();

            cus_info = data3.GetCustomerInfo_ByID(id);

            StaffData     st        = new StaffData();
            DataTable     dt        = new DataTable();
            List <Staffs> staffList = new List <Staffs>();

            dt = st.GetStaffRole(0, 5);
            if (dt.Rows.Count > 0)
            {
                staffList = dt.AsEnumerable().Select(dr => new Staffs()
                {
                    StaffID        = dr.Field <int>("StaffID"),
                    StaffCode      = dr.Field <string>("StaffCode"),
                    StaffTitleName = dr.Field <string>("StaffTitleName"),
                    StaffFirstName = dr.Field <string>("StaffFirstName"),
                    StaffLastName  = dr.Field <string>("StaffLastName"),
                    StaffRoleID    = dr.Field <int>("StaffRoleID"),
                    StaffRoleName  = dr.Field <string>("StaffRoleName"),
                    StaffName      = dr.Field <string>("StaffTitleName") + dr.Field <string>("StaffFirstName") + " "
                                     + dr.Field <string>("StaffLastName"),
                }).ToList();
            }
            return(Json(new
            {
                dataCustomer = cus_info,
                dataZone = staffList,
                success = true
            }, JsonRequestBehavior.AllowGet));
        }
示例#3
0
        public ActionResult IntroductionDefault()
        {
            ErrorMessage = "";
            string          path      = new System.IO.DirectoryInfo(Request.PhysicalPath + "..\\..\\..\\..\\..\\..\\..\\Data\\AdventureWorks\\AdventureWorks_Person_Contact.csv").FullName;
            CheckFileStatus CheckFile = new CheckFileStatus();

            ErrorMessage = CheckFile.CheckFile(path);
            if (ErrorMessage == "")
            {
                try
                {
                    //Binding the result to the grid
                    List <PersonDetail> DataSource = CustomersData.list();
                    ViewBag.datasource = DataSource;
                    ErrorMessage       = "";
                }
                catch (HqlConnectionException)
                {
                    ErrorMessage = "Could not establish a connection to the HiveServer. Please run HiveServer2 from the Syncfusion service manager dashboard.";
                }
            }


            return(View());
        }
示例#4
0
        public RuleResponse Execute(CustomersData data)
        {
            if (data == null)
            {
                return(new BusinessRules.RuleResponse()
                {
                    ErrorString = "missing data"
                });
            }

            var isValid = false;

            foreach (var item in data.Customers)
            {
                if (item.FullName == "Blaine Bailey5")
                {
                    isValid = true;
                }
            }

            return(new RuleResponse()
            {
                IsValid = isValid,
                RuleName = "Rule1"
            });
        }
示例#5
0
        // GET: /Customers/GetDataPurchaseData/:id
        public JsonResult GetDataPurchaseData(int id)
        {
            try
            {
                IList <Customers> listData = new List <Customers>();
                CustomersData     data     = new CustomersData();
                listData = data.Get(id);


                ProductData      dataPro     = new ProductData();
                IList <Products> listProduct = new List <Products>();
                listProduct = dataPro.GetListProduct();

                IList <ProductSelect> listProductsSelect = new List <ProductSelect>();
                listProductsSelect = dataPro.GetProductCustomer(id, 0);

                return(Json(new
                {
                    data = listData,
                    dataProduct = listProduct,
                    dataProductSelect = listProductsSelect,
                    success = true
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    success = false,
                    errMsg = ex.Message
                }, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult LogIn(StaffLogin login)
        {
            if (!String.IsNullOrEmpty(login.StaffCode) || !String.IsNullOrEmpty(login.StaffPassword))
            {
                if (Session["iuser"] == null)
                {
                    try
                    {
                        CustomersData data = new CustomersData();
                        login                 = data.GetStaffLogin(login);
                        Session["iuser"]      = login.StaffID;
                        Session["iusername"]  = login.StaffName;
                        Session["istaffrole"] = login.StaffRoleID;
                        Session["imageUrl"]   = login.ImageUrl;


                        StaffData st = new StaffData();
                        List <StaffPermissionGroup> item = new List <StaffPermissionGroup>();
                        item = st.GetStaffMenu(login.StaffRoleID);
                        string menu = st.GetMenu(item);

                        Session["imenu"] = menu;
                        return(RedirectToAction("Index"));
                    }
                    catch (Exception ex)
                    {
                        TempData["error"] = ex.Message;
                        return(View());
                    }
                }
                else
                {
                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                if (String.IsNullOrEmpty(login.StaffCode) || String.IsNullOrEmpty(login.StaffPassword))
                {
                    TempData["error"] = "กรุณากรอกรหัสพนักงานและรหัสผ่าน";
                    return(View());
                }
                else if (String.IsNullOrEmpty(login.StaffCode))
                {
                    TempData["error"] = "กรุณากรอกรหัสพนักงาน";
                    return(View());
                }
                else if (String.IsNullOrEmpty(login.StaffPassword))
                {
                    TempData["error"] = "กรุณากรอกรหัสผ่าน";
                    return(View());
                }
                else
                {
                    TempData["error"] = "ไม่มีข้อมูลพนักงาน";
                    return(View());
                }
            }
        }
示例#7
0
        /// <summary>
        /// Prints inactive customers on console screen.
        /// </summary>
        public void PrintInactiveCustomers()
        {
            var inactiveCustomersList = CustomersData.GetAllCustomers().Where(c => c.IsActive == false);

            foreach (var customer in inactiveCustomersList)
            {
                Console.WriteLine($"ID: {customer.ID}\tName: {customer.Name}");
            }
        }
示例#8
0
        //  POST: /Customers/ExportCard

        public FileResult ExportCard(int ContractID, int CustomerID)
        {
            IList <Customers> listData = new List <Customers>();
            CustomersData     data     = new CustomersData();

            listData = data.Get(CustomerID);

            try
            {
                string yourcode   = CustomerID + ":" + ContractID;
                string firstText  = listData[0].CustomerName;
                string secondText = "(" + listData[0].CustomerNickName + ")";

                PointF firstLocation  = new PointF(550f, 250f);
                PointF secondLocation = new PointF(550f, 300f);

                string imageFilePath = Server.MapPath("~/Content/bg_1.png");

                Bitmap bitmap = new Bitmap(1800, 1400);
                bitmap = (Bitmap)Image.FromFile(imageFilePath);//load the image file

                //string imageFilePath1 = Server.MapPath("~/Content/qr1.png");
                //Bitmap bitmap1 = new Bitmap(400, 400);
                //bitmap1 = (Bitmap)Image.FromFile(imageFilePath1.ToString());//load the image file


                QRCodeEncoder enc = new QRCodeEncoder();
                enc.QRCodeScale = 5;
                Bitmap qrcode = enc.Encode(yourcode);


                using (Graphics graphics = Graphics.FromImage(bitmap))
                {
                    using (Font arialFont = new Font("Cordia New", 30))
                    {
                        graphics.DrawString(firstText, arialFont, Brushes.White, firstLocation);
                        graphics.DrawString(secondText, new Font("Cordia New", 30), Brushes.White, secondLocation);


                        graphics.DrawImage(qrcode.Clone(new Rectangle(0, 0, qrcode.Width - 1, qrcode.Height - 1), qrcode.PixelFormat), new Point(200, 200));
                    }
                }
                MemoryStream ms = new MemoryStream();
                bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);

                bitmap.Save(Server.MapPath("~/Content/img1.jpg"), System.Drawing.Imaging.ImageFormat.Png);

                return(File(Server.MapPath("~/Content/img1.jpg"), System.Net.Mime.MediaTypeNames.Application.Octet,
                            "MEMBER" + (CustomerID * 1000) + ContractID + ".png"));
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#9
0
        public static Customer Create(string id, string name, DateTime?validFrom = null, DateTime?validTo = null)
        {
            CustomersData o = new CustomersData
            {
                ID        = id,
                Name      = name,
                ValidFrom = validFrom ?? DateTime.MinValue,
                ValidTo   = validTo ?? DateTime.MaxValue
            };

            return(new Customer(o));
        }
示例#10
0
 public static IResponse <List <Customer> > Find(string name)
 {
     try
     {
         var result = new CustomersData().Find(name);
         return(ResponseFactory <List <Customer> > .Ok(result, $"{result.Count} records found."));
     }
     catch (Exception ex)
     {
         return(ResponseFactory <List <Customer> > .Exception(ex));
     }
 }
示例#11
0
        // GET: /Customers/GetContract?CustomerID=id&ContractID=id
        public JsonResult GetContract(int CustomerID, int ContractID)
        {
            try
            {
                IList <Contract> listContract = new List <Contract>();
                ContractData     cd           = new ContractData();
                listContract = cd.GetContract(CustomerID, ContractID);

                IList <Customers> listData = new List <Customers>();
                CustomersData     dataCus  = new CustomersData();
                listData = dataCus.Get(CustomerID);

                ProductData           dataPro            = new ProductData();
                IList <ProductSelect> listProductsSelect = new List <ProductSelect>();

                IList <Products> listProduct = new List <Products>();
                listProduct = dataPro.GetListProduct();


                List <ProductSelect> listProductsSelect1 = new List <ProductSelect>();

                if (ContractID > 0)
                {
                    listProductsSelect = dataPro.GetProductCustomer(CustomerID, ContractID);
                }
                double ContractPayment = 0;
                listProductsSelect1 = dataPro.ProductContractSummary(ref ContractPayment, listProductsSelect);



                return(Json(new
                {
                    data = listContract,
                    dataCustomers = listData,
                    dataProduct = listProduct,
                    dataProductSelect = listProductsSelect1,
                    success = true
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    data = ex.Message,
                    success = false
                }, JsonRequestBehavior.AllowGet));
            }
        }
        public JsonResult PostStaffLoginOnMobile(StaffLogin item)
        {
            try
            {
                string hostname = "http://203.154.41.217/";

                if (!String.IsNullOrEmpty(item.StaffCode) || !String.IsNullOrEmpty(item.StaffPassword))
                {
                    CustomersData data = new CustomersData();
                    item = data.GetStaffLoginOnMobile(item);
                }
                else
                {
                    if (String.IsNullOrEmpty(item.StaffCode) || String.IsNullOrEmpty(item.StaffPassword))
                    {
                        throw new Exception("กรุณากรอกรหัสพนักงานและรหัสผ่าน");
                    }
                    else if (String.IsNullOrEmpty(item.StaffCode))
                    {
                        throw new Exception("กรุณากรอกรหัสพนักงาน");
                    }
                    else if (String.IsNullOrEmpty(item.StaffPassword))
                    {
                        throw new Exception("กรุณากรอกรหัสผ่าน");
                    }
                    else
                    {
                        throw new Exception("ไม่มีข้อมูลพนักงาน");
                    }
                }
                return(Json(new
                            { success = true,
                              iuser = item.StaffID,
                              iusername = item.StaffName,
                              istaffrole = item.StaffRoleID,
                              imageUrl = hostname + item.ImageUrl }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    success = false,
                    errorMessage = ex.Message
                }, JsonRequestBehavior.AllowGet));
            }
        }
示例#13
0
        public static IResponse <Customer> Get(int id)
        {
            try
            {
                var result = new CustomersData().Get(id);
                if (result == null)
                {
                    return(ResponseFactory <Customer> .Error($"Could not find a record with Id: {id}", ErrorResponseStatus.NotFound));
                }

                return(ResponseFactory <Customer> .Ok(result));
            }
            catch (Exception ex)
            {
                return(ResponseFactory <Customer> .Exception(ex));
            }
        }
示例#14
0
        public static IResponse <int> Add(Customer customer)
        {
            try
            {
                if (customer == null)
                {
                    return(ResponseFactory <int> .Error("Invalid customer data.", ErrorResponseStatus.BadRequest));
                }

                var customerId = new CustomersData().Add(customer);
                return(ResponseFactory <int> .Ok(customerId, "Customer has been added."));
            }
            catch (Exception ex)
            {
                return(ResponseFactory <int> .Exception(ex));
            }
        }
示例#15
0
        public ActionResult ExportPDF(Customers item)
        {
            IList <Customers> listData = new List <Customers>();
            CustomersData     data     = new CustomersData();

            listData = data.Get(item);

            Dictionary <string, object> param = new Dictionary <string, object>();

            param.Add("pCondition", listData[0].CustomerFirstName + " " + listData[0].CustomerLastName);

            param.Add("pAddress", "  100 ต.ควนมะพร้าว อ.เมืองพัทลุง จ.พัทลุง 10000 เบอร์โทร 081-476-2091");
            Utility.ExportPDF(
                "RedemptionReport_" + DateTime.Now.ToString("yyyyMMdd_HHmmss"),
                "~/Report/CustomerReport.rpt",
                listData,
                param
                );
            return(View());
        }
示例#16
0
        public ActionResult IntroductionDefault()
        {
            ErrorMessage = "";
            string path = new System.IO.DirectoryInfo(Request.PhysicalPath + "..\\..\\..\\..\\..\\..\\..\\Data\\AdventureWorks\\AdventureWorks_Person_Contact.csv").FullName;

            try
            {
                //Binding the result to the grid
                List <Customers> DataSource = CustomersData.list(path);
                ViewBag.datasource = DataSource;
                ErrorMessage       = "";
            }
            catch (HBaseConnectionException)
            {
                ErrorMessage = "Could not establish a connection to the HBaseServer. Please run HBaseServer from the Syncfusion service manager dashboard.";
            }
            catch (HBaseException ex)
            {
                ErrorMessage = ex.Message;
            }
            return(View());
        }
示例#17
0
        public void WhenCustomersAvailable()
        {
            // Arrange
            IRaceDayService raceDayService =
                new RaceDayService(new MockRaceService());

            int     expectedCustomerCount     = 5;
            decimal expectedTotalAmountOnBets = 120 + 200 + 500 + 50;
            IDictionary <int, int> expectedNumberOfBetsByCustomer = new Dictionary <int, int>
            {
                { 1, 1 }, { 2, 1 }, { 3, 1 }, { 4, 1 }, { 5, 0 }
            };

            IDictionary <int, decimal> expectedTotalAmountOnBetsByCustomer = new Dictionary <int, decimal>
            {
                { 1, 120 }, { 2, 200 }, { 3, 500 }, { 4, 50 }, { 5, 0 }
            };

            IDictionary <int, bool> expectedRiskByCustomer = new Dictionary <int, bool>
            {
                { 1, false }, { 2, false }, { 3, true }, { 4, false }, { 5, false }
            };

            // Act
            CustomersData customersData = raceDayService.GetCustomers();

            // Assert
            Assert.IsNotNull(customersData);
            Assert.AreEqual(expectedCustomerCount, customersData.Customers.Count());
            Assert.AreEqual(expectedTotalAmountOnBets, customersData.TotalAmountOnBetsForAll);

            foreach (CustomerData customerData in customersData.Customers)
            {
                Assert.IsNotNull(customerData);
                Assert.AreEqual(expectedNumberOfBetsByCustomer[customerData.Id], customerData.NumberOfBets);
                Assert.AreEqual(expectedTotalAmountOnBetsByCustomer[customerData.Id], customerData.TotalAmountOnBets);
                Assert.AreEqual(expectedRiskByCustomer[customerData.Id], customerData.IsAtRisk);
            }
        }
示例#18
0
        // POST: /Customers/PostChangeMobilePhone
        public JsonResult PostChangeMobilePhone(Customers item)
        {
            try
            {
                CustomersData CD = new CustomersData();
                CD.GetChangeMobilePhone(item);

                return(Json(new
                {
                    data = "บันทึกการแก้ไขข้อมูลสำเร็จ",
                    success = true
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    data = ex.Message,
                    success = false
                }, JsonRequestBehavior.AllowGet));
            }
        }
示例#19
0
        /// <summary>
        /// Регистрация нового покупателя
        /// </summary>
        /// <param name="customer">Данные покупателя</param>
        public void RegisterNewCustomer(CustomersData customer)
        {
            registrationPage.OpenPage();
            registrationPage.FirstNameInput.SendKeys(customer.Firstname);
            registrationPage.LastNameInput.SendKeys(customer.Lastname);
            registrationPage.AddressInput.SendKeys(customer.Address);
            registrationPage.PostcodeInput.SendKeys(customer.Postcode);
            registrationPage.CityInput.SendKeys(customer.City);
            registrationPage.SelectCountry(customer.Country);
            registrationPage.SelectZone(customer.Zone);
            registrationPage.EmailInput.SendKeys(customer.Email);
            registrationPage.PhoneInput.SendKeys(customer.Phone);
            registrationPage.PasswordInput.SendKeys(customer.Password);
            registrationPage.ConfirmedPasswordInput.SendKeys(customer.Password);
            registrationPage.CreateAccountButton.Click();

            registrationPage.Logout();

            registrationPage
            .AuthCustomer(customer.Email, customer.Password)
            .LoginButton.Click();

            registrationPage.Logout();
        }
        [HttpPost] // Post: /ManagePayment/PostPaymentDailyReceipts
        public JsonResult PostPaymentDailyReceipts(DailyReceiptsReport item)
        {
            try
            {
                List <DailyReceiptsReport> listData = new List <DailyReceiptsReport>();
                CustomersData data = new CustomersData();
                data.PaymentDailyReceipts(item);


                return(Json(new
                {
                    data = "บันทึกรายการสำเร็จ",
                    success = true
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    success = false,
                    data = ex.Message
                }, JsonRequestBehavior.AllowGet));
            }
        }
        // GET: /ManagePayment/GetListCustomerOnMobile?staffId=1
        public JsonResult GetListCustomerOnMobile(int staffId)
        {
            try
            {
                CustomersData cus = new CustomersData();
                IList <ListCustomerOnMobile> listData = new List <ListCustomerOnMobile>();
                listData = cus.GetListCustomerOnMobile(staffId);


                return(Json(new
                {
                    data = listData,
                    success = true
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    success = false,
                    errMsg = ex.Message
                }, JsonRequestBehavior.AllowGet));
            }
        }
示例#22
0
 public CustomersBusiness()
 {
     customersData = new CustomersData();
 }
示例#23
0
 private static void add(SentryDbContext c, CustomersData customers)
 {
     customers.ID = Guid.NewGuid().ToString();
     c.Customers.Add(customers);
 }
示例#24
0
 public IEnumerable <Customer> Get()
 {
     return(CustomersData.GetData());
 }
示例#25
0
 public static Customer Create(CustomersData data)
 {
     return(new Customer(data));
 }
示例#26
0
        public ActionResult ExportDefault(string SaveOption)
        {
            if (SaveOption == null)
            {
                ErrorMessage = "";
                return(View());
            }
            else if (SaveOption == "Excel 2013" || SaveOption == "Excel 2010" || SaveOption == "Excel 2007" || SaveOption == "Excel 2003" || SaveOption == "CSV")
            {
                ErrorMessage = "";
                string          path      = new System.IO.DirectoryInfo(Request.PhysicalPath + "..\\..\\..\\..\\..\\..\\..\\Data\\AdventureWorks\\AdventureWorks_Person_Contact.csv").FullName;
                CheckFileStatus CheckFile = new CheckFileStatus();
                ErrorMessage = CheckFile.CheckFile(path);
                if (ErrorMessage == "")
                {
                    try
                    {
                        //Instantiate the spreadsheet creation engine.
                        ExcelEngine excelEngine = new ExcelEngine();

                        //Instantiate the excel application object.
                        IApplication application = excelEngine.Excel;

                        //A new workbook is created.[Equivalent to creating a new workbook in MS Excel]
                        //The new workbook will have 1 worksheets
                        IWorkbook workbook = application.Workbooks.Create(1);

                        //The first worksheet object in the worksheets collection is accessed.
                        IWorksheet worksheet = workbook.Worksheets[0];
                        var        result    = CustomersData.list();
                        ErrorMessage = null;

                        //Adding header text for worksheet
                        worksheet[1, 1].Text = "Contact Id";
                        worksheet[1, 2].Text = "Full Name";
                        worksheet[1, 3].Text = "Age";
                        worksheet[1, 4].Text = "Phone Number";
                        worksheet[1, 5].Text = "Email Id";
                        worksheet[1, 6].Text = "Modified Date";

                        int i = 1;
                        //Reading each row from the fetched result
                        foreach (PersonDetail records in result)
                        {
                            //Reading each data from the row
                            //Assigning each data to the worksheet based on index
                            worksheet[i + 1, 1].Text = records.ContactId;
                            worksheet[i + 1, 2].Text = records.FullName;
                            worksheet[i + 1, 3].Text = records.Age;
                            worksheet[i + 1, 4].Text = records.PhoneNumber;
                            worksheet[i + 1, 5].Text = records.EmailId;
                            worksheet[i + 1, 6].Text = records.ModifiedDate;
                            i++;
                        }
                        //Assigning Header text with cell color
                        worksheet.Range["A1:F1"].CellStyle.Color      = System.Drawing.Color.FromArgb(51, 153, 51);
                        worksheet.Range["A1:F1"].CellStyle.Font.Color = Syncfusion.XlsIO.ExcelKnownColors.White;
                        worksheet.Range["A1:F1"].CellStyle.Font.Bold  = true;
                        worksheet.UsedRange.AutofitColumns();
                        #endregion

                        //Save as .xls format
                        if (SaveOption == "Excel 2003")
                        {
                            return(excelEngine.SaveAsActionResult(workbook, "Sample.xls", HttpContext.ApplicationInstance.Response, ExcelDownloadType.PromptDialog, ExcelHttpContentType.Excel97));
                        }
                        //Save as .xlsx format
                        else if (SaveOption == "Excel 2007")
                        {
                            workbook.Version = ExcelVersion.Excel2007;
                            return(excelEngine.SaveAsActionResult(workbook, "Sample.xlsx", HttpContext.ApplicationInstance.Response, ExcelDownloadType.PromptDialog, ExcelHttpContentType.Excel2007));
                        }
                        //Save as .xlsx format
                        else if (SaveOption == "Excel 2010")
                        {
                            workbook.Version = ExcelVersion.Excel2010;
                            return(excelEngine.SaveAsActionResult(workbook, "Sample.xlsx", HttpContext.ApplicationInstance.Response, ExcelDownloadType.PromptDialog, ExcelHttpContentType.Excel2010));
                        }
                        //Save as .xlsx format
                        else if (SaveOption == "Excel 2013")
                        {
                            workbook.Version = ExcelVersion.Excel2013;
                            return(excelEngine.SaveAsActionResult(workbook, "Sample.xlsx", HttpContext.ApplicationInstance.Response, ExcelDownloadType.PromptDialog, ExcelHttpContentType.Excel2013));
                        }
                        //Save as .csv format
                        else if (SaveOption == "CSV")
                        {
                            return(excelEngine.SaveAsActionResult(workbook, "Sample.csv", ",", HttpContext.ApplicationInstance.Response, ExcelDownloadType.PromptDialog, ExcelHttpContentType.CSV));
                        }
                        //Close the workbook
                        workbook.Close();

                        //Close the excelengine
                        excelEngine.Dispose();
                    }
                    catch (HqlConnectionException)
                    {
                        ErrorMessage = "Could not establish a connection to the HiveServer. Please run HiveServer2 from the Syncfusion service manager dashboard.";
                    }
                }

                return(View());
            }
            else
            {
                ErrorMessage = "";
                string          path      = new System.IO.DirectoryInfo(Request.PhysicalPath + "..\\..\\..\\..\\..\\..\\..\\Data\\AdventureWorks\\AdventureWorks_Person_Contact.csv").FullName;
                CheckFileStatus CheckFile = new CheckFileStatus();
                ErrorMessage = CheckFile.CheckFile(path);
                //A new document is created.
                if (ErrorMessage == "")
                {
                    try
                    {
                        WordDocument document = new WordDocument();

                        //Adding new table to the document
                        WTable doctable = new WTable(document);

                        //Adding a new section to the document.
                        WSection section = document.AddSection() as WSection;

                        //Set Margin of the section
                        section.PageSetup.Margins.All = 72;

                        //Set page size of the section
                        section.PageSetup.PageSize = new SizeF(800, 792);

                        //Create Paragraph styles
                        WParagraphStyle style = document.AddParagraphStyle("Normal") as WParagraphStyle;
                        style.CharacterFormat.FontName = "Calibri";
                        style.CharacterFormat.FontSize = 11f;

                        //Reading the data from the table
                        var result = CustomersData.list();
                        doctable.AddRow(true, false);

                        //creating new cell
                        WTableCell cell = new WTableCell(document);

                        //Create a character format for declaring font color and style for the text inside the cell
                        WCharacterFormat charFormat = new WCharacterFormat(document);
                        charFormat.TextColor = System.Drawing.Color.White;
                        charFormat.Bold      = true;

                        //Adding header text for the table
                        cell.AddParagraph().AppendText("Customer Id").ApplyCharacterFormat(charFormat);
                        cell.Width = 75;
                        cell.CellFormat.BackColor = System.Drawing.Color.FromArgb(51, 153, 51);
                        //Adding cell to rows
                        doctable.Rows[0].Cells.Add(cell);
                        cell = new WTableCell(document);
                        cell.AddParagraph().AppendText("Full Name").ApplyCharacterFormat(charFormat);
                        cell.Width = 90;
                        cell.CellFormat.BackColor = System.Drawing.Color.FromArgb(51, 153, 51);
                        doctable.Rows[0].Cells.Add(cell);
                        cell = new WTableCell(document);
                        cell.AddParagraph().AppendText("Age").ApplyCharacterFormat(charFormat);
                        cell.Width = 75;
                        cell.CellFormat.BackColor = System.Drawing.Color.FromArgb(51, 153, 51);
                        doctable.Rows[0].Cells.Add(cell);
                        cell = new WTableCell(document);
                        cell.AddParagraph().AppendText("Phone Number").ApplyCharacterFormat(charFormat);
                        cell.Width = 90;
                        cell.CellFormat.BackColor = System.Drawing.Color.FromArgb(51, 153, 51);
                        doctable.Rows[0].Cells.Add(cell);
                        cell = new WTableCell(document);
                        cell.AddParagraph().AppendText("Email Id").ApplyCharacterFormat(charFormat);
                        cell.Width = 180;
                        cell.CellFormat.BackColor = System.Drawing.Color.FromArgb(51, 153, 51);
                        doctable.Rows[0].Cells.Add(cell);
                        cell = new WTableCell(document);
                        cell.AddParagraph().AppendText("Modified Date").ApplyCharacterFormat(charFormat);
                        cell.Width = 125;
                        cell.CellFormat.BackColor = System.Drawing.Color.FromArgb(51, 153, 51);
                        doctable.Rows[0].Cells.Add(cell);

                        int i = 1;
                        //Reading each row from the fetched result
                        foreach (PersonDetail records in result)
                        {
                            doctable.AddRow(true, false);

                            //Assigning fetched result to the cell
                            cell = new WTableCell(document);
                            cell.AddParagraph().AppendText(records.ContactId.ToString());
                            cell.Width = 75;
                            doctable.Rows[i].Cells.Add(cell);
                            cell = new WTableCell(document);
                            cell.AddParagraph().AppendText(records.FullName.ToString());
                            cell.Width = 90;
                            doctable.Rows[i].Cells.Add(cell);
                            cell = new WTableCell(document);
                            cell.AddParagraph().AppendText(records.Age.ToString());
                            cell.Width = 75;
                            doctable.Rows[i].Cells.Add(cell);
                            cell = new WTableCell(document);
                            cell.AddParagraph().AppendText(records.PhoneNumber.ToString());
                            cell.Width = 90;
                            doctable.Rows[i].Cells.Add(cell);
                            cell = new WTableCell(document);
                            cell.AddParagraph().AppendText(records.EmailId.ToString());
                            cell.Width = 180;
                            doctable.Rows[i].Cells.Add(cell);
                            cell = new WTableCell(document);
                            cell.AddParagraph().AppendText(records.ModifiedDate.ToString());
                            cell.Width = 125;
                            doctable.Rows[i].Cells.Add(cell);

                            i++;
                        }
                        //Adding table to the section
                        section.Tables.Add(doctable);

                        #region saveOption
                        //Save as .doc Word 97-2003 format
                        if (SaveOption == "Word 97-2003")
                        {
                            return(document.ExportAsActionResult("Sample.doc", FormatType.Doc, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment));
                        }
                        //Save as .docx Word 2007 format
                        else if (SaveOption == "Word 2007")
                        {
                            return(document.ExportAsActionResult("Sample.docx", FormatType.Word2007, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment));
                        }
                        //Save as .docx Word 2010 format
                        else if (SaveOption == "Word 2010")
                        {
                            return(document.ExportAsActionResult("Sample.docx", FormatType.Word2010, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment));
                        }
                        //Save as .docx Word 2013 format
                        else if (SaveOption == "Word 2013")
                        {
                            return(document.ExportAsActionResult("Sample.docx", FormatType.Word2013, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment));
                        }

                        #endregion saveOption
                    }

                    catch (HqlConnectionException)
                    {
                        ErrorMessage = "Could not establish a connection to the HiveServer. Please run HiveServer2 from the Syncfusion service manager dashboard.";
                    }
                }
                return(View());
            }
        }
示例#27
0
 public InsuredPerson(int id, CustomersData customersData)
 {
     this.id       = id;
     this.ageGroup = (int)customersData.ageGroup;
 }
示例#28
0
 public CustomersController()
 {
     Customers = CustomersData.Get();
 }
示例#29
0
        public void CanRegistration()
        {
            CustomersData customer = new CustomersData();

            app.RegisterNewCustomer(customer);
        }