Esempio n. 1
0
        public ModelInvokeResult <OldManConfigInfoPK> NEWUPDATE(string strIDNo, OldManConfigInfo oldManConfigInfo)
        {
            ModelInvokeResult <OldManConfigInfoPK> result = new ModelInvokeResult <OldManConfigInfoPK> {
                Success = true
            };

            try
            {
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();


                var oldmanbaseinfo = BuilderFactory.DefaultBulder().ExecuteNativeSqlForQuery("select OldManId from Oca_OldManBaseInfo where IDNo='" + strIDNo + "'");

                string OldManId = "";
                foreach (var item in oldmanbaseinfo)
                {
                    OldManId = item["OldManId"].ToString();
                }
                // string a = OldManBaseInfo.GetProperty("OldManId").ToString();
                // var oldManBaseInfo = BuilderFactory.DefaultBulder().Load<OldManBaseInfo, OldManBaseInfoPK>(new OldManBaseInfoPK { IDNo = strOldManId });


                Guid?_OldManId = OldManId.ToGuid();
                if (_OldManId == null)
                {
                    result.Success   = false;
                    result.ErrorCode = 59996;
                    return(result);
                }
                oldManConfigInfo.OldManId = _OldManId;
                /***********************begin 自定义代码*******************/
                oldManConfigInfo.OperatedBy = NormalSession.UserId.ToGuid();
                oldManConfigInfo.OperatedOn = DateTime.Now;
                oldManConfigInfo.DataSource = GlobalManager.DIKey_00012_ManualEdit;


                if (oldManConfigInfo.CallNo != null && oldManConfigInfo.CallNo.Trim() != "")
                {
                    //检测号码是否库内唯一
                    if (BuilderFactory.DefaultBulder().ExecuteNativeSqlForCount("select OldManId,CallNo from Oca_OldManConfigInfo where CallNo='" + oldManConfigInfo.CallNo + "' and OldManId <> '" + oldManConfigInfo.OldManId.ToString() + "'") > 0)
                    {
                        result.Success   = false;
                        result.ErrorCode = 51001;
                        return(result);
                    }
                }
                /***********************end 自定义代码*********************/
                if (BuilderFactory.DefaultBulder().ExecuteNativeSqlForCount(string.Format("select * from {0} where OldManId='{1}'", oldManConfigInfo.GetMappingTableName(), OldManId)) == 1)
                {
                    statements.Add(new IBatisNetBatchStatement {
                        StatementName = oldManConfigInfo.GetUpdateMethodName(), ParameterObject = oldManConfigInfo.ToStringObjectDictionary(false), Type = SqlExecuteType.UPDATE
                    });
                }
                else
                {
                    statements.Add(new IBatisNetBatchStatement {
                        StatementName = oldManConfigInfo.GetCreateMethodName(), ParameterObject = oldManConfigInfo.ToStringObjectDictionary(false), Type = SqlExecuteType.INSERT
                    });
                }

                /***********************begin 自定义代码*******************/
                /***********************此处添加自定义代码*****************/
                /***********************end 自定义代码*********************/
                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements);
                result.instance = new OldManConfigInfoPK {
                    OldManId = _OldManId
                };
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
Esempio n. 2
0
        public ModelInvokeResult <OldManConfigInfoPK> PamConfigInfo(string strOldManId, OldManConfigInfo oldManConfigInfo)
        {
            ModelInvokeResult <OldManConfigInfoPK> result = new ModelInvokeResult <OldManConfigInfoPK> {
                Success = true
            };

            try
            {
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                Guid?_OldManId = strOldManId.ToGuid();
                if (_OldManId == null)
                {
                    result.Success   = false;
                    result.ErrorCode = 59996;
                    return(result);
                }
                oldManConfigInfo.OldManId = _OldManId;
                /***********************begin 自定义代码*******************/
                oldManConfigInfo.OperatedBy = NormalSession.UserId.ToGuid();
                oldManConfigInfo.OperatedOn = DateTime.Now;
                oldManConfigInfo.DataSource = GlobalManager.DIKey_00012_ManualEdit;


                string        sqlCount    = "select a.OldManId,CallNo,CallNo2,CallNo3 from Oca_OldManConfigInfo a left join Oca_OldManBaseInfo b on a.OldManId=b.OldManId where b.Status=3 And a.OldManId <> '" + oldManConfigInfo.OldManId.ToString() + "'";
                List <string> whereClause = new List <string>();
                if (oldManConfigInfo.CallNo != null && oldManConfigInfo.CallNo.Trim() != "")
                {
                    whereClause.Add(" a.CallNo='" + oldManConfigInfo.CallNo + "' ");
                }
                if (oldManConfigInfo.CallNo2 != null && oldManConfigInfo.CallNo2.Trim() != "")
                {
                    whereClause.Add(" a.CallNo2='" + oldManConfigInfo.CallNo2 + "' ");
                }
                if (oldManConfigInfo.CallNo3 != null && oldManConfigInfo.CallNo3.Trim() != "")
                {
                    whereClause.Add(" a.CallNo3='" + oldManConfigInfo.CallNo3 + "' ");
                }
                if (whereClause.Count > 0)
                {
                    sqlCount += " And (" + string.Join("OR", whereClause.ToArray()) + ")";
                    //检测号码是否库内唯一
                    if (BuilderFactory.DefaultBulder().ExecuteNativeSqlForCount(sqlCount) > 0)
                    {
                        result.Success   = false;
                        result.ErrorCode = 51001;
                        return(result);
                    }
                }

                /***********************end 自定义代码*********************/
                if (BuilderFactory.DefaultBulder().ExecuteNativeSqlForCount(string.Format("select * from {0} where OldManId='{1}'", oldManConfigInfo.GetMappingTableName(), strOldManId)) == 1)
                {
                    statements.Add(new IBatisNetBatchStatement {
                        StatementName = oldManConfigInfo.GetUpdateMethodName(), ParameterObject = oldManConfigInfo.ToStringObjectDictionary(false), Type = SqlExecuteType.UPDATE
                    });
                }
                else
                {
                    statements.Add(new IBatisNetBatchStatement {
                        StatementName = oldManConfigInfo.GetCreateMethodName(), ParameterObject = oldManConfigInfo.ToStringObjectDictionary(false), Type = SqlExecuteType.INSERT
                    });
                }

                /***********************begin 自定义代码*******************/
                /***********************此处添加自定义代码*****************/
                /***********************end 自定义代码*********************/
                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements);
                result.instance = new OldManConfigInfoPK {
                    OldManId = _OldManId
                };
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
Esempio n. 3
0
        public ModelInvokeResult <OldManConfigInfoPK> Create(OldManConfigInfo oldManConfigInfo)
        {
            ModelInvokeResult <OldManConfigInfoPK> result = new ModelInvokeResult <OldManConfigInfoPK> {
                Success = true
            };

            try
            {
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                if (oldManConfigInfo.OldManId == GlobalManager.GuidAsAutoGenerate)
                {
                    oldManConfigInfo.OldManId = Guid.NewGuid();
                }
                /***********************begin 自定义代码*******************/
                oldManConfigInfo.OperatedBy = NormalSession.UserId.ToGuid();
                oldManConfigInfo.OperatedOn = DateTime.Now;
                oldManConfigInfo.DataSource = GlobalManager.DIKey_00012_ManualEdit;
                /***********************end 自定义代码*********************/
                statements.Add(new IBatisNetBatchStatement {
                    StatementName = oldManConfigInfo.GetCreateMethodName(), ParameterObject = oldManConfigInfo.ToStringObjectDictionary(false), Type = SqlExecuteType.INSERT
                });
                /***********************begin 自定义代码*******************/
                /***********************此处添加自定义代码*****************/
                /***********************end 自定义代码*********************/
                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements);
                result.instance = new OldManConfigInfoPK {
                    OldManId = oldManConfigInfo.OldManId
                };
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }