private void FrmProgramParameterSub_Load(object sender, EventArgs e)
        {
            string tempvar;

            MyModules.applyGridTheme(dGrid);
            dGrid.Columns[0].Width = 50;
            dGrid.Columns[1].Width = 60;

            for (int h = 1; h <= mlevel; h = h + 1)
            {
                dGrid.Rows.Add();
                dGrid[0, dGrid.Rows.Count - 1].Value = h;
                int g = mPercentageStr.IndexOf(",");
                if (g > 0)
                {
                    tempvar = MyModules.GetIt4Me(mPercentageStr, ",");
                    dGrid[1, dGrid.Rows.Count - 1].Value = tempvar;
                    mPercentageStr = MyModules.Mid(mPercentageStr, g + 1, -1);
                }
                else
                {
                    dGrid[1, dGrid.Rows.Count - 1].Value = mPercentageStr;
                }
            }
        }
Exemplo n.º 2
0
        private void cmdOk_Click(object sender, EventArgs e)
        {
            try
            {
                //if (lblAction.Text == "New Record")
                //{
                //    tCode1.Text = FetchNextNo();
                //}

                if (string.IsNullOrEmpty(tRefNo.Text.Trim(' ')) || string.IsNullOrEmpty(tClientsDetails.Text.Trim(' ')) || string.IsNullOrEmpty(tServiceDetails.Text.Trim(' ')) || string.IsNullOrEmpty(tServiceValue.Text.Trim(' ')) || string.IsNullOrEmpty(tAmountPaid.Text.Trim(' ')) || string.IsNullOrEmpty(tReward.Text.Trim(' ')))
                {
                    MessageBox.Show("Incomplete relevant data", MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Information);

                    return;
                }

                if (Convert.ToDouble(tServiceValue.Text) != Convert.ToDouble(tAmountPaid.Text) + Convert.ToDouble(tReward.Text))
                {
                    MessageBox.Show("Amount Payable do not correspond with actual payment ", MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Information);

                    return;
                }
                if (Convert.ToDouble(tReward.Text) > Convert.ToDouble(tRewardBalance.Text))
                {
                    MessageBox.Show("Drawal on Reward more than available !!!", MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Information);

                    return;
                }

                if (Convert.ToDouble(tReward.Text) > Convert.ToDouble(tRewardBalance.Text) * (MyModules.PercentDrawable / 100))
                {
                    MessageBox.Show("Reward overdrawn !!!", MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Information);

                    return;
                }

                SqlConnection cnSQL = new SqlConnection(MyModules.strConnect);
                SqlCommand    cmSQL = new SqlCommand();
                cmSQL.Connection = cnSQL;
                cnSQL.Open();

                System.Data.SqlClient.SqlTransaction myTrans = cnSQL.BeginTransaction();
                cmSQL.Transaction = myTrans;

                // Dim drSQL As SqlDataReader

                if (Action == AppAction.Add)
                {
                    FetchNextNo();

                    string Telephone = MyModules.GetIt4Me(tClientsDetails.Text, " (");
                    cmSQL.Parameters.Clear();
                    cmSQL.CommandText = "InsertServices";
                    cmSQL.CommandType = CommandType.StoredProcedure;
                    cmSQL.Parameters.AddWithValue("@Sn", tTransNo.Text);
                    cmSQL.Parameters.AddWithValue("@TransDate", dtpDate.Text);
                    cmSQL.Parameters.AddWithValue("@RefNo", tRefNo.Text);
                    cmSQL.Parameters.AddWithValue("@Name", tClientsDetails.Text.ToString().Substring(Telephone.Length + 2, tClientsDetails.Text.ToString().Length - Telephone.Length - 3));
                    cmSQL.Parameters.AddWithValue("@Telephone", Telephone);
                    cmSQL.Parameters.AddWithValue("@ServiceRendered", tServiceDetails.Text);
                    cmSQL.Parameters.AddWithValue("@ValueOfService", Convert.ToDouble(tServiceValue.Text));
                    cmSQL.Parameters.AddWithValue("@AmountPaid", Convert.ToDouble(tAmountPaid.Text));
                    cmSQL.Parameters.AddWithValue("@AmountChargedFromReward", Convert.ToDouble(tReward.Text));
                    cmSQL.Parameters.AddWithValue("@Username", MyModules.sysUserName);

                    cmSQL.ExecuteNonQuery();


                    for (int t = 0; t <= lvList.Items.Count - 1; t++)
                    {
                        cmSQL.Parameters.Clear();
                        cmSQL.CommandText = "InsertRewards";
                        cmSQL.Parameters.AddWithValue("@SourceRefNo", tTransNo.Text);
                        cmSQL.Parameters.AddWithValue("@ClientRefNo", lvList.Items[t].Text);
                        cmSQL.Parameters.AddWithValue("@Reward", lvList.Items[t].SubItems[3].Text);
                        cmSQL.Parameters.AddWithValue("@RewardPercent", lvList.Items[t].SubItems[2].Text);
                        cmSQL.Parameters.AddWithValue("@ClientDetails", lvList.Items[t].SubItems[4].Text);
                        cmSQL.Parameters.AddWithValue("@CourtesyRefNo", tRefNo.Text);
                        cmSQL.Parameters.AddWithValue("@CourtesyClientDetails", tClientsDetails.Text.ToString());
                        cmSQL.ExecuteNonQuery();
                    }
                }

                if (Action == AppAction.Edit)
                {
                    cmSQL.Parameters.Clear();

                    cmSQL.CommandText = "DeleteServices";
                    cmSQL.CommandType = CommandType.StoredProcedure;
                    cmSQL.Parameters.AddWithValue("@Sn", tTransNo.Text);
                    cmSQL.ExecuteNonQuery();

                    cmSQL.Parameters.Clear();
                    cmSQL.CommandText = "DeleteRewards";
                    cmSQL.CommandType = CommandType.StoredProcedure;
                    cmSQL.Parameters.AddWithValue("@SourceRefNo", tTransNo.Text);
                    cmSQL.ExecuteNonQuery();

                    //cmSQL.Parameters.Clear();
                    //cmSQL.CommandText = "DeleteSales";
                    //cmSQL.CommandType = CommandType.StoredProcedure;
                    //cmSQL.Parameters.AddWithValue("@OrderNo", tTransNo.Text);
                    //cmSQL.ExecuteNonQuery();

                    string Telephone = MyModules.GetIt4Me(tClientsDetails.Text, " (");
                    cmSQL.Parameters.Clear();
                    cmSQL.CommandText = "InsertServices";
                    cmSQL.CommandType = CommandType.StoredProcedure;
                    cmSQL.Parameters.AddWithValue("@Sn", tTransNo.Text);
                    cmSQL.Parameters.AddWithValue("@TransDate", dtpDate.Text);
                    cmSQL.Parameters.AddWithValue("@RefNo", tRefNo.Text);
                    cmSQL.Parameters.AddWithValue("@Name", tClientsDetails.Text.ToString().Substring(Telephone.Length + 2, tClientsDetails.Text.ToString().Length - Telephone.Length - 3));
                    cmSQL.Parameters.AddWithValue("@Telephone", Telephone);
                    cmSQL.Parameters.AddWithValue("@ServiceRendered", tServiceDetails.Text);
                    cmSQL.Parameters.AddWithValue("@ValueOfService", Convert.ToDouble(tServiceValue.Text));
                    cmSQL.Parameters.AddWithValue("@AmountPaid", Convert.ToDouble(tAmountPaid.Text));
                    cmSQL.Parameters.AddWithValue("@AmountChargedFromReward", Convert.ToDouble(tReward.Text));
                    cmSQL.Parameters.AddWithValue("@Username", MyModules.sysUserName);

                    cmSQL.ExecuteNonQuery();

                    for (int t = 0; t <= lvList.Items.Count - 1; t++)
                    {
                        cmSQL.Parameters.Clear();
                        cmSQL.CommandText = "InsertRewards";
                        cmSQL.Parameters.AddWithValue("@SourceRefNo", tTransNo.Text);
                        cmSQL.Parameters.AddWithValue("@ClientRefNo", lvList.Items[t].Text);
                        cmSQL.Parameters.AddWithValue("@Reward", lvList.Items[t].SubItems[3].Text);
                        cmSQL.Parameters.AddWithValue("@RewardPercent", lvList.Items[t].SubItems[2].Text);
                        cmSQL.Parameters.AddWithValue("@ClientDetails", lvList.Items[t].SubItems[4].Text);
                        cmSQL.Parameters.AddWithValue("@CourtesyRefNo", tRefNo.Text);
                        cmSQL.Parameters.AddWithValue("@CourtesyClientDetails", tClientsDetails.Text.ToString());
                        cmSQL.ExecuteNonQuery();
                    }
                }

                if (Action == AppAction.Delete)
                {
                    if (MessageBox.Show("The selected record would be Deleted Parmanently....Continue(y/n)?", MyModules.strApptitle, MessageBoxButtons.YesNo, MessageBoxIcon.Information) != DialogResult.Yes)
                    {
                        return;
                    }

                    cmSQL.Parameters.Clear();
                    cmSQL.CommandText = "DeleteServices";
                    cmSQL.CommandType = CommandType.StoredProcedure;
                    cmSQL.Parameters.AddWithValue("@Sn", tTransNo.Text);
                    cmSQL.ExecuteNonQuery();

                    cmSQL.Parameters.Clear();
                    cmSQL.CommandText = "DeleteRewards";
                    cmSQL.CommandType = CommandType.StoredProcedure;
                    cmSQL.Parameters.AddWithValue("@SourceRefNo", tTransNo.Text);
                    cmSQL.ExecuteNonQuery();

                    cmSQL.Parameters.Clear();
                    cmSQL.CommandText = "DeleteSales";
                    cmSQL.CommandType = CommandType.StoredProcedure;
                    cmSQL.Parameters.AddWithValue("@OrderNo", tTransNo.Text);
                    cmSQL.ExecuteNonQuery();

                    try {
                        cmSQL.Parameters.Clear();
                        cmSQL.CommandText = "Delete FROM SalonFinance WHERE EnteredBy='" + tTransNo.Text + "'";
                        cmSQL.CommandType = CommandType.Text;
                        cmSQL.ExecuteNonQuery();
                    }
                    catch
                    {
                    }
                }

                myTrans.Commit();

                cmSQL.Connection.Close();
                cmSQL.Dispose();
                cnSQL.Close();
                cnSQL.Dispose();

                mnuNew_Click(sender, e);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 3
0
        private void GetSubLevel(string ClientRef)
        {
            try
            {
                string d1 = null;
                lvList.Items.Clear();
                string initialText  = null;
                string dRealOutline = MyModules.GetIt4Me(ClientOutline.ToString(), ClientRef);

                dRealOutline = Reverse(dRealOutline);

                int theIndex = CountCharacter(dRealOutline, Convert.ToChar("@"));
                if (theIndex == 1)
                {
                    return;
                }
                if (theIndex - 1 > MyModules.PyramidLevel)
                {
                    theIndex = MyModules.PyramidLevel + 1;
                }
                int pIndex = theIndex - 1;
                for (int s = 1; s <= theIndex - 1; s++)
                //for (int s = theIndex - 1; s >= 1; s--)
                {
                    d1           = dRealOutline.Substring(1, dRealOutline.Substring(1).IndexOf("@"));
                    dRealOutline = dRealOutline.Substring(d1.Length + 1);

                    initialText = Reverse(d1.ToString());

                    ListViewItem LvItems = new ListViewItem(initialText);


                    //LvItems.SubItems.Add(s.ToString());
                    LvItems.SubItems.Add(pIndex.ToString());
                    LvItems.SubItems.Add(0.ToString());
                    LvItems.SubItems.Add("");
                    LvItems.SubItems.Add("");

                    lvList.Items.AddRange(new ListViewItem[] { LvItems });
                    pIndex = pIndex - 1;
                }

                string tempPyramidLevelPercent = GetPyramidLevelPercent(lvList.Items.Count);

                //tempPyramidLevelPercent = Reverse(tempPyramidLevelPercent);

                theIndex = CountCharacter(tempPyramidLevelPercent, Convert.ToChar(","));
                if (theIndex < 1)
                {
                    lvList.Items[0].SubItems[2].Text = tempPyramidLevelPercent;
                }
                if (theIndex + 1 > MyModules.PyramidLevel)
                {
                    theIndex = MyModules.PyramidLevel;
                }
                //for (int s = 1; s <= theIndex + 1; s++)
                for (int s = theIndex + 1; s >= 1; s--)
                {
                    d1 = MyModules.GetIt4Me(tempPyramidLevelPercent, ","); //.Substring(1, tempPyramidLevelPercent.Substring(1).IndexOf(","));
                    if (CountCharacter(tempPyramidLevelPercent, Convert.ToChar(",")) > 0)
                    {
                        tempPyramidLevelPercent = tempPyramidLevelPercent.Substring(d1.Length + 1);
                    }
                    else
                    {
                        tempPyramidLevelPercent = "";
                    }
                    lvList.Items[s - 1].SubItems[2].Text = d1;
                }

                for (int t = 0; t <= lvList.Items.Count - 1; t++)
                {
                    lvList.Items[t].SubItems[4].Text = GetClientDetails(lvList.Items[t].Text);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 4
0
        private void cmdOk1_Click(object sender, EventArgs e)
        {
            try
            {
                if (lblAction.Text == "New Record")
                {
                    tCode1.Text = FetchNextNo();
                }

                if (string.IsNullOrEmpty(tCode1.Text.Trim(' ')) || string.IsNullOrEmpty(tPhone1.Text.Trim(' ')) || string.IsNullOrEmpty(tName1.Text.Trim(' ')))
                {
                    MessageBox.Show("Incomplete relevant data", MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Information);

                    return;
                }

                SqlConnection cnSQL = new SqlConnection(MyModules.strConnect);
                SqlCommand    cmSQL = new SqlCommand();
                cmSQL.Connection = cnSQL;
                cnSQL.Open();

                System.Data.SqlClient.SqlTransaction myTrans = cnSQL.BeginTransaction();
                cmSQL.Transaction = myTrans;

                // Dim drSQL As SqlDataReader

                string strDate = "";
                if (cboDay1.Text == "" || cboMonth1.Text == "")
                {
                    strDate = "01-01-1900";
                }
                else
                {
                    strDate = cboDay1.Text + "-" + cboMonth1.Text + "-2020";
                }


                if (lblAction.Text == "New Record")
                {
                    cmSQL.Parameters.Clear();
                    cmSQL.CommandText = "InsertRegister";
                    cmSQL.CommandType = CommandType.StoredProcedure;
                    cmSQL.Parameters.AddWithValue("@Code", tCode1.Text);
                    cmSQL.Parameters.AddWithValue("@Telephone", tPhone1.Text);
                    cmSQL.Parameters.AddWithValue("@Name", tName1.Text);
                    cmSQL.Parameters.AddWithValue("@Address", tAddress1.Text);
                    cmSQL.Parameters.AddWithValue("@Email", tEmail1.Text);
                    cmSQL.Parameters.AddWithValue("@IsHeader", 0);
                    cmSQL.Parameters.AddWithValue("@Parent", MyModules.GetIt4Me(lblParentName.Text, " - "));
                    cmSQL.Parameters.AddWithValue("@Outline", lblParentName.Tag + tCode1.Text + "@");
                    cmSQL.Parameters.AddWithValue("@mLevel", Convert.ToInt16((lblParent.Tag)) + 1);
                    cmSQL.Parameters.AddWithValue("@AutoID", Convert.ToInt16(tCode1.Text));
                    cmSQL.Parameters.AddWithValue("@Discontinue", chkDiscontinue1.Checked);
                    cmSQL.Parameters.AddWithValue("@DOB", strDate);
                    cmSQL.ExecuteNonQuery();
                }

                if (lblAction.Text == "Edit Record")
                {
                    cmSQL.Parameters.Clear();

                    cmSQL.CommandText = "DeleteRegister";
                    cmSQL.CommandType = CommandType.StoredProcedure;
                    cmSQL.Parameters.AddWithValue("@Code", tCode1.Text);
                    cmSQL.ExecuteNonQuery();

                    cmSQL.Parameters.Clear();

                    cmSQL.CommandText = "InsertRegister";
                    cmSQL.CommandType = CommandType.StoredProcedure;
                    cmSQL.Parameters.AddWithValue("@Code", tCode1.Text);
                    cmSQL.Parameters.AddWithValue("@Telephone", tPhone1.Text);
                    cmSQL.Parameters.AddWithValue("@Name", tName1.Text);
                    cmSQL.Parameters.AddWithValue("@Address", tAddress1.Text);
                    cmSQL.Parameters.AddWithValue("@Email", tEmail1.Text);
                    cmSQL.Parameters.AddWithValue("@IsHeader", 0);
                    cmSQL.Parameters.AddWithValue("@Parent", MyModules.GetIt4Me(lblParentName.Text, " - "));
                    cmSQL.Parameters.AddWithValue("@Outline", lblParentName.Tag);
                    cmSQL.Parameters.AddWithValue("@mLevel", Convert.ToInt16(lblParent.Tag));
                    cmSQL.Parameters.AddWithValue("@AutoID", Convert.ToInt16(tCode1.Text));
                    cmSQL.Parameters.AddWithValue("@Discontinue", chkDiscontinue1.Checked);
                    cmSQL.Parameters.AddWithValue("@DOB", strDate);
                    cmSQL.ExecuteNonQuery();
                }


                myTrans.Commit();

                cmSQL.Connection.Close();
                cmSQL.Dispose();
                cnSQL.Close();
                cnSQL.Dispose();

                Panel4.Visible = false;
                LoadGrid();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 5
0
        private void loadChildren(string dOutline, string Code)
        {
            try
            {
                SqlConnection cnSQL1 = new SqlConnection(MyModules.strConnect);
                SqlCommand    cmSQL1 = new SqlCommand();
                cmSQL1.Connection = cnSQL1;
                cnSQL1.Open();
                SqlDataReader drSQL1 = null;
                int           H1     = 0;

                cmSQL1.CommandText = "SELECT * FROM Register WHERE outline like '%@" + Code + "%' AND Code<>'" + Code + "'  ORDER BY mLevel";

                cmSQL1.CommandType = CommandType.Text;
                drSQL1             = cmSQL1.ExecuteReader();
                string d1           = null;
                string d2           = null;
                string d3           = null;
                string d4           = null;
                string d5           = null;
                string d6           = null;
                string d7           = null;
                string d8           = null;
                string d9           = null;
                string d10          = null;
                string dRealOutline = "";
                while (drSQL1.Read())
                {
                    TVList.BeginUpdate();
                    if (MyModules.Left(drSQL1["Outline"].ToString(), Code.Length + 1) == "@" + Code)
                    {
                        dRealOutline = drSQL1["Outline"].ToString();
                    }
                    else
                    {
                        dRealOutline = drSQL1["Outline"].ToString().Substring(MyModules.GetIt4Me(drSQL1["Outline"].ToString(), "@" + Code).Length);    // MyModules.Mid(drSQL1["Outline"].ToString(),;
                    }
                    //dRealOutline =MyModules.Mid(drSQL1["Outline"].ToString(), drSQL1["Outline"].ToString().Length,-1);
                    // dRealOutline =  drSQL1["Outline"].ToString().Substring(dOutline.Length-1); //drSQL1["Outline"].ToString(); //

                    //for (int i=1;i<CountCharacter(dRealOutline, Convert.ToChar("@")); i++)
                    //{
                    int theIndex = CountCharacter(dRealOutline, Convert.ToChar("@"));
                    //}
                    switch (theIndex)
                    {
                    case 2:
                        TVList.Nodes.Add(drSQL1["Code"].ToString() + "a", drSQL1["Code"].ToString() + " - " + drSQL1["Telephone"].ToString() + " (" + drSQL1["Name"].ToString() + ")");
                        break;

                    case 3:
                        if (MyModules.PyramidLevel < 1)
                        {
                        }
                        else
                        {
                            d1 = dRealOutline.Substring(1, dRealOutline.Substring(1).IndexOf("@"));
                            TVList.Nodes[d1 + "a"].Nodes.Add(drSQL1["Code"].ToString(), drSQL1["Code"].ToString() + " - " + drSQL1["Telephone"].ToString() + " (" + drSQL1["Name"].ToString() + ")");
                        }
                        break;

                    case 4:
                        if (MyModules.PyramidLevel < 2)
                        {
                        }
                        else
                        {
                            d1 = dRealOutline.Substring(1, dRealOutline.Substring(1).IndexOf("@"));
                            d2 = dRealOutline.Substring((d1.Length + 3) - 1, dRealOutline.Substring((d1.Length + 4) - 1).IndexOf("@") + 1);
                            TVList.Nodes[d1 + "a"].Nodes[d2].Nodes.Add(drSQL1["Code"].ToString(), drSQL1["Code"].ToString() + " - " + drSQL1["Telephone"].ToString() + " (" + drSQL1["Name"].ToString() + ")");
                        }
                        break;

                    case 5:
                        if (MyModules.PyramidLevel < 3)
                        {
                        }
                        else
                        {
                            d1 = dRealOutline.Substring(1, dRealOutline.Substring(1).IndexOf("@"));
                            d2 = dRealOutline.Substring((d1.Length + 3) - 1, dRealOutline.Substring((d1.Length + 4) - 1).IndexOf("@") + 1);
                            d3 = dRealOutline.Substring((d1.Length + d2.Length + 4) - 1, dRealOutline.Substring((d1.Length + d2.Length + 4) - 1).IndexOf("@"));
                            TVList.Nodes[d1 + "a"].Nodes[d2].Nodes[d3].Nodes.Add(drSQL1["Code"].ToString(), drSQL1["Code"].ToString() + " - " + drSQL1["Telephone"].ToString() + " (" + drSQL1["Name"].ToString() + ")");
                        }
                        break;

                    case 6:
                        if (MyModules.PyramidLevel < 4)
                        {
                        }
                        else
                        {
                            d1 = dRealOutline.Substring(1, dRealOutline.Substring(1).IndexOf("@"));
                            d2 = dRealOutline.Substring((d1.Length + 3) - 1, dRealOutline.Substring((d1.Length + 4) - 1).IndexOf("@") + 1);
                            d3 = dRealOutline.Substring((d1.Length + d2.Length + 4) - 1, dRealOutline.Substring((d1.Length + d2.Length + 4) - 1).IndexOf("@"));
                            d4 = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + 5) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + 5) - 1).IndexOf("@"));
                            TVList.Nodes[d1 + "a"].Nodes[d2].Nodes[d3].Nodes[d4].Nodes.Add(drSQL1["Code"].ToString(), drSQL1["Code"].ToString() + " - " + drSQL1["Telephone"].ToString() + " (" + drSQL1["Name"].ToString() + ")");
                        }

                        break;

                    case 7:
                        if (MyModules.PyramidLevel < 5)
                        {
                        }
                        else
                        {
                            d1 = dRealOutline.Substring(1, drSQL1["Outline"].ToString().Substring(1).IndexOf("@"));
                            d2 = dRealOutline.Substring((d1.Length + 3) - 1, dRealOutline.Substring((d1.Length + 4) - 1).IndexOf("@") + 1);
                            d3 = dRealOutline.Substring((d1.Length + d2.Length + 4) - 1, dRealOutline.Substring((d1.Length + d2.Length + 4) - 1).IndexOf("@"));
                            d4 = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + 5) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + 5) - 1).IndexOf("@"));
                            d5 = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + 6) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + 6) - 1).IndexOf("@"));
                            TVList.Nodes[d1 + "a"].Nodes[d2].Nodes[d3].Nodes[d4].Nodes[d5].Nodes.Add(drSQL1["Code"].ToString(), drSQL1["Code"].ToString() + " - " + drSQL1["Telephone"].ToString() + " (" + drSQL1["Name"].ToString() + ")");
                        }
                        break;

                    case 8:
                        if (MyModules.PyramidLevel < 6)
                        {
                        }
                        else
                        {
                            d1 = dRealOutline.Substring(1, drSQL1["Outline"].ToString().Substring(1).IndexOf("@"));
                            d2 = dRealOutline.Substring((d1.Length + 3) - 1, dRealOutline.Substring((d1.Length + 4) - 1).IndexOf("@") + 1);
                            d3 = dRealOutline.Substring((d1.Length + d2.Length + 4) - 1, dRealOutline.Substring((d1.Length + d2.Length + 4) - 1).IndexOf("@"));
                            d4 = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + 5) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + 5) - 1).IndexOf("@"));
                            d5 = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + 6) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + 6) - 1).IndexOf("@"));
                            d6 = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + 7) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + 7) - 1).IndexOf("@"));
                            TVList.Nodes[d1 + "a"].Nodes[d2].Nodes[d3].Nodes[d4].Nodes[d5].Nodes[d6].Nodes.Add(drSQL1["Code"].ToString(), drSQL1["Code"].ToString() + " - " + drSQL1["Telephone"].ToString() + " (" + drSQL1["Name"].ToString() + ")");
                        }
                        break;

                    case 9:
                        if (MyModules.PyramidLevel < 7)
                        {
                        }
                        else
                        {
                            d1 = dRealOutline.Substring(1, drSQL1["Outline"].ToString().Substring(1).IndexOf("@"));
                            d2 = dRealOutline.Substring((d1.Length + 3) - 1, dRealOutline.Substring((d1.Length + 4) - 1).IndexOf("@") + 1);
                            d3 = dRealOutline.Substring((d1.Length + d2.Length + 4) - 1, dRealOutline.Substring((d1.Length + d2.Length + 4) - 1).IndexOf("@"));
                            d4 = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + 5) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + 5) - 1).IndexOf("@"));
                            d5 = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + 6) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + 6) - 1).IndexOf("@"));
                            d6 = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + 7) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + 7) - 1).IndexOf("@"));
                            d7 = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + d6.Length + 8) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + d6.Length + 8) - 1).IndexOf("@"));
                            TVList.Nodes[d1 + "a"].Nodes[d2].Nodes[d3].Nodes[d4].Nodes[d5].Nodes[d6].Nodes[d7].Nodes.Add(drSQL1["Code"].ToString(), drSQL1["Code"].ToString() + " - " + drSQL1["Telephone"].ToString() + " (" + drSQL1["Name"].ToString() + ")");
                        }
                        break;

                    case 10:
                        if (MyModules.PyramidLevel < 8)
                        {
                        }
                        else
                        {
                            d1 = dRealOutline.Substring(1, drSQL1["Outline"].ToString().Substring(1).IndexOf("@"));
                            d2 = dRealOutline.Substring((d1.Length + 3) - 1, dRealOutline.Substring((d1.Length + 4) - 1).IndexOf("@") + 1);
                            d3 = dRealOutline.Substring((d1.Length + d2.Length + 4) - 1, dRealOutline.Substring((d1.Length + d2.Length + 4) - 1).IndexOf("@"));
                            d4 = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + 5) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + 5) - 1).IndexOf("@"));
                            d5 = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + 6) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + 6) - 1).IndexOf("@"));
                            d6 = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + 7) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + 7) - 1).IndexOf("@"));
                            d7 = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + d6.Length + 8) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + d6.Length + 8) - 1).IndexOf("@"));
                            d8 = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + d6.Length + d7.Length + 9) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + d6.Length + d7.Length + 9) - 1).IndexOf("@"));

                            TVList.Nodes[d1 + "a"].Nodes[d2].Nodes[d3].Nodes[d4].Nodes[d5].Nodes[d6].Nodes[d7].Nodes[d8].Nodes.Add(drSQL1["Code"].ToString(), drSQL1["Code"].ToString() + " - " + drSQL1["Telephone"].ToString() + " (" + drSQL1["Name"].ToString() + ")");
                        }
                        break;

                    case 11:
                        if (MyModules.PyramidLevel < 9)
                        {
                        }
                        else
                        {
                            d1 = dRealOutline.Substring(1, drSQL1["Outline"].ToString().Substring(1).IndexOf("@"));
                            d2 = dRealOutline.Substring((d1.Length + 3) - 1, dRealOutline.Substring((d1.Length + 4) - 1).IndexOf("@") + 1);
                            d3 = dRealOutline.Substring((d1.Length + d2.Length + 4) - 1, dRealOutline.Substring((d1.Length + d2.Length + 4) - 1).IndexOf("@"));
                            d4 = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + 5) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + 5) - 1).IndexOf("@"));
                            d5 = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + 6) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + 6) - 1).IndexOf("@"));
                            d6 = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + 7) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + 7) - 1).IndexOf("@"));
                            d7 = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + d6.Length + 8) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + d6.Length + 8) - 1).IndexOf("@"));
                            d8 = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + d6.Length + d7.Length + 9) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + d6.Length + d7.Length + 9) - 1).IndexOf("@"));
                            d9 = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + d6.Length + d7.Length + d8.Length + 10) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + d6.Length + d7.Length + d8.Length + 10) - 1).IndexOf("@"));

                            TVList.Nodes[d1 + "a"].Nodes[d2].Nodes[d3].Nodes[d4].Nodes[d5].Nodes[d6].Nodes[d7].Nodes[d8].Nodes[d9].Nodes.Add(drSQL1["Code"].ToString(), drSQL1["Code"].ToString() + " - " + drSQL1["Telephone"].ToString() + " (" + drSQL1["Name"].ToString() + ")");
                        }
                        break;

                    case 12:
                        if (MyModules.PyramidLevel < 10)
                        {
                        }
                        else
                        {
                            d1  = dRealOutline.Substring(1, drSQL1["Outline"].ToString().Substring(1).IndexOf("@"));
                            d2  = dRealOutline.Substring((d1.Length + 3) - 1, dRealOutline.Substring((d1.Length + 4) - 1).IndexOf("@") + 1);
                            d3  = dRealOutline.Substring((d1.Length + d2.Length + 4) - 1, dRealOutline.Substring((d1.Length + d2.Length + 4) - 1).IndexOf("@"));
                            d4  = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + 5) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + 5) - 1).IndexOf("@"));
                            d5  = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + 6) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + 6) - 1).IndexOf("@"));
                            d6  = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + 7) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + 7) - 1).IndexOf("@"));
                            d7  = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + d6.Length + 8) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + d6.Length + 8) - 1).IndexOf("@"));
                            d8  = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + d6.Length + d7.Length + 9) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + d6.Length + d7.Length + 9) - 1).IndexOf("@"));
                            d9  = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + d6.Length + d7.Length + d8.Length + 10) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + d6.Length + d7.Length + d8.Length + 10) - 1).IndexOf("@"));
                            d10 = dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + d6.Length + d7.Length + d8.Length + d9.Length + 10) - 1, dRealOutline.Substring((d1.Length + d2.Length + d3.Length + d4.Length + d5.Length + d6.Length + d7.Length + d8.Length + d9.Length + 10) - 1).IndexOf("@"));

                            TVList.Nodes[d1 + "a"].Nodes[d2].Nodes[d3].Nodes[d4].Nodes[d5].Nodes[d6].Nodes[d7].Nodes[d8].Nodes[d9].Nodes[d10].Nodes.Add(drSQL1["Code"].ToString(), drSQL1["Code"].ToString() + " - " + drSQL1["Telephone"].ToString() + " (" + drSQL1["Name"].ToString() + ")");
                        }
                        break;

                    default:
                        if (H1 == 0)
                        {
                            TVList.Nodes.Add("MORE12345", "More Than 10 Levels");
                            H1 = 1;
                        }
                        TVList.Nodes["MORE12345"].Nodes.Add(drSQL1["Code"].ToString(), drSQL1["Code"].ToString() + " - " + drSQL1["Telephone"].ToString() + " (" + drSQL1["Name"].ToString() + ")");
                        break;
                    }
                    TVList.EndUpdate();
                }

                drSQL1.Close();
                cnSQL1.Close();
            }
            catch (Exception ex)
            {
                // if (Microsoft.VisualBasic.Information.Err().Number == 91)
                //{
                //     Microsoft.VisualBasic.Information.Err().Clear();

                //    TVList.Nodes.Add(drSQL["Code"].ToString(), drSQL["Code"].ToString() + " - " + drSQL["Telephone"].ToString() + "(" + drSQL["Name"].ToString() + ")");

                //}
                //else
                //{
                MessageBox.Show(ex.Message, MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                //}
            }
        }