Example #1
0
        private void dgvCompanyList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                if (e.ColumnIndex == 9)
                {
                    //DeleteForCompany
                    DialogResult result = MessageBox.Show(this, "Are you sure you want to delete?", "Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                    if (result.Equals(DialogResult.OK))
                    {
                        DataGridViewRow row = dgvCompanyList.Rows[e.RowIndex];
                        companyProfileID          = Convert.ToString(row.Cells[0].Value);
                        dgvCompanyList.DataSource = "";
                        CompanyProfile companyProfile = (from cp in mbmsEntities.CompanyProfiles where cp.CompanyProfileID == companyProfileID select cp).FirstOrDefault();
                        companyProfile.Active        = false;
                        companyProfile.DeletedUserID = UserID;
                        companyProfile.DeletedDate   = DateTime.Now;
                        companyProfileController.DeleteCompanyProfile(companyProfile);
                        dgvCompanyList.DataSource = (from cp in mbmsEntities.CompanyProfiles where cp.Active == true orderby cp.CompanyName descending select cp).ToList();
                        MessageBox.Show(this, "Successfully Deleted!", "Delete Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Clear();
                        FormRefresh();
                    }
                }
                else if (e.ColumnIndex == 8)
                {
                    //EditCompany
                    DataGridViewRow row = dgvCompanyList.Rows[e.RowIndex];
                    companyProfileID       = Convert.ToString(row.Cells[0].Value);
                    txtCompanyName.Text    = Convert.ToString(row.Cells[1].Value);
                    txtPhoneNumber.Text    = Convert.ToString(row.Cells[2].Value);
                    txtCompanyEmail.Text   = Convert.ToString(row.Cells[3].Value);
                    txtCompanyWebsite.Text = Convert.ToString(row.Cells[4].Value);
                    txtAddressEng.Text     = Convert.ToString(row.Cells[5].Value);
                    txtAddressMM.Text      = Convert.ToString(row.Cells[6].Value);


                    CompanyProfile updateCompanyProfile = (from cp in mbmsEntities.CompanyProfiles where cp.CompanyProfileID == companyProfileID select cp).FirstOrDefault();
                    if (updateCompanyProfile.LogoURL != null && updateCompanyProfile.LogoURL != "")
                    {
                        this.txtphotoPath.Text = updateCompanyProfile.LogoURL.ToString();
                        string FileNmae = txtphotoPath.Text.Substring(9);
                        this.pbCompanyPhoto.ImageLocation = Application.StartupPath + "\\Images\\" + FileNmae;
                        this.pbCompanyPhoto.SizeMode      = PictureBoxSizeMode.Zoom;
                    }
                    else
                    {
                        pbCompanyPhoto.Image = null;
                    }
                    isEdit = true;
                }
            }
        }
 private void CompanyProfileRemove()
 {
     CompanyProfileController controller = new CompanyProfileController();
     var result = controller.DeleteCompanyProfile(new CompanyProfilePoco[] { _companyProfile });
 }