Beispiel #1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (dgvTempStd.Rows.Count > 0)
     {
         if (DialogResult.Yes == MessageBox.Show("Are you sure want to save these data?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
         {
             Model.DBSchoolEntities db = new Model.DBSchoolEntities();
             foreach (DataGridViewRow dr in dgvTempStd.Rows)
             {
                 Model.tblStd std = new Model.tblStd()
                 {
                     BrId     = null,
                     SchoolId = 1,
                     StdName  = dr.Cells["StdName"].Value.ToString()
                 };
                 db.tblStds.Add(std);
             }
             db.SaveChanges();
         }
         GLOBAL.GLOBALMETHODS.SHOW_MESSAGEBOX(Resources.msgs.SaveRecord, Resources.msgs.SaveRecordTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         GLOBAL.GLOBALMETHODS.SHOW_MESSAGEBOX("Please Add atleast one Standrad.", "Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Beispiel #2
0
        private void BindStds()
        {
            Model.DBSchoolEntities db = new Model.DBSchoolEntities();
            var       tblStds         = db.tblStds;
            DataTable dt = new DataTable();

            dt.Columns.Add("StdName");
            dt.Columns.Add("StdId");

            foreach (var dr in tblStds)
            {
                DataRow drdt = dt.NewRow();
                drdt["StdName"] = dr.StdName;
                drdt["StdId"]   = dr.StdId;

                dt.Rows.Add(drdt);
            }

            dgvStd.DataSource = dt;
        }