예제 #1
0
        // GET: /office/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            office office = db.offices.Find(id);

            if (office == null)
            {
                return(HttpNotFound());
            }
            else
            {
                try
                {
                    TempData["Message"] = "Record Deleted Successfully";
                    return(RedirectToAction("Index", "Office"));
                }
                catch {
                    TempData["ErrorMessage"] = "No Records Deleted";
                    return(RedirectToAction("Index", "Office"));
                }
            }
        }
예제 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            office office = db.offices.Find(id);

            db.offices.Remove(office);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #3
0
파일: Program.cs 프로젝트: Shoz1/Csharp_5
        public static void offices()
        {
            office ob = new office();

            ob.GetName();
            ob.GetComand();
            ob.GetEngName();
            ob.GetAdmName();
        }
예제 #4
0
        // GET: /office/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            office office = db.offices.Find(id);

            if (office == null)
            {
                return(HttpNotFound());
            }
            return(View(office));
        }
예제 #5
0
        public ActionResult Edit(office off)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.Entry(off).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
                return(View(off));
            }
            catch
            {
                return(View());
            }
        }
예제 #6
0
        public ActionResult Create(office off)
        {
            try
            {
                // TODO: Add insert logic here
                if (ModelState.IsValid)
                {
                    db.offices.Add(off);
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
                return(View(off));
            }
            catch
            {
                return(View());
            }
        }
예제 #7
0
        public ActionResult Create([Bind(Include = "officeId,mantralaye,bibhag,karyalaye,address,phone,url_web,email,POBoxNo,officeCode")] office office)
        {
            if (ModelState.IsValid)
            {
                office objOffice = new office();
                objOffice.mantralaye = TrimText(office.mantralaye);
                objOffice.bibhag     = TrimText(office.bibhag);
                objOffice.karyalaye  = TrimText(office.karyalaye);
                objOffice.address    = TrimText(office.address);
                objOffice.phone      = TrimText(office.phone);
                objOffice.url_web    = office.url_web;
                objOffice.email      = office.email;
                objOffice.POBoxNo    = TrimText(office.POBoxNo);
                objOffice.officeCode = TrimText(office.officeCode);
                db.offices.Add(office);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(office));
        }
예제 #8
0
 public ActionResult Edit([Bind(Include = "officeId,mantralaye,bibhag,karyalaye,address,phone,url_web,email,POBoxNo,officeCode")] office office)
 {
     if (office == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     if (ModelState.IsValid)
     {
         office objOffice = db.offices.Find(office.officeId);
         objOffice.mantralaye = TrimText(office.mantralaye);
         objOffice.bibhag     = TrimText(office.bibhag);
         objOffice.karyalaye  = TrimText(office.karyalaye);
         objOffice.address    = TrimText(office.address);
         objOffice.phone      = TrimText(office.phone);
         objOffice.url_web    = office.url_web;
         objOffice.email      = office.email;
         objOffice.POBoxNo    = TrimText(office.POBoxNo);
         objOffice.officeCode = TrimText(office.officeCode);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(office));
 }
예제 #9
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                office   off   = new office();
                OfficeDB offDB = new OfficeDB();
                off.OfficeID = txtID.Text;
                off.name     = txtName.Text;
                try
                {
                    //////off.RegionID = cmbRegion.SelectedItem.ToString().Trim().Substring(0, cmbRegion.SelectedItem.ToString().Trim().IndexOf('-'));
                    off.RegionID = ((Structures.ComboBoxItem)cmbRegion.SelectedItem).HiddenValue;

                    //////off.RegionName = cmbRegion.SelectedItem.ToString().Trim().Substring(cmbRegion.SelectedItem.ToString().Trim().IndexOf('-') + 1);
                    off.RegionName = ((Structures.ComboBoxItem)cmbRegion.SelectedItem).ToString();
                }
                catch (Exception)
                {
                    off.RegionID   = "";
                    off.RegionName = "";
                }
                off.Address1 = txtaddress1.Text;
                off.Address2 = txtaddress2.Text;
                off.Address3 = txtaddress3.Text;
                off.Address4 = txtaddress4.Text;
                off.status   = ComboFIll.getStatusCode(cmbStatus.SelectedItem.ToString());
                System.Windows.Forms.Button btn = sender as System.Windows.Forms.Button;
                string btnText = btn.Text;
                if (offDB.validateOffice(off))
                {
                    if (btnText.Equals("Update"))
                    {
                        if (offDB.updateOffice(off))
                        {
                            MessageBox.Show("Office updated");
                            closeAllPanels();
                            ListOffice();
                        }
                        else
                        {
                            MessageBox.Show("Failed to update Office");
                        }
                    }
                    else if (btnText.Equals("Save"))
                    {
                        if (offDB.insertOffice(off))
                        {
                            MessageBox.Show("Office Added");
                            closeAllPanels();
                            ListOffice();
                        }
                        else
                        {
                            MessageBox.Show("Failed to Insert Office");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Office Data Validation failed");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Failed Adding / Editing Office");
            }
        }
예제 #10
0
 public static OfficeDto ToDto(this office entity) => Mapper.Map <OfficeDto>(entity);