Exemplo n.º 1
0
 /// <summary>
 /// 车单状态接口
 /// </summary>
 /// <param name="userID">车单编号(不能为空)</param>
 /// <param name="status">状态(=0 无效,=1 有效)</param>
 /// <param name="activationDate">生效日期(为空时不修改,格式yyyy-MM-dd)</param>
 /// <returns>=0 成功,=其他 错误代码</returns>
 public int SheetStatus(string userID, byte status, string activationDate)
 {
     try
     {
         if ((status != 0 && status != 1) ||
             string.IsNullOrEmpty(userID))
         {
             return((int)InterfaceReturnCode.ParameterError);
         }
         //卡片状态  = 1 Enabled 已发行, = 3 Disabled 禁用,
         byte cardStatus             = (byte)(status == 0 ? 3 : 1);
         SQLHelperProvider sqlHelper = new SQLHelperProvider(AppConifg.Current.ParkingConnection);
         string            cmdstr;
         if (!string.IsNullOrEmpty(activationDate))
         {
             cmdstr = @"update Card set Status=@status,ActivationDate=@activationDate where CardID=@cardID";
         }
         else
         {
             cmdstr = @"update Card set Status=@status where CardID=@cardID";
         }
         SqlCommand cmd = new SqlCommand();
         cmd.CommandText = cmdstr;
         cmd.Parameters.AddWithValue("@status", cardStatus);
         if (!string.IsNullOrEmpty(activationDate))
         {
             cmd.Parameters.AddWithValue("@activationDate", activationDate);
         }
         cmd.Parameters.AddWithValue("@cardID", userID);
         SQLQueryResult <int> result = sqlHelper.SQLExecuteNonQuery(cmd);
         InterfaceReturnCode  code   = CreateInterfaceReturnCode(result.Result);
         if (code == InterfaceReturnCode.Success && result.QueryObject == 0)
         {
             //返回更新行数为0时,标识为无记录
             code = InterfaceReturnCode.DatabaseNoRecord;
         }
         return((int)code);
     }
     catch (Exception)
     {
         return((int)InterfaceReturnCode.InterfaceException);//接口执行期间发生错误
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 通过员工编号删除员工记录接口
 /// </summary>
 /// <param name="employeeNum"></param>
 /// <returns></returns>
 public int DeleteEmployee(string employeeNum)
 {
     try
     {
         if (string.IsNullOrEmpty(employeeNum))
         {
             return((int)InterfaceReturnCode.ParameterError);
         }
         SQLHelperProvider sqlHelper = new SQLHelperProvider(AppConifg.Current.ParkingConnection);
         string            cmdstr    = @"delete from Card where CardID=@cardID";
         SqlCommand        cmd       = new SqlCommand();
         cmd.CommandText = cmdstr;
         cmd.Parameters.AddWithValue("@cardID", employeeNum);
         SQLResultCode       code   = sqlHelper.SQLExecuteNonQuery(cmd).Result;
         InterfaceReturnCode result = CreateInterfaceReturnCode(code);
         return((int)result);
     }
     catch (Exception)
     {
         return((int)InterfaceReturnCode.InterfaceException);//接口执行期间发生错误
     }
 }