Пример #1
0
        public ActionResult Insert(account act, string command, AccountMaster oCls)
        {
            if (command == "Save")
            {
                CompxERP.Models.clsSubmitModel oSubmit = new CompxERP.Models.clsSubmitModel();
                DataTable dt;
                dt           = oSubmit.GetData("select isnull(max(AcctCode) ,0 )+1 AcctCode from Account");
                act.acctcode = Convert.ToInt32(dt.Rows[0]["AcctCode"]);

                act.compcode  = int.Parse(Session["CompCode"].ToString());
                act.acctOwner = oCls.acctOwner;

                act.acctcldr   = 0;
                act.acctclcr   = 0;
                act.acctjmbl   = -1;
                act.acctagen   = 0;
                act.acctrema   = act.CSTNo + ',' + act.PAN + ',' + act.TinNo + ',' + act.acctrema;
                act.acwithbl   = 0;
                act.acctitrd   = 0;
                act.acctdsap   = 0;
                act.acctprty   = 0;
                act.acctprbl   = 0;
                act.acFarmerDC = 0;

                if (oCls.groumain == "9" || oCls.groumain == "10" || oCls.groumain == "40" || oCls.groumain == "41")
                {
                    act.acctpinc = oCls.acctpinc_Hearder;
                }

                db.accounts.InsertOnSubmit(act);
                db.SubmitChanges();


                //********************************* User Work *********************************
                clsUserWork oUser = new clsUserWork();
                oUser.woruser = SessionMaster.UserID;
                oUser.wormode = 0;
                oUser.worcomp = SessionMaster.CompCode;
                oUser.wortype = 0;
                oUser.worcode = act.acctcode;
                oUser.worsrno = oSubmit.GetUsWoCode();;
                oUser.worrema = "D-" + oCls.acctname + "#" + oCls.acctgroup + "#" + oCls.acctphon;
                oUser.wordate = Convert.ToDateTime("04/01/1900");
                oUser.worrfsr = "";
                oUser.worsysn = Environment.MachineName;
                oSubmit.InsUserWork(oUser);
                //***************************************************************************

                TempData["Msg"] = "Data Save Successfully";
                return(RedirectToAction("Insert"));
            }
            else
            {
                clsSubmitModel oSubmit = new clsSubmitModel();
                var            res     = from k in db.accounts where k.acctcode == act.acctcode select k;
                account        temp    = new account();// db.accounts.First(m => m.acctcode == id);
                switch (act.acctgrou)
                {
                case 34:    //Agent
                    break;

                case 24:    //Bank
                    act.acctarea = 0;
                    act.acctcity = 0;
                    act.acctstat = 0;
                    break;
                }
                temp.acctOwner  = act.acctOwner;
                temp.acctgsta   = act.acctgsta;
                temp.acctgstin  = act.acctgstin;
                temp.acctname   = act.acctname;
                temp.acctgrou   = act.acctgrou;
                temp.acctcode   = act.acctcode;
                temp.acctalia   = act.acctalia;
                temp.acctrema   = act.CSTNo + ',' + act.PAN + ',' + act.TinNo + ',' + act.acctrema;
                temp.acctsort   = act.acctsort;
                temp.acctconp   = act.acctconp;
                temp.acctdsa    = act.acctdsa;
                temp.TinNo      = act.TinNo;
                temp.PAN        = act.PAN;
                temp.CSTNo      = act.CSTNo;
                temp.acctPhone  = act.acctPhone;
                temp.acctMob2   = act.acctMob2;
                temp.acctphon   = act.acctphon;
                temp.accthind   = act.accthind;
                temp.acctaddr   = act.acctaddr;
                temp.acctarea   = act.acctarea;
                temp.acctcity   = act.acctcity;
                temp.acctstat   = act.acctstat;
                temp.acctledg   = act.acctledg;
                temp.PIN        = act.PIN;
                temp.acctconp   = act.acctconp;
                temp.acctcurr   = act.acctcurr;
                temp.acctcate   = act.acctcate;
                temp.acctpinc   = act.acctpinc;
                temp.acctmail   = act.acctmail;
                temp.acctfax    = act.acctfax;
                temp.acctjmbl   = act.acctjmbl; //-1
                temp.acctagen   = act.acctagen;
                temp.acctitrd   = act.acctitrd; //0;
                temp.acctrate   = act.acctrate; //0
                temp.acformreq  = act.acformreq;
                temp.acwithbl   = 0;
                temp.acctcldr   = 0;
                temp.acctclcr   = 0;
                temp.acctprty   = 0;
                temp.acctprbl   = 0;
                temp.acFarmerDC = 0;
                temp.acctdsap   = 0;

                if (oCls.groumain == "9" || oCls.groumain == "10" || oCls.groumain == "40" || oCls.groumain == "41")
                {
                    temp.acctpinc = oCls.acctpinc_Hearder;
                }

                temp.compcode = Convert.ToInt32(Session["compcode"]);
                oSubmit.UpdAccount(temp);


                //********************************* User Work *********************************
                clsUserWork oUser = new clsUserWork();
                oUser.woruser = SessionMaster.UserID;
                oUser.wormode = 1;
                oUser.worcomp = SessionMaster.CompCode;
                oUser.wortype = 0;
                oUser.worcode = act.acctcode;
                oUser.worsrno = oSubmit.GetUsWoCode();;
                oUser.worrema = "D-" + oCls.acctname + "#" + oCls.acctgroup + "#" + oCls.acctphon;
                oUser.wordate = Convert.ToDateTime("04/01/1900");//DateTime.Now.Date;
                oUser.worrfsr = "";
                oUser.worsysn = Environment.MachineName;
                oSubmit.InsUserWork(oUser);
                //***************************************************************************

                TempData["Msg"] = "Updated Successfully";
                return(RedirectToAction("Insert"));
            }
        }