private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
        {
            var srNos = GetSelectedSrNo();
            if (!srNos.Any())
                return;

            var result = MessageBox.Show(string.Format("Do you want to delete SrNos : {0}",
                                            string.Join(",", srNos.Select(x => x.ToString()).ToArray())),
                                                                        "Delete Alert", MessageBoxButtons.YesNo);

            if (result != DialogResult.Yes)
                return;

            // ask for password
            Loginfrm frm = new Loginfrm(HomePage.UserDetail);
            frm.ShowDialog();

            if (!frm.IsLogedIn)
                return;

            var deleteReasionfrm = new DeleteReasionfrm();
            deleteReasionfrm.ShowDialog();

            if (string.IsNullOrEmpty(DeleteReasionfrm.DeleteReasion))
                return;

            var companys = _uniDb.CustomerDetails.Where(x => srNos.Contains(x.SrNo) && x.CompanyType == _companyType.ToString()).ToList();

            foreach (var company in companys)
            {
                company.IsDeleted = true;
                company.ExecutiveName = HomePage.UserDetail.UserId;
                company.ModifiedDateTime = DateTime.Now;
                company.DeletedReason = DeleteReasionfrm.DeleteReasion;
            }
            _uniDb.SubmitChanges();

            _uniDb.Refresh(System.Data.Linq.RefreshMode.KeepChanges, _pagination.PageData);
            BindGridView();
            BindControls();
        }
Beispiel #2
0
        private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count < 1)
                return;

            var srNos = new List<long>();
            for (int i = 0; i < dataGridView1.SelectedRows.Count; i++)
            {
                srNos.Add(Convert.ToInt64(dataGridView1.SelectedRows[i].Cells["SrNo"].Value));
            }

            var result = MessageBox.Show(string.Format("Do you want to delete SrNos : {0}",
                                            string.Join(",", srNos.Select(x => x.ToString()).ToArray())),
                                                                        "Delete Alert", MessageBoxButtons.YesNo);

            if (result != DialogResult.Yes)
                return;

            // ask for password
            Loginfrm frm = new Loginfrm(HomePage.UserDetail);
            frm.ShowDialog();

            if (!frm.IsLogedIn)
                return;

            var deleteReasionfrm = new DeleteReasionfrm();
            deleteReasionfrm.ShowDialog();

            if (string.IsNullOrEmpty(DeleteReasionfrm.DeleteReasion))
                return;

            var candidates = uniDb.CandidateDetails.Where(x => srNos.Contains(x.SrNo)).ToList();

            foreach (var candidate in candidates)
            {
                candidate.IsDeleted = true;
                candidate.ExecutiveName = HomePage.UserDetail.UserId;
                candidate.ModifiedDateTime = DateTime.Now;
                candidate.DeletedReason = DeleteReasionfrm.DeleteReasion;
            }
            uniDb.SubmitChanges();

            uniDb.Refresh(System.Data.Linq.RefreshMode.KeepChanges, pagination.PageData);
            BindGridView();
        }