Example #1
0
        private void itemDeleteProject_Click(object sender, EventArgs e)
        {
            if (dataGridViewProjects.Rows.Count > 0 && dataGridViewProjects.SelectedRows.Count > 0)
            {
                this.Enabled = false;
                // int selectedrowindex = dataGridViewProjects.SelectedCells[0].RowIndex;
                // DataGridViewRow selectedRow = dataGridViewProjects.Rows[selectedrowindex];
                // _projectCode = Convert.ToDecimal(selectedRow.Cells["ProjectCode"].Value);

                //// _dtProjects.Rows.Remove(selectedRow);
                // dataGridViewProjects.DataSource = _dtProjects;

                foreach (DataGridViewRow sr in this.dataGridViewProjects.SelectedRows)
                {
                    //Project project = (Project)item.DataBoundItem;
                    decimal pc   = Convert.ToDecimal(sr.Cells[0].Value);
                    Project proj = _LstProjects.Where(x => x.ProjectCode == pc).FirstOrDefault();
                    if (proj != null)
                    {
                        _LstProjects.Remove(proj);
                    }
                    _dtProjects.Rows.RemoveAt(sr.Index);
                    //_LstProjects.RemoveAt()
                    _pc.DeleteModel(proj.ProjectCode);
                }
                this.Enabled = true;
            }
        }
Example #2
0
        private void itemDeleteProject_Click(object sender, EventArgs e)
        {
            if (dataGridViewProjects.Rows.Count > 0 && dataGridViewProjects.SelectedRows.Count > 0)
            {
                // int selectedrowindex = dataGridViewProjects.SelectedCells[0].RowIndex;
                // DataGridViewRow selectedRow = dataGridViewProjects.Rows[selectedrowindex];
                // _projectCode = Convert.ToDecimal(selectedRow.Cells["ProjectCode"].Value);

                //// _dtProjects.Rows.Remove(selectedRow);
                // dataGridViewProjects.DataSource = _dtProjects;

                foreach (DataGridViewRow sr in this.dataGridViewProjects.SelectedRows)
                {
                    //Project project = (Project)item.DataBoundItem;
                    decimal pc   = Convert.ToDecimal(sr.Cells[0].Value);
                    Project proj = _LstProjects.Where(x => x.ProjectCode == pc).FirstOrDefault();
                    if (proj != null)
                    {
                        _LstProjects.Remove(proj);
                    }
                    _dtProjects.Rows.RemoveAt(sr.Index);
                    //_LstProjects.RemoveAt()
                    _pc.DeleteModel(proj.ProjectCode);

                    DataView dv = _dtProjects.DefaultView;
                    dv.Sort     = "ProjectCode desc";
                    _dtProjects = dv.ToTable();
                    dataGridViewProjects.DataSource = _dtProjects;

                    if (_dtProjects.Rows.Count == 0)
                    {
                        ClearAll();
                        _pc.ReseedPk();
                        _newMode = true;
                    }


                    //dataGridViewProjects.Refresh();
                }
            }
            else
            {
                ClearAll();
            }
        }
        private void DeleteProjectAndChildern()
        {
            // int selectedrowindex = dataGridViewProjects.SelectedCells[0].RowIndex;
            // DataGridViewRow selectedRow = dataGridViewProjects.Rows[selectedrowindex];
            // _projectCode = Convert.ToDecimal(selectedRow.Cells["ProjectCode"].Value);

            //// _dtProjects.Rows.Remove(selectedRow);
            // dataGridViewProjects.DataSource = _dtProjects;

            foreach (DataGridViewRow sr in this.dataGridViewProjects.SelectedRows)
            {
                //Project project = (Project)item.DataBoundItem;
                decimal pc   = Convert.ToDecimal(sr.Cells[0].Value);
                Project proj = _LstProjects.Where(x => x.ProjectCode == pc).FirstOrDefault();
                if (proj != null)
                {
                    _LstProjects.Remove(proj);
                }
                _dtProjects.Rows.RemoveAt(sr.Index);
                //_LstProjects.RemoveAt()
                _pc.DeleteModel(proj.ProjectCode);
            }
        }