Пример #1
0
        public ActionResult Create([Bind(Include = "ENTDATE,CONO,JOBNO,SYSGENBool,PRFALLOCBool,CASENO,CASECODE,ITEMTYPE,ITEMDESC,ITEMSPEC,TAXRATE,ITEMAMT1,TAXAMT1,NETAMT1,ITEMAMT2,TAXAMT2,NETAMT2,ITEMAMT,TAXAMT,NETAMT,SYSGEN,PRFALLOC,PRFNO,PRFID,STAMP")] CSBILL cSBILL)
        {
            if (ModelState.IsValid)
            {
                SALASTNO serialTbl = db.SALASTNOes.Find("CSBILL");
                if (serialTbl != null)
                {
                    try
                    {
                        string prefix  = serialTbl.LASTPFIX;
                        int    MaxNo   = serialTbl.LASTNOMAX;
                        bool   AutoGen = serialTbl.AUTOGEN == "Y";
                        serialTbl.LASTNO = serialTbl.LASTNO + 1;
                        cSBILL.BILLNO    = serialTbl.LASTNO.ToString("D10");


                        serialTbl.STAMP           = serialTbl.STAMP + 1;
                        db.Entry(serialTbl).State = EntityState.Modified;
                        db.CSBILLs.Add(cSBILL);
                        db.SaveChanges();
                        return(RedirectToAction("Index"));
                    }
                    catch (Exception e)
                    {
                        ModelState.AddModelError(string.Empty, e.Message);
                    }
                    finally
                    {
                        View("Edit", cSBILL);
                    }
                }
            }

            return(CallView("Edit", cSBILL));
        }
Пример #2
0
        public ActionResult Create([Bind(Include = "TRNO,VDATE,CONO,COADDRID,ATTN,REM,SEQNO,POSTBool,STAMP")] CSCNM cSCNM)
        {
            if (ModelState.IsValid)
            {
                SALASTNO serialTbl = db.SALASTNOes.Find("CSCN");
                if (serialTbl != null)
                {
                    CSCOMSTR cSCOMSTR = db.CSCOMSTRs.Find(cSCNM.CONO);
                    if (cSCOMSTR != null)
                    {
                        try
                        {
                            string prefix  = serialTbl.LASTPFIX;
                            int    MaxNo   = serialTbl.LASTNOMAX;
                            bool   AutoGen = serialTbl.AUTOGEN == "Y";
                            if (AutoGen)
                            {
                                serialTbl.LASTNO          = serialTbl.LASTNO + 1;
                                cSCNM.TRNO                = serialTbl.LASTNO.ToString("D10");
                                serialTbl.STAMP           = serialTbl.STAMP + 1;
                                db.Entry(serialTbl).State = EntityState.Modified;
                            }
                            cSCNM.STAMP = 1;

                            // increment company seqno count before using it in transaction
                            cSCOMSTR.SEQNO = cSCOMSTR.SEQNO + 1;
                            cSCOMSTR.STAMP = cSCOMSTR.STAMP + 1;

                            cSCNM.SEQNO = cSCOMSTR.SEQNO;
                            db.Entry(cSCOMSTR).State = EntityState.Modified;

                            db.CSCNMs.Add(cSCNM);
                            db.SaveChanges();

                            //return Edit(MyHtmlHelpers.ConvertIdToByteStr(cSCNM.TRNO), 1);
                            return(RedirectToAction("Edit", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSCNM.TRNO), page = 1 }));
                        }
                        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);
                            }
                        }
                        catch (Exception e)
                        {
                            db.CSCNMs.Remove(cSCNM);
                            ModelState.AddModelError(string.Empty, e.Message);
                        }
                        finally
                        {
                        }
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, "Unable to find company #");
                    }
                }
            }


            ViewBag.CSCND    = db.CSCNDs.Where(x => x.TRNO == cSCNM.TRNO);
            ViewBag.CONAME   = db.CSCOMSTRs.Where(x => x.CONO == cSCNM.CONO).Select(y => y.CONAME).FirstOrDefault();
            ViewBag.CONO     = new SelectList(db.CSCOMSTRs.Select(x => new { CONO = x.CONO, CONAME = x.CONAME + "  (" + x.CONO + ")" }).OrderBy(y => y.CONAME), "CONO", "CONAME", cSCNM.CONO);
            ViewBag.ATTNDESC = new SelectList(db.CSCOPICs.Where(x => x.CONO == cSCNM.CONO).Select(x => new { PRSNAME = x.CSPR.PRSNAME, PRSDESC = x.CSPR.PRSNAME }).OrderBy(y => y.PRSDESC), "PRSNAME", "PRSDESC", cSCNM.ATTN);
            ViewBag.COADDR   = new SelectList(db.CSCOADDRs.Where(x => x.CONO == cSCNM.CONO).Select(x => new { COADDR = x.CONO + "|" + x.ADDRID, COADDRDESC = x.ADDRTYPE + " | " + x.MAILADDR + " | " + x.ADDR1 + " " + x.ADDR2 + " " + x.ADDR3 }), "COADDR", "COADDRDESC", cSCNM.COADDR);

            ViewBag.Title = "Create Discounted Bill";
            return(View("Edit", cSCNM));
        }
Пример #3
0
        public ActionResult Create([Bind(Include = "ENTDATE,CONO,JOBNO,SYSGENBool,PRFALLOCBool,CASENO,CASECODE,ITEMTYPE,ITEMDESC,ITEMSPEC,TAXCODE,TAXRATE,ITEMAMT1,TAXAMT1,NETAMT1,ITEMAMT2,TAXAMT2,NETAMT2,ITEMAMT,TAXAMT,NETAMT,SYSGEN,PRFALLOC,PRFNO,PRFID,STAMP")] CSBILL cSBILL)
        {
            if (ModelState.IsValid)
            {
                SALASTNO serialTbl = db.SALASTNOes.Find("CSBILL");
                if (serialTbl != null)
                {
                    try
                    {
                        string prefix  = serialTbl.LASTPFIX;
                        int    MaxNo   = serialTbl.LASTNOMAX;
                        bool   AutoGen = serialTbl.AUTOGEN == "Y";
                        serialTbl.LASTNO = serialTbl.LASTNO + 1;
                        cSBILL.BILLNO    = serialTbl.LASTNO.ToString("D10");


                        serialTbl.STAMP           = serialTbl.STAMP + 1;
                        db.Entry(serialTbl).State = EntityState.Modified;
                        db.CSBILLs.Add(cSBILL);
                        db.SaveChanges();

                        int page = (int)Session["CSBillPage"];
                        return(RedirectToAction("Index", new { page = page }));
                    }
                    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);
                        }
                    }
                    catch (Exception e)
                    {
                        ModelState.AddModelError(string.Empty, e.Message);
                    }
                    finally
                    {
                        View("Edit", cSBILL);
                    }
                }
            }

            return(CallView("Edit", cSBILL));
        }
Пример #4
0
        public ActionResult Create([Bind(Include = "JOBNO,VDATE,CONO,REM,JOBSTAFF,JOBPOST,CASECNT,OKCNT,COMPLETE,COMPLETED,STAMP")] CSJOBM cSJOBM)
        {
            if (ModelState.IsValid)
            {
                SALASTNO serialTbl = db.SALASTNOes.Find("CSJOB");
                if (serialTbl != null)
                {
                    CSCOMSTR cSCOMSTR = db.CSCOMSTRs.Find(cSJOBM.CONO);
                    if (cSCOMSTR != null)
                    {
                        try
                        {
                            string prefix  = serialTbl.LASTPFIX;
                            int    MaxNo   = serialTbl.LASTNOMAX;
                            bool   AutoGen = serialTbl.AUTOGEN == "Y";
                            serialTbl.LASTNO = serialTbl.LASTNO + 1;
                            cSJOBM.JOBNO     = serialTbl.LASTNO.ToString("D10");

                            serialTbl.STAMP           = serialTbl.STAMP + 1;
                            db.Entry(serialTbl).State = EntityState.Modified;


                            db.CSJOBMs.Add(cSJOBM);

                            db.SaveChanges();
                            //return Edit(MyHtmlHelpers.ConvertIdToByteStr(cSRCP.TRNO), 1);
                            return(RedirectToAction("Edit", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSJOBM.JOBNO), page = 1 }));
                        }
                        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);
                            }
                        }
                        catch (Exception e)
                        {
                            ModelState.AddModelError(string.Empty, e.Message);
                        }
                        finally
                        {
                        }
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, "Unable to find company #");
                    }
                }
            }

            ViewBag.CONO     = new SelectList(db.CSCOMSTRs.Select(x => new { CONO = x.CONO, CONAME = x.CONAME + "  (" + x.CONO + ")" }).OrderBy(y => y.CONAME), "CONO", "CONAME", cSJOBM.CONO);
            ViewBag.JOBSTAFF = new SelectList(db.HKSTAFFs, "STAFFCODE", "STAFFDESC", cSJOBM.JOBSTAFF);
            ViewBag.Title    = "Create New Job Taking";
            return(View("Edit", cSJOBM));
        }
Пример #5
0
        public ActionResult Create([Bind(Include = "PRSCODE,CONSTCODE,PRSNAME,PRSTITLE,NATION,RACE,SEX,DOB,CTRYINC,MOBILE1,MOBILE2,EMAIL,OCCUPATION,REM,STAMP")] CSPR cSPR)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    cSPR.STAMP = 0;

                    SALASTNO serialTbl = db.SALASTNOes.Find("CSPRS");
                    if (serialTbl != null)
                    {
                        try
                        {
                            string prefix  = serialTbl.LASTPFIX;
                            int    MaxNo   = serialTbl.LASTNOMAX;
                            bool   AutoGen = serialTbl.AUTOGEN == "Y";
                            serialTbl.LASTNO = serialTbl.LASTNO + 1;
                            cSPR.PRSCODE     = serialTbl.LASTNO.ToString("D10");


                            serialTbl.STAMP           = serialTbl.STAMP + 1;
                            db.Entry(serialTbl).State = EntityState.Modified;

                            db.CSPRS.Add(cSPR);
                            db.SaveChanges();
                            int page = (int)Session["CSPRSPage"];
                            return(RedirectToAction("Edit", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSPR.PRSCODE), page = page }));
                        }
                        catch (Exception e)
                        {
                            ModelState.AddModelError(string.Empty, e.Message);
                        }
                    }
                }
                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);
                    }
                }
            }
            ViewBag.SEX       = cSPR.gender;
            ViewBag.CONSTCODE = new SelectList(db.HKCONSTs.OrderBy(x => x.CONSTCODE).Select(x => new { CONSTCODE = x.CONSTCODE, CONSTDESC = x.CONSTCODE + " | " + x.CONSTDESC + " | " + x.CONSTTYPE }), "CONSTCODE", "CONSTDESC", cSPR.CONSTCODE);
            ViewBag.PRSTITLE  = new SelectList(db.HKTITLEs, "TITLE", "TITLE", cSPR.PRSTITLE);
            ViewBag.NATION    = new SelectList(db.HKNATIONs, "NATION", "NATION", cSPR.NATION);
            ViewBag.RACE      = new SelectList(db.HKRACEs, "RACE", "RACE", cSPR.RACE);
            ViewBag.CTRYINC   = new SelectList(db.HKCTRies, "CTRYCODE", "CTRYDESC", cSPR.CTRYINC);
            ViewBag.Title     = "Create Entity ";
            ViewBag.page      = (int)Session["CSPRSPage"];
            return(View("Edit", cSPR));
        }
Пример #6
0
        public ActionResult Post(string[] cono)
        {
            CSPRFsController CSPRFControl = new CSPRFsController();

            try
            {
                SALASTNO serialTbl0 = db.SALASTNOes.Find("CSBILL");
                if ((serialTbl0 != null))
                {
                    foreach (string item in cono)
                    {
                        var      conofee  = item.Split('|');
                        var      myCono   = conofee[0];
                        var      myFee    = conofee[1];
                        string   lastCono = "";
                        CSCOMSTR cSCOMSTR = null;
                        myCono = myCono.Trim();
                        myFee  = myFee.Trim();



                        var     csFees  = db.CSCOFEEs.Where(x => x.CONO == myCono && x.FEETYPE == myFee);
                        decimal taxrate = 0;
                        string  taxcode = "SSTN01";
                        CSPRF   cSPRF   = null;
                        int     prfId   = 0;
                        foreach (var feerec in csFees)
                        {
                            CSITEM cSITEM = db.CSITEMs.Find(feerec.FEETYPE);
                            if (cSITEM != null)
                            {
                                taxrate = cSITEM.GSTRATE ?? 0;
                            }

                            if (lastCono != feerec.CONO)
                            {
                                cSCOMSTR                 = db.CSCOMSTRs.Find(feerec.CONO);
                                cSCOMSTR.SEQNO           = cSCOMSTR.SEQNO + 1;
                                cSCOMSTR.STAMP           = cSCOMSTR.STAMP;
                                db.Entry(cSCOMSTR).State = EntityState.Modified;
                            }

                            var feedate = feerec.LASTTOUCH;


                            feerec.LASTTOUCH       = feedate.AddMonths(feerec.FEEMTH);
                            feerec.STAMP           = feerec.STAMP + 1;
                            db.Entry(feerec).State = EntityState.Modified;


                            SALASTNO serialTbl = db.SALASTNOes.Find("CSPRF");
                            if ((serialTbl != null) && (lastCono != feerec.CONO))
                            {
                                string prefix  = serialTbl.LASTPFIX;
                                int    MaxNo   = serialTbl.LASTNOMAX;
                                bool   AutoGen = serialTbl.AUTOGEN == "Y";
                                serialTbl.LASTNO = serialTbl.LASTNO + 1;


                                cSPRF         = new CSPRF();
                                cSPRF.STAMP   = 0;
                                cSPRF.VDATE   = feedate;
                                cSPRF.DUEDATE = feedate;
                                cSPRF.DUEDAYS = 0;
                                cSPRF.SEQNO   = cSCOMSTR.SEQNO;
                                cSPRF.CONO    = feerec.CONO;
                                short?coid = db.CSCOADDRs.Where(x => x.CONO == feerec.CONO && x.MAILADDR == "Y").Select(y => y.ADDRID).FirstOrDefault();
                                if (coid == 0)
                                {
                                    coid = db.CSCOADDRs.Where(x => x.CONO == feerec.CONO && x.MAILADDR == "N").Select(y => y.ADDRID).FirstOrDefault();
                                }
                                if (coid != 0)
                                {
                                    cSPRF.COADDRID = coid;
                                }

                                cSPRF.ATTN     = "The Board of Directors";
                                cSPRF.PRFNO    = serialTbl.LASTNO.ToString("D10");
                                cSPRF.INVALLOC = "N";

                                serialTbl.STAMP           = serialTbl.STAMP + 1;
                                db.Entry(serialTbl).State = EntityState.Modified;
                                db.CSPRFs.Add(cSPRF);
                                prfId = 0;
                            }

                            prfId++;
                            serialTbl0.LASTNO = serialTbl0.LASTNO + 1;
                            string prefix0  = serialTbl0.LASTPFIX;
                            int    MaxNo0   = serialTbl0.LASTNOMAX;
                            bool   AutoGen0 = serialTbl0.AUTOGEN == "Y";
                            CSBILL cSBILL   = new WebApplication1.CSBILL();
                            cSBILL.STAMP    = 0;
                            cSBILL.CONO     = feerec.CONO;
                            cSBILL.PRFALLOC = "Y";
                            cSBILL.SYSGEN   = "Y";
                            cSBILL.PRFNO    = cSPRF.PRFNO;
                            cSBILL.PRFID    = prfId;
                            cSBILL.BILLNO   = serialTbl0.LASTNO.ToString("D10");;
                            cSBILL.ENTDATE  = feedate;
                            cSBILL.CASECODE = feerec.FEECODE;
                            cSBILL.ITEMTYPE = feerec.FEETYPE;
                            cSBILL.ITEMDESC = feerec.CSCASE.CASEDESC;
                            cSBILL.ITEMSPEC = "- From " + feedate.ToString("dd/MM/yyyy") + " To " + feedate.AddMonths(feerec.FEEMTH).ToString("dd/MM/yyyy");

                            cSBILL.ITEMAMT = feerec.FEEAMT;
                            cSBILL.TAXAMT  = taxrate * feerec.FEEAMT / 100;
                            cSBILL.NETAMT  = cSBILL.ITEMAMT + cSBILL.TAXAMT;

                            cSBILL.ITEMAMT1 = feerec.FEEAMT;
                            cSBILL.TAXAMT1  = taxrate * feerec.FEEAMT / 100;
                            cSBILL.NETAMT1  = cSBILL.ITEMAMT1 + cSBILL.TAXAMT1;

                            cSBILL.ITEMAMT2 = 0;
                            cSBILL.TAXAMT2  = 0;
                            cSBILL.NETAMT2  = 0;
                            cSBILL.TAXRATE  = taxrate;

                            taxcode        = db.CSTAXTYPEs.Where(x => x.TAXRATE == taxrate && x.EFFECTIVE_START <= cSBILL.ENTDATE && x.EFFECTIVE_END >= cSBILL.ENTDATE).Select(y => y.TAXCODE).FirstOrDefault() ?? taxcode;
                            cSBILL.TAXCODE = taxcode;
                            db.CSBILLs.Add(cSBILL);


                            CSTRANM cSTRANM = new CSTRANM();
                            cSTRANM.STAMP = 0;
                            CSPRFControl.BD_UpdateCSTRANM(cSPRF, cSBILL, cSTRANM);

                            db.CSTRANMs.Add(cSTRANM);

                            lastCono = feerec.CONO;
                        }
                        //db.Entry(serialTbl0).State = EntityState.Modified;
                        //db.SaveChanges();
                    }
                    db.Entry(serialTbl0).State = EntityState.Modified;
                    db.SaveChanges();
                }
            }
            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);
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError(string.Empty, e.Message);
            }
            finally
            {
                CSPRFControl.Dispose();
            }

            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }