예제 #1
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);
        }