Exemplo n.º 1
0
        //private void Export_Click(object sender, EventArgs e)
        //{
        //    string com = JsonConvert.SerializeObject(MIB.cardtblExport);
        //    SaveFileDialog saveFileDialog1 = new SaveFileDialog();
        //    saveFileDialog1.Filter = "allfiles|*.json";
        //    saveFileDialog1.Title = "Save Json File";
        //    saveFileDialog1.ShowDialog();

        //    File.WriteAllText(saveFileDialog1.FileName, com);
        //}

        private void btnDelete_Click(object sender, EventArgs e)
        {
            Int32 selectedRowCount = GVCards.Rows.GetRowCount(DataGridViewElementStates.Selected);

            if (selectedRowCount > 0)
            {
                for (int i = 0; i < selectedRowCount; i++)
                {
                    //try
                    //{
                    int  card_serial_number = Int32.Parse(GVCards.Rows[GVCards.SelectedCells[i].RowIndex].Cells[0].Value.ToString());
                    Card crd = new Card();
                    crd = MIB.cardtbl.FirstOrDefault(x => x.card_serial_number == card_serial_number);
                    //MIB.cardtblExport.Add(crd);
                    MIB.cardtbl.Remove(crd);
                    //}
                    //catch { }
                }
                GVCards.ClearSelection();
                GVCards.DataSource = null;
                GVCards.Rows.Clear();

                GVCards.DataSource = MIB.cardtbl;
                GVCards.Refresh();
            }
        }
Exemplo n.º 2
0
        private void btnClear_Click(object sender, EventArgs e)
        {
            GVCards.ClearSelection();
            GVCards.DataSource = null;
            GVCards.Rows.Clear();

            GVCards.DataSource = MIB.cardtbl;
            GVCards.Refresh();
        }
Exemplo n.º 3
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            GVCards.ClearSelection();
            GVCards.DataSource = null;
            GVCards.Rows.Clear();

            GVCards.DataSource = MIB.cardtbl.Where(x => x.card_number == txCardNo.Text || x.household_name == tbHouseHold.Text).ToList();
            GVCards.Refresh();
        }
Exemplo n.º 4
0
        private void GVCards_DoubleClick(object sender, EventArgs e)
        {
            string path = "C:\\Cards";

            try
            {
                Directory.CreateDirectory(path);
            }
            catch (Exception ex)
            {
                // handle them here
            }

            Int32 selectedRowCount = GVCards.Rows.GetRowCount(DataGridViewElementStates.Selected);

            if (selectedRowCount > 0)
            {
                for (int i = 0; i < selectedRowCount; i++)
                {
                    //try
                    //{
                    int  card_serial_number = Int32.Parse(GVCards.Rows[GVCards.SelectedCells[i].RowIndex].Cells[0].Value.ToString());
                    Card crd = new Card();
                    crd = MIB.cardtbl.First(x => x.card_serial_number == card_serial_number);
                    MIB.cardtbl.Remove(crd);

                    string com = JsonConvert.SerializeObject(crd);
                    com = "[" + com + "]";

                    File.WriteAllText(path + "\\" + crd.card_number + ".json", com);
                    //}
                    //catch { }
                }
                GVCards.ClearSelection();
                GVCards.DataSource = null;
                GVCards.Rows.Clear();

                GVCards.DataSource = MIB.cardtbl;
                GVCards.Refresh();
            }
        }