public static Print_State AddPrint_State(Print_State print_State) { string sql = "INSERT Print_State (PrintBH, PrintState, PrintTimes)" + "VALUES (@PrintBH, @PrintState, @PrintTimes)"; sql += " ; SELECT @@IDENTITY"; try { SqlParameter[] para = new SqlParameter[] { new SqlParameter("@PrintBH", print_State.PrintBH), new SqlParameter("@PrintState", print_State.PrintState), new SqlParameter("@PrintTimes", print_State.PrintTimes) }; string IdStr = DBUnity.ExecuteScalar(CommandType.Text, sql, para); int newId = Convert.ToInt32(IdStr); return(GetPrint_StateByPtintID(newId)); } catch (Exception e) { Console.WriteLine(e.Message); throw e; } }
public static Print_State GetPrint_StateByPtintID(int ptintID) { string sql = "SELECT * FROM Print_State WHERE PtintID = @PtintID"; try { SqlParameter para = new SqlParameter("@PtintID", ptintID); DataTable dt = DBUnity.AdapterToTab(sql, para); if (dt.Rows.Count > 0) { Print_State print_State = new Print_State(); print_State.PtintID = dt.Rows[0]["PtintID"] == DBNull.Value ? 0 : (int)dt.Rows[0]["PtintID"]; print_State.PrintBH = dt.Rows[0]["PrintBH"] == DBNull.Value ? "" : (string)dt.Rows[0]["PrintBH"]; print_State.PrintState = dt.Rows[0]["PrintState"] == DBNull.Value ? "" : (string)dt.Rows[0]["PrintState"]; print_State.PrintTimes = dt.Rows[0]["PrintTimes"] == DBNull.Value ? 0 : (int)dt.Rows[0]["PrintTimes"]; return(print_State); } else { return(null); } } catch (Exception e) { Console.WriteLine(e.Message); throw e; } }
public static bool ModifyPrint_State(Print_State print_State) { string sql = "UPDATE Print_State " + "SET " + "PrintBH = @PrintBH, " + "PrintState = @PrintState, " + "PrintTimes = @PrintTimes " + "WHERE PtintID = @PtintID"; try { SqlParameter[] para = new SqlParameter[] { new SqlParameter("@PtintID", print_State.PtintID), new SqlParameter("@PrintBH", print_State.PrintBH), new SqlParameter("@PrintState", print_State.PrintState), new SqlParameter("@PrintTimes", print_State.PrintTimes) }; int t = DBUnity.ExecuteNonQuery(CommandType.Text, sql, para); if (t > 0) { return(true); } else { return(false); } } catch (Exception e) { Console.WriteLine(e.Message); throw e; } }
public static bool DeletePrint_State(Print_State print_State) { return(DeletePrint_StateByPtintID(print_State.PtintID)); }
public static bool ModifyPrint_State(Print_State print_State) { return(Print_StateService.ModifyPrint_State(print_State)); }
public static bool DeletePrint_State(Print_State print_State) { return(Print_StateService.DeletePrint_State(print_State)); }
public static Print_State AddPrint_State(Print_State print_State) { return(Print_StateService.AddPrint_State(print_State)); }