Example #1
0
        public bool SaveModelBySqlToDB(User.UserModel user, ref TBase_Model model, ref string strError)
        {
            try
            {
                List <string> lstSql = new List <string>();

                int i = dbFactory.ExecuteNonQueryList(this.GetSaveSql(user, ref model), ref strError);

                if (i > 0)
                {
                    model = GetModelByID(model.ID);
                    if (model == null)
                    {
                        strError = "GetModelByID(modelID)出错,没有找到相符的记录,可能是视图有错误!";
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                strError = ex.Message;
                return(false);
                //throw new Exception(ex.Message);
            }
        }
Example #2
0
        public bool TransferModelByProcedure(User.UserModel user, ref TBase_Model model, string ProcedureName, IDataParameter[] param, ref string strError)
        {
            try
            {
                bool succ = false;
                //int iRows = 0;
                int iOut = 0;

                //把creater、createTime、modifyer等信息填到model中去.
                AddModelOperatorInfo(user, ref model);

                int i = dbFactory.RunProcedure(ProcedureName, param, out iOut);
                if ((int)param[0].Value == -1)
                {
                    strError = param[1].Value.ToString();
                }
                else
                {
                    succ = true;
                    int modelID = (int)param[2].Value;
                    //model.ID = (int)param[2].Value;
                    model = GetModelByID(modelID);
                    if (model == null)
                    {
                        throw new Exception("GetModelByID(modelID)出错,没有找到相符的记录,可能是视图有错误!");
                    }
                }
                return(succ);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #3
0
        public bool UpdateModelListBySqlToDB(User.UserModel user, ref List <TBase_Model> modelList, ref string strError)
        {
            try
            {
                List <string> lstSql = new List <string>();

                lstSql = this.GetUpdateModelListSql(user, modelList);

                if (lstSql == null || lstSql.Count == 0)
                {
                    return(true);
                }

                int i = dbFactory.ExecuteNonQueryList(lstSql, ref strError);

                if (i > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                strError = ex.Message;
                return(false);
                //throw new Exception(ex.Message);
            }
        }
Example #4
0
        public bool SaveModelListToDB(User.UserModel user, List <TBase_Model> modelList, ref string strError)
        {
            try
            {
                bool succ = false;
                List <IDataParameter[]> ParameterList = new List <IDataParameter[]>();

                //把creater、createTime、modifyer等信息填到model中去.

                for (int i = 0; i < modelList.Count; i++)
                {
                    TBase_Model model = modelList[i];
                    AddModelOperatorInfo(user, ref model);

                    IDataParameter[] param = GetSaveModelIDataParameter(model);
                    ParameterList.Add(param);
                }

                succ = dbFactory.RunProcedures(this.GetSaveProcedureName(), ParameterList);

                return(succ);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #5
0
        //public static bool CheckImportTable(int iType, UserInfo user, ref string strError)
        //{
        //    switch (iType)
        //    {
        //        case 1:
        //            Basic.Area.Area_DB areadb = new Basic.Area.Area_DB();
        //            return areadb.CheckImportTable(ref strError);

        //        case 2:
        //            Stock.Stock_DB stockdb = new Stock.Stock_DB();
        //            return stockdb.CheckImportTable(ref strError);

        //        default:
        //            strError = "找不到对应的导入类型";
        //            return false;
        //    }
        //}

        public static bool UpLoadSql(List <string> lstSql, User.UserModel user, ref string strError)
        {
            if (lstSql == null || lstSql.Count <= 0)
            {
                strError = "上传数据不能为空";
                return(false);
            }

            if (OracleDBHelper.ExecuteNonQueryList(lstSql, ref strError) >= 1)
            {
                return(true);
            }
            else
            {
                if (string.IsNullOrEmpty(strError))
                {
                    try
                    {
                        OracleDBHelper.ExecuteNonQuery2(CommandType.Text, lstSql[0], null);
                        if (lstSql.Count >= 2)
                        {
                            OracleDBHelper.ExecuteNonQuery2(CommandType.Text, lstSql[1], null);
                        }
                    }
                    catch (Exception ex)
                    {
                        strError = ex.Message;
                    }
                }
                return(false);
            }
        }
Example #6
0
        public virtual bool DeleteModelByModel(User.UserModel user, TBase_Model model, ref string strError)
        {
            try
            {
                int bResult = 0;
                int iOut    = 0;

                OracleParameter[] param = new OracleParameter[] {
                    new OracleParameter("@bResult", bResult),
                    new OracleParameter("@ErrorMsg", OracleDbType.NVarchar2, 100),
                    new OracleParameter("@ID", OracleDBHelper.ToDBValue(model.ID)),

                    new OracleParameter("@Deleter", OracleDBHelper.ToDBValue(user.UserNo))
                };

                param[0].Direction = System.Data.ParameterDirection.Output;
                param[1].Direction = System.Data.ParameterDirection.Output;

                int i = OracleDBHelper.RunProcedure(this.GetDeleteProcedureName(), param, out iOut);
                strError = param[1].Value.ToString();
                if (i == -1)//(int)param[0].Value == -1
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #7
0
        public virtual bool DeleteModelByModel(User.UserModel user, TBase_Model model, ref string strError)
        {
            try
            {
                int bResult = 0;
                int iOut    = 0;
                dbFactory.dbF.CreateParameters(4);
                dbFactory.dbF.AddParameters(0, "@bResult", bResult, 0);
                //   dbFactory.dbF.AddParameters(1, "@ErrorMsg", OracleDbType.NVarchar2, 100);
                dbFactory.dbF.AddParameters(2, "@ID", dbFactory.ToDBValue(model.ID), 100);
                dbFactory.dbF.AddParameters(3, "@Deleter", dbFactory.ToDBValue(user.UserNo), 0);

                dbFactory.dbF.Parameters[0].Direction = System.Data.ParameterDirection.Output;
                dbFactory.dbF.Parameters[1].Direction = System.Data.ParameterDirection.Output;

                int i = dbFactory.RunProcedure(this.GetDeleteProcedureName(), dbFactory.dbF.Parameters, out iOut);
                strError = dbFactory.dbF.Parameters[1].Value.ToString();
                if (i == -1)    //(int)param[0].Value == -1
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #8
0
 public bool GetModelListByPage(ref List <TBase_Model> modelList, User.UserModel user, TBase_Model model, ref Common.DividPage page, ref string strError)
 {
     try
     {
         modelList = db.GetModelListByPage(user, model, ref page);
         return(true);
     }
     catch (Exception ex)
     {
         strError = "获取" + GetModelChineseName() + "列表失败!" + ex.Message + "\r\n" + ex.TargetSite;
         return(false);
     }
 }
Example #9
0
 private void AddModelOperatorInfo(User.UserModel user, ref TBase_Model model)
 {
     model.RowVersion = DateTime.Now;
     if (model.ID <= 0)
     {
         model.Creater    = user.UserNo;
         model.CreateTime = DateTime.Now;
     }
     else
     {
         model.Modifyer   = user.UserNo;
         model.ModifyTime = DateTime.Now;
     }
 }
Example #10
0
        public virtual List <TBase_Model> GetModelListADF(User.UserModel user, TBase_Model model)
        {
            try
            {
                string sql = "SELECT *  FROM  " + GetViewName() + GetFilterSql(user, model);

                using (IDataReader reader = dbFactory.ExecuteReader(sql))
                {
                    return(ToModels(reader));
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #11
0
 public bool UpdateModelStatus(User.UserModel user, ref TBase_Model model, int NewStatus, ref string strError, bool NeedReturnModel = true)
 {
     try
     {
         if (!CheckModelBeforeUpdateStatus(user, model, NewStatus, ref strError))
         {
             return(false);
         }
         return(db.UpdateModelStatus(user, ref model, NewStatus, ref strError, NeedReturnModel));
     }
     catch (Exception ex)
     {
         strError = ex.Message + "\r\n" + ex.TargetSite;
         return(false);
     }
 }
Example #12
0
 public bool SaveModelToDB(User.UserModel user, ref TBase_Model model, ref string strError)
 {
     try
     {
         if (CheckModelBeforeSave(model, ref strError) == false)
         {
             return(false);
         }
         return(db.SaveModelToDB(user, ref model, ref strError));
     }
     catch (Exception ex)
     {
         strError = "保存" + GetModelChineseName() + "失败!" + ex.Message + "\r\n" + ex.TargetSite;
         return(false);
     }
 }
Example #13
0
        /// <summary>
        /// 分页获取modellist的记录  condition:多条件的情况下
        /// </summary>
        public virtual List <TBase_Model> GetModelListByPage(User.UserModel user, TBase_Model model, ref Common.DividPage page, string condition = "")
        {
            try
            {
                CanQuery(model);

                using (IDataReader reader = common_FactoryDB.QueryByDividPage(ref page, GetViewName(), GetFilterSql(user, model), GetFieldsSql(), GetOrderBySql(), condition))
                {
                    return(ToModels(reader));
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #14
0
        /// <summary>
        /// 修改状态
        /// </summary>
        /// <param name="user"></param>
        /// <param name="model"></param>
        /// <param name="NewStatus"></param>
        /// <param name="strError"></param>
        /// <returns></returns>
        public bool UpdateModelStatus(User.UserModel user, ref TBase_Model model, int NewStatus, ref string strError, bool NeedReturnModel)
        {
            try
            {
                int iRows = 0;
                int iOut  = 0;

                OracleParameter[] param = new OracleParameter[] {
                    new OracleParameter("@Rows", iRows),
                    new OracleParameter("@ErrorMsg", OracleDbType.NVarchar2, 100),
                    new OracleParameter("@ID", OracleDBHelper.ToDBValue(GetUpdateModelStatusID(user, model, NewStatus))),

                    new OracleParameter("@NewStatus", OracleDBHelper.ToDBValue(NewStatus)),
                    new OracleParameter("@Auditor", OracleDBHelper.ToDBValue(user.UserNo)),
                    new OracleParameter("@AuditorTime", OracleDBHelper.ToDBValue(DateTime.Now)),
                    new OracleParameter("@TerminateReasonID", OracleDBHelper.ToDBValue(model.TerminateReasonID)),
                    new OracleParameter("@TerminateReason", OracleDBHelper.ToDBValue(model.TerminateReason)),
                    new OracleParameter("@RowVersion", OracleDBHelper.ToDBValue(DateTime.Now))
                };

                param[0].Direction = System.Data.ParameterDirection.Output;
                param[1].Direction = System.Data.ParameterDirection.Output;

                int i = OracleDBHelper.RunProcedure(this.GetUpdateStatusProcedureName(), param, out iOut);
                strError = param[1].Value.ToString();
                if ((int)param[0].Value == -1)
                {
                    return(false);
                }
                else
                {
                    if (NeedReturnModel)
                    {
                        model = GetModelByID(model.ID);
                        if (model == null)
                        {
                            throw new Exception("GetModelByID(modelID)出错,没有找到相符的记录,可能是视图有错误!");
                        }
                    }
                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #15
0
 public bool UpadteModelByModelSql(User.UserModel user, TBase_Model model, ref string strError)
 {
     try
     {
         if (db.UpdateModelByModelSql(user, model, ref strError) == false)
         {
             strError = "更新" + GetModelChineseName() + "失败!" + strError;
             return(false);
         }
         return(true);
     }
     catch (Exception ex)
     {
         strError = "删除" + GetModelChineseName() + "失败!" + ex.Message + "\r\n" + ex.TargetSite;
         return(false);
     }
 }
Example #16
0
        public string UpdateModelListSqlToDBADF(string UserJson, string ModelJson)
        {
            BaseMessage_Model <List <TBase_Model> > model = new BaseMessage_Model <List <TBase_Model> >();

            try
            {
                bool bSucc = false;

                string strError = "";


                if (string.IsNullOrEmpty(UserJson))
                {
                    model.HeaderStatus = "E";
                    model.Message      = "传入用户信息为空!";
                    return(JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <List <TBase_Model> > >(model));
                }

                User.UserModel user = JSONUtil.JSONHelper.JsonToObject <User.UserModel>(UserJson);

                List <TBase_Model> modelList = GetModelListByJson(UserJson, ModelJson);

                bSucc = db.UpdateModelListBySqlToDB(user, ref modelList, ref strError);

                if (bSucc == false)
                {
                    model.HeaderStatus = "E";
                    model.Message      = strError;
                }
                else
                {
                    model.HeaderStatus = "S";
                    model.TaskNo       = modelList[0].TaskNo;
                    model.Message      = GetSuccessMessage(model.MaterialDoc, modelList[0].TaskNo);
                }

                return(JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <List <TBase_Model> > >(model));
            }
            catch (Exception ex)
            {
                model.HeaderStatus = "E";
                model.Message      = "更新" + GetModelChineseName() + "失败!" + ex.Message + ex.TargetSite;

                return(JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <List <TBase_Model> > >(model));
            }
        }
Example #17
0
        /// <summary>
        /// 修改状态
        /// </summary>
        /// <param name="user"></param>
        /// <param name="model"></param>
        /// <param name="NewStatus"></param>
        /// <param name="strError"></param>
        /// <returns></returns>
        public bool UpdateModelStatus(User.UserModel user, ref TBase_Model model, int NewStatus, ref string strError, bool NeedReturnModel)
        {
            try
            {
                int iRows = 0;
                int iOut  = 0;
                dbFactory.dbF.CreateParameters(9);
                dbFactory.dbF.AddParameters(0, "@Rows", iRows, 0);
                //   dbFactory.dbF.AddParameters(1, "ErrorMsg", OracleDbType.NVarchar2,100);
                dbFactory.dbF.AddParameters(2, "ID", dbFactory.ToDBValue(GetUpdateModelStatusID(user, model, NewStatus)), 0);
                dbFactory.dbF.AddParameters(3, "@NewStatus", dbFactory.ToDBValue(NewStatus), 0);
                dbFactory.dbF.AddParameters(4, "@Auditor", dbFactory.ToDBValue(user.UserNo), 0);
                dbFactory.dbF.AddParameters(5, "@AuditorTime", dbFactory.ToDBValue(DateTime.Now), 0);
                dbFactory.dbF.AddParameters(6, "@TerminateReasonID", dbFactory.ToDBValue(model.TerminateReasonID), 0);
                dbFactory.dbF.AddParameters(7, "@TerminateReason", dbFactory.ToDBValue(model.TerminateReason), 0);
                dbFactory.dbF.AddParameters(8, "@RowVersion", dbFactory.ToDBValue(DateTime.Now), 0);

                dbFactory.dbF.Parameters[0].Direction = System.Data.ParameterDirection.Output;
                dbFactory.dbF.Parameters[1].Direction = System.Data.ParameterDirection.Output;

                int i = dbFactory.RunProcedure(this.GetUpdateStatusProcedureName(), dbFactory.dbF.Parameters, out iOut);
                strError = dbFactory.dbF.Parameters[1].Value.ToString();
                if ((int)dbFactory.dbF.Parameters[0].Value == -1)
                {
                    return(false);
                }
                else
                {
                    if (NeedReturnModel)
                    {
                        model = GetModelByID(model.ID);
                        if (model == null)
                        {
                            throw new Exception("GetModelByID(modelID)出错,没有找到相符的记录,可能是视图有错误!");
                        }
                    }
                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #18
0
        public bool DeleteModelByID(User.UserModel user, int iD, ref string strError)
        {
            try
            {
                if (!db.CanDelModel(user, iD, ref strError))
                {
                    return(false);
                }

                if (db.DeleteModelByID(user, iD) == false)
                {
                    strError = "删除" + GetModelChineseName() + "失败!";
                    return(false);
                }
                return(true);
            }
            catch (Exception ex)
            {
                strError = "删除" + GetModelChineseName() + "失败!" + ex.Message + "\r\n" + ex.TargetSite;
                return(false);
            }
        }
Example #19
0
        public virtual bool UpdateModelByModelSql(User.UserModel user, TBase_Model model, ref string strError)
        {
            try
            {
                List <string> lstSql = new List <string>();

                int i = dbFactory.ExecuteNonQueryList(this.GetUpdateSql(user, model), ref strError);

                if (i > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                strError = ex.Message;
                return(false);
                //throw new Exception(ex.Message);
            }
        }
Example #20
0
        public bool SaveModelToDB(User.UserModel user, ref TBase_Model model, ref string strError)
        {
            try
            {
                bool succ = false;
                //int iRows = 0;
                int iOut = 0;

                //把creater、createTime、modifyer等信息填到model中去.
                AddModelOperatorInfo(user, ref model);

                IDataParameter[] param = GetSaveModelIDataParameter(model);

                int i = dbFactory.RunProcedure(this.GetSaveProcedureName(), param, out iOut);
                if (i == -1)    //(int)param[0].Value == -1
                {
                    strError = param[1].Value.ToString();
                }
                else
                {
                    succ = true;
                    int modelID = Convert.ToInt32(((DbParameter)param[2]).Value);
                    //model.ID = (int)param[2].Value;
                    model = GetModelByID(modelID);
                    if (model == null)
                    {
                        throw new Exception("GetModelByID(modelID)出错,没有找到相符的记录,可能是视图有错误!");
                    }
                }
                return(succ);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #21
0
        public bool SaveModelBySqlToDB2(User.UserModel user, TBase_Model model, ref string strError)
        {
            try
            {
                List <string> lstSql = new List <string>();

                int i = OracleDBHelper.ExecuteNonQueryList(this.GetSaveSql(user, ref model), ref strError);

                if (i > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                strError = ex.Message;
                return(false);
                //throw new Exception(ex.Message);
            }
        }
Example #22
0
 public virtual int GetUpdateModelStatusID(User.UserModel user, TBase_Model model, int NewStatus)
 {
     return(model.ID);
 }
Example #23
0
 public virtual bool CanDelModel(User.UserModel user, TBase_Model model, ref string strError)
 {
     return(true);
 }
Example #24
0
 /// <summary>
 /// 根据ID删除数据
 /// </summary>
 /// <param name="user"></param>
 /// <param name="iD"></param>
 /// <returns></returns>
 public bool DeleteModelByID(User.UserModel user, int iD)
 {
     return(false);
 }
Example #25
0
        public string SaveModelListSqlToDBADF(User.UserModel user, List <TBase_Model> modelList)
        {
            BaseMessage_Model <List <TBase_Model> > model = new BaseMessage_Model <List <TBase_Model> >();

            try
            {
                bool bSucc = false;

                string strError = "";


                if (user == null)
                {
                    model.HeaderStatus = "E";
                    model.Message      = "传入用户信息为空!";
                    JsonConvert.SerializeObject(model);
                }


                if (CheckModelBeforeSave(modelList, ref strError) == false)
                {
                    model.HeaderStatus = "E";
                    model.Message      = strError;
                    JsonConvert.SerializeObject(model);
                }

                T_Interface_Func tfunc   = new T_Interface_Func();
                string           ERPJson = GetModelListByJsonToERP(user, modelList);//JSONUtil.JSONHelper.ObjectToJson<List<TBase_Model>>(modelList);

                LogNet.LogInfo("ERPJsonBefore:" + ERPJson);
                string interfaceJson = tfunc.PostModelListToInterface(ERPJson);
                LogNet.LogInfo("YMH00000000ERP:" + interfaceJson);

                model = JSONUtil.JSONHelper.JsonToObject <BaseMessage_Model <List <TBase_Model> > >(interfaceJson);

                LogNet.LogInfo("ERPJsonAfter:" + JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <List <TBase_Model> > >(model));

                //过账失败直接返回
                if (model.HeaderStatus == "E" && !string.IsNullOrEmpty(model.Message))
                {
                    return(interfaceJson);
                }
                else if (model.HeaderStatus == "S" && !string.IsNullOrEmpty(model.MaterialDoc)) //过账成功,并且生成了凭证要记录数据库
                {
                    modelList.ForEach(t => t.MaterialDoc = model.MaterialDoc);
                }

                //LogNet.LogInfo("ERPJson:" + JSONUtil.JSONHelper.ObjectToJson<List<TBase_Model>>(modelList));

                bSucc = db.SaveModelListBySqlToDB(user, ref modelList, ref strError);

                if (bSucc == false)
                {
                    model.HeaderStatus = "E";
                    model.Message      = strError;
                }
                else
                {
                    model.HeaderStatus = "S";
                    model.TaskNo       = modelList[0].TaskNo;
                    model.Message      = GetSuccessMessage(model.MaterialDoc, modelList[0].TaskNo);
                }

                return(JsonConvert.SerializeObject(model));
            }
            catch (Exception ex)
            {
                model.HeaderStatus = "E";
                model.Message      = "保存" + GetModelChineseName() + "失败!" + ex.Message + ex.TargetSite;

                return(JsonConvert.SerializeObject(model));
            }
        }
Example #26
0
        public string SaveModelListSqlToDBADF(string UserJson, string ModeJson, string Guid = "", string strPost = "")
        {
            BaseMessage_Model <List <TBase_Model> > model = new BaseMessage_Model <List <TBase_Model> >();

            try
            {
                string strError = "";
                if (Guid != "")
                {
                    if (!CheckGuid(Guid, ref strError))
                    {
                        model.HeaderStatus = "E";
                        model.Message      = "GUID已经存在,不能重复提交-" + strError;
                        return(JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <List <TBase_Model> > >(model));
                    }
                }

                bool bSucc = false;
                if (string.IsNullOrEmpty(UserJson))
                {
                    model.HeaderStatus = "E";
                    model.Message      = "传入用户信息为空!";
                    return(JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <List <TBase_Model> > >(model));
                }

                User.UserModel user = JSONUtil.JSONHelper.JsonToObject <User.UserModel>(UserJson);
                user.GUID = Guid;

                List <TBase_Model> modelList = GetModelListByJson(UserJson, ModeJson);

                if (strPost != "复核")
                {
                    if (CheckModelBeforeSave(modelList, ref strError) == false)
                    {
                        model.HeaderStatus = "E";
                        model.Message      = strError;
                        return(JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <List <TBase_Model> > >(model));
                    }
                }


                //是否过账
                if (string.IsNullOrEmpty(strPost) || (strPost == "下架" && (modelList[0].VoucherType == 31 || modelList[0].VoucherType == 53)) || strPost == "复核")
                {
                    T_Interface_Func tfunc   = new T_Interface_Func();
                    string           ERPJson = GetModelListByJsonToERP(user, modelList, strPost);//JSONUtil.JSONHelper.ObjectToJson<List<TBase_Model>>(modelList);

                    //LogNet.LogInfo("-----------------------ERPJsonBefore:" + ERPJson);
                    string interfaceJson = tfunc.PostModelListToInterface(ERPJson);

                    model = JSONUtil.JSONHelper.JsonToObject <BaseMessage_Model <List <TBase_Model> > >(interfaceJson);

                    //LogNet.LogInfo("-----------------------ERPJsonAfter:" + JSONUtil.JSONHelper.ObjectToJson<BaseMessage_Model<List<TBase_Model>>>(model));
                    //过账失败直接返回
                    if (model.HeaderStatus == "E" && !string.IsNullOrEmpty(model.Message))
                    {
                        return(interfaceJson);
                    }
                    else if (model.HeaderStatus == "S" && !string.IsNullOrEmpty(model.MaterialDoc)) //过账成功,并且生成了凭证要记录数据库
                    {
                        modelList.ForEach(t => t.MaterialDoc = model.MaterialDoc);
                    }
                }
                //modelList.ForEach(t => t.MaterialDoc = "Wgr0401210221054");

                //LogNet.LogInfo("ERPJson:" + JSONUtil.JSONHelper.ObjectToJson<List<TBase_Model>>(modelList));
                //LogNet.LogInfo("------------------------ymh:ERPtoWMS-" + JSONUtil.JSONHelper.ObjectToJson<List<TBase_Model>>(modelList));
                bSucc = db.SaveModelListBySqlToDB(user, ref modelList, ref strError, strPost);

                if (bSucc == false)
                {
                    model.HeaderStatus = "E";
                    model.Message      = strError;
                    //LogInfo.ErrorLog("------------------WMS失败:单号:【"+ modelList[0].ErpVoucherNo==null?"":modelList[0].ErpVoucherNo + "】错误信息:"+ strError);
                    LogNet.LogInfo("------------------ymh:WMS-失败:单号:【" + modelList[0].ErpVoucherNo == null ? "" : modelList[0].ErpVoucherNo + "】错误信息:" + strError);
                }
                else
                {
                    model.HeaderStatus = "S";
                    model.TaskNo       = modelList[0].TaskNo;
                    model.Message      = GetSuccessMessage(model.MaterialDoc, modelList[0].TaskNo);
                    LogNet.LogInfo("-----------------ymh:WMS-成功:单号:【" + modelList[0].ErpVoucherNo == null ? "" : modelList[0].ErpVoucherNo + "】");
                }

                return(JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <List <TBase_Model> > >(model));
            }
            catch (Exception ex)
            {
                //LogInfo.ErrorLog("------------------WMS失败:错误信息:" + ex.ToString());
                LogNet.LogInfo("------------------ymh:WMS-失败:错误信息:" + ex.ToString());
                model.HeaderStatus = "E";
                model.Message      = "保存" + GetModelChineseName() + "失败!" + ex.Message + ex.TargetSite;
                return(JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <List <TBase_Model> > >(model));
            }
        }
Example #27
0
        public string GetModelListADF(User.UserModel user, TBase_Model baseModel)
        {
            BaseMessage_Model <List <TBase_Model> > messageModel = new BaseMessage_Model <List <TBase_Model> >();

            try
            {
                string strError = string.Empty;

                List <TBase_Model> modelList = new List <TBase_Model>();
                if (user == null)
                {
                    messageModel.HeaderStatus = "E";
                    messageModel.Message      = "用户对象为空!";
                    //return JSONUtil.JSONHelper.ObjectToJson<BaseMessage_Model<List<TBase_Model>>>(messageModel);
                    return(JsonConvert.SerializeObject(messageModel));
                }


                if (baseModel == null)
                {
                    messageModel.HeaderStatus = "E";
                    messageModel.Message      = "业务对象为空!";
                    //return JSONUtil.JSONHelper.ObjectToJson<BaseMessage_Model<List<TBase_Model>>>(messageModel);
                    return(JsonConvert.SerializeObject(messageModel));
                }

                //TBase_Model model = GetModelByJson(ModelJson);

                if (!string.IsNullOrEmpty(baseModel.ErpVoucherNo))
                {
                    //请求ERP数据
                    if (Sync(baseModel, ref strError) == false)
                    {
                        messageModel.HeaderStatus = "E";
                        messageModel.Message      = "获取" + GetModelChineseName() + "ERP数据失败!" + strError;
                        //return JSONUtil.JSONHelper.ObjectToJson<BaseMessage_Model<List<TBase_Model>>>(messageModel);
                        return(JsonConvert.SerializeObject(messageModel));
                    }
                }


                modelList = db.GetModelListADF(user, baseModel);

                if (modelList == null || modelList.Count == 0)
                {
                    messageModel.HeaderStatus = "E";
                    messageModel.Message      = "获取" + GetModelChineseName() + "数据列表为空!";
                }
                else
                {
                    messageModel.HeaderStatus = "S";
                    messageModel.ModelJson    = modelList;
                }
                //return JSONUtil.JSONHelper.ObjectToJson<BaseMessage_Model<List<TBase_Model>>>(messageModel);
                return(JsonConvert.SerializeObject(messageModel));
            }
            catch (Exception ex)
            {
                messageModel.HeaderStatus = "E";
                messageModel.Message      = ex.Message;
                messageModel.ModelJson    = null;
                //return JSONUtil.JSONHelper.ObjectToJson<BaseMessage_Model<List<TBase_Model>>>(messageModel);
                return(JsonConvert.SerializeObject(messageModel));
            }
        }
Example #28
0
 public virtual bool CheckModelBeforeUpdateStatus(User.UserModel user, TBase_Model model, int NewStatus, ref string strError)
 {
     return(true);
 }
Example #29
0
 protected virtual string GetModelListByJsonToERP(User.UserModel user, List <TBase_Model> modelList, string strpost = "")
 {
     return(JSONUtil.JSONHelper.ObjectToJson <List <TBase_Model> >(modelList));
 }
Example #30
0
 public virtual bool CanDelModel(User.UserModel user, int ID, ref string strError)
 {
     return(true);
 }