public static void ReadyOrderSave(string orderNo, long operatorId, long customerId, string customerName, string customerDepart,
string customerTEL, long productId, int problemProgress, DateTime repairTime, string problemOverView, string printType, out long Id)
{
string connString = System.Configuration.ConfigurationManager.ConnectionStrings["Sql"].ConnectionString;
using (TransactionScope scope = new TransactionScope())
{
using (SqlConnection conn = new SqlConnection(connString))
{
conn.Open();
// Stored procedure
SqlCommand cmd = new SqlCommand("dbo.MAJ_ReadyOrder_Save", conn);
= CommandType.StoredProcedure;
cmd.Parameters.Add("@OrderNo", SqlDbType.NVarChar, 50).Value = orderNo;
cmd.Parameters.Add("@OperatorId", SqlDbType.BigInt).Value = operatorId;
cmd.Parameters.Add("@CustomerId", SqlDbType.BigInt).Value = customerId;
cmd.Parameters.Add("@CustomerName", SqlDbType.NVarChar, 50).Value = customerName;
cmd.Parameters.Add("@CustomerDepart", SqlDbType.NVarChar, 50).Value = customerDepart;
cmd.Parameters.Add("@CustomerTEL", SqlDbType.NVarChar, 50).Value = customerTEL;
cmd.Parameters.Add("@ProductId", SqlDbType.BigInt).Value = productId;
cmd.Parameters.Add("@ProblemProgress", SqlDbType.Int).Value = problemProgress;
cmd.Parameters.Add("@RepairTime", SqlDbType.DateTime).Value = repairTime;
cmd.Parameters.Add("@ProblemOverView", SqlDbType.NVarChar, 500).Value = problemOverView;
cmd.Parameters.Add("@PrintType", SqlDbType.NVarChar, 30).Value = printType;
cmd.Parameters.Add(new SqlParameter("@Id", SqlDbType.BigInt));
cmd.Parameters["@Id"].Direction = ParameterDirection.Output;
int count = cmd.ExecuteNonQuery();
Id = Convert.ToInt64(cmd.Parameters["@Id"].Value.ToString());
conn.Close();
}
();
}
}
//存储过程
ALTER PROCEDURE[dbo].[MAJ_ReadyOrder_Save]
-- Add the parameters for the stored procedure here
@Id Bigint output,
@OrderNo nvarchar(50) = null,--订单编号
@OperatorId Bigint = null,--操作员
@CustomerId Bigint = null,--客户单位名称
@CustomerName nvarchar(50) = null,--客户联系人
@CustomerDepart nvarchar(50) = null,--联系部门
@CustomerTEL nvarchar(50) = null,--联系人电话
@ProductId bigint = null,--产品ID
@ProblemProgress int = null,--进度
@RepairTime datetime = null,--报修时间
@ProblemOverView nvarchar(max) = null,--问题描述
@PrintType nvarchar(30) = null--设备型号
AS
BEGIN
insert into MAJ_Order
(OrderNo,
OperatorId,
CustomerId,
CustomerName,
CustomerDepart,
CustomerTEL,
ProductId,
ProblemProgress,
RepairTime,
ProblemOverView,
PrintType) values
(
@OrderNo,
@OperatorId,
@CustomerId,
@CustomerName,
@CustomerDepart,
@CustomerTEL,
@ProductId,
@ProblemProgress,
@RepairTime,
@ProblemOverView,
@PrintType
)
-- Return Id
SET @Id = SCOPE_IDENTITY();
END