示例#1
0
        private void grdPrestation_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                ExternPrestation externPrestation;
                int newID;

                if (m_FlagGrdPrestationLoaded)
                {
                    externPrestation = new ExternPrestation();

                    if (grdPrestation[grdPrestation.Columns["externprestation"].Index, e.RowIndex].Value.ToString() == "")
                    {
                        MessageBox.Show("Le mapping ne peut pas être vide", "Team Editor");
                        LoadGridMappingPrestation();
                        return;
                    }

                    // check if the externprestation is already created
                    if (grdPrestation[grdPrestation.Columns["externprestationid"].Index, e.RowIndex].Value.ToString() == "")
                    {
                        externPrestation.ExternPrestationValue = grdPrestation[grdPrestation.Columns["externprestation"].Index, e.RowIndex].Value.ToString();
                        externPrestation.ExternSystemID        = m_ExternSystemID;
                        externPrestation.PrestationID          = Convert.ToInt32(grdPrestation[grdPrestation.Columns["prestationid"].Index, e.RowIndex].Value);

                        newID = externPrestation.Add();

                        if (newID != -1)
                        {
                            m_FlagGrdPrestationLoaded = false;

                            grdPrestation[grdPrestation.Columns["externprestation"].Index, e.RowIndex].Value   = externPrestation.ExternPrestationValue;
                            grdPrestation[grdPrestation.Columns["externprestationid"].Index, e.RowIndex].Value = newID;
                            grdPrestation[grdPrestation.Columns["prestationid"].Index, e.RowIndex].Value       = externPrestation.PrestationID;


                            // update the usererable grid
                            LoadGridMappingPrestation();

                            m_FlagGrdPrestationLoaded = true;
                        }
                    }
                    else
                    {
                        // update
                        externPrestation.Load(Convert.ToInt32(grdPrestation[grdPrestation.Columns["externprestationid"].Index, e.RowIndex].Value));
                        externPrestation.ExternPrestationValue = grdPrestation[grdPrestation.Columns["externprestation"].Index, e.RowIndex].Value.ToString();
                        externPrestation.Update();
                    }
                }
            }
            catch (Exception err)
            {
                MessageBox.Show("Message : " + err.Message + "- Source : " + err.Source);
            }
        }
示例#2
0
        private void LoadGridMappingPrestation()
        {
            m_FlagGrdPrestationLoaded = false;

            ExternPrestation externPrestation = new ExternPrestation();

            grdPrestation.DataSource = externPrestation.getListMapping(m_ExternSystemID);
            grdPrestation.DataMember = "Table";

            grdPrestation.Columns["externprestationid"].Visible  = false;
            grdPrestation.Columns["externprestation"].HeaderText = "PrestationID Externe";
            grdPrestation.Columns["externprestation"].Width      = 130;
            grdPrestation.Columns["prestationid"].HeaderText     = "PrestationID Messenger";
            grdPrestation.Columns["prestationid"].Width          = 130;
            grdPrestation.Columns["prestationtitle"].HeaderText  = "Titre Prestation";
            grdPrestation.Columns["prestationtitle"].Width       = 130;
            grdPrestation.Columns["externprestationid"].ReadOnly = true;
            grdPrestation.Columns["prestationid"].ReadOnly       = true;
            grdPrestation.Columns["prestationtitle"].ReadOnly    = true;
            grdPrestation.Columns["externprestation"].DefaultCellStyle.BackColor = Color.LightGreen;

            m_FlagGrdPrestationLoaded = true;
        }