public static string BtoE(String B, String E, Int64 F, String DD, String MM, String YYYY)
    {
        string A = "";

        A = B + E;
        String C = CompKeyIns.C1toC5GetC(A, F, DD, MM, YYYY);

        return(C);
    }
    public static Boolean BtnABCKeyAtLicenseServer(string CompanyLoginId, string ServerId)
    {
        Boolean Status = true;
        Int64   X      = 0;
        Int64   Y      = 0;
        Int64   Z      = 0;

        Int64 C1 = 0;
        Int64 C2 = 0;
        Int64 C3 = 0;
        Int64 C4 = 0;
        Int64 C5 = 0;

        DataTable dt_getCompanyABCMaster = MyCommonfile.selectBZ(" Select * From CompanyABCMaster where CompanyLoginId='" + CompanyLoginId + "' ");

        if (dt_getCompanyABCMaster.Rows.Count > 0)
        {
            Boolean Del_CABCD        = CompKeyIns.Delete_CompanyABCDetail(CompanyLoginId);
            Boolean Del_CABCD_Server = CompKeyIns.Delete_CompanyABCDetail_Server(CompanyLoginId);
            if (Del_CABCD_Server == true && Del_CABCD_Server == true)
            {
                string txt_c = dt_getCompanyABCMaster.Rows[0]["C"].ToString();

                string txt_c1 = dt_getCompanyABCMaster.Rows[0]["C1"].ToString();
                string txt_c2 = dt_getCompanyABCMaster.Rows[0]["C2"].ToString();
                string txt_c3 = dt_getCompanyABCMaster.Rows[0]["C3"].ToString();
                string txt_c4 = dt_getCompanyABCMaster.Rows[0]["C4"].ToString();
                string txt_c5 = dt_getCompanyABCMaster.Rows[0]["C5"].ToString();

                C1 = Convert.ToInt64(txt_c1.Substring(0, 4));
                C2 = Convert.ToInt64(txt_c2.Substring(0, 4));
                C3 = Convert.ToInt64(txt_c3.Substring(0, 4));
                C4 = Convert.ToInt64(txt_c4.Substring(0, 4));
                C5 = Convert.ToInt64(txt_c5.Substring(0, 4));

                DateTime todaydatefull = DateTime.Now;
                todaydatefull = todaydatefull.AddDays(-1);
                string    strdt       = todaydatefull.ToString("MM-dd-yyyy");
                DataTable dtfunction  = MyCommonfile.selectBZ(" Select * From FunctionMaster ");
                DateTime  startDate   = DateTime.Parse(strdt);
                DateTime  expiryDate  = startDate.AddDays(2);
                int       DayInterval = 1;
                while (startDate <= expiryDate && Status == true)
                {
                    Random random         = new Random();
                    int    randomNumberA1 = random.Next(1, 6);
                    int    randomNumberA2 = random.Next(1, 6);
                    int    randomNumberA3 = random.Next(1, 6);
                    int    randomNumberA4 = random.Next(1, 6);
                    int    randomNumberA5 = random.Next(1, 6);

                    Int64 F1 = Convert.ToInt64(randomNumberA1);
                    Int64 F2 = Convert.ToInt64(randomNumberA2);
                    Int64 F3 = Convert.ToInt64(randomNumberA3);
                    Int64 F4 = Convert.ToInt64(randomNumberA4);
                    Int64 F5 = Convert.ToInt64(randomNumberA5);

                    DateTime datevalue = (Convert.ToDateTime(startDate.ToString("MM-dd-yyyy")));
                    string   DD        = datevalue.Day.ToString();
                    string   MM        = datevalue.Month.ToString();
                    string   YYYY      = datevalue.Year.ToString();
                    string   ZDate     = DD + "" + MM + "" + YYYY;

                    X = Convert.ToInt64(DD);
                    Y = Convert.ToInt64(MM);
                    Z = Convert.ToInt64(YYYY);

                    string dateid = DD + "" + MM + "" + YYYY;

                    String A1 = CompKeyIns.C1toC5GetA(C1, F1, DD, MM, YYYY);
                    String A2 = CompKeyIns.C1toC5GetA(C2, F2, DD, MM, YYYY);
                    String A3 = CompKeyIns.C1toC5GetA(C3, F3, DD, MM, YYYY);
                    String A4 = CompKeyIns.C1toC5GetA(C4, F4, DD, MM, YYYY);
                    String A5 = CompKeyIns.C1toC5GetA(C5, F5, DD, MM, YYYY);

                    string D1 = A1.Substring(0, 1);
                    string E1 = A1.Substring(1, A1.Length - 1);

                    string D2 = A2.Substring(0, 1);
                    string E2 = A2.Substring(1, A2.Length - 1);

                    string D3 = A3.Substring(0, 1);
                    string E3 = A3.Substring(1, A3.Length - 1);

                    string D4 = A4.Substring(0, 1);
                    string E4 = A4.Substring(1, A4.Length - 1);

                    string D5 = A5.Substring(0, 1);
                    string E5 = A5.Substring(1, A5.Length - 1);

                    //---------------------------------
                    //if (C1 != Convert.ToInt64(txt_c1.Substring(0, 4)))
                    //{
                    //}
                    string txt_ansc = "";
                    //----------------------------------------------------------------------------------------------------------------
                    Boolean Insert_CABCD_License = CompKeyIns.Insert_CompanyABCDetail(CompanyLoginId, ZDate, A1, A2, A3, A4, A5, D1, D2, D3, D4, D5, E1, E2, E3, E4, E5, Convert.ToString(F1), Convert.ToString(F2), Convert.ToString(F3), Convert.ToString(F4), Convert.ToString(F5), Convert.ToString(C1), Convert.ToString(C2), Convert.ToString(C3), Convert.ToString(C4), Convert.ToString(C5), txt_ansc, ServerId);
                    if (Insert_CABCD_License == true)
                    {
                        Boolean Insert_CABCD_Server = CompKeyIns.Insert_CompanyABCDetail_SERVER(CompanyLoginId, ZDate, D1, D2, D3, D4, D5, E1, E2, E3, E4, E5, Convert.ToString(F1), Convert.ToString(F2), Convert.ToString(F3), Convert.ToString(F4), Convert.ToString(F5));
                        if (Insert_CABCD_Server == true)
                        {
                            Status = false;
                        }
                    }
                    startDate = startDate.AddDays(DayInterval);
                }
            }
            else
            {
                Status = false;
            }
        }
        else
        {
            Status = false;
        }
        return(Status);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        string ss      = BZ_Common.BZ_Decrypted("d2fu/WL5XmM=");
        string ssdd    = BZ_Common.BZ_Decrypted("member");
        string ssddfdf = BZ_Common.BZ_Encrypted("member");

        //ABC Key Insert At Server DB
        if (Request.QueryString["comid"] != null && Request.QueryString["ABCenckey"] != null && Request.QueryString["returl"] != null)
        {
            //string hh = BZ_Common.BZ_Decrypted(Request.QueryString["comid"].ToString().Replace(" ", "+"));
            string companyid = BZ_Common.BZ_Decrypted(Request.QueryString["comid"].ToString().Replace(" ", "+"));

            DataTable DtServid = MyCommonfile.selectBZ(" Select ServerMasterTbl.Busiwizsatellitesiteurl,CompanyMaster.CompanyLoginId,ServerMasterTbl.Id FROM dbo.ServerMasterTbl INNER JOIN dbo.CompanyMaster ON dbo.ServerMasterTbl.Id = dbo.CompanyMaster.ServerId Where CompanyMaster.CompanyLoginId='" + companyid + "' ");
            if (DtServid.Rows.Count > 0)
            {
                string  Busiwizsatellitesiteurl = DtServid.Rows[0]["Busiwizsatellitesiteurl"].ToString();
                string  ServerId            = DtServid.Rows[0]["Id"].ToString();
                Boolean Comp__Actve__Status = CompanyWizard.Company_Active_Status(companyid);
                Boolean Comp__Licen__Active = CompanyWizard.Company_LicenseExpire_Status(companyid);
                Boolean Server__Active      = ServerWizard.Server_Active_Status(companyid);
                if (Comp__Actve__Status == true && Comp__Licen__Active == true && Server__Active == true)
                {
                    Boolean Insert_Today_Key = CompKeyIns.BtnABCKey(companyid, ServerId);
                    if (Insert_Today_Key == true)
                    {
                        string Z  = "";
                        string D1 = "";
                        string D2 = "";
                        string D3 = "";
                        string D4 = "";
                        string D5 = "";

                        string E1 = "";
                        string E2 = "";
                        string E3 = "";
                        string E4 = "";
                        string E5 = "";

                        string    F1 = "";
                        string    F2 = "";
                        string    F3 = "";
                        string    F4 = "";
                        string    F5 = "";
                        DataTable Dt = MyCommonfile.selectBZ(" Select TOP(15)* From CompanyABCDetail Where CompanyLoginId='" + companyid + "' Order By Id Desc ");
                        foreach (DataRow drmaxdb in Dt.Rows)
                        {
                            Z += drmaxdb["Z"].ToString() + ",";

                            D1 += drmaxdb["D1"].ToString() + ",";
                            D2 += drmaxdb["D2"].ToString() + ",";
                            D3 += drmaxdb["D3"].ToString() + ",";
                            D4 += drmaxdb["D4"].ToString() + ",";
                            D5 += drmaxdb["D5"].ToString() + ",";

                            E1 += drmaxdb["E1"].ToString() + ",";
                            E2 += drmaxdb["E2"].ToString() + ",";
                            E3 += drmaxdb["E3"].ToString() + ",";
                            E4 += drmaxdb["E4"].ToString() + ",";
                            E5 += drmaxdb["E5"].ToString() + ",";

                            F1 += drmaxdb["F1"].ToString() + ",";
                            F2 += drmaxdb["F2"].ToString() + ",";
                            F3 += drmaxdb["F3"].ToString() + ",";
                            F4 += drmaxdb["F4"].ToString() + ",";
                            F5 += drmaxdb["F5"].ToString() + ",";
                        }
                        if (Dt.Rows.Count > 0)
                        {
                            Z = Z.Remove(Z.Length - 1);

                            D1 = D1.Remove(D1.Length - 1);
                            D2 = D2.Remove(D2.Length - 1);
                            D3 = D3.Remove(D3.Length - 1);
                            D4 = D4.Remove(D4.Length - 1);
                            D5 = D5.Remove(D5.Length - 1);

                            E1 = E1.Remove(E1.Length - 1);
                            E2 = E2.Remove(E2.Length - 1);
                            E3 = E3.Remove(E3.Length - 1);
                            E4 = E4.Remove(E4.Length - 1);
                            E5 = E5.Remove(E5.Length - 1);

                            F1 = F1.Remove(F1.Length - 1);
                            F2 = F2.Remove(F2.Length - 1);
                            F3 = F3.Remove(F3.Length - 1);
                            F4 = F4.Remove(F4.Length - 1);
                            F5 = F5.Remove(F5.Length - 1);

                            //Response.Redirect("http://" + Busiwizsatellitesiteurl + "/Satelliteservfunction.aspx?Compid=" + BZ_Common.BZ_Encrypted(companyid) + "&E1=" + BZ_Common.BZ_Encrypted(E1) + "&E2=" + BZ_Common.BZ_Encrypted(E2) + "&E3=" + BZ_Common.BZ_Encrypted(E3) + "&E4=" + BZ_Common.BZ_Encrypted(E4) + "&E5=" + BZ_Common.BZ_Encrypted(E5) + "&D1=" + BZ_Common.BZ_Encrypted(D1) + "&D2=" + BZ_Common.BZ_Encrypted(D2) + "&D3=" + BZ_Common.BZ_Encrypted(D3) + "&D4=" + BZ_Common.BZ_Encrypted(D4) + "&D5=" + BZ_Common.BZ_Encrypted(D5) + "&Z=" + BZ_Common.BZ_Encrypted(Z) + "&F1=" + BZ_Common.BZ_Encrypted(F1) + "&F2=" + BZ_Common.BZ_Encrypted(F2) + "&F3=" + BZ_Common.BZ_Encrypted(F3) + "&F4=" + BZ_Common.BZ_Encrypted(F4) + "&F5=" + BZ_Common.BZ_Encrypted(F5) + "");
                            Response.Redirect("http://" + Busiwizsatellitesiteurl + "/Satelliteservfunction.aspx?Compid=" + BZ_Common.BZ_Encrypted(companyid) + "&E1=" + E1 + "&E2=" + E2 + "&E3=" + E3 + "&E4=" + E4 + "&E5=" + E5 + "&D1=" + D1 + "&D2=" + D2 + "&D3=" + D3 + "&D4=" + D4 + "&D5=" + D5 + "&Z=" + Z + "&F1=" + F1 + "&F2=" + F2 + "&F3=" + F3 + "&F4=" + F4 + "&F5=" + F5 + "&returl=" + Request.QueryString["returl"] + "");
                        }
                        lbl_msg.Text = "Successfully ";
                    }
                    else
                    {
                        lbl_msg.Text = "Some problem when we try to adding records in database ";
                    }
                }
                else if (Comp__Actve__Status == false)
                {
                    lbl_msg.Text = "Company not active ";
                }
                else if (Comp__Licen__Active == false)
                {
                    lbl_msg.Text = "License Expired";
                }
                else if (Server__Active == false)
                {
                    lbl_msg.Text = "Server Inactive";
                }
            }
        }
    }