Exemple #1
0
        private void label6_Click(object sender, EventArgs e)
        {
            Form11_addMasrafi form = new Form11_addMasrafi();

            form.Show();
            this.Hide();
        }
Exemple #2
0
        private void label7_Click(object sender, EventArgs e)
        {
            mostaan.Model.masrafi model = new Model.masrafi()
            {
                count        = Int32.Parse(count.Text),
                creatoreCo   = Ctitle.Text,
                title        = title.Text,
                kollPD       = Int32.Parse(koldollary.Text),
                kollPR       = Int32.Parse(kolrially.Text),
                vahedPD      = Int32.Parse(vaheddollary.Text),
                vahedPR      = Int32.Parse(vahedrially.Text),
                shenasnameID = GlobalVariable.shenasnameID,
            };
            Model.masrafi item = dbcontext.masrafis.SingleOrDefault(x => x.title == title.Text && x.shenasnameID == GlobalVariable.shenasnameID);
            if (item == null)
            {
                dbcontext.masrafis.Add(model);
                dbcontext.SaveChanges();
                int index = 0;
                foreach (Form form in Application.OpenForms)
                {
                    if (form.Name == "Form11_addMasrafi")
                    {
                        break;
                    }

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

                Application.OpenForms[index].Close();
                Form11_addMasrafi form11 = new Form11_addMasrafi();
                form11.Show();
            }
            else
            {
                message.Text = "عنوان تکراری مجاز نیست";
            }
        }
Exemple #3
0
        private void dataGridView1_CellContentDoubleClick(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.masrafi model = dbcontext.masrafis.SingleOrDefault(x => x.title == rowID && x.shenasnameID == GlobalVariable.shenasnameID);
                    dbcontext.Entry(model).State = EntityState.Deleted;
                    dbcontext.SaveChanges();
                    int index = 0;
                    foreach (Form form in Application.OpenForms)
                    {
                        if (form.Name == "Form11_addMasrafi")
                        {
                            break;
                        }

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

                    Application.OpenForms[index - 1].Close();
                    Form11_addMasrafi form13 = new Form11_addMasrafi();
                    form13.Show();
                }
            }
        }