public JsonResult GetList(string[] stringArray)
        {
            ViewBag.IsView = true;
            DALExportProperty dalExportProperty = new DALExportProperty();
            BALExportProperty model = new BALExportProperty();
            string filepath = Convert.ToString(Session["FilePath"]);
            model.ItemList = dalExportProperty.getExcelColumnName(filepath);
            List<string> MatchListOfExcel = new List<string>();
            model.ListtblColumnName = (List<string>)Session["DBColumnName"];
            List<tblColumn> list = new List<tblColumn>();

            MatchListOfExcel.Add("ClientId");
            MatchListOfExcel.Add("Client");
            MatchListOfExcel.Add("NetworkId");
            MatchListOfExcel.Add("Network");
            MatchListOfExcel.Add("PropertyBandId");
            MatchListOfExcel.Add("Property Band");

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

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

            model.dtItem = dalExportProperty.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]);

                list.Add(tblColumnObj);
            }

            return this.Json(list);
        }
        public string Save(string[] stringArray)
        {
            try
            {
                int i = 0;
                DALExportProperty dalExportProperty = new DALExportProperty();
                BALExportProperty model = new BALExportProperty();
                string filepath = Convert.ToString(Session["FilePath"]);
                model.ItemList = dalExportProperty.getExcelColumnName(filepath);
                ViewBag.IsView = true;

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

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

                MatchListOfExcel.Add("ClientId");
                MatchListOfExcel.Add("Client");
                MatchListOfExcel.Add("NetworkId");
                MatchListOfExcel.Add("Network");
                MatchListOfExcel.Add("PropertyBandId");
                MatchListOfExcel.Add("Property Band");

                foreach (var item in stringArray)
                {
                    MatchListOfExcel.Add(item);
                    i++;
                    if (i == 6)
                    {
                        break;
                    }
                }

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

                if (!dt.Columns.Contains("ClientId") || !dt.Columns.Contains("Client") || !dt.Columns.Contains("NetworkId")
                 && !dt.Columns.Contains("Network") || !dt.Columns.Contains("PropertyBandId") || !dt.Columns.Contains("Property Band"))
                {
                    dalExportProperty.AddTemplateValue(dt, stringArray);
                }

                model.dtItem = dalExportProperty.ExportView(dt, MatchListOfExcel.ToArray(), model.ListtblColumnName.ToArray(), filepath);
                LoginSession loginsession = (LoginSession)Session["Login"];
                dalExportProperty.AddCreatedById(model.dtItem, loginsession.ClientID);
                SqlParameterProperty sqlParameterProperty = new SqlParameterProperty();
                sqlParameterProperty.ExecuteExportData(model.dtItem);

                return "Import Data Sucessfully.";
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }
        public ActionResult ImportProperty(HttpPostedFileBase file, BALExportProperty model, string Command)
        {
            DALExportProperty dalExportProperty = new DALExportProperty();
            ImportProperty importProperty = new ImportProperty();
            LoginSession loginsession = (LoginSession)Session["Login"];

            try
            {
                if (Command == "Export")
                {
                    if (importProperty.ImportExcel(Convert.ToString(model.PropertyBrandId)))
                    {
                        string filepath = Path.Combine(Server.MapPath("~/Upload"), "PropertyTemplate.xlsx");
                        var fileName = "PropertyTemplate.xlsx";
                        var mimeType = "application/vnd.ms-excel";
                        return File(new FileStream(filepath, FileMode.Open), mimeType, fileName);
                    }
                    else
                    {
                        if (loginsession.ClientID != null)
                        {
                            ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(loginsession.ClientID), "Value", "Text");
                        }
                        else
                        {
                            ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(), "Value", "Text");
                        }
                    }
                }
                else if (Command == "Submit")
                {
                    model.Istemplate = false;
                    ViewBag.Isload = true;
                    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 = dalExportProperty.getExcelColumnName(path);

                    model.Istemplate=dalExportProperty.IsTemplateUsed(model.ItemList);

                    //Get DB Table Column
                    model.ListtblColumnName = dalExportProperty.GetTableColumnName();

                    Session["DBColumnName"] = model.ListtblColumnName;

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

                    if (loginsession.ClientID != null)
                    {
                        ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(loginsession.ClientID), "Value", "Text");
                    }
                    else
                    {
                        ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(), "Value", "Text");
                    }

                    //---------------------------------------------------------

                }
            }

            catch (Exception Ex)
            {
                ViewBag.Isload = false;

                if (loginsession.ClientID != null)
                {
                    ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(loginsession.ClientID), "Value", "Text");
                }
                else
                {
                    ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(), "Value", "Text");
                }

                ViewBag.Message = Ex.Message;
            }

            return View(model);
        }