示例#1
0
        public ActionResult Complaint(clsComplaint oTbl)
        {
            string sLine = "";
            var    sMsg  = new { Message = "Successfully Saved ...", MsgID = 1, ComplaintNo = "0" };

            try
            {
                string       CompNo  = DateTime.Now.Date.Date.ToString("yy") + DateTime.Now.Date.Date.ToString("MM") + DateTime.Now.Date.Date.ToString("dd");
                int          iCustID = 0;
                tblComplaint oComp   = new tblComplaint();

                oComp.CustID = oTbl.CustID;
                if (oTbl.IsNewCust == 1)
                {
                    iCustID = Convert.ToInt32(oSubmit.GetSingleData("Select isnull(max(studCode)+1,1) from studdet where studType = 68", "0", true));
                    studdet Cust = new studdet();
                    Cust.studType = 68;
                    Cust.studCode = iCustID;
                    Cust.studName = oTbl.studName;
                    Cust.studadd1 = oTbl.studadd1;
                    Cust.studadd2 = oTbl.studadd2;
                    Cust.studcity = oTbl.studcity;
                    Cust.studstat = oTbl.studstat;
                    Cust.studphon = oTbl.studphon;

                    db.studdets.InsertOnSubmit(Cust);
                    db.SubmitChanges();

                    oComp.CustID = iCustID;
                }

                sLine = "1";

                oComp.CompNo = CompNo + GetNo(oSubmit.GetSingleData("Select isnull(max(CompID)+1,1) from tblComplaint", "0", true).ToString());
                //oComp.CompDt = oSubmit.GetDateFormat(oTbl.CompDt.ToString());
                sLine           = "2";
                oComp.CreatedOn = DateTime.Now;
                oComp.StatusID  = 1;
                oComp.UserID    = SessionMaster.UserID;
                sLine           = "3";
                if (oTbl.sTentetiveTm != null && oTbl.sTentetiveTm.ToString() != "")
                {
                    oComp.TentetiveTm = oSubmit.GetDate(oTbl.sTentetiveTm.ToString());
                }

                sLine  = "4";
                sLine += oTbl.CompDt.ToString();

                oComp.CompDt   = oSubmit.GetDate(oTbl.sCompDt.ToString());
                sLine          = "5";
                oComp.DealerID = oTbl.DealerID;

                oComp.CustNM      = oTbl.CustNM;
                oComp.ModelNo     = oTbl.ModelNo;
                oComp.SrvType     = oTbl.SrvType;
                oComp.EmpID       = oTbl.EmpID;
                oComp.ItemID      = oTbl.ItemID;
                oComp.InvNo       = oTbl.InvNo;
                oComp.Charge      = oTbl.Charge;
                oComp.Remark_Cust = oTbl.Remark_Cust;
                oComp.Remark_Mgr  = oTbl.Remark_Eng; //Remark_Eng to Remark_Mgr 181101

                oComp.cmIsRead   = 1;                //181027
                oComp.cmIsPaid   = oTbl.IsPaid;      //181027
                oComp.cmSrvcMode = oTbl.IsSrvcMode;  //181027
                oComp.cmCategory = oTbl.Category;    //181027

                db.tblComplaints.InsertOnSubmit(oComp);
                db.SubmitChanges();

                CompNo = CompNo + GetNo(oSubmit.GetSingleData("Select isnull(max(CompID)+1,1) from tblComplaint", "0", true).ToString());

                sMsg = new { Message = "Complaint Successfully Registered . Your Complaint No Is " + CompNo + " .", MsgID = 1, ComplaintNo = CompNo };
            }
            catch (Exception ex)
            {
                sMsg = new { Message = sLine + "#" + ex.Message, MsgID = 2, ComplaintNo = "0" };
            }

            return(Json(sMsg, JsonRequestBehavior.AllowGet));
        }