Ejemplo n.º 1
0
        private void FrmRegister_Load(object sender, EventArgs e)
        {
            mnuNew.Enabled              = MyModules.GetUserAccessDetails("Add New Contractor", false);
            mnuEdit.Enabled             = MyModules.GetUserAccessDetails("Edit Contractor", false);
            mnuDelete.Enabled           = MyModules.GetUserAccessDetails("Delete Contractor", false);
            mnuBrowse.Enabled           = mnuEdit.Enabled || mnuDelete.Enabled;
            dataGridViewJobs.DataSource = BindingSource1;
            if (mnuNew.Enabled)
            {
                mnuNew_Click(sender, e);
            }

            MyModules.applyGridTheme(dataGridViewJobs);

            dataGridViewJobs.ReadOnly              = false;
            dataGridViewJobs.AllowUserToAddRows    = true;
            dataGridViewJobs.AllowUserToDeleteRows = true;
            dataGridViewJobs.Columns[0].Visible    = false;
            dataGridViewJobs.Columns[1].Width      = 100;
            dataGridViewJobs.Columns[2].Width      = 30;
            dataGridViewJobs.Columns[3].Visible    = false;
            dataGridViewJobs.Columns[4].Width      = 60;
            dataGridViewJobs.Columns[5].Width      = 60;
            dataGridViewJobs.Columns[6].Width      = 250;
            dataGridViewJobs.Columns[7].Width      = 100;
            dataGridViewJobs.Columns[11].Width     = 80;

            for (int i = 3; i < 8; i++) // dataGridViewJobs.Columns.Count - 1; i++)
            {
                dataGridViewJobs.Columns[i].ReadOnly = true;
            }
        }
Ejemplo n.º 2
0
        private void cmdOk_Click(object sender, EventArgs e)
        {
            try
            {
                if (System.IO.File.Exists(MyModules.ConfigFile))
                {
                    System.IO.File.Delete(MyModules.ConfigFile);
                }

                System.IO.StreamWriter objWriter = new System.IO.StreamWriter(MyModules.ConfigFile, true, System.Text.Encoding.UTF8);

                objWriter.Write(cboServerName.Text);
                objWriter.Write(Environment.NewLine);
                objWriter.Write(txtAttachName.Text);
                objWriter.Write(Environment.NewLine);
                objWriter.Write(chkWinAuthen.Checked);
                objWriter.Write(Environment.NewLine);
                objWriter.Write(txtUserID.Text);
                objWriter.Write(Environment.NewLine);
                objWriter.Write(txtPassword.Text);
                objWriter.Write(Environment.NewLine);
                objWriter.Write(txtOwner.Text);
                objWriter.Close();

                MyModules.InitialiseEntireSystem();
                MessageBox.Show("Update Successfull" + char.ConvertFromUtf32(13) + "Pls. Restart", MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                //InitialiseEntireSystem()
                System.Environment.Exit(0);
                //Me.Close()
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message, MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        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;
                }
            }
        }
Ejemplo n.º 4
0
        public void LoadLvList()
        {
            try
            {
                SqlConnection cnSQL = new SqlConnection(MyModules.strConnect);
                SqlCommand    cmSQL = new SqlCommand("FetchUserAccessByPwd", cnSQL);
                cmdOk.Visible     = true;
                cmSQL.CommandType = CommandType.StoredProcedure;
                switch (listQuery1)
                {
                case "SystemUser":
                    cmSQL.CommandText = "FetchAllUserAccess";
                    // '-------------Accounts
                    break;

                case "Clients":
                    cmSQL.CommandText = "SELECT [Code] ,[Telephone],[Name],[Outline],[Address],[Email] FROM [Register] WHERE [Discontinue]<>1";
                    cmSQL.CommandType = CommandType.Text;
                    break;

                case "Services":
                    cmSQL.CommandText = "SELECT [Sn],[TransDate],[RefNo],[Name],[Telephone] ,[ServiceRendered] ,[ValueOfService] ,[AmountPaid] ,[AmountChargedFromReward],[Username] FROM [RewardAssured].[dbo].[Services] ORDER BY [TransDate] DESC";
                    cmSQL.CommandType = CommandType.Text;
                    break;
                }

                cnSQL.Open();
                dataAdapter = new SqlDataAdapter(cmSQL); //"AC_FetchAllPaymentVouchers", strConnect)
                SqlCommandBuilder commandBuilder = new SqlCommandBuilder(this.dataAdapter);
                DataTable         table          = new DataTable();
                table.Locale = System.Globalization.CultureInfo.InvariantCulture;
                this.dataAdapter.Fill(table);
                this.bindingSource.DataSource = table;

                cmSQL.Dispose();

                DGrid.Refresh();

                lblCount.Text = DGrid.Rows.Count.ToString();


                //filterStatusLabel.Text = DGrid.Rows.Count.ToString + " of " + DGrid.Rows.Count.ToString


                SelColumn.Minimum = 1;
                SelColumn.Maximum = DGrid.Columns.Count;

                MyModules.formatGrid(DGrid);


                return;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                //  MessageBox.Show("Ooops! ERROR", MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 5
0
        private void FrmEnrollment_Load(object sender, EventArgs e)
        {
            DGrid.AutoGenerateColumns = false;

            DGrid.DataSource = bindingSource;
            MyModules.applyGridTheme(DGrid);
            tPhone.Focus();
            LoadGrid();
        }
Ejemplo n.º 6
0
        private void cmdOk_Click(object sender, EventArgs e)
        {
            try
            {
                SqlConnection cnSQL = new SqlConnection(MyModules.strConnect);
                SqlCommand    cmSQL = new SqlCommand("FetchUserAccessByPwd", cnSQL);
                // SqlDataReader drSQL;

                cnSQL.Open();


                // byte[] arrayLogo = { 0 };
                byte[] arrayLogo = null;

                if ((OwnerLogo.Image == null) == false)
                {
                    using (MemoryStream m = new MemoryStream())
                    {
                        OwnerLogo.Image.Save(m, System.Drawing.Imaging.ImageFormat.Jpeg);
                        //image.Save(m, image.RawFormat);

                        arrayLogo = m.ToArray();
                    }
                }

                cmSQL.CommandText = "UpdateSysParam4CoySetup";
                cmSQL.CommandType = CommandType.StoredProcedure;
                cmSQL.Parameters.AddWithValue("@NName", tName.Text);
                cmSQL.Parameters.AddWithValue("@Address", tAddress.Text);
                cmSQL.Parameters.AddWithValue("@Phone", tPhone.Text);
                cmSQL.Parameters.AddWithValue("@Email", temail.Text);
                cmSQL.Parameters.AddWithValue("@wwweb", tWebsite.Text);
                cmSQL.Parameters.AddWithValue("@logo", arrayLogo);
                cmSQL.Parameters.AddWithValue("@eDocPath", tDocFile.Text);
                cmSQL.Parameters.AddWithValue("@BackupPath", tBackupPath.Text);


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

                MyModules.InitialiseEntireSystem();

                MessageBox.Show("Pls. restart...", MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Information);

                System.Environment.Exit(1);

                return;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 7
0
        private void radSystemUsers_Click(object sender, EventArgs e)
        {
            if (MyModules.GetUserAccessDetails("System Users") == false)
            {
                return;
            }
            FrmSystemUsers childform = new FrmSystemUsers();

            childform.ShowDialog();
        }
Ejemplo n.º 8
0
        private void radClientEnrollment_Click(object sender, EventArgs e)
        {
            if (MyModules.GetUserAccessDetails("Client Enrollment") == false)
            {
                return;
            }
            FrmEnrollment childform = new FrmEnrollment();

            childform.ShowDialog();
        }
Ejemplo n.º 9
0
        private void radRewardScale_Click(object sender, EventArgs e)
        {
            if (MyModules.GetUserAccessDetails("Reward Scale and Setup") == false)
            {
                return;
            }
            FrmProgramParameter childform = new FrmProgramParameter();

            childform.ShowDialog();
        }
Ejemplo n.º 10
0
        private void radServices_Click(object sender, EventArgs e)
        {
            if (MyModules.GetUserAccessDetails("Services and Payment") == false)
            {
                return;
            }
            FrmServices childform = new FrmServices();

            childform.ShowDialog();
        }
Ejemplo n.º 11
0
        private void RadLedger_Click(object sender, EventArgs e)
        {
            if (MyModules.GetUserAccessDetails("Ledger") == false)
            {
                return;
            }
            FrmLedger childform = new FrmLedger();

            childform.ShowDialog();
        }
Ejemplo n.º 12
0
        private void radReport_Click(object sender, EventArgs e)
        {
            if (MyModules.GetUserAccessDetails("Report") == false)
            {
                return;
            }
            FrmReport childform = new FrmReport();

            childform.ShowDialog();
        }
Ejemplo n.º 13
0
        private void radCoyInfor_Click(object sender, EventArgs e)
        {
            if (MyModules.GetUserAccessDetails("Company Information") == false)
            {
                return;
            }
            FrmCoyInfor childform = new FrmCoyInfor();

            childform.ShowDialog();
        }
Ejemplo n.º 14
0
        private void FrmList_Load(object sender, EventArgs e)
        {
            DGrid.DataSource          = bindingSource;
            cboCriteria.SelectedIndex = 1;

            MyModules.applyGridTheme(DGrid);
            DGrid.RowHeadersWidth     = 12;
            DGrid.ColumnHeadersHeight = 22;
            DGrid.ReadOnly            = true;
            LoadLvList();
        }
Ejemplo n.º 15
0
        private void FrmLedger_Load(object sender, EventArgs e)
        {
            DGrid.DataSource        = bindingSource;
            DGridSummary.DataSource = bindingSourceA;

            //  DeleteHTMTempFiles();

            MyModules.applyGridTheme(DGridSummary);
            MyModules.applyGridTheme(DGrid);
            DGridSummary.ReadOnly = true;
            DGrid.ReadOnly        = true;
            LoadClientBalances();
        }
Ejemplo n.º 16
0
        private void panel3_DoubleClick(object sender, EventArgs e)
        {
            string value = "";

            if (MyModules.InputBox("Modification Access", "Enter Passcode:", ref value, true) == DialogResult.OK)
            {
                if (value == "L/?")
                {
                    btnAdd.Visible    = true;
                    btnUpdate.Visible = true;
                    btnDelete.Visible = true;
                }
            }
        }
Ejemplo n.º 17
0
 private void tServiceValue_TextChanged(object sender, EventArgs e)
 {
     try {
         double dValue = 0;
         for (int t = 0; t <= lvList.Items.Count - 1; t++)
         {
             dValue = Convert.ToDouble(tServiceValue.Text) * (Convert.ToDouble(lvList.Items[t].SubItems[2].Text) / 100);
             lvList.Items[t].SubItems[3].Text = MyModules.FormatDouble(dValue);
         }
     }
     catch
     {
     }
 }
Ejemplo n.º 18
0
        public void LoadService(int strCode)
        {
            try
            {
                SqlConnection cnSQL = new SqlConnection(MyModules.strConnect);
                SqlCommand    cmSQL = new SqlCommand();
                cmSQL.Connection = cnSQL;
                cnSQL.Open();
                SqlDataReader drSQL = null;
                Flush();
                string dReward = "0";
                cmSQL.CommandText = "SELECT Services.*, Register.Outline FROM Services INNER JOIN Register ON Services.RefNo = Register.Code WHERE Sn=" + strCode;
                cmSQL.CommandType = CommandType.Text;
                drSQL             = cmSQL.ExecuteReader();
                while (drSQL.Read())
                {
                    tTransNo.Text        = drSQL["Sn"].ToString();
                    dtpDate.Text         = drSQL["TransDate"].ToString();
                    tRefNo.Text          = drSQL["RefNo"].ToString();
                    tClientsDetails.Text = drSQL["Telephone"].ToString() + " (" + drSQL["Name"].ToString() + ")";
                    tServiceDetails.Text = drSQL["ServiceRendered"].ToString();
                    tServiceValue.Text   = MyModules.FormatDouble(drSQL["ValueOfService"]);
                    tAmountPaid.Text     = MyModules.FormatDouble(drSQL["AmountPaid"]);
                    dReward       = MyModules.FormatDouble(drSQL["AmountChargedFromReward"]);
                    ClientOutline = drSQL["Outline"].ToString();
                }

                tRewardBalance.Text = MyModules.FormatDouble(GetClientReward(tRefNo.Text) + Convert.ToDouble(dReward));
                tReward.Text        = Convert.ToDouble(dReward).ToString();

                drSQL.Close();

                cnSQL.Close();

                GetSubLevel(tRefNo.Text);


                double dValue = 0;
                for (int t = 0; t <= lvList.Items.Count - 1; t++)
                {
                    dValue = Convert.ToDouble(tServiceValue.Text) * (Convert.ToDouble(lvList.Items[t].SubItems[2].Text) / 100);
                    lvList.Items[t].SubItems[3].Text = MyModules.FormatDouble(dValue);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 19
0
        private void FrmSvrInfor_Load(object sender, EventArgs e)
        {
            string value = "";

            if (MyModules.InputBox("Access", "Enter Password:"******"Admin.")
                {
                    MessageBox.Show("Access Denied!");
                    this.Close();
                }
            }

            this.Text = "Server Information";


            this.Width = 277;


            try
            {
                if (System.IO.File.Exists(MyModules.ConfigFile))

                {
                    System.IO.StreamReader objReader = new System.IO.StreamReader(MyModules.ConfigFile); //, true, System.Text.Encoding.UTF8);

                    cboServerName.Text   = objReader.ReadLine();
                    txtAttachName.Text   = objReader.ReadLine();
                    chkWinAuthen.Checked = Convert.ToBoolean(objReader.ReadLine());
                    txtUserID.Text       = objReader.ReadLine();
                    txtPassword.Text     = objReader.ReadLine();
                    txtOwner.Text        = objReader.ReadLine();
                    objReader.Close();
                }
                else
                {
                    MessageBox.Show("Invalid Configuration Parameter" + "\r" + "System Halted", MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    System.Environment.Exit(0);
                }


                chkWinAuthen_CheckedChanged(sender, e);
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message, MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 20
0
        private void cmdClient_Click(object sender, EventArgs e)
        {
            using (var form = new FrmList("Clients", "List of Clients"))
            {
                var result = form.ShowDialog();
                if (result == DialogResult.OK)
                {
                    tRefNo.Text          = form.ReturnValue.ToString();
                    tClientsDetails.Text = form.ReturnValue1.ToString() + " (" + form.ReturnValue2.ToString() + ")";
                    ClientOutline        = form.ReturnValue3.ToString();

                    GetSubLevel(tRefNo.Text);
                    tRewardBalance.Text = MyModules.FormatDouble(GetClientReward(tRefNo.Text));
                    tServiceValue_TextChanged(sender, e);
                }
            }
        }
Ejemplo n.º 21
0
        private void tReward_TextChanged(object sender, EventArgs e)
        {
            if (tRewardBalance.Text == "")
            {
                tRewardBalance.Text = "0";
            }
            if (tReward.Text == "")
            {
                tReward.Text = "0";
            }
            if (Convert.ToDouble(tReward.Text) > Convert.ToDouble(tRewardBalance.Text))
            {
                MessageBox.Show("Exceeds Available Reward", MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                tReward.Text = "0";
            }

            tAmountPaid.Text = MyModules.FormatDouble(Convert.ToDouble(tServiceValue.Text) - Convert.ToDouble(tReward.Text));
        }
        private void FrmProgramParameter_Load(object sender, EventArgs e)
        {
            try
            {
                numPyramidLevel.Value = MyModules.PyramidLevel;
                numPercent.Value      = Convert.ToDecimal(MyModules.PyramidPercent);
                numdrawable.Value     = Convert.ToDecimal(MyModules.PercentDrawable);

                MyModules.applyGridTheme(dGrid);
                dGrid.Columns[0].Width = 80;
                dGrid.Columns[1].Width = 200;
                dGrid.Columns[2].Width = 30;
                FillPyramidScale();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 23
0
        private void FrmSchoolListings_Load(object sender, EventArgs e)
        {
            dGrid.DataSource = BindingSource1;
            MyModules.applyGridTheme(dGrid);
            dGrid.ReadOnly = true;
            SplitContainer2.SplitterDistance = 322;
            cboCriteria.SelectedIndex        = 1;

            TV.BeginUpdate();
            TV.Nodes.Add("ALL", "ALL").ForeColor = Color.Red;

            TV.Nodes.Add("2016", "2016-Lot1");
            TV.Nodes.Add("2017", "2016-Lot2");
            TV.Nodes.Add("2018", "2016-Lot3");

            TV.EndUpdate();

            //  LoadTV();
        }
Ejemplo n.º 24
0
        public void GetRewardSummary()
        {
            try
            {
                SqlConnection cnSQL = new SqlConnection(MyModules.strConnect);
                SqlCommand    cmSQL = new SqlCommand();
                cmSQL.Connection = cnSQL;
                SqlDataReader drSQL;

                cnSQL.Open();

                cmSQL.CommandText = "SELECT ISNULL(SUM([Reward]),0) AS Reward,ISNULL(SUM(AmountDrawnFromReward),0) AS AmountDrawnFromReward FROM Ledger";
                cmSQL.CommandType = System.Data.CommandType.Text;
                drSQL             = cmSQL.ExecuteReader();
                if (drSQL.HasRows == false)
                {
                    lblRewardDrawn.Text       = "0.0";
                    lblRewardBalance.Text     = "0.0";
                    lblTotalRewardEarned.Text = "0.0";
                }
                else
                {
                    if (drSQL.Read())
                    {
                        lblRewardDrawn.Text       = MyModules.FormatDouble(drSQL["AmountDrawnFromReward"]);
                        lblRewardBalance.Text     = MyModules.FormatDouble(Convert.ToDouble(drSQL["Reward"]) - Convert.ToDouble(drSQL["AmountDrawnFromReward"]));
                        lblTotalRewardEarned.Text = MyModules.FormatDouble(drSQL["Reward"]);
                    }
                }


                //cmSQL.Connection.Close()
                cmSQL.Dispose();
                drSQL.Close();
                cnSQL.Close();
                //cnSQL.Dispose()
            }
            catch //(Exception ex)
            {
                // MessageBox.Show(ex.Message, MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 25
0
 private void tReward_Leave(object sender, EventArgs e)
 {
     tReward.Text = MyModules.FormatDouble(tReward.Text);
 }
Ejemplo n.º 26
0
        private void cmdAttach_Click(object sender, EventArgs e)
        {
            try
            {
                string connectStr = null;
                if (string.IsNullOrEmpty(txtDBName.Text.Trim()))
                {
                    MessageBox.Show("Pls. select the database", MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                if (chkWinAuthen.Checked)
                {
                    connectStr = "workstation id=" + cboServerName.Text + ";packet size=4096;data source=" + cboServerName.Text + ";Integrated Security=True;initial catalog=master";
                }
                else
                {
                    connectStr = "workstation id=" + cboServerName.Text + ";packet size=4096;user id=" + txtUserID.Text + ";pwd=" + txtPassword.Text + ";data source=" + cboServerName.Text + ";persist security info=False;initial catalog=master";
                }

                SqlConnection SqlCn = new SqlConnection(connectStr);
                SqlCn.Open();
                if (txtAttachName.Text.Trim().Length == 0)
                {
                    MessageBox.Show("Pls. choose a valid data file", MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                // ERROR: Not supported in C#: OnErrorStatement

                //'Dim myTrans As SqlTransaction
                //'myTrans = SqlCn.BeginTransaction(IsolationLevel.Serializable, "MyTrans")
                SqlCommand myCommand = new SqlCommand("FetchUserAccessByPwd", SqlCn);

                //'myCommand.Transaction = myTrans

                myCommand.CommandText = "EXEC sp_detach_db @dbname = '" + cboavaliableDB.Text + "'";
                myCommand.ExecuteNonQuery();

                // ERROR: Not supported in C#: OnErrorStatement

                myCommand.CommandText = "EXEC sp_attach_db @dbname = N'" + txtAttachName.Text + "',@filename1 = N'" + txtDBName.Text.Trim() + "',@filename2 = N'" + MyModules.Mid((txtDBName.Text.Trim()), 1, Microsoft.VisualBasic.Strings.InStr(txtDBName.Text.Trim(), ".") - 1) + ".ldf" + "'";
                myCommand.ExecuteNonQuery();
                //'myTrans.Commit()

                myCommand.Connection.Close();
                myCommand.Dispose();
                SqlCn.Close();
                SqlCn.Dispose();
                MessageBox.Show("Successfully Attached", MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message, MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 27
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);
            }
        }
Ejemplo n.º 28
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);
            }
        }
Ejemplo n.º 29
0
 private void tServiceValue_Leave(object sender, EventArgs e)
 {
     tServiceValue.Text = MyModules.FormatDouble(tServiceValue.Text);
     tReward.Text       = "0";
     tAmountPaid.Text   = "0";
 }
Ejemplo n.º 30
0
 private void tAmountPaid_Leave(object sender, EventArgs e)
 {
     tAmountPaid.Text = MyModules.FormatDouble(tAmountPaid.Text);
 }