Exemplo n.º 1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Do You really want to delete this Sales Record?", "DELETE", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
            {
                int refsales = (int)gridAll.Rows[gridAll.CurrentRow.Index].Cells[0].Value;

                if (admin.Delete_Sales(refsales))
                {
                    MessageBox.Show("Sales Record ID" + refsales + " is successfully Deleted", "Sales Deleted");
                }
                else
                {
                    MessageBox.Show("Sales Record ID " + refsales + " is not deleted.", "Try Again");
                }
            }
            admin.Refresh_Database();
            if (permission != 2)
            {
                gridAll.DataSource = admin.All_Sales();
            }
            else
            {
                gridAll.DataSource = admin.Search_Sales_Belong_To_RefAgent(RefAgent);
            }
            ButtonControl(true, true, false, false, true, false);
        }
Exemplo n.º 2
0
        private void frmSales_Load(object sender, EventArgs e)
        {
            admin = new clsAdmin();
            DataTable temp = new DataTable();

            // fill cboHouse
            cboHouse.DisplayMember = "Address";
            cboHouse.ValueMember   = "RefHouse";
            cboHouse.DataSource    = admin.HouseListToDataTable(admin.Search_All_Houses());

            // fill cboClient
            cboClient.DisplayMember = "ClientName";
            cboClient.ValueMember   = "RefClient";
            cboClient.DataSource    = admin.ClientListToDataTable(admin.All_Client());

            // fill cboAgent
            cboAgent.DisplayMember = "AgentName";
            cboAgent.ValueMember   = "RefAgent";
            cboAgent.DataSource    = admin.AgentListToDataTable(admin.Search_All_Agents());

            if (permission != 2)
            {
                gridAll.DataSource = admin.All_Sales();
            }
            else
            {
                gridAll.DataSource = admin.Search_Sales_Belong_To_RefAgent(RefAgent);
            }
            gridAll.ReadOnly = true;
            ButtonControl(true, false, false, false, true, false);
        }
Exemplo n.º 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            clsAdmin admin = new clsAdmin();
            clsSales sales = new clsSales();

            sales.RefAgent    = Convert.ToInt32(cboAgent.SelectedValue);
            sales.RefClient   = Convert.ToInt32(cboClient.SelectedValue);
            sales.RefHouse    = Convert.ToInt32(cboHouse.SelectedValue);
            sales.Description = txtDescription.Text;
            sales.SalesDate   = DateTime.Parse(DateSales.Text);

            if (Addmode)
            {
                if (admin.Add_Sales(sales))
                {
                    MessageBox.Show("New Sales Record is successfully added", "New Sales Added");
                }
                else
                {
                    MessageBox.Show("The Sales Record is not added.", "Try Again");
                }
                admin.Refresh_Database();
            }
            else
            {
                sales.RefSales = (int)gridAll.Rows[gridAll.CurrentRow.Index].Cells[0].Value;

                if (admin.Edit_Sales(sales))
                {
                    MessageBox.Show("New Sales Record ID " + sales.RefSales + " is successfully modified", "Sales Modified");
                }
                else
                {
                    MessageBox.Show("The Sales Record " + sales.RefSales + " is not modified.", "Try Again");
                }
            }
            if (permission != 2)
            {
                gridAll.DataSource = admin.All_Sales();
            }
            else
            {
                gridAll.DataSource = admin.Search_Sales_Belong_To_RefAgent(RefAgent);
            }

            ButtonControl(true, true, false, false, true, false);
        }