Example #1
0
        public bool UpdateRecord(Model.Management.Master.SiteMaster_stm_Info infoObject)
        {
            using (VPMSDBDataContext db = new VPMSDBDataContext())
            {
                SiteMaster_stm stm = new SiteMaster_stm();
                try
                {
                    stm = db.SiteMaster_stms.SingleOrDefault(t => t.stm_iRecordID == infoObject.stm_iRecordID);
                    if (stm != null)
                    {
                        stm.stm_cBuildingNumber = infoObject.stm_cBuildingNumber;
                        stm.stm_cName           = infoObject.stm_cName;
                        stm.stm_cNumber         = infoObject.stm_cNumber;
                        stm.stm_cRemark         = infoObject.stm_cRemark;
                        stm.stm_cLast           = infoObject.stm_cLast;

                        stm.stm_dLastDate = infoObject.stm_dLastDate.Value;

                        db.SubmitChanges();
                    }
                    return(true);
                }
                catch (Exception Ex)
                {
                    throw Ex;
                }
            }
        }
Example #2
0
        public bool InsertRecord(Model.Management.Master.SiteMaster_stm_Info infoObject)
        {
            using (VPMSDBDataContext db = new VPMSDBDataContext())
            {
                SiteMaster_stm stm = new SiteMaster_stm();
                try
                {
                    stm = Common.General.CopyObjectValue <Model.Management.Master.SiteMaster_stm_Info, SiteMaster_stm>(infoObject);


                    db.SiteMaster_stms.InsertOnSubmit(stm);
                    db.SubmitChanges();
                    return(true);
                }
                catch (Exception Ex)
                {
                    throw Ex;
                }
            }
        }
Example #3
0
        public List <Model.Management.Master.SiteMaster_stm_Info> SearchRecords(Model.IModel.IModelObject MDobject)
        {
            string sqlString   = string.Empty;
            string whereString = string.Empty;

            sqlString  = "SELECT TOP " + Common.DefineConstantValue.ListRecordMaxCount.ToString() + Environment.NewLine;
            sqlString += " stm.stm_iRecordID," + Environment.NewLine;
            sqlString += " stm.stm_cNumber," + Environment.NewLine;
            sqlString += " bdm.bdm_cName AS BuildingName," + Environment.NewLine;
            sqlString += " stm.stm_cName," + Environment.NewLine;
            sqlString += " stm.stm_cRemark, " + Environment.NewLine;
            sqlString += " stm.stm_cAdd," + Environment.NewLine;
            sqlString += " stm.stm_dAddDate," + Environment.NewLine;
            sqlString += " stm.stm_cLast," + Environment.NewLine;
            sqlString += " stm.stm_dLastDate " + Environment.NewLine;
            sqlString += " FROM SiteMaster_stm stm" + Environment.NewLine;
            sqlString += " LEFT JOIN BuildingMaster_bdm bdm" + Environment.NewLine;
            sqlString += " ON stm.stm_cBuildingNumber=bdm.bdm_cNumber" + Environment.NewLine;


            model.SiteMaster_stm_Info stm_info = null;

            stm_info = MDobject as model.SiteMaster_stm_Info;

            if (stm_info != null)
            {
                whereString = " WHERE 1=1 ";

                if (stm_info.stm_cBuildingNumber.Trim() != "")
                {
                    whereString += " AND stm_cBuildingNumber='" + stm_info.stm_cBuildingNumber.Trim() + "'" + Environment.NewLine;
                }

                if (stm_info.stm_cNumber.Trim() != "")
                {
                    if (stm_info.stm_cNumber.ToString().Contains("*") || stm_info.stm_cNumber.ToString().Contains("?"))
                    {
                        whereString += " AND stm_cNumber LIKE N'" + LocalDefine.General.ReplaceSQLLikeCondition(stm_info.stm_cNumber) + "'";
                    }
                    else
                    {
                        whereString += "AND stm_cNumber = N'" + stm_info.stm_cNumber.ToString().Trim() + "'";
                    }
                }

                if (stm_info.stm_cName.Trim() != "")
                {
                    if (stm_info.stm_cName.ToString().Contains("*") || stm_info.stm_cName.ToString().Contains("?"))
                    {
                        whereString += " AND stm_cName LIKE N'" + LocalDefine.General.ReplaceSQLLikeCondition(stm_info.stm_cName) + "'";
                    }
                    else
                    {
                        whereString += "AND stm_cName = N'" + stm_info.stm_cName.ToString().Trim() + "'";
                    }
                }
            }

            sqlString += whereString;

            IEnumerable <model.SiteMaster_stm_Info> infos    = null;
            List <model.SiteMaster_stm_Info>        infoList = null;

            try
            {
                using (VPMSDBDataContext db = new VPMSDBDataContext())
                {
                    infos = db.ExecuteQuery <model.SiteMaster_stm_Info>(sqlString, new object[] { });

                    if (infos != null)
                    {
                        infoList = infos.ToList <model.SiteMaster_stm_Info>();
                    }
                }
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
            return(infoList);
        }