Exemple #1
0
        public ActionResult DeleteConfirmed(string id)
        {
            CSCOADDR cSCOADDR = db.CSCOADDRs.Find(id);

            db.CSCOADDRs.Remove(cSCOADDR);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #2
0
        public ActionResult DeleteConfirmed(string id, short row)
        {
            CSCOADDR cSCOADDR = db.CSCOADDRs.Find(MyHtmlHelpers.ConvertByteStrToId(id), row);

            try
            {
                db.CSCOADDRs.Remove(cSCOADDR);
                db.SaveChanges();
                return(new RedirectResult(Url.Action("Edit", "CSCOMSTRs", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSCOADDR.CONO) }) + "#Address"));
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        //string message = string.Format("{0}:{1}",
                        //    validationErrors.Entry.Entity.ToString(),
                        //   validationError.ErrorMessage);
                        // raise a new exception nesting
                        // the current instance as InnerException
                        ModelState.AddModelError(validationError.PropertyName, validationError.ErrorMessage);
                    }
                }
            }
            catch (DbUpdateException ex)
            {
                UpdateException updateException = (UpdateException)ex.InnerException;
                if (updateException != null)
                {
                    if (updateException.InnerException != null)
                    {
                        var sqlException = (FirebirdSql.Data.FirebirdClient.FbException)updateException.InnerException;

                        foreach (var error in sqlException.Errors)
                        {
                            if (error.Message != null)
                            {
                                ModelState.AddModelError(string.Empty, error.Message);
                            }
                        }
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, updateException.Message);
                    }
                }
                else
                {
                    ModelState.AddModelError(string.Empty, updateException.Message);
                }
            }
            cSCOADDR.CSCOMSTR = db.CSCOMSTRs.Find(cSCOADDR.CONO);
            return(View(cSCOADDR));
        }
Exemple #3
0
 public ActionResult Edit([Bind(Include = "CONO,ADDRID,MAILADDR,ADDRTYPE,ADDR1,ADDR2,ADDR3,POSTAL,CITYCODE,STATECODE,CTRYCODE,PHONE1,PHONE2,FAX1,FAX2,OPRHRS,REM,SDATE,EDATE,ENDDATE,STAMP")] CSCOADDR cSCOADDR)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cSCOADDR).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CITYCODE  = new SelectList(db.HKCITies, "CITYCODE", "CITYDESC", cSCOADDR.CITYCODE);
     ViewBag.STATECODE = new SelectList(db.HKSTATEs, "STATECODE", "STATEDESC", cSCOADDR.STATECODE);
     ViewBag.CTRYCODE  = new SelectList(db.HKCTRies, "CTRYCODE", "CTRYDESC", cSCOADDR.CTRYCODE);
     return(View(cSCOADDR));
 }
Exemple #4
0
        // GET: CSCOADDRs/Details/5
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CSCOADDR cSCOADDR = db.CSCOADDRs.Find(id);

            if (cSCOADDR == null)
            {
                return(HttpNotFound());
            }
            return(View(cSCOADDR));
        }
Exemple #5
0
        // GET: CSCOADDRs/Delete/5
        public ActionResult Delete(string id, short row)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CSCOADDR cSCOADDR = db.CSCOADDRs.Find(MyHtmlHelpers.ConvertByteStrToId(id), row);

            if (cSCOADDR == null)
            {
                return(HttpNotFound());
            }
            return(View(cSCOADDR));
        }
Exemple #6
0
        // GET: CSCOADDRs/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CSCOADDR cSCOADDR = db.CSCOADDRs.Find(id);

            if (cSCOADDR == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CITYCODE  = new SelectList(db.HKCITies, "CITYCODE", "CITYDESC", cSCOADDR.CITYCODE);
            ViewBag.STATECODE = new SelectList(db.HKSTATEs, "STATECODE", "STATEDESC", cSCOADDR.STATECODE);
            ViewBag.CTRYCODE  = new SelectList(db.HKCTRies, "CTRYCODE", "CTRYDESC", cSCOADDR.CTRYCODE);
            return(View(cSCOADDR));
        }
Exemple #7
0
        // GET: CSCOADDRs/Edit/5
        public ActionResult Edit(string id, short row)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CSCOADDR cSCOADDR = db.CSCOADDRs.Find(MyHtmlHelpers.ConvertByteStrToId(id), row);

            if (cSCOADDR == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ADDRTYPE  = cSCOADDR.addrtypeList;
            ViewBag.CITYCODE  = new SelectList(db.HKCITies.OrderBy(x => x.CITYCODE), "CITYCODE", "CITYDESC", cSCOADDR.CITYCODE);
            ViewBag.STATECODE = new SelectList(db.HKSTATEs.OrderBy(x => x.STATECODE), "STATECODE", "STATEDESC", cSCOADDR.STATECODE);
            ViewBag.CTRYCODE  = new SelectList(db.HKCTRies.OrderBy(x => x.CTRYCODE), "CTRYCODE", "CTRYDESC", cSCOADDR.CTRYCODE);
            return(View(cSCOADDR));
        }
Exemple #8
0
        // GET: CSCOADDRs/Create
        public ActionResult Create(string id)
        {
            ViewBag.Parent = MyHtmlHelpers.ConvertByteStrToId(id);
            CSCOADDR cSCOADDR = new CSCOADDR();

            cSCOADDR.CONO = ViewBag.Parent;

            cSCOADDR.SDATE        = DateTime.Today;
            cSCOADDR.ENDDATE      = new DateTime(3000, 1, 1);
            cSCOADDR.EDATE        = cSCOADDR.ENDDATE;
            cSCOADDR.MAILADDRBool = true;
            cSCOADDR.CSCOMSTR     = db.CSCOMSTRs.Find(cSCOADDR.CONO);

            ViewBag.ADDRTYPE  = cSCOADDR.addrtypeList;
            ViewBag.CITYCODE  = new SelectList(db.HKCITies.OrderBy(x => x.CITYCODE), "CITYCODE", "CITYDESC", cSCOADDR.CITYCODE);
            ViewBag.STATECODE = new SelectList(db.HKSTATEs.OrderBy(x => x.STATECODE), "STATECODE", "STATEDESC", cSCOADDR.STATECODE);
            ViewBag.CTRYCODE  = new SelectList(db.HKCTRies.OrderBy(x => x.CTRYCODE), "CTRYCODE", "CTRYDESC", cSCOADDR.CTRYCODE);
            return(View(cSCOADDR));
        }
Exemple #9
0
        public V_CSCOAGM getReminder(string sid)
        {
            if (sid == null)
            {
                return(null);
            }
            V_CSCOAGM v_CSCOAGM = db.V_CSCOAGM.Find(sid);
            CSCOADDR  cSCOADDR  = db.CSCOADDRs.Where(x => x.CONO == sid && x.MAILADDR == "Y").FirstOrDefault();

            if (cSCOADDR == null)
            {
                cSCOADDR = db.CSCOADDRs.Where(x => x.CONO == sid).FirstOrDefault();
            }
            if (cSCOADDR != null)
            {
                ViewBag.Addr1 = cSCOADDR.ADDR1;
                ViewBag.Addr2 = cSCOADDR.ADDR2;
                ViewBag.Addr3 = cSCOADDR.ADDR3;
                ViewBag.Addr4 = cSCOADDR.POSTAL;
                if (cSCOADDR.HKCITY != null)
                {
                    ViewBag.Addr4 = ViewBag.Addr4 + " " + cSCOADDR.HKCITY.CITYDESC;
                }
                else
                {
                    ViewBag.Addr4 = ViewBag.Addr4 + " " + cSCOADDR.CITYCODE;
                }
            }
            else
            {
                ViewBag.Addr1 = "";
                ViewBag.Addr2 = "";
                ViewBag.Addr3 = "";
                ViewBag.Addr4 = "";
            }

            string   pSearchCode    = "";
            string   pSearchName    = "";
            string   pSearchStaff   = "";
            DateTime pSearchAgmDate = DateTime.Parse("01/01/0001");
            DateTime pSearchEndDate = DateTime.Parse("01/01/0001");

            if (Session["SearchVCSCOAGMRec"] != null)
            {
                V_CSCOAGM searchRec = (V_CSCOAGM)(Session["SearchVCSCOAGMRec"]);
                pSearchCode    = searchRec.CONO ?? "";
                pSearchName    = searchRec.CONAME ?? "";
                pSearchStaff   = searchRec.STAFFCODE ?? "";
                pSearchAgmDate = searchRec.AGMDATE ?? DateTime.Parse("01/01/0001");
            }
            else
            {
                pSearchAgmDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
            }
            pSearchEndDate = pSearchAgmDate.AddMonths(1).AddDays(-1);

            SACOMP profileRec = db.SACOMPs.FirstOrDefault();

            ViewBag.Company = profileRec.CONAME.ToUpper() + " (" + profileRec.COREGNO + ") ";
            ViewBag.Address = profileRec.COADDR1 + " " + profileRec.COADDR2 + " " + profileRec.COADDR3 + " " + profileRec.COADDR4;
            ViewBag.Contact = "Tel: " + profileRec.COPHONE1 + " Fax: " + profileRec.COFAX1 + " E-Mail: " + profileRec.COWEB;


            v_CSCOAGM.ReminderMonth = pSearchAgmDate.Month;
            v_CSCOAGM.ReminderYear  = pSearchAgmDate.Year;
            ViewBag.ReminderDate    = v_CSCOAGM.ReminderDate?.ToString("dd MMM yyyy");

            if (v_CSCOAGM.FYETOFILE.HasValue)
            {
                DateTime DeadlineCirculationDate = v_CSCOAGM.FYETOFILE.Value.AddMonths(6);
                if (DeadlineCirculationDate.Month < 12)
                {
                    DeadlineCirculationDate = new DateTime(DeadlineCirculationDate.Year, DeadlineCirculationDate.Month + 1, 1);
                }
                else
                {
                    DeadlineCirculationDate = new DateTime(DeadlineCirculationDate.Year + 1, DeadlineCirculationDate.Month - 12 + 1, 1);
                }
                DeadlineCirculationDate = DeadlineCirculationDate.AddDays(-1);
                DateTime DeadlineSubmissionDate = DeadlineCirculationDate.AddDays(30);
                ViewBag.Deadline1 = DeadlineCirculationDate.ToString("dd MMM yyyy");
                ViewBag.Deadline2 = DeadlineSubmissionDate.ToString("dd MMM yyyy");
                ViewBag.FYE       = v_CSCOAGM.FYETOFILE.Value.ToString("dd MMM yyyy");
            }

            int      c       = 0;
            DateTime lastfye = DateTime.Parse("01/01/0001");

            if (v_CSCOAGM.CReminderType == "Special")
            {
                MvcHtmlString        s       = MvcHtmlString.Create("");// MvcHtmlString.Create(ViewBag.FYE);
                IQueryable <CSCOAGM> cSCOAGM = db.CSCOAGMs.Where(x => x.CONO == v_CSCOAGM.CONO && x.FILEDFYE == null).OrderBy(y => y.AGMNO);
                foreach (CSCOAGM rec in cSCOAGM)
                {
                    if (rec.FYETOFILE != null)
                    {
                        if (c == 0)
                        {
                            s = MvcHtmlString.Create(s + rec.FYETOFILE?.ToString("dd MMM yyyy"));
                        }
                        else
                        {
                            s = MvcHtmlString.Create(s + " <br /> " + rec.FYETOFILE?.ToString("dd MMM yyyy"));
                        }
                        c++;

                        lastfye = rec.FYETOFILE ?? DateTime.Parse("01/01/0001");
                    }
                }

                if (lastfye.Year != 1) // this is to stop processing if there is no AGM records
                {
                    lastfye = lastfye.AddYears(1);
                    // while (lastfye.Year <= pSearchAgmDate.Year)
                    while (lastfye <= pSearchAgmDate)
                    {
                        if (c == 0)
                        {
                            s = MvcHtmlString.Create(s + lastfye.ToString("dd MMM yyyy"));
                        }
                        else
                        {
                            s = MvcHtmlString.Create(s + " <br /> " + lastfye.ToString("dd MMM yyyy"));
                        }
                        c++;
                        if (true || (lastfye.Year >= pSearchAgmDate.Year))
                        {
                            DateTime DeadlineCirculationDate = lastfye.AddMonths(6);
                            if (DeadlineCirculationDate.Month < 12)
                            {
                                DeadlineCirculationDate = new DateTime(DeadlineCirculationDate.Year, DeadlineCirculationDate.Month + 1, 1);
                            }
                            else
                            {
                                DeadlineCirculationDate = new DateTime(DeadlineCirculationDate.Year + 1, DeadlineCirculationDate.Month - 12 + 1, 1);
                            }
                            DeadlineCirculationDate = DeadlineCirculationDate.AddDays(-1);
                            DateTime DeadlineSubmissionDate = DeadlineCirculationDate.AddDays(30);
                            ViewBag.Deadline1 = DeadlineCirculationDate.ToString("dd MMM yyyy");
                            ViewBag.Deadline2 = DeadlineSubmissionDate.ToString("dd MMM yyyy");
                            //break;
                        }
                        lastfye = lastfye.AddYears(1);
                    }
                }
                ViewBag.FYE = s;
            }
            return(v_CSCOAGM);
        }
Exemple #10
0
        public V_CSCOAR getReminder(string sid) // Should use a ViewModel rather than using ViewBag
        {
            if (sid == null)
            {
                return(null);
            }
            V_CSCOAR v_CSCOAR = db.V_CSCOAR.Find(sid);
            CSCOADDR cSCOADDR = db.CSCOADDRs.Where(x => x.CONO == sid && x.MAILADDR == "Y").FirstOrDefault();

            if (cSCOADDR == null)
            {
                cSCOADDR = db.CSCOADDRs.Where(x => x.CONO == sid).FirstOrDefault();
            }

            if (cSCOADDR != null)
            {
                ViewBag.Addr1 = cSCOADDR.ADDR1;
                ViewBag.Addr2 = cSCOADDR.ADDR2;
                ViewBag.Addr3 = cSCOADDR.ADDR3;
                ViewBag.Addr4 = cSCOADDR.POSTAL;
                if (cSCOADDR.HKCITY != null)
                {
                    ViewBag.Addr4 = ViewBag.Addr4 + " " + cSCOADDR.HKCITY.CITYDESC;
                }
                else
                {
                    ViewBag.Addr4 = ViewBag.Addr4 + " " + cSCOADDR.CITYCODE;
                }
            }
            else
            {
                ViewBag.Addr1 = "";
                ViewBag.Addr2 = "";
                ViewBag.Addr3 = "";
                ViewBag.Addr4 = "";
            }

            string   pSearchCode    = "";
            string   pSearchName    = "";
            string   pSearchStaff   = "";
            DateTime pSearchARDate  = DateTime.Parse("01/01/0001");
            DateTime pSearchEndDate = DateTime.Parse("01/01/0001");

            if (Session["SearchVCSCOARRec"] != null)
            {
                V_CSCOAR searchRec = (V_CSCOAR)(Session["SearchVCSCOARRec"]);
                pSearchCode    = searchRec.CONO ?? "";
                pSearchName    = searchRec.CONAME ?? "";
                pSearchStaff   = searchRec.STAFFCODE ?? "";
                pSearchARDate  = searchRec.LASTAR ?? DateTime.Parse("01/01/0001");
                pSearchEndDate = pSearchARDate.AddMonths(1).AddDays(-1);
            }
            else
            {
                pSearchARDate  = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
                pSearchEndDate = pSearchARDate.AddMonths(1).AddDays(-1);
            }


            SACOMP profileRec = db.SACOMPs.FirstOrDefault();

            ViewBag.Company = profileRec.CONAME.ToUpper() + " (" + profileRec.COREGNO + ") ";
            ViewBag.Address = profileRec.COADDR1 + " " + profileRec.COADDR2 + " " + profileRec.COADDR3 + " " + profileRec.COADDR4;
            ViewBag.Contact = "Tel: " + profileRec.COPHONE1 + " Fax: " + profileRec.COFAX1 + " E-Mail: " + profileRec.COWEB;


            v_CSCOAR.ReminderMonth = pSearchARDate.Month;
            v_CSCOAR.ReminderYear  = pSearchARDate.Year;
            ViewBag.ReminderDate   = v_CSCOAR.ReminderDate?.ToString("dd MMM yyyy");

            if (v_CSCOAR.ARTOFILE.HasValue)
            {
                ViewBag.AR = v_CSCOAR.ARTOFILE.Value.ToString("dd MMM yyyy");
                DateTime Deadline = v_CSCOAR.ARTOFILE.Value.AddDays(30);
                ViewBag.Deadline = Deadline.ToString("dd MMM yyyy");
            }

            int      c      = 0;
            DateTime lastar = DateTime.Parse("01/01/0001");

            if (v_CSCOAR.CReminderType == "Special")
            {
                MvcHtmlString       s      = MvcHtmlString.Create("");// MvcHtmlString.Create(ViewBag.AR);
                MvcHtmlString       t      = MvcHtmlString.Create("");
                IQueryable <CSCOAR> cSCOAR = db.CSCOARs.Where(x => x.CONO == v_CSCOAR.CONO && x.FILEDAR == null).OrderBy(y => y.ARNO);
                foreach (CSCOAR rec in cSCOAR)
                {
                    if (rec.ARTOFILE != null)
                    {
                        if (c == 0)
                        {
                            s = MvcHtmlString.Create(s + rec.ARTOFILE?.ToString("dd MMM yyyy"));
                            t = MvcHtmlString.Create(t + rec.ARTOFILE.Value.AddDays(30).ToString("dd MMM yyyy"));
                        }
                        else
                        {
                            s = MvcHtmlString.Create(s + " <br /> " + rec.ARTOFILE?.ToString("dd MMM yyyy"));
                            t = MvcHtmlString.Create(t + " <br /> " + rec.ARTOFILE.Value.AddDays(30).ToString("dd MMM yyyy"));
                        }
                        c++;

                        lastar = rec.ARTOFILE ?? DateTime.Parse("01/01/0001");
                    }
                }

                if (lastar.Year != 1) // this is to stop processing if there is no AR records
                {
                    lastar = lastar.AddYears(1);
                    while (lastar.Year <= pSearchARDate.Year)
                    {
                        if (c == 0)
                        {
                            s = MvcHtmlString.Create(s + lastar.ToString("dd MMM yyyy"));
                            t = MvcHtmlString.Create(t + lastar.AddDays(30).ToString("dd MMM yyyy"));
                        }
                        else
                        {
                            s = MvcHtmlString.Create(s + " <br /> " + lastar.ToString("dd MMM yyyy"));
                            t = MvcHtmlString.Create(t + " <br /> " + lastar.AddDays(30).ToString("dd MMM yyyy"));
                        }
                        c++;
                        if (lastar.Year >= pSearchARDate.Year)
                        {
                            break;
                        }
                        lastar = lastar.AddYears(1);
                    }
                }
                ViewBag.AR       = s;
                ViewBag.Deadline = t;
            }
            return(v_CSCOAR);
        }
Exemple #11
0
        public ActionResult Create([Bind(Include = "CONO,ADDRID,MAILADDRBool,ADDRTYPE,ADDR1,ADDR2,ADDR3,POSTAL,CITYCODE,STATECODE,CTRYCODE,PHONE1,PHONE2,FAX1,FAX2,OPRHRS,OPRHRSStr,REM,SDATE,EDATE,ENDDATE,STAMP")] CSCOADDR cSCOADDR)
        {
            if (ModelState.IsValid)
            {
                short lastRowNo = 0;
                try
                {
                    lastRowNo = db.CSCOADDRs.Where(m => m.CONO == cSCOADDR.CONO).Max(n => n.ADDRID);
                }
                catch (Exception e) { lastRowNo = 0; }
                finally { };

                try
                {
                    cSCOADDR.STAMP  = 0;
                    cSCOADDR.ADDRID = (short)(lastRowNo + 1);
                    db.CSCOADDRs.Add(cSCOADDR);
                    db.SaveChanges();
                    return(new RedirectResult(Url.Action("Edit", "CSCOMSTRs", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSCOADDR.CONO) }) + "#Address"));
                }
                catch (DbEntityValidationException dbEx)
                {
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            //string message = string.Format("{0}:{1}",
                            //    validationErrors.Entry.Entity.ToString(),
                            //   validationError.ErrorMessage);
                            // raise a new exception nesting
                            // the current instance as InnerException
                            ModelState.AddModelError(validationError.PropertyName, validationError.ErrorMessage);
                        }
                    }
                }
                catch (DbUpdateException ex)
                {
                    UpdateException updateException = (UpdateException)ex.InnerException;
                    if (updateException != null)
                    {
                        if (updateException.InnerException != null)
                        {
                            var sqlException = (FirebirdSql.Data.FirebirdClient.FbException)updateException.InnerException;

                            foreach (var error in sqlException.Errors)
                            {
                                if (error.Message != null)
                                {
                                    ModelState.AddModelError(string.Empty, error.Message);
                                }
                            }
                        }
                        else
                        {
                            ModelState.AddModelError(string.Empty, updateException.Message);
                        }
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, updateException.Message);
                    }
                }
            }
            cSCOADDR.CSCOMSTR = db.CSCOMSTRs.Find(cSCOADDR.CONO);
            ViewBag.ADDRTYPE  = cSCOADDR.addrtypeList;
            ViewBag.CITYCODE  = new SelectList(db.HKCITies.OrderBy(x => x.CITYCODE), "CITYCODE", "CITYDESC", cSCOADDR.CITYCODE);
            ViewBag.STATECODE = new SelectList(db.HKSTATEs.OrderBy(x => x.STATECODE), "STATECODE", "STATEDESC", cSCOADDR.STATECODE);
            ViewBag.CTRYCODE  = new SelectList(db.HKCTRies.OrderBy(x => x.CTRYCODE), "CTRYCODE", "CTRYDESC", cSCOADDR.CTRYCODE);
            return(View(cSCOADDR));
        }