Beispiel #1
0
        public InterfaceOutPut Add(string data)
        {
            InterfaceOutPut output = new InterfaceOutPut();
            TAB_Plan_InRoom model  = null;

            try
            {
                model = Newtonsoft.Json.JsonConvert.DeserializeObject <TAB_Plan_InRoom>(data);
                DBRoom db = new DBRoom();
                if (!db.ExistsInRoom(model.strInRoomGUID))
                {
                    if (db.AddInRoom(model))
                    {
                        output.result    = 0;
                        output.resultStr = "插入入寓记录成功";
                    }
                    else
                    {
                        output.result    = 1;
                        output.resultStr = "插入入寓记录失败";
                    }
                }
                else
                {
                    if (db.UpdateInRoom(model))
                    {
                        output.result    = 0;
                        output.resultStr = "已经存在入寓记录,更新成功";
                    }
                    else
                    {
                        output.result    = 1;
                        output.resultStr = "已经存在出寓记录,更新失败";
                    }
                }
            }
            catch (Exception ex)
            {
                TF.CommonUtility.LogClass.logex(ex, "");
                throw ex;
            }
            return(output);
        }
Beispiel #2
0
        /// <summary>
        /// 更新入寓数据
        /// </summary>
        public bool UpdateInRoom(TAB_Plan_InRoom model)
        {
            SqlConnection conn = new SqlConnection(SqlHelper.ConnString);

            conn.Open();
            try
            {
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("update TAB_Plan_InRoom set ");
                        strSql.Append("strTrainPlanGUID=@strTrainPlanGUID,");
                        strSql.Append("strTrainmanGUID=@strTrainmanGUID,");
                        strSql.Append("dtInRoomTime=@dtInRoomTime,");
                        strSql.Append("nInRoomVerifyID=@nInRoomVerifyID,");
                        strSql.Append("strDutyUserGUID=@strDutyUserGUID,");
                        strSql.Append("strTrainmanNumber=@strTrainmanNumber,");
                        strSql.Append("strSiteGUID=@strSiteGUID,");
                        strSql.Append("strRoomNumber=@strRoomNumber,");
                        strSql.Append("nBedNumber=@nBedNumber");
                        strSql.Append(" where strInRoomGUID=@strInRoomGUID");
                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@strInRoomGUID",     SqlDbType.VarChar,   50),
                            new SqlParameter("@strTrainPlanGUID",  SqlDbType.VarChar,   50),
                            new SqlParameter("@strTrainmanGUID",   SqlDbType.VarChar,   50),
                            new SqlParameter("@dtInRoomTime",      SqlDbType.DateTime),
                            new SqlParameter("@nInRoomVerifyID",   SqlDbType.Int,        4),
                            new SqlParameter("@strDutyUserGUID",   SqlDbType.VarChar,   50),
                            new SqlParameter("@strTrainmanNumber", SqlDbType.VarChar,   50),
                            new SqlParameter("@strSiteGUID",       SqlDbType.VarChar,   50),
                            new SqlParameter("@strRoomNumber",     SqlDbType.VarChar,   50),
                            new SqlParameter("@nBedNumber",        SqlDbType.Int, 4)
                        };
                        parameters[0].Value = model.strInRoomGUID;
                        parameters[1].Value = model.strTrainPlanGUID;
                        parameters[2].Value = model.strTrainmanGUID;
                        parameters[3].Value = model.dtInRoomTime;
                        parameters[4].Value = model.nInRoomVerifyID;
                        parameters[5].Value = model.strDutyUserGUID;
                        parameters[6].Value = model.strTrainmanNumber;
                        parameters[7].Value = model.strSiteGUID;
                        parameters[8].Value = model.strRoomNumber;
                        parameters[9].Value = model.nBedNumber;
                        int rows = (int)SqlHelper.ExecuteNonQuery(trans, CommandType.Text, strSql.ToString(), parameters);
                        if (rows > 0)
                        {
                            string strSqlUpTrainman = "update TAB_Org_Trainman set dtLastInRoomTime='" + model.dtInRoomTime + "' where strTrainmanGUID='" + model.strTrainmanGUID + "'";
                            int    rows2            = (int)SqlHelper.ExecuteNonQuery(trans, CommandType.Text, strSqlUpTrainman.ToString());
                            if (rows2 > 0)
                            {
                                trans.Commit();
                                return(true);
                            }
                            else
                            {
                                trans.Rollback();
                                return(false);
                            }
                        }
                        else
                        {
                            trans.Rollback();
                            return(false);
                        }
                    }
                    catch
                    {
                        trans.Rollback();
                        return(false);
                    }
                }
            }
            finally
            {
                conn.Close();
            }
        }