예제 #1
0
    private void SalesfilesUpload(int RecordCount, string sFileName)
    {
        try
        {
            Int64 Return = 0;

            LeadBatchFile objLeadBatchFile = new LeadBatchFile();
            LeadsBL objLeadsBL = new LeadsBL();

            objLeadBatchFile.Leaddate = System.DateTime.Now.ToString();
            objLeadBatchFile.LeadFile = sFileName;
            objLeadBatchFile.RecordCount = RecordCount.ToString();
            objLeadBatchFile.LeadUploadedBy = (Session[Constants.USER_ID]).ToString();
            objLeadBatchFile.Leadsource = "1";

            DataSet ds = new DataSet();

            ds = objLeadsBL.SaveFileDetails(objLeadBatchFile, ref Return, ddlVehicleType.SelectedItem.Value);

            Session["FileId"] = ds.Tables[0].Rows[0][0].ToString();

        }
        catch (Exception ex)
        {
            //bool rethrow = ExceptionPolicy.HandleException(ex, ConstantClass.StrCRMUIPolicy);
            throw ex;
            //if (rethrow)
            //    throw;

            //Redirecting to error message page
            //Server.Transfer(ConstantClass.StrErrorPageURL);
        }
    }
예제 #2
0
    private void ReadExcelData(string sFileName)
    {
        ArrayList RowNo = new ArrayList();
        ArrayList ColNo = new ArrayList();

        ArrayList SArray = new ArrayList();

        LeadsBL objLeadsBL = new LeadsBL();

        ExcelReading objExcelData = new ExcelReading();

        DataSet ds = new DataSet();
        DataSet dsStatus = new DataSet();

        DataSet dsSales = new DataSet();
        bool bnew = false;
        try
        {

            lblErrorMsg.Text = "";
            ds = objExcelData.GetLeadsExcelToDataset(sFileName);

            DataSet dsError = new DataSet();

            dsError.Tables.Add();
            dsError.Tables["Table1"].Columns.Add("PhoneNo");
            dsError.Tables["Table1"].Columns.Add("RowNo");
            dsError.Tables["Table1"].Columns.Add("Error");

            if (ds.Tables[0].Columns.Contains("PhoneNo") && ds.Tables[0].Columns.Contains("Price") &&
                ds.Tables[0].Columns.Contains("Header") &&
                ds.Tables[0].Columns.Contains("Description") && (ds.Tables[0].Columns.Contains("URL") || ds.Tables[0].Columns.Contains("City")) &&
                ds.Tables[0].Columns.Contains("State") && ds.Tables[0].Columns.Contains("Lead_Date") &&
                ds.Tables[0].Columns.Contains("Make") &&
                    ds.Tables[0].Columns.Contains("Model") &&
                        ds.Tables[0].Columns.Contains("Email") &&
                            ds.Tables[0].Columns.Contains("Year") &&
                                ds.Tables[0].Columns.Contains("VehicleType"))
            {
                int count = objExcelData.GetExcelDistictBTNCOunt_Sales(sFileName);
                ViewState["Count"] = count.ToString();
                if (ds != null)
                {

                    if (ds.Tables[0].Rows.Count > 8000)
                    {
                        lblErrorMsg.Text = "Upload Only 8000 rows Only!";
                        return;
                    }
                    else if (Convert.ToInt32(txtNoofRecords.Text) != Convert.ToInt32(ds.Tables[0].Rows.Count))
                    {
                        lblErrorMsg.Text = "Records Count Does Not Match!";
                        return;
                    }
                    if (ds.Tables[0].Rows.Count == count)
                    {

                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            //return;
                            //RowNo.Add(i);

                            if (ds.Tables[0].Rows[i]["PhoneNo"].ToString().Trim() == ""
                             || ds.Tables[0].Rows[i]["PhoneNo"].ToString().Trim().Length != 10
                             || !GeneralFunc.IsNumeric(ds.Tables[0].Rows[i]["PhoneNo"].ToString().Trim()))
                            {
                                dsError.Tables["Table1"].Rows.Add();
                                dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["PhoneNo"] = ds.Tables[0].Rows[i]["PhoneNo"].ToString().Trim();
                                dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["RowNo"] = (i + 1).ToString();
                                dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["Error"] = "Please enter valid phone number in the excel sheet";

                            }
                            //else if (ds.Tables[0].Rows[i]["PhoneNo"].ToString().Trim().Length != 10)
                            //{
                            //    dsError.Tables["Table1"].Rows.Add();
                            //    dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["PhoneNo"] = ds.Tables[0].Rows[i]["PhoneNo"].ToString().Trim();
                            //    dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["RowNo"] = (i + 1).ToString();
                            //    dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["Error"] = "Please enter valid phone number in the excel sheet";

                            //}
                            //else if (!GeneralFunc.IsNumeric(ds.Tables[0].Rows[i]["PhoneNo"].ToString().Trim()))
                            //{
                            //    dsError.Tables["Table1"].Rows.Add();
                            //    dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["PhoneNo"] = ds.Tables[0].Rows[i]["PhoneNo"].ToString().Trim();
                            //    dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["RowNo"] = (i + 1).ToString();
                            //    dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["Error"] = "Please enter valid phone number in the excel sheet";
                            //}
                            else if (CheckBTN(ds.Tables[0].Rows[i]["PhoneNo"].ToString().Trim()))
                            {
                                dsError.Tables["Table1"].Rows.Add();
                                dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["PhoneNo"] = ds.Tables[0].Rows[i]["PhoneNo"].ToString().Trim();
                                dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["RowNo"] = (i + 1).ToString();
                                dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["Error"] = "Phone number already exists in database.";

                            }
                            else
                            {
                                if (ds.Tables[0].Rows[i]["STATE"].ToString().Trim() == ""
                                 || ds.Tables[0].Rows[i]["STATE"].ToString().Trim().Length != 2
                                 || ds.Tables[0].Rows[i]["STATE"].ToString().Trim() == null)
                                {
                                    dsError.Tables["Table1"].Rows.Add();
                                    dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["PhoneNo"] = ds.Tables[0].Rows[i]["PhoneNo"].ToString().Trim();
                                    dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["RowNo"] = (i + 1).ToString();
                                    dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["Error"] = "Please enter the state code in the excel sheet";

                                }
                                //else if (ds.Tables[0].Rows[i]["STATE"].ToString().Trim().Length != 2)
                                //{
                                //    dsError.Tables["Table1"].Rows.Add();
                                //    dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["Phoneno"] = ds.Tables[0].Rows[i]["Phoneno"].ToString().Trim();
                                //    dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["RowNo"] = (i + 1).ToString();
                                //    dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["Error"] = "Please enter the proper state code in the excel Sheet";
                                //}
                                //if (ds.Tables[0].Rows[i]["STATE"].ToString().Trim() == null)
                                //{
                                //    dsError.Tables["Table1"].Rows.Add();
                                //    dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["PhoneNo"] = ds.Tables[0].Rows[i]["PhoneNo"].ToString().Trim();
                                //    dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["RowNo"] = (i + 1).ToString();
                                //    dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["Error"] = "Error in record state code is not valid..";

                                //}

                                else if (ds.Tables[0].Rows[i]["STATE"].ToString().Trim().Length == 2)
                                {
                                    string Stateid = GetStateId(ds.Tables[0].Rows[i]["STATE"].ToString().Trim().ToUpper());
                                    if (Stateid == "0")
                                    {
                                        btnUpload.Text = "Upload";
                                        dsError.Tables["Table1"].Rows.Add();
                                        dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["PhoneNo"] = ds.Tables[0].Rows[i]["PhoneNo"].ToString().Trim();
                                        dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["RowNo"] = (i + 1).ToString();
                                        dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["Error"] = "Please check the record in the sheet, state is invalid.";

                                        ColNo.Add(12);
                                    }
                                }
                                //if (ds.Tables[0].Rows[i]["Price"].ToString().Trim().Length < 0)
                                //{
                                //    dsError.Tables["Table1"].Rows.Add();
                                //    dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["PhoneNo"] = ds.Tables[0].Rows[i]["PhoneNo"].ToString().Trim();
                                //    dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["RowNo"] = (i + 1).ToString();
                                //    dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["Error"] = "Please enter price in the excel sheet";

                                //}
                                if (ds.Tables[0].Rows[i]["Price"].ToString().Trim() != "")
                                {
                                    if (!GeneralFunc.IsNumeric(ds.Tables[0].Rows[i]["Price"].ToString().Trim()))
                                    {
                                        dsError.Tables["Table1"].Rows.Add();
                                        dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["PhoneNo"] = ds.Tables[0].Rows[i]["PhoneNo"].ToString().Trim();
                                        dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["RowNo"] = (i + 1).ToString();
                                        dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["Error"] = "Please enter numeric price in the excel sheet";
                                    }
                                }

                                if (ds.Tables[0].Rows[i]["Lead_Date"].ToString().Trim() == "")
                                {
                                    dsError.Tables["Table1"].Rows.Add();
                                    dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["PhoneNo"] = ds.Tables[0].Rows[i]["PhoneNo"].ToString().Trim();
                                    dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["RowNo"] = (i + 1).ToString();
                                    dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["Error"] = "Please enter lead date in the excel sheet";

                                }
                                else if (!GeneralFunc.ValidateDate(ds.Tables[0].Rows[i]["Lead_Date"].ToString().Trim()))
                                {
                                    dsError.Tables["Table1"].Rows.Add();
                                    dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["PhoneNo"] = ds.Tables[0].Rows[i]["PhoneNo"].ToString().Trim();
                                    dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["RowNo"] = (i + 1).ToString();
                                    dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["Error"] = "Please enter valid lead date in the excel sheet";
                                }
                                else
                                {
                                    DataSet dsDatetime = objHotLeadBL.GetDatetime();
                                    DateTime dtNow = Convert.ToDateTime(dsDatetime.Tables[0].Rows[0]["Datetime"].ToString());
                                    if (Convert.ToDateTime(ds.Tables[0].Rows[i]["Lead_Date"].ToString().Trim()) > dtNow)
                                    {
                                        dsError.Tables["Table1"].Rows.Add();
                                        dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["PhoneNo"] = ds.Tables[0].Rows[i]["PhoneNo"].ToString().Trim();
                                        dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["RowNo"] = (i + 1).ToString();
                                        dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["Error"] = "Lead date cannot be greater than today date";
                                    }

                                }
                                if (ds.Tables[0].Rows[i]["Email"].ToString().Trim() != "")
                                {
                                    if (!GeneralFunc.isEmail(ds.Tables[0].Rows[i]["Email"].ToString().Trim()))
                                    {
                                        dsError.Tables["Table1"].Rows.Add();
                                        dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["PhoneNo"] = ds.Tables[0].Rows[i]["PhoneNo"].ToString().Trim();
                                        dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["RowNo"] = (i + 1).ToString();
                                        dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["Error"] = "Please enter valid email in the excel sheet";

                                    }
                                }
                                if (ds.Tables[0].Rows[i]["Year"].ToString().Trim() != "")
                                {
                                    if (!GeneralFunc.IsNumeric(ds.Tables[0].Rows[i]["Year"].ToString().Trim()))
                                    {
                                        dsError.Tables["Table1"].Rows.Add();
                                        dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["PhoneNo"] = ds.Tables[0].Rows[i]["PhoneNo"].ToString().Trim();
                                        dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["RowNo"] = (i + 1).ToString();
                                        dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["Error"] = "Please enter valid year in the excel sheet";

                                    }
                                    else if (ds.Tables[0].Rows[i]["Year"].ToString().Trim().Length != 4)
                                    {
                                        dsError.Tables["Table1"].Rows.Add();
                                        dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["PhoneNo"] = ds.Tables[0].Rows[i]["PhoneNo"].ToString().Trim();
                                        dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["RowNo"] = (i + 1).ToString();
                                        dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["Error"] = "Please enter valid year in the excel sheet";
                                    }
                                    else
                                    {
                                        DataSet dsDatetime = objHotLeadBL.GetDatetime();
                                        DateTime dtNow = Convert.ToDateTime(dsDatetime.Tables[0].Rows[0]["Datetime"].ToString());
                                        DateTime EnterDate = Convert.ToDateTime("1/1/" + ds.Tables[0].Rows[i]["Year"].ToString().Trim());
                                        if (EnterDate > dtNow)
                                        {
                                            dsError.Tables["Table1"].Rows.Add();
                                            dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["PhoneNo"] = ds.Tables[0].Rows[i]["PhoneNo"].ToString().Trim();
                                            dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["RowNo"] = (i + 1).ToString();
                                            dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["Error"] = "Please enter valid year in the excel sheet";
                                        }
                                    }
                                }
                            }
                            VehicleTypeBL objVehicleTypeBL = new VehicleTypeBL();

                            DataSet dsVehicleTypes = new DataSet();

                            if (Cache["VehicleType"] == null)
                            {
                                dsVehicleTypes = objVehicleTypeBL.GetVehicleType();
                                Cache["VehicleType"] = dsVehicleTypes;
                            }
                            else
                            {
                                dsVehicleTypes = (DataSet)Cache["VehicleType"];
                            }
                            int cint = 0;

                            foreach (DataRow row in dsVehicleTypes.Tables[0].Rows) // Loop over the rows.
                            {
                                if (row.ItemArray[0].ToString().ToLower() == ds.Tables[0].Rows[i]["VehicleType"].ToString().Trim().ToLower())
                                {
                                    cint = cint + 1;
                                    break;
                                }
                            }
                            if (cint == 0)
                            {
                                dsError.Tables["Table1"].Rows.Add();
                                dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["PhoneNo"] = ds.Tables[0].Rows[i]["PhoneNo"].ToString().Trim();
                                dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["RowNo"] = (i + 1).ToString();
                                dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["Error"] = "Please Enter Proper Vehicle Type";
                            }
                            cint = 0;
                            LeadSourceBL objLeadSourceBL = new LeadSourceBL();
                            DataSet dsLeadSource = new DataSet();
                            if (Cache["LeadSource"] == null)
                            {
                                dsLeadSource = objLeadSourceBL.GetLeadSources();
                                Cache["LeadSource"] = dsVehicleTypes;
                            }
                            else
                            {
                                dsLeadSource = (DataSet)Cache["LeadSource"];
                            }
                            foreach (DataRow row in dsLeadSource.Tables[0].Rows) // Loop over the rows.
                            {
                                if (row.ItemArray[0].ToString().ToLower() == ds.Tables[0].Rows[i]["LeadSourceID"].ToString().Trim().ToLower())
                                {
                                    cint = cint + 1;
                                    break;
                                }
                            }
                            if (cint == 0)
                            {
                                dsError.Tables["Table1"].Rows.Add();
                                dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["PhoneNo"] = ds.Tables[0].Rows[i]["PhoneNo"].ToString().Trim();
                                dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["RowNo"] = (i + 1).ToString();
                                dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["Error"] = "Please Enter Proper Lead Source ID";
                            }
                        }

                        if (dsError.Tables["Table1"].Rows.Count > 0)
                        {
                            grdIntroInfo.DataSource = null;
                            grdIntroInfo.DataBind();
                            grdErrors.DataSource = dsError.Tables["Table1"].DefaultView;
                            grdErrors.DataBind();
                            Header.Visible = false;

                        }
                        else
                        {
                            grdErrors.DataSource = null;
                            grdErrors.DataBind();
                            Header.Visible = true;
                            grdIntroInfo.DataSource = ds.Tables["XLData"].DefaultView;
                            grdIntroInfo.DataBind();
                            btnSubmit.Enabled = false; ;
                            btnUpload.Enabled = true;
                        }
                    }
                    else
                    {
                        for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                        {
                            int phoneCount = 0;
                            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                            {
                                if (ds.Tables[0].Rows[j]["PhoneNo"].ToString() == ds.Tables[0].Rows[i]["PhoneNo"].ToString())
                                {

                                    phoneCount = phoneCount + 1;
                                    if (phoneCount > 1)
                                    {
                                        dsError.Tables["Table1"].Rows.Add();
                                        dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["PhoneNo"] = ds.Tables[0].Rows[i]["PhoneNo"].ToString().Trim();
                                        dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["RowNo"] = (j + 1).ToString();
                                        dsError.Tables["Table1"].Rows[dsError.Tables["Table1"].Rows.Count - 1]["Error"] = "Exist Duplicates PhoneNo In Excel Sheet Plz Check Excel Sheet";
                                    }
                                    ColNo.Add(8);

                                }
                            }
                        }

                        if (dsError.Tables["Table1"].Rows.Count > 0)
                        {
                            grdIntroInfo.DataSource = null;
                            grdIntroInfo.DataBind();
                            grdErrors.DataSource = dsError.Tables["Table1"].DefaultView;
                            grdErrors.DataBind();
                            Header.Visible = false;

                        }
                    }
                }
            }

            else
            {
                btnUpload.Text = "Upload";
                lblErrorMsg.Text = "Enter Valid Sales Excel Sheet Proper Columns.";
                btnSubmit.Enabled = true;
            }
        }
        catch (Exception ex)
        {
            if (ex.Message.ToString() == "Not a legal OleAut date.")
            {
                Header.Visible = false;
                lblErrorMsg.Text = "Enter valid date format in excel sheet";
            }
            else
            {
                throw ex;
            }

        }
    }
예제 #3
0
    private bool CheckBTN(string BTN)
    {
        try
        {
            bool bFalse = false;
            LeadsBL ObjLeads = new LeadsBL();
            DataSet dsLeads = new DataSet();

            if (Session["LeadBTNs"] == null)
            {
                dsLeads = ObjLeads.LeadsCheckBTN();
                Session["LeadBTNs"] = dsLeads;
            }
            else
            {
                dsLeads = (DataSet)Session["LeadBTNs"];
            }

            DataView dv = new DataView();
            DataTable dt = new DataTable();
            dv = dsLeads.Tables[0].DefaultView;
            dv.RowFilter = "Phone=" + BTN + "";
            dt = dv.ToTable();

            if (dt.Rows.Count > 0)
            {
                bFalse = true;
            }
            return bFalse;
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
예제 #4
0
    private Int64 LeadsUploadExcel(int rowNo, ref DbTransaction Transaction, ref DbConnection Connection)
    {
        Int64 refOut = 0;

        bool bfirst = true;

        DataSet ds = new DataSet();
        LeadsInfo objLeadsInfo = new LeadsInfo();
        LeadsBL objleadBL = new LeadsBL();
        DataSet dsCampaigns = new DataSet();
        DataView dv = new DataView();
        DataTable dt = new DataTable();
        try
        {
            if (grdIntroInfo.Rows.Count > 0)
            {
                #region SalesTable

                objLeadsInfo.Phone = GenFunc.ExcelTextFormat(((Label)grdIntroInfo.Rows[rowNo].FindControl("lblPhoneno")).Text).ToString();
                objLeadsInfo.Header = GenFunc.ExcelTextFormat(((Label)grdIntroInfo.Rows[rowNo].FindControl("lblHeader")).Text).ToString();
                objLeadsInfo.Price = GenFunc.ExcelTextFormat(((Label)grdIntroInfo.Rows[rowNo].FindControl("lblPrice")).Text).ToString();
                objLeadsInfo.State = GenFunc.ExcelTextFormat(((Label)grdIntroInfo.Rows[rowNo].FindControl("lblState")).Text).ToString(); ;
                objLeadsInfo.City = GenFunc.ExcelTextFormat(((Label)grdIntroInfo.Rows[rowNo].FindControl("lblCity")).Text).ToString();
                //objLeadsInfo.Zip = GenFunc.ExcelTextFormat(((Label)grdIntroInfo.Rows[rowNo].FindControl("lblSaleBY")).Text).ToString();
                objLeadsInfo.URL = GenFunc.ExcelTextFormat(((HyperLink)grdIntroInfo.Rows[rowNo].FindControl("lblURL")).Text).ToString();
                objLeadsInfo.VehicleTypeID = ddlVehicleType.SelectedItem.Value;
                objLeadsInfo.LeadUpBatchID = Session["FileId"].ToString();

                //objLeadsInfo.se
                //objLeadsInfo.yhe = GenFunc.ExcelTextFormat(((Label)grdIntroInfo.Rows[rowNo].FindControl("lblSaleBY")).Text).ToString();

                //objLeadsInfo .Sales_Notes = GenFunc.ExcelTextFormat(((Label)grdIntroInfo.Rows[rowNo].FindControl("hdnSALESNOTES")).Text.ToString());

                #endregion ContactTable

                //Excel File Opening Transaction
                if (rowNo == 0)
                {
                    bfirst = true;
                }
                if (rowNo > 0)
                {
                    if (grdIntroInfo.Rows.Count - 1 == rowNo)
                    {
                        bfirst = false;
                    }
                }
                //bool bnew = CheckBTN(GenFunc.ExcelTextFormat(((Label)grdIntroInfo.Rows[rowNo].FindControl("lblPhoneno")).Text).ToString());
                //if (bnew == false)
                //{
                Count = Count + 1;
                objleadBL.SaveLeadsInfo(objLeadsInfo, bfirst, rowNo, grdIntroInfo.Rows.Count - 1, ref Transaction, ref Connection);
                Transaction = Transaction;
                Connection = Connection;
                //}

            }
        }
        catch (Exception ex)
        {
            Transaction.Rollback();
            Connection.Close();

            //bool rethrow = ExceptionPolicy.HandleException(ex, ConstantClass.StrCRMUIPolicy);

            //if (rethrow)
            //    throw;

            //Redirecting to error message page
            //Server.Transfer(ConstantClass.StrErrorPageURL);
        }
        return refOut;
    }
예제 #5
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        LeadsBL ObjLeads = new LeadsBL();
        DataSet dsLeads = new DataSet();

        dsLeads = ObjLeads.LeadsCheckBTN();
        Session["LeadBTNs"] = dsLeads;

        string FILENAME = string.Empty;
        string OpenPath = string.Empty;
        string SaveLoc = string.Empty;
        string FileExt = string.Empty;
        string hp = string.Empty;
        string sLoc = string.Empty;

        ArrayList RowNo = new ArrayList();
        ArrayList ColNo = new ArrayList();

        ArrayList SArray = new ArrayList();

        FilesBL objFilesBL = new FilesBL();

        IDataReader IdataReader = null;

        if (Page.IsValid)
        {
            try
            {
                FileExt = System.IO.Path.GetExtension(fuAttachments.PostedFile.FileName);
                //Get The Ext of File
                //FileName = Server.MapPath(".") + fuAttachments.PostedFile.FileName;

                if (FileExt != ".xls")
                {
                    if (FileExt != ".xlsx")
                    {
                        lblErrorMsg.Text = "You have Selected a Wrong File.Kindly Select Excel File";
                        //grdErrors.DataSource = null;
                        //grdErrors.DataBind();

                        return;
                    }
                }
                if (fuAttachments.HasFile)
                {
                    OpenPath = fuAttachments.PostedFile.FileName;

                    FILENAME = OpenPath;
                    if (FILENAME.Contains("\\"))
                    {
                        string[] strFile = FILENAME.Split('\\');
                        int max = strFile.Length - 1;
                        FILENAME = strFile[max].ToString();
                    }

                    ViewState["FileName"] = FILENAME;

                    SaveLoc = Server.MapPath("LeadsUpload\\");

                    if (System.IO.Directory.Exists(SaveLoc) == false)
                    {
                        // Try to create the directory.
                        System.IO.DirectoryInfo di = System.IO.Directory.CreateDirectory(SaveLoc);

                    }
                    SaveLoc = Server.MapPath("LeadsUpload\\" + FILENAME);

                    fuAttachments.PostedFile.SaveAs(SaveLoc);

                    Session["SaveLocation"] = SaveLoc;

                    Session["FileName"] = FILENAME;

                    IdataReader = objFilesBL.Get_FileByFileName(FILENAME);

                    while (IdataReader.Read())
                    {
                        lblErrorMsg.Text = "Leads File Already Exists. Please Upload a new file";

                        btnUpload.Text = "Upload";

                        return;
                    }

                    ReadExcelData(SaveLoc);

                }
                else
                {
                    btnSubmit.Text = "Process";
                    btnSubmit.Enabled = true;
                    btnUpload.Enabled = false;

                }
            }
            catch (Exception ex)
            {
                throw ex;
                //bool rethrow = ExceptionPolicy.HandleException(ex, ConstantClass.StrCRMUIPolicy);
                //if (rethrow)
                //    throw;
                //Redirecting to error message page
                //Response.Redirect(ConstantClass.StrErrorPageURL);
            }
        }
        divresults.Visible = true;
    }