Пример #1
0
        private void btndelete_Click(object sender, EventArgs e)
        {
            if (RestrictionClass.restrictActionOnDefualtRow(dataBrand.SelectedRows))
            {
                return;
            }

            if (dataBrand.SelectedRows.Count > 0)
            {
                DialogResult dir = MessageBox.Show("Do you want to delete " + dataBrand.SelectedRows.Count + " Rows?", "Your Data will be delete", MessageBoxButtons.YesNo);
                if (dir == DialogResult.Yes)
                {
                    while (dataBrand.SelectedRows.Count > 0)
                    {
                        int index = dataBrand.SelectedRows[0].Index;
                        dataBrand.Rows.RemoveAt(index);
                    }
                    Clear();
                    update = true;
                }
            }
            else
            {
                MessageBox.Show("Please Select any data in List to Edit");
            }
        }
Пример #2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (searchedDate != null)
            {
                if (RestrictionClass.validateBetweenTwoDate(dtpFrom.Value, dtpTo.Value))
                {
                    MessageBox.Show("The Date on the left side must be lessor than or equal to the date on the right side", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
            }
            else
            {
                if (dtpFrom.Value.Year >= dtpTo.Value.Year)
                {
                    MessageBox.Show("The year on the left side must be lessor than the year on the right side", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
            }



            TextBox txt = (TextBox)txtSearchDate;


            if (searchedDate == null)
            {
                DialogResult = DialogResult.Yes;
                DateTime date = dtpFrom.Value;

                DateTime min = new DateTime(date.Year, 1, 1, 0, 0, 0);
                date = dtpTo.Value;
                DateTime max = new DateTime(date.Year, 12, 31, 0, 0, 0);



                string st = min.Year + "/" + min.Month + "/" + min.Day + " - " + max.Year + "/" + max.Month + "/" + max.Day;

                txt.Text = st;
                return;
            }
            txt.Text = dtpFrom.Text + " - " + dtpTo.Text;

            searchedDate[0] = dtpFrom.Value;
            searchedDate[1] = dtpTo.Value;
            DialogResult    = DialogResult.Yes;
            txt.Enabled     = false;
            btnSearch.PerformClick();
        }
Пример #3
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (dataBrand.SelectedRows.Count == 1)
            {
                if (RestrictionClass.restrictActionOnDefualtRow(dataBrand.SelectedRows))
                {
                    return;
                }


                int index = dataBrand.SelectedRows[0].Index;
                dt.Rows[index].SetField("BrandID", lblID.Text);
                dt.Rows[index].SetField("BrandName", txtBarndName.Text);
                Clear();
                update = true;
            }
            else
            {
                MessageBox.Show("Please Select one data in List to Edit");
            }
        }