コード例 #1
0
        private void label7_Click(object sender, EventArgs e)
        {
            Model.tashvighi model = new Model.tashvighi()
            {
                kollPD       = Int32.Parse(dollari.Text),
                kollPR       = Int32.Parse(rially.Text),
                title        = title.Text,
                shenasnameID = GlobalVariable.shenasnameID,
            };
            dbcontext.tashvighis.Add(model);
            dbcontext.SaveChanges();
            int index = 0;

            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "Form21_tashvighi")
                {
                    break;
                }

                index += 1;
            }
            this.Hide();

            Application.OpenForms[index].Close();
            Form21_tashvighi form13 = new Form21_tashvighi();

            form13.Show();
        }
コード例 #2
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            using (var dbcontext = new Model.Context())
            {
                Model.shenasname item = dbcontext.shenasnames.Where(x => x.ID == GlobalVariable.shenasnameID).FirstOrDefault();
                if (item.final != 1)
                {
                    int iSelectedGridIndex = dataGridView1.CurrentCell.ColumnIndex;
                    if (iSelectedGridIndex != 0)
                    {
                        return;
                    }
                    int    rowindex = dataGridView1.CurrentCell.RowIndex;
                    string rowID    = dataGridView1.Rows[rowindex].Cells[2].Value.ToString();

                    Model.tashvighi model = dbcontext.tashvighis.SingleOrDefault(x => x.title == rowID);
                    dbcontext.Entry(model).State = EntityState.Deleted;
                    dbcontext.SaveChanges();
                    int index = 0;
                    foreach (Form form in Application.OpenForms)
                    {
                        if (form.Name == "Form21_tashvighi")
                        {
                            break;
                        }

                        index += 1;
                    }
                    this.Hide();

                    Application.OpenForms[index].Close();
                    Form21_tashvighi form13 = new Form21_tashvighi();
                    form13.Show();
                }
            }
        }