コード例 #1
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            try
            {
                using (DEWSRMEntities db = new DEWSRMEntities())
                {
                    int[]       selRows  = ((GridView)grdModels.MainView).GetSelectedRows();
                    DataRowView oModelID = (DataRowView)(((GridView)grdModels.MainView).GetRow(selRows[0]));

                    int   nModelID = Convert.ToInt32(oModelID["ModelID"]);
                    Model oModel   = db.Models.FirstOrDefault(p => p.ModelID == nModelID);


                    if (oModel == null)
                    {
                        MessageBox.Show("select an item to edit", "Item not yet selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }

                    fModel frm = new  fModel();
                    frm.ItemChanged = RefreshList;
                    frm.ShowDlg(oModel, false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #2
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            fModel frm = new fModel();

            frm.ItemChanged = RefreshList;
            frm.ShowDlg(new Model(), true);
        }
コード例 #3
0
        private void btnModel_Click(object sender, EventArgs e)
        {
            ForNewModel = true;
            fModel frm = new fModel();

            frm.ShowDlg(new Model(), true);

            if (ForNewModel)
            {
                db = new DEWSRMEntities();
                List <Model> oModList = db.Models.ToList();
                ctlModel.SelectedID = oModList[oModList.Count - 1].ModelID;
                ForNewModel         = false;
            }
        }