public ActionResult ImportClient()
        {
            if (Session["Login"] != null)
            {
                BAL.Common.DeleteAllFromFolder("~/ExportFileUpload");
                LoginSession loginsession = (LoginSession)Session["Login"];
                BALExportClient model = new BALExportClient();
                ViewBag.Isload = false;

                ViewBag.Curry = new SelectList(BAL.CurrencyModel.CurrencyDropDownList(), "Value", "Text");
                ViewBag.Notif = new SelectList(BAL.NotificationModel.NotificationDropDownList(1), "Value", "Text");
                ViewBag.conType = new SelectList(BAL.ContractModel.ContractDropDownList(), "Value", "Text");
                ViewBag.Department = new SelectList(BAL.DepartmentModels.DepartmentDropDownList(), "Value", "Text");
                ViewBag.STime = new SelectList(BAL.Common.TimeDropDownList(), "Value", "Text");

                return View(model);
            }
            else
            { return RedirectToAction("Index", "Home"); }
        }
        public string Save(string[] stringArray)
        {
            try
            {

                DALExportClient dalExportClient = new DALExportClient();
                BALExportClient model = new BALExportClient();
                string filepath = Convert.ToString(Session["FilePathClient"]);
                model.ItemList = dalExportClient.getExcelColumnName(filepath);
                ViewBag.IsView = true;

                List<string> MatchListOfExcel = new List<string>();

                model.ListtblColumnName = (List<string>)Session["DBColumnNameClient"];

                MatchListOfExcel.Add("NotificationFrequencyId");
                MatchListOfExcel.Add("Notification Frequency");
                MatchListOfExcel.Add("Notification Time");
                MatchListOfExcel.Add("BillingCurrencyId");
                MatchListOfExcel.Add("Billing Currency");
                MatchListOfExcel.Add("ContractTypeId");
                MatchListOfExcel.Add("Contract Type");
                MatchListOfExcel.Add("ClientContactDepartmentId");
                MatchListOfExcel.Add("Client Contact Department");

                foreach (var item in stringArray)
                {
                    MatchListOfExcel.Add(item);
                }

                DataTable dt = dalExportClient.GetExcelTable(filepath, 0);

                model.dtItem = dalExportClient.ExportView(dt, MatchListOfExcel.ToArray(), model.ListtblColumnName.ToArray(), filepath);

                LoginSession loginsession = (LoginSession)Session["Login"];
                dalExportClient.AddCreatedById(model.dtItem, loginsession.ClientID);
                SqlParameterClient sqlParameterClient = new SqlParameterClient();
                sqlParameterClient.ExecuteExportData(model.dtItem);

                return "Import Data Sucessfully.";
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }
        public JsonResult GetList(string[] stringArray)
        {
            ViewBag.IsView = true;
            DALExportClient dalExportClient = new DALExportClient();
            BALExportClient model = new BALExportClient();

            string filepath = Convert.ToString(Session["FilePathClient"]);
            model.ItemList = dalExportClient.getExcelColumnName(filepath);
            List<string> MatchListOfExcel = new List<string>();
            model.ListtblColumnName = (List<string>)Session["DBColumnNameClient"];
            List<tblColumn> list = new List<tblColumn>();

            MatchListOfExcel.Add("NotificationFrequencyId");
            MatchListOfExcel.Add("Notification Frequency");
            MatchListOfExcel.Add("Notification Time");
            MatchListOfExcel.Add("BillingCurrencyId" );
            MatchListOfExcel.Add("Billing Currency");
            MatchListOfExcel.Add("ContractTypeId");
            MatchListOfExcel.Add("Contract Type");
            MatchListOfExcel.Add("ClientContactDepartmentId");
            MatchListOfExcel.Add("Client Contact Department");

            foreach (var item in stringArray)
            {
                MatchListOfExcel.Add(item);
            }
            DataTable dt = dalExportClient.GetExcelTable(filepath, 0);

            model.dtItem = dalExportClient.ExportView(dt, MatchListOfExcel.ToArray(), model.ListtblColumnName.ToArray(), filepath);

            foreach (DataRow row in model.dtItem.Rows)
            {
                tblColumn tblColumnObj = new tblColumn();
                tblColumnObj.col1 = Convert.ToString(row[0]);
                tblColumnObj.col2 = Convert.ToString(row[1]);
                tblColumnObj.col3 = Convert.ToString(row[2]);
                tblColumnObj.col4 = Convert.ToString(row[3]);
                tblColumnObj.col5 = Convert.ToString(row[4]);
                tblColumnObj.col6 = Convert.ToString(row[5]);
                tblColumnObj.col7 = Convert.ToString(row[6]);
                tblColumnObj.col8 = Convert.ToString(row[7]);
                tblColumnObj.col9 = Convert.ToString(row[8]);
                tblColumnObj.col10 = Convert.ToString(row[9]);
                tblColumnObj.col11 = Convert.ToString(row[10]);
                tblColumnObj.col12 = Convert.ToString(row[11]);
                tblColumnObj.col13 = Convert.ToString(row[12]);
                tblColumnObj.col14 = Convert.ToString(row[13]);
                tblColumnObj.col15 = Convert.ToString(row[14]);
                tblColumnObj.col16 = Convert.ToString(row[15]);
                tblColumnObj.col17 = Convert.ToString(row[16]);
                tblColumnObj.col18 = Convert.ToString(row[17]);
                tblColumnObj.col19 = Convert.ToString(row[18]);
                tblColumnObj.col20 = Convert.ToString(row[19]);
                tblColumnObj.col21 = Convert.ToString(row[20]);
                tblColumnObj.col22 = Convert.ToString(row[21]);
                tblColumnObj.col23 = Convert.ToString(row[22]);
                tblColumnObj.col24 = Convert.ToString(row[23]);
                tblColumnObj.col25 = Convert.ToString(row[24]);
                tblColumnObj.col26 = Convert.ToString(row[25]);
                tblColumnObj.col27 = Convert.ToString(row[26]);
                tblColumnObj.col28 = Convert.ToString(row[27]);
                tblColumnObj.col29 = Convert.ToString(row[28]);
                tblColumnObj.col30 = Convert.ToString(row[29]);
                tblColumnObj.col31 = Convert.ToString(row[30]);
                tblColumnObj.col32 = Convert.ToString(row[31]);
                list.Add(tblColumnObj);
            }

            return this.Json(list);
        }
        public ActionResult ImportClient(HttpPostedFileBase file, BALExportClient model, string Command)
        {
            DALExportClient dalExportClient = new DALExportClient();
            ImportClient importClient = new ImportClient();

            try
            {
                if (Command == "Export")
                {
                    if (importClient.ImportExcel(Convert.ToString(model.NotificationFrequencyID), model.NotificationFrequency, model.NotificationTime,
                        Convert.ToString(model.BillingCurrencyID), model.BillingCurrency, Convert.ToString(model.ContractTypeId), model.ContractType,
                        Convert.ToString(model.ClientContactDepartmentId), model.ClientContactDepartment))
                    {

                        string filepath = Path.Combine(Server.MapPath("~/Upload"), "ClientTemplate.xls");
                        var fileName = "ClientTemplate.xls";
                        var mimeType = "application/vnd.ms-excel";
                        return File(new FileStream(filepath, FileMode.Open), mimeType, fileName);
                    }
                    else
                    {
                        ViewBag.Curry = new SelectList(BAL.CurrencyModel.CurrencyDropDownList(), "Value", "Text");
                        ViewBag.Notif = new SelectList(BAL.NotificationModel.NotificationDropDownList(1), "Value", "Text");
                        ViewBag.conType = new SelectList(BAL.ContractModel.ContractDropDownList(), "Value", "Text");
                        ViewBag.Department = new SelectList(BAL.DepartmentModels.DepartmentDropDownList(), "Value", "Text");
                        ViewBag.STime = new SelectList(BAL.Common.TimeDropDownList(), "Value", "Text");
                    }
                }
                else if (Command == "Submit")
                {
                    ViewBag.Isload = true;
                    LoginSession loginsession = (LoginSession)Session["Login"];
                    string extension = Path.GetExtension(file.FileName);
                    fileName = string.Format(@"{0}." + extension, Guid.NewGuid());
                    var path = Path.Combine(Server.MapPath("~/ExportFileUpload"), fileName);
                    file.SaveAs(path);

                    //Get Excel Column
                    model.ItemList = dalExportClient.getExcelColumnName(path);

                    //Get DB Table Column
                    model.ListtblColumnName = dalExportClient.GetTableColumnName("SYCOUS.ClientMaster");

                    Session["DBColumnNameClient"] = model.ListtblColumnName;

                    Session["FilePathClient"] = Path.Combine(Server.MapPath("~/ExportFileUpload"), fileName);

                    ViewBag.Curry = new SelectList(BAL.CurrencyModel.CurrencyDropDownList(), "Value", "Text");
                    ViewBag.Notif = new SelectList(BAL.NotificationModel.NotificationDropDownList(1), "Value", "Text");
                    ViewBag.conType = new SelectList(BAL.ContractModel.ContractDropDownList(), "Value", "Text");
                    ViewBag.Department = new SelectList(BAL.DepartmentModels.DepartmentDropDownList(), "Value", "Text");
                    ViewBag.STime = new SelectList(BAL.Common.TimeDropDownList(), "Value", "Text");

                }

            }
            catch (Exception Ex)
            {
                ViewBag.Isload = false;
                ViewBag.Message = Ex.Message;
                ViewBag.Curry = new SelectList(BAL.CurrencyModel.CurrencyDropDownList(), "Value", "Text");
                ViewBag.Notif = new SelectList(BAL.NotificationModel.NotificationDropDownList(1), "Value", "Text");
                ViewBag.conType = new SelectList(BAL.ContractModel.ContractDropDownList(), "Value", "Text");
                ViewBag.Department = new SelectList(BAL.DepartmentModels.DepartmentDropDownList(), "Value", "Text");
                ViewBag.STime = new SelectList(BAL.Common.TimeDropDownList(), "Value", "Text");
            }

            return View(model);
        }