Exemple #1
0
        private void  Btsave_Click(object sender, EventArgs e)
        {
            SaleRecordModel inputData = new SaleRecordModel();

            inputData.Id         = id.ToString();
            inputData.StaffName  = txtStaffName.Text;
            inputData.Time       = txtTime.Text;
            inputData.Date       = txtDate.Text;
            inputData.TotalPrice = Convert.ToInt32(txtTotalPrice.Text);

            SaleReportController controller = new SaleReportController();
            bool update = controller.UpdateData(inputData);


            if (update == true)
            {
                SaleReport report = new SaleReport();

                report.Show();
                this.Owner.Hide();
                MessageBox.Show("Update successfully");

                //saleReport.Show();
                Close();
            }
            else
            {
                MessageBox.Show("Unsuccessfully update");
            }
        }
Exemple #2
0
        private void BtDelete_Click(object sender, EventArgs e)
        {
            try
            {
                SaleRecordModel inputData = new SaleRecordModel();
                inputData.Id         = id.ToString();
                inputData.StaffName  = "";
                inputData.Time       = "";
                inputData.Date       = "";
                inputData.TotalPrice = 0;

                SaleReportController controller = new SaleReportController();
                bool delete = controller.DeleteValue(inputData);
                if (delete == true)
                {
                    SaleReport report = new SaleReport();
                    report.Show();
                    this.Owner.Hide();
                    MessageBox.Show("Delete successfully");

                    Close();
                }
                else
                {
                    MessageBox.Show("Unsuccessfully delete");
                }
            }catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #3
0
        private void LoadMonthlyData(monthInYear type, int year)
        {
            saleRecordModelBindingSource.Clear();
            SaleReportController controller = new SaleReportController();

            MySqlConnection connection =
                new MySqlConnection("server = " + connectData.server()
                                    + "; database = " + connectData.database()
                                    + "; username = "******"; password="******";");

            string       txt     = "select sum(totalprice) from salesrecord group by year(date)='" + year.ToString() + "'" + ", month(date)='" + type.ToString() + "'";
            MySqlCommand command = new MySqlCommand(txt, connection);

            connection.Open();
            MySqlDataReader r = command.ExecuteReader();

            MonthlyResult monthlyResult = new MonthlyResult((int)type, year);

            while (r.Read())
            {
                int total   = int.Parse(r[0].ToString());
                int monthly = Convert.ToInt32(type);
                //int totalItems = int.Parse(r[1].ToString());

                monthlyResult.LoadData(year, monthly, total);
            }
            monthlyResult.Show();
        }
        private void LoadGridViewMonth(int month, int year)
        {
            SaleReportController controller = new SaleReportController();

            foreach (var data in controller.GetALlSaleRecordByMonthAndYear((monthInYear)month, year))
            {
                saleRecordModelBindingSource1.Add(data);
            }
        }
Exemple #5
0
        /// <summary>
        ///we load all data to sale report when the user forget to set the year or if they
        ///want to see all sale report
        /// </summary>
        private void LoadDataToSaleReport()
        {
            saleRecordModelBindingSource.Clear();
            SaleReportController controller = new SaleReportController();

            foreach (var data in controller.GetAllSaleRecord())
            {
                saleRecordModelBindingSource.Add(data);
            }
        }
Exemple #6
0
        public Edit(int data)
        {
            InitializeComponent();
            SaleReportController controller = new SaleReportController();

            //get the sale record by ID
            SaleRecordModel saleEdit = controller.GetValueByID(data.ToString());

            id = data;
            Display(saleEdit);
        }
Exemple #7
0
        //we will load the weekly by get the week and the year and send the request to ask the datas of the weekly
        //to controller, then controller will do the rest.
        //after get the value from controller, we will store them to the saleRecord Model
        private void LoadWeeklyData(int week, int year)
        {
            //we call the controller to send the request
            SaleReportController controller = new SaleReportController();

            //firstly we have to clear the sale record to make sure it will be empty before reload it again
            saleRecordModelBindingSource.Clear();

            //View will send the request to controller to ask the value in specifict week in that year
            //then we will get each date in that week and show them in Sale record
            foreach (var data in controller.GetAllSaleRecordByWeekAndYear(week, year))
            {
                saleRecordModelBindingSource.Add(data);
            }
        }