Esempio n. 1
0
        public override void edit_button_Click(object sender, EventArgs e)
        {
            if (name_textBox.Text == "" || phone_textBox.Text == "" || address_textBox.Text == "" || password_textBox.Text == "" || username_textBox.Text == "" || roles_comboBox.SelectedIndex == -1)
            {
                CodingSourceClass.ShowMsg("Please select a record to edit.", "Error");

                enable_crud_buttons();

                CodingSourceClass.disable_reset(left_panel);
            }
            else
            {
                CodingSourceClass.enable(left_panel);

                edit = true;                   //editing option enabled

                add_button.Enabled = false;    //can't add

                delete_button.Enabled = false; //can't delete

                view_button.Enabled = false;   //can't view

                save_button.Enabled = true;    //can save after editing
            }
        }
Esempio n. 2
0
        private void PAYMENT_Load(object sender, EventArgs e)
        {
            try
            {
                edit_button.Enabled = false;

                LoadPayments();

                SQL_TASKS.LoadList("st_getSHOPS", shop_comboBox_payments, "ID", "Name");

                cheque_no_textBox.Visible = false; cheque_no_label.Visible = false;

                bank_and_branch_label.Visible = false; bank_and_branch_textBox.Visible = false;

                clearing_date_label.Visible = false; clearing_date_dateTimePicker.Visible = false;

                base.edit_button.Text = "CANNOT EDIT";

                CodingSourceClass.disable_reset(left_panel);
            }
            catch (Exception ex)
            {
                CodingSourceClass.ShowMsg(ex.Message, "Error");

                CodingSourceClass.disable_reset(left_panel);

                enable_crud_buttons();
            }
        }
Esempio n. 3
0
        public override void edit_button_Click(object sender, EventArgs e)
        {
            if (roles_textBox.Text == "" || roles_textBox.Enabled == true)
            {
                CodingSourceClass.ShowMsg("Please select a record to edit.", "Error");

                enable_crud_buttons();

                CodingSourceClass.disable_reset(left_panel);
            }
            else
            {
                CodingSourceClass.enable(left_panel);

                edit = true;

                add_button.Enabled = false;    //can't add

                delete_button.Enabled = false; //can't delete

                view_button.Enabled = false;   //can't view

                save_button.Enabled = true;
            }
        }
Esempio n. 4
0
        private void sales_invoice_comboBox_payments_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (sales_invoice_comboBox_payments.SelectedIndex != -1)
                {
                    Hashtable ht = new Hashtable();

                    ht.Add("@custID", Convert.ToInt32(customer_comboBox_payments.SelectedValue.ToString()));

                    ht.Add("@salesinvoiceID", Convert.ToInt64(sales_invoice_comboBox_payments.SelectedValue.ToString()));

                    double[] arr = SQL_TASKS.SaleInvoiceAmounts("st_getSALESINVOICEAMOUNT", ht);

                    total_amount_textBox_payments.Text = arr[0].ToString();

                    amount_paid_textBox_payments.Text = arr[1].ToString();

                    remaining_amount_textBox_payments.Text = arr[2].ToString();
                }
            }
            catch (Exception ex)
            {
                CodingSourceClass.ShowMsg(ex.Message, "Error");

                CodingSourceClass.disable_reset(left_panel); enable_crud_buttons();
            }
        }
        private void SALES_RETURN_Load(object sender, EventArgs e)
        {
            try
            {
                CodingSourceClass.disable_reset(left_panel);

                edit_button.Enabled = false; delete_button.Enabled = false;

                LoadSalesReturn();

                SQL_TASKS.LoadList("st_getSHOPS", shop_comboBox_salesreturn, "ID", "Name");

                base.delete_button.Text = "CANNOT DELETE"; base.delete_button.Enabled = false;

                base.edit_button.Text = "CANNOT EDIT"; base.edit_button.Enabled = false;
            }
            catch (Exception ex)
            {
                CodingSourceClass.ShowMsg(ex.Message, "Error");

                CodingSourceClass.disable_reset(left_panel);

                enable_crud_buttons();
            }
        }
Esempio n. 6
0
        public static void load_data(string proc, DataGridView dv, ListBox lb)
        {
            try
            {
                SqlConnection sql_con = new SqlConnection(CodingSourceClass.connection());

                SqlCommand command = new SqlCommand(proc, sql_con);

                command.CommandType = CommandType.StoredProcedure;

                SqlDataAdapter adapter = new SqlDataAdapter(command);

                DataTable dat = new DataTable();

                adapter.Fill(dat);

                for (int i = 0; i < lb.Items.Count; i++)
                {
                    string colName1 = ((DataGridViewColumn)lb.Items[i]).Name;

                    dv.Columns[colName1].DataPropertyName = dat.Columns[i].ToString();
                }

                dv.DataSource = dat;
            }
            catch (Exception ex)
            {
                CodingSourceClass.ShowMsg(ex.Message, "Error");
            }
        }
Esempio n. 7
0
        //to be fixed
        //overloaded version:
        public static void load_roles_like(DataGridView dv, DataGridViewColumn RoleGV, string data)
        {
            SqlConnection sql_con = new SqlConnection(CodingSourceClass.connection());

            try
            {
                SqlCommand cmd = new SqlCommand();

                cmd.CommandText = "st_getROLESlike";

                cmd.Parameters.AddWithValue("@data", data);

                cmd.Connection = sql_con;

                cmd.CommandType = CommandType.StoredProcedure;

                SqlDataAdapter sqladp = new SqlDataAdapter(cmd);

                DataTable dt = new DataTable();

                sqladp.Fill(dt);

                RoleGV.DataPropertyName = dt.Columns["Role"].ToString();

                dv.DataSource = dt;
            }
            catch (Exception ex)
            {
                CodingSourceClass.ShowMsg(ex.Message, "Error");
            }
        }
Esempio n. 8
0
        public override void edit_button_Click(object sender, EventArgs e)
        {
            try
            {
                if (shops_comboBox_customers.SelectedIndex == -1)
                {
                    throw new Exception("Please select a record to edit.");
                }
                else
                {
                    CodingSourceClass.enable(left_panel);

                    edit = true;                   //editing option enabled

                    add_button.Enabled = false;    //can't add

                    delete_button.Enabled = false; //can't delete

                    view_button.Enabled = false;   //can't view

                    save_button.Enabled = true;    //can save after editing
                }
            }
            catch (Exception ex)
            {
                CodingSourceClass.ShowMsg(ex.Message, "Error");

                CodingSourceClass.disable_reset(left_panel); enable_crud_buttons();
            }
        }
Esempio n. 9
0
        public static void LoadList(string proc, ComboBox cb, string valueMember, string displayMember)
        {
            try
            {
                cb.Items.Clear();

                SqlConnection sql = new SqlConnection(CodingSourceClass.connection());

                SqlCommand cmd = new SqlCommand(proc, sql);

                cmd.CommandType = CommandType.StoredProcedure;

                SqlDataAdapter da = new SqlDataAdapter(cmd);

                DataTable dt = new DataTable(); da.Fill(dt);

                cb.DisplayMember = displayMember; cb.ValueMember = valueMember;

                cb.DataSource = dt; cb.SelectedIndex = -1;
            }
            catch (Exception ex)
            {
                CodingSourceClass.ShowMsg(ex.Message, "Error");
            }
        }
Esempio n. 10
0
        public static int insert_update_delete(string proc, Hashtable ht)
        {
            int res = 0;

            try
            {
                SqlConnection sql_con = new SqlConnection(CodingSourceClass.connection());

                SqlCommand cmd = new SqlCommand(proc, sql_con);

                cmd.CommandType = CommandType.StoredProcedure;

                foreach (DictionaryEntry item in ht)
                {
                    cmd.Parameters.AddWithValue(item.Key.ToString(), item.Value);
                }
                sql_con.Open();

                //returns an integer which indicates how many rows have been affected
                res = cmd.ExecuteNonQuery();

                sql_con.Close();
            }
            catch (Exception ex)
            {
                CodingSourceClass.ShowMsg(ex.Message, "Error");
            }

            return(res);
        }
Esempio n. 11
0
        private void send_code_button_Click(object sender, EventArgs e)
        {
            if (email_address_textBox.Text == "")
            {
                CodingSourceClass.ShowMsg("Please enter email address.", "error");
            }
            else
            {
                try
                {
                    Random r = new Random();

                    x = r.Next(1, 1000000); //Generating 6-digit verification code

                    SmtpClient cl = new SmtpClient("smtp.gmail.com");

                    cl.Port = 587;

                    cl.Credentials = new System.Net.NetworkCredential("*****@*****.**", "syedkamranali90.");

                    cl.EnableSsl = true;

                    MailMessage mail = new MailMessage("*****@*****.**", email_address_textBox.Text, "VERIFICATION CODE", "Your confirmation code is " + x.ToString() + ".");

                    cl.Send(mail);

                    MessageBox.Show("A code is sent to " + email_address_textBox.Text + ".Enter code to verify it.", "CODE SENT...", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    CodingSourceClass.ShowMsg(ex.Message, "error");
                }
            }
        }
Esempio n. 12
0
        private void users_dataGridView_CellClick_1(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex != -1)
                {
                    add_button.Enabled = false;

                    if (edit == true) //updating member
                    {
                        save_button.Enabled = true;
                    }
                    else if (edit == false) //adding member
                    {
                        save_button.Enabled = false;
                    }

                    DataGridViewRow row = users_dataGridView.Rows[e.RowIndex];

                    userID = Convert.ToInt32(row.Cells[0].Value.ToString());

                    name_textBox.Text = row.Cells[1].Value.ToString();

                    username_textBox.Text = row.Cells[2].Value.ToString();

                    password_textBox.Text = row.Cells[3].Value.ToString();

                    phone_textBox.Text = row.Cells[4].Value.ToString();

                    address_textBox.Text = row.Cells[5].Value.ToString();

                    roles_comboBox.SelectedValue = row.Cells[6].Value;

                    CodingSourceClass.disable(left_panel);

                    delete_button.Enabled = true;

                    edit_button.Enabled = true;

                    save_button.Enabled = false;

                    cancel_button.Enabled = true;

                    view_button.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                CodingSourceClass.ShowMsg(ex.Message, "Error");

                enable_crud_buttons();

                CodingSourceClass.disable_reset(left_panel);
            }
        }
        private void save_new_details_button_change_Click(object sender, EventArgs e)
        {
            try
            {
                if (new_password_textBox_change.Text != "" && admin_radioButton.Checked == true && other_radioButton.Checked == false)
                {
                    Hashtable ht = new Hashtable();

                    ht.Add("@username", usernameGLOBAL);

                    ht.Add("@password", new_password_textBox_change.Text);

                    if (SQL_TASKS.insert_update_delete("st_updateAdminPASSWORD", ht) > 0)
                    {
                        CodingSourceClass.ShowMsg("Password changed successfully.", "Success");

                        clear(); sq.Close();
                    }
                    else
                    {
                        throw new Exception("An error occured.");
                    }
                }
                else if (new_password_textBox_change.Text != "" && admin_radioButton.Checked == false && other_radioButton.Checked == true)
                {
                    Hashtable ht = new Hashtable();

                    ht.Add("@username", usernameGLOBAL);

                    ht.Add("@password", new_password_textBox_change.Text);

                    if (SQL_TASKS.insert_update_delete("st_updateUSERPASSWORD", ht) > 0)
                    {
                        CodingSourceClass.ShowMsg("Password changed successfully.", "Success");

                        clear(); sq.Close();
                    }
                    else
                    {
                        throw new Exception("An error occured.");
                    }
                }
                else
                {
                    throw new Exception("Please fill all required fields properly.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                sq.Close();
            }
        }
Esempio n. 14
0
        public override void delete_button_Click(object sender, EventArgs e)
        {
            try
            {
                if (roles_textBox.Text != "" && roles_textBox.Enabled == false)
                {
                    Hashtable ht = new Hashtable();

                    DialogResult dr = MessageBox.Show("Are you sure? ", "Question.....", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (dr == DialogResult.Yes)
                    {
                        //key ,  value
                        ht.Add("@id", roleID);

                        if (SQL_TASKS.insert_update_delete("st_deleteROLES", ht) > 0)
                        {
                            MainClass.CodingSourceClass.ShowMsg(roles_textBox.Text + " deleted successfully from the system.", "Success");

                            CodingSourceClass.disable_reset(left_panel);

                            enable_crud_buttons();

                            LoadRoles();

                            SQL_TASKS.TotalRecords("getTOTALROLES", total_roles_label);
                        }
                        else
                        {
                            CodingSourceClass.ShowMsg("Unable to delete.", "Error");

                            CodingSourceClass.disable_reset(left_panel);

                            enable_crud_buttons();
                        }
                    }
                }
                else
                {
                    CodingSourceClass.ShowMsg("Select a record to delete.", "Error");

                    enable_crud_buttons();

                    CodingSourceClass.disable_reset(left_panel);
                }
            }
            catch (Exception ex)
            {
                CodingSourceClass.ShowMsg(ex.Message, "Error");

                CodingSourceClass.disable_reset(left_panel); enable_crud_buttons();
            }
        }
        private void save_settings_button_Click(object sender, EventArgs e)
        {
            try
            {
                bool windowsAuth;

                if (integrated_checkBox_settings.Checked)
                {
                    if (server_name_textBox_settings.Text != "" && database_textBox_settings.Text != "")
                    {
                        windowsAuth = true;

                        CodingSourceClass.createFile("\\bms_connect", windowsAuth, server_name_textBox_settings.Text, database_textBox_settings.Text);

                        login log = new login();

                        CodingSourceClass.ShowWindow(log, this, MDI.ActiveForm);
                    }
                    else
                    {
                        CodingSourceClass.ShowMsg("Please fill all required fields", "Error");
                    }
                }
                else
                {
                    if (server_name_textBox_settings.Text != "" && database_textBox_settings.Text != "" && username_textBox_settings.Text != "" && password_textBox_settings.Text != "")
                    {
                        windowsAuth = false;

                        bool result = CodingSourceClass.createFile("\\bms_connect", windowsAuth, server_name_textBox_settings.Text, database_textBox_settings.Text, username_textBox_settings.Text, password_textBox_settings.Text);

                        if (result == true)
                        {
                            login log = new login();

                            CodingSourceClass.ShowWindow(log, this, MDI.ActiveForm);

                            LoginCodeClass.set_logged(true);
                        }
                    }
                    else
                    {
                        LoginCodeClass.set_logged(false);

                        CodingSourceClass.ShowMsg("Please fill all required fields", "Error");
                    }
                }
            }
            catch (Exception ex)
            {
                CodingSourceClass.ShowMsg(ex.Message, "Error");
            }
        }
Esempio n. 16
0
        private void users_button_Click(object sender, EventArgs e)
        {
            if (LoginCodeClass.isAdmin == true)
            {
                USERS us = new USERS();

                CodingSourceClass.ShowWindow(us, MDI.ActiveForm);
            }
            else
            {
                CodingSourceClass.ShowMsg("You do not have permission to view users.", "Error");
            }
        }
Esempio n. 17
0
        private void roles_button_Click(object sender, EventArgs e)
        {
            if (LoginCodeClass.isAdmin == true)
            {
                ROLES rl = new ROLES();

                CodingSourceClass.ShowWindow(rl, MDI.ActiveForm);
            }
            else
            {
                CodingSourceClass.ShowMsg("You do not have permission to view roles.", "Error");
            }
        }
        private void logoutToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (LoginCodeClass.get_logged() == true)
            {
                login lg = new login();

                CodingSourceClass.ShowWindow(lg, MDI.ActiveForm);
            }
            else
            {
                CodingSourceClass.ShowMsg("Already logged out!", "Error");
            }
        }
Esempio n. 19
0
        private void verify_code_button_Click(object sender, EventArgs e)
        {
            if (x.ToString() == verification_code_textBox.Text)
            {
                disabled_new_details_label.Text = "ENABLED";

                disable_control_panel.Enabled = true;
            }
            else
            {
                CodingSourceClass.ShowMsg("Incorrect code.", "error");
            }
        }
Esempio n. 20
0
        private void customers_dataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex != -1)
                {
                    add_button.Enabled = false;

                    if (edit == true) //updating member
                    {
                        save_button.Enabled = true;
                    }
                    else if (edit == false) //adding member
                    {
                        save_button.Enabled = false;
                    }

                    DataGridViewRow row = customers_dataGridView.Rows[e.RowIndex];

                    customerID = Convert.ToInt32(row.Cells[0].Value.ToString());

                    customer_name_textBox.Text = row.Cells["CustomernameGV"].Value.ToString();

                    shops_comboBox_customers.SelectedValue = Convert.ToInt32(row.Cells["ShopIDGV"].Value.ToString());

                    email_textBox_customers.Text = row.Cells["CustomeremailGV"].Value.ToString();

                    phone_textBox_customers.Text = row.Cells["CustomerphoneGV"].Value.ToString();

                    CodingSourceClass.disable(left_panel);

                    delete_button.Enabled = true;

                    edit_button.Enabled = true;

                    save_button.Enabled = false;

                    cancel_button.Enabled = true;

                    view_button.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                CodingSourceClass.ShowMsg(ex.Message, "Error");

                CodingSourceClass.disable_reset(left_panel);

                enable_crud_buttons();
            }
        }
        public static bool getlogindetails(string proc, Hashtable ht)
        {
            bool check = false;

            try
            {
                SqlConnection sql_con = new SqlConnection(MainClass.CodingSourceClass.connection());

                SqlCommand cmd = new SqlCommand(proc, sql_con);

                cmd.CommandType = CommandType.StoredProcedure;

                foreach (DictionaryEntry item in ht)
                {
                    cmd.Parameters.AddWithValue(item.Key.ToString(), item.Value);
                }

                sql_con.Open();

                SqlDataReader dr = cmd.ExecuteReader();

                if (dr.HasRows)
                {
                    check = true;

                    while (dr.Read())
                    {
                        USERID = Convert.ToInt32(dr[0].ToString());
                        NAME   = dr[1].ToString();

                        ROLEID = Convert.ToInt32(dr[2].ToString());
                        ROLE   = dr[3].ToString();
                    }
                }
                else
                {
                    check = false;

                    CodingSourceClass.ShowMsg("Invalid username or password", "Error");
                }

                sql_con.Close();
            }
            catch (Exception ex)
            {
                CodingSourceClass.ShowMsg(ex.Message, "Error");
            }

            return(check);
        }
Esempio n. 22
0
        public override void delete_button_Click(object sender, EventArgs e)
        {
            try
            {
                if (true)
                {
                    Hashtable ht = new Hashtable();

                    DialogResult dr = MessageBox.Show("Are you sure? ", "Question.....", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (dr == DialogResult.Yes)
                    {
                        ht.Add("@payid", paymentID);

                        if (SQL_TASKS.insert_update_delete("st_deletePAYMENTS", ht) > 0)
                        {
                            CodingSourceClass.ShowMsg("Record deleted successfully from the system.", "Success");

                            enable_crud_buttons();

                            CodingSourceClass.disable_reset(left_panel);

                            LoadPayments();
                        }
                        else
                        {
                            CodingSourceClass.ShowMsg("Unable to delete.An error occured.", "Error");

                            enable_crud_buttons();

                            CodingSourceClass.disable_reset(left_panel);
                        }
                    }
                }
                else
                {
                    throw new Exception("Select a record to delete.");
                }
            }
            catch (Exception ex)
            {
                CodingSourceClass.ShowMsg(ex.Message, "Error");

                CodingSourceClass.disable_reset(left_panel); enable_crud_buttons();
            }
        }
Esempio n. 23
0
        public override void delete_button_Click(object sender, EventArgs e)
        {
            try
            {
                if (name_textBox.Text != "" && phone_textBox.Text != "" && address_textBox.Text != "" && password_textBox.Text != "" && username_textBox.Text != "" && roles_comboBox.SelectedIndex != -1)
                {
                    Hashtable ht = new Hashtable();

                    DialogResult dr = MessageBox.Show("Are you sure? ", "Question.....", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (dr == DialogResult.Yes)
                    {
                        ht.Add("@id", userID);

                        if (SQL_TASKS.insert_update_delete("st_deleteUSERS", ht) > 0)
                        {
                            CodingSourceClass.ShowMsg("Record deleted successfully from the system.", "Success");

                            enable_crud_buttons();

                            CodingSourceClass.disable_reset(left_panel);

                            LoadUsers();
                        }
                        else
                        {
                            CodingSourceClass.ShowMsg("Unable to delete.An error occured.", "Error");

                            enable_crud_buttons();

                            CodingSourceClass.disable_reset(left_panel);
                        }
                    }
                }
                else
                {
                    throw new Exception("Select a record to delete.");
                }
            }
            catch (Exception ex)
            {
                CodingSourceClass.ShowMsg(ex.Message, "Error");

                CodingSourceClass.disable_reset(left_panel); enable_crud_buttons();
            }
        }
Esempio n. 24
0
        private void SALES_INVOICE_Load(object sender, EventArgs e)
        {
            try
            {
                base.edit_button.Enabled = false;

                base.edit_button.Text = "CANNOT EDIT";

                LoadSalesInvoice();

                SQL_TASKS.LoadList("st_getSHOPS", shops_comboBox_sales_invoice, "ID", "Name");

                CodingSourceClass.disable_reset(left_panel);
            }
            catch (Exception ex)
            {
                CodingSourceClass.ShowMsg(ex.Message, "Error");
            }
        }
Esempio n. 25
0
        public override void delete_button_Click(object sender, EventArgs e)
        {
            try
            {
                if (shops_comboBox_sales_invoice.SelectedIndex == -1 || order_details_textBox.Text == "" || amount_textBox_sales_invoice.Text == "")
                {
                    throw new Exception("Please enter/select a record.");
                }
                else
                {
                    DialogResult dr = MessageBox.Show("SaleInvoice " + bill_no_textBox_salesinvoice.Text + "is associated with Payments,Sales Return and Vendor/Owner Ledger.\nDeleting this invoice will delete the particular data related to that invoice from Payments,Sales Return and Vendor/Owner Ledger.\nAlso particular data of Customer Leder which is associated with Payments will be deleted.\nWe recommend you to not delete this.\nAre you sure you want to delete?", "!!!WARNING!!!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                    if (DialogResult.Yes == dr)
                    {
                        Hashtable ht = new Hashtable();

                        ht.Add("@salesinvoiceID", salesinvoiceID);

                        if (SQL_TASKS.insert_update_delete("st_deleteSALESINVOICE", ht) > 0)
                        {
                            CodingSourceClass.ShowMsg("Record deleted successfully.", "Success");

                            CodingSourceClass.disable_reset(left_panel); enable_crud_buttons();

                            LoadSalesInvoice();
                        }
                        else
                        {
                            throw new Exception("Unabled to delete record.");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CodingSourceClass.ShowMsg(ex.Message, "Error");

                CodingSourceClass.disable_reset(left_panel);

                enable_crud_buttons();
            }
        }
Esempio n. 26
0
        private void load_button_ledger_Click(object sender, EventArgs e)
        {
            try
            {
                if (shop_comboBox_ledger.SelectedIndex == -1 || customers_comboBox_ledger.SelectedIndex == -1 || (complete_ledger_radioButton.Checked == false && range_radioButton.Checked == false))
                {
                    CodingSourceClass.ShowMsg("Please enter/select a record.", "Error");
                }
                else if (shop_comboBox_ledger.SelectedIndex != -1 && customers_comboBox_ledger.SelectedIndex != -1)
                {
                    Hashtable ht = new Hashtable();

                    ht.Add("@custID", Convert.ToInt32(customers_comboBox_ledger.SelectedValue.ToString()));

                    ht.Add("@shopID", Convert.ToInt32(shop_comboBox_ledger.SelectedValue.ToString()));

                    string path = Application.StartupPath + "\\Reports\\CustomerLedger.rpt";

                    if (range_radioButton.Checked == true && complete_ledger_radioButton.Checked == false)
                    {
                        ht.Add("@from", FROM_dateTimePicker.Value);

                        ht.Add("@to", TO_dateTimePicker.Value);

                        SQL_TASKS.LoadReport("st_getCUSTOMERLEDGERwrtRANGE", crystalReportViewer1, ht, rd, path);
                    }
                    else if (range_radioButton.Checked == false && complete_ledger_radioButton.Checked == true)
                    {
                        SQL_TASKS.LoadReport("st_getCUSTOMERLEDGER", crystalReportViewer1, ht, rd, path);
                    }
                }
            }
            catch (Exception ex)
            {
                CodingSourceClass.ShowMsg(ex.Message, "Error");

                if (rd != null)
                {
                    rd.Close();
                }
            }
        }
Esempio n. 27
0
        public override void edit_button_Click(object sender, EventArgs e)
        {
            if (shop_name_textBox.Text == "" || vendors_comboBox_shops.SelectedIndex == -1 || shop_branch_address_textBox.Text == "" || managers_comboBox_shops.SelectedIndex == -1)
            {
                CodingSourceClass.ShowMsg("Please select a record to edit.", "Error");
            }
            else
            {
                CodingSourceClass.enable(left_panel);

                edit = true;                   //editing option enabled

                add_button.Enabled = false;    //can't add

                delete_button.Enabled = false; //can't delete

                view_button.Enabled = false;   //can't view

                save_button.Enabled = true;    //can save after editing
            }
        }
Esempio n. 28
0
        public override void delete_button_Click(object sender, EventArgs e)
        {
            try
            {
                if (shop_name_textBox.Text != "" || vendors_comboBox_shops.SelectedIndex != -1 || shop_branch_address_textBox.Text != "" || managers_comboBox_shops.SelectedIndex != -1)
                {
                    Hashtable ht = new Hashtable();

                    DialogResult dr = MessageBox.Show("Are you sure? ", "Question.....", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (dr == DialogResult.Yes)
                    {
                        ht.Add("@id", shopID);

                        if (SQL_TASKS.insert_update_delete("st_deleteSHOPS", ht) > 0)
                        {
                            CodingSourceClass.ShowMsg("Record deleted successfully from the system.", "Success");

                            CodingSourceClass.disable_reset(left_panel);

                            enable_crud_buttons();

                            LoadShops();
                        }
                    }
                }
                else
                {
                    throw new Exception("Select a record to delete.");
                }
            }
            catch (Exception ex)
            {
                CodingSourceClass.ShowMsg(ex.Message, "Error");

                CodingSourceClass.disable_reset(left_panel);

                enable_crud_buttons();
            }
        }
Esempio n. 29
0
        private void payments_dataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex != -1)
                {
                    add_button.Enabled = false;

                    if (edit == true) //updating member
                    {
                        save_button.Enabled = true;
                    }
                    else if (edit == false) //adding member
                    {
                        save_button.Enabled = false;
                    }

                    DataGridViewRow row = payments_dataGridView.Rows[e.RowIndex];

                    paymentID = Convert.ToInt32(row.Cells[0].Value.ToString());

                    customer_comboBox_payments.Text = row.Cells["customernameGV"].Value.ToString();

                    sales_invoice_comboBox_payments.Text = row.Cells["billnoGV"].Value.ToString();

                    shop_comboBox_payments.Text = row.Cells["shopGV"].Value.ToString();

                    customerID = Convert.ToInt32(row.Cells["customerIDGV"].Value);

                    salesinvoiceID = Convert.ToInt32(row.Cells["salesinvoiceIDGV"].Value);

                    if (/*sales_invoice_comboBox_payments.SelectedIndex != -1*/ true)
                    {
                        Hashtable ht = new Hashtable();

                        ht.Add("@custID", customerID);

                        ht.Add("@salesinvoiceID", salesinvoiceID);

                        double[] arr = SQL_TASKS.SaleInvoiceAmounts("st_getSALESINVOICEAMOUNT", ht);

                        total_amount_textBox_payments.Text = arr[0].ToString();

                        amount_paid_textBox_payments.Text = arr[1].ToString();

                        remaining_amount_textBox_payments.Text = arr[2].ToString();
                    }

                    dateTimePicker_payments.Value = Convert.ToDateTime(row.Cells[1].Value);

                    userID = Convert.ToInt32(row.Cells[3].Value.ToString());

                    postedby = row.Cells[4].Value.ToString();

                    amount_to_pay_textBox_payments.Text = row.Cells[10].Value.ToString();

                    cheque_no_textBox.Text = row.Cells[11].Value.ToString();

                    bank_and_branch_textBox.Text = row.Cells[12].Value.ToString();

                    clearing_date_dateTimePicker.Text = row.Cells["clearingdateGV"].Value.ToString();

                    if (cheque_no_textBox.Text == "" && bank_and_branch_textBox.Text == "")
                    {
                        cash_radioButton_sales_invoice.Checked = true;
                    }
                    else
                    {
                        cheque_radioButton.Checked = true;
                    }

                    CodingSourceClass.disable(left_panel);

                    delete_button.Enabled = true;

                    edit_button.Enabled = true;

                    save_button.Enabled = false;

                    cancel_button.Enabled = true;

                    view_button.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                CodingSourceClass.ShowMsg(ex.Message, "Error");

                enable_crud_buttons();

                CodingSourceClass.disable_reset(left_panel);
            }
        }
Esempio n. 30
0
        public override void save_button_Click(object sender, EventArgs e)
        {
            try
            {
                if (shop_comboBox_payments.SelectedIndex == -1 || customer_comboBox_payments.SelectedIndex == -1 || sales_invoice_comboBox_payments.SelectedIndex == -1 || total_amount_textBox_payments.Text == "" || amount_paid_textBox_payments.Text == "" || remaining_amount_textBox_payments.Text == "" || amount_to_pay_textBox_payments.Text == "" || (cash_radioButton_sales_invoice.Checked == false && cheque_radioButton.Checked == false))
                {
                    throw new Exception("Please enter/select a record.");
                }
                else if ((shop_comboBox_payments.SelectedIndex != -1 && customer_comboBox_payments.SelectedIndex != -1 && sales_invoice_comboBox_payments.SelectedIndex != -1 && total_amount_textBox_payments.Text != "" && amount_paid_textBox_payments.Text != "" && remaining_amount_textBox_payments.Text != "" && amount_to_pay_textBox_payments.Text != "" && cheque_radioButton.Checked == true) && (clearing_date_dateTimePicker.Text == "" || bank_and_branch_textBox.Text == "" || cheque_no_textBox.Text == ""))
                {
                    throw new Exception("Please enter/select a record.");
                }
                else
                {
                    if (Convert.ToDouble(amount_to_pay_textBox_payments.Text) > Convert.ToDouble(total_amount_textBox_payments.Text))
                    {
                        throw new Exception("Amount to pay cannot be greater than total amount.");
                    }
                    else
                    {
                        double debit = 0, credit = 0, bal = 0;

                        using (TransactionScope sc = new TransactionScope())
                        {
                            Hashtable ht = new Hashtable();

                            if (cash_radioButton_sales_invoice.Checked == true)
                            {
                                ht.Add("@salesinvoiceid", Convert.ToInt32(sales_invoice_comboBox_payments.SelectedValue.ToString()));

                                ht.Add("@amount", Convert.ToInt32(amount_to_pay_textBox_payments.Text));

                                ht.Add("@date", dateTimePicker_payments.Value);

                                if (LoginCodeClass.isAdmin)
                                {
                                    throw new Exception("Admin cannot enter payments.");
                                }
                                else
                                {
                                    ht.Add("@userID", LoginCodeClass.USERID);
                                }

                                SQL_TASKS.insert_update_delete("st_insertPAYMENTSwrtCASH", ht);
                            }
                            else
                            {
                                ht.Add("@salesinvoiceid", Convert.ToInt32(sales_invoice_comboBox_payments.SelectedValue.ToString()));

                                ht.Add("@amount", Convert.ToInt32(amount_to_pay_textBox_payments.Text));

                                ht.Add("@date", dateTimePicker_payments.Value);

                                if (LoginCodeClass.isAdmin)
                                {
                                    ht.Add("@userID", LoginCodeClass.idOFadmin);
                                }
                                else
                                {
                                    ht.Add("@userID", LoginCodeClass.USERID);
                                }

                                ht.Add("@cheque", cheque_no_textBox.Text);

                                ht.Add("@bank", bank_and_branch_textBox.Text);

                                ht.Add("@clearing", clearing_date_dateTimePicker.Value);

                                SQL_TASKS.insert_update_delete("st_insertPAYMENTSwrtCHEQUE", ht);
                            }

                            Hashtable loadht = new Hashtable();

                            loadht.Add("@custID", Convert.ToInt32(customer_comboBox_payments.SelectedValue.ToString()));

                            loadht.Add("@shopID", Convert.ToInt32(shop_comboBox_payments.SelectedValue.ToString()));

                            double[] dd = SQL_TASKS.LoadLastBalance("st_getLASTBALANCES", loadht);

                            bal = dd[0];     //customer balance

                            debit = 0;

                            credit = Convert.ToDouble(amount_to_pay_textBox_payments.Text);

                            bal += debit - credit;

                            Hashtable ht2 = new Hashtable();

                            Int64 salesinvoiceID = Convert.ToInt64(sales_invoice_comboBox_payments.SelectedValue.ToString());

                            DataRowView drvcustomer = customer_comboBox_payments.SelectedItem as DataRowView;

                            DataRowView drvshop = shop_comboBox_payments.SelectedItem as DataRowView;

                            DataRowView drvsalesinvoice = sales_invoice_comboBox_payments.SelectedItem as DataRowView;

                            ht2.Add("@custID", Convert.ToInt32(customer_comboBox_payments.SelectedValue.ToString()));

                            ht2.Add("@desc", drvcustomer[1].ToString() + " has done the payment of Rs. " + amount_to_pay_textBox_payments.Text + " on bill # " + drvsalesinvoice[1].ToString() + " to " + drvshop[1].ToString());

                            ht2.Add("@debit", debit);

                            ht2.Add("@credit", credit);

                            ht2.Add("@balance", bal);

                            ht2.Add("@date", dateTimePicker_payments.Value);

                            ht2.Add("@salesinvoiceid", salesinvoiceID);

                            SQL_TASKS.insert_update_delete("st_insertCUSTOMERLEDGER", ht2);

                            bal = dd[1];     //shop balance

                            debit = Convert.ToDouble(amount_to_pay_textBox_payments.Text);

                            credit = 0;

                            bal += debit - credit;

                            Hashtable ht3 = new Hashtable();

                            ht3.Add("@shopID", Convert.ToInt32(shop_comboBox_payments.SelectedValue.ToString()));

                            ht3.Add("@desc", drvshop[1].ToString() + " has received Rs. " + amount_to_pay_textBox_payments.Text + " as paid from customer " + drvcustomer[1].ToString() + " on bill # " + drvsalesinvoice[1].ToString());

                            ht3.Add("@debit", debit);

                            ht3.Add("@credit", credit);

                            ht3.Add("@balance", bal);

                            ht3.Add("@date", dateTimePicker_payments.Value);

                            ht3.Add("@salesinvoiceid", salesinvoiceID);

                            SQL_TASKS.insert_update_delete("insertVENDORLEDGER", ht3);

                            Hashtable ht4 = new Hashtable();

                            if (Convert.ToDouble(amount_to_pay_textBox_payments.Text) == Convert.ToDouble(total_amount_textBox_payments.Text))
                            {
                                //complete payment

                                ht4.Add("@status", 2);
                            }
                            else if (Convert.ToDouble(amount_to_pay_textBox_payments.Text) < Convert.ToDouble(total_amount_textBox_payments.Text))
                            {
                                //partial payment

                                ht4.Add("@status", 1);
                            }

                            /*else //if status == 2
                             * {
                             *  ht4.Add("@status", 0);
                             * }*/

                            ht4.Add("@salesinvoiceid", salesinvoiceID);

                            CodingSourceClass.ShowMsg("Record added successfully into the system.", "Success");

                            CodingSourceClass.disable_reset(left_panel);

                            LoadPayments();

                            sc.Complete();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CodingSourceClass.ShowMsg(ex.Message, "Error");
            }
        }