Exemplo n.º 1
0
        /// <summary>
        /// 部分修改保存
        /// </summary>
        /// <param name="OprObject">对象clsMachine的一个实例参数</param>
        /// <returns></returns>
        public int UpdatePart(clsMachine OprObject, out string errMsg)
        {
            errMsg = string.Empty;
            int rtn = 0;

            try
            {
                sb.Length = 0;
                sb.Append("UPDATE tMachine SET ");
                sb.AppendFormat("LinkComNo={0}", OprObject.LinkComNo);
                sb.AppendFormat(",IsSupport={0}", OprObject.IsSupport);
                sb.AppendFormat(",TestValue={0}", OprObject.TestValue);
                sb.AppendFormat(",TestSign='{0}'", OprObject.TestSign);
                sb.AppendFormat(",LinkStdCode='{0}'", OprObject.LinkStdCode);
                sb.AppendFormat(" WHERE SysCode='{0}'", OprObject.SysCode);

                //string updateSql="update tMachine set "
                //    + "LinkComNo=" + OprObject.LinkComNo + ","
                //    + "IsSupport=" + OprObject.IsSupport + ","
                //    + "TestValue=" + OprObject.TestValue + ","
                //    + "TestSign='" + OprObject.TestSign + "',"
                //    + "LinkStdCode='" + OprObject.LinkStdCode + "'"
                //    + " where SysCode='" + OprObject.SysCode + "' ";
                DataBase.ExecuteCommand(sb.ToString(), out errMsg);

                rtn = 1;
            }
            catch (Exception e)
            {
                errMsg = e.Message;
            }

            return(rtn);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 部分修改保存
        /// </summary>
        /// <param name="model">对象clsMachine的一个实例参数</param>
        /// <returns></returns>
        public int InsertOrUpdate(clsMachine model, bool isAdd, out string sErrMsg)
        {
            sErrMsg = string.Empty;
            int rtn = 0;

            sb.Length = 0;
            try
            {
                //sb.AppendFormat("IF Exists(SELECT SysCode FROM tMachine WHERE SysCode='{0}')",model.SysCode);//如果存在进行update操作
                if (!isAdd)
                {
                    sb.Append("UPDATE tMachine SET ");

                    sb.AppendFormat("LinkComNo={0}", model.LinkComNo);
                    sb.AppendFormat(",MachineName='{0}'", model.MachineName);
                    sb.AppendFormat(",MachineModel='{0}'", model.MachineModel);
                    sb.AppendFormat(",Company='{0}'", model.Company);
                    sb.AppendFormat(",Protocol='{0}'", model.Protocol);
                    sb.AppendFormat(",IsSupport={0}", model.IsSupport);
                    sb.AppendFormat(",IsShow={0}", model.IsShow);
                    sb.AppendFormat(",TestValue={0}", model.TestValue);
                    sb.AppendFormat(",TestSign='{0}'", model.TestSign);
                    sb.AppendFormat(",LinkStdCode='{0}'", model.LinkStdCode);
                    sb.AppendFormat(",OrderId='{0}'", model.OrderId);
                    sb.AppendFormat(" WHERE SysCode='{0}'", model.SysCode);
                }
                else
                {
                    //sb.Append(" ELSE ");
                    sb.Append("INSERT INTO tMachine");
                    sb.Append("(SysCode,MachineName,MachineModel,Company,Protocol,IsSupport,");
                    sb.Append("LinkComNo,TestSign,TestValue,LinkStdCode,IsShow,OrderId)");
                    sb.Append("VALUES(");

                    sb.AppendFormat("'{0}'", model.SysCode);
                    sb.AppendFormat(",'{0}'", model.MachineName);
                    sb.AppendFormat(",'{0}'", model.MachineModel);
                    sb.AppendFormat(",'{0}'", model.Company);
                    sb.AppendFormat(",'{0}'", model.Protocol);
                    sb.AppendFormat(",{0}", model.IsSupport);
                    sb.AppendFormat(",{0}", model.LinkComNo);
                    sb.AppendFormat(",'{0}'", model.TestSign);
                    sb.AppendFormat(",{0}", model.TestValue);
                    sb.AppendFormat(",'{0}'", model.LinkStdCode);
                    sb.AppendFormat(",{0}", model.IsShow);
                    sb.AppendFormat(",{0}", model.OrderId);

                    sb.Append(")");
                }
                //string updateSql="update tMachine set "
                //    + "LinkComNo=" + OprObject.LinkComNo + ","
                //    + "IsSupport=" + OprObject.IsSupport + ","
                //    + "TestValue=" + OprObject.TestValue + ","
                //    + "TestSign='" + OprObject.TestSign + "',"
                //    + "LinkStdCode='" + OprObject.LinkStdCode + "'"
                //    + " where SysCode='" + OprObject.SysCode + "' ";
                DataBase.ExecuteCommand(sb.ToString(), out sErrMsg);
                sb.Length = 0;
                rtn       = 1;
            }
            catch (Exception e)
            {
                sErrMsg = e.Message;
            }

            return(rtn);
        }