Ejemplo n.º 1
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(DS_RecordModel model)
 {
     try
     {
         string TableName = DateTime.Now.ToString("yyyy");
         if (!AutoCreateDB.IsExistTable(TableName))
         {
             AutoCreateDB.CreateTable(TableName);
         }
         StringBuilder strSql = new StringBuilder();
         strSql.Append("insert into dbo.[" + TableName + "](");
         strSql.Append("DSType,BarCode,Action,MatId,MatCode,MatName,UnitType,UnitPrice,DSQuantity,RealQuantity,TotalPrice,DeviceId,DeviceName,PotCode,PotName,EntryDate,EntryFilterYMD)");
         strSql.Append(" values (");
         strSql.Append("@DSType,@BarCode,@Action,@MatId,@MatCode,@MatName,@UnitType,@UnitPrice,@DSQuantity,@RealQuantity,@TotalPrice,@DeviceId,@DeviceName,@PotCode,@PotName,@EntryDate,@EntryFilterYMD)");
         strSql.Append(";select @@IDENTITY");
         SqlParameter[] parameters =
         {
             new SqlParameter("@DSType",         SqlDbType.Int,               4),
             new SqlParameter("@BarCode",        SqlDbType.NVarChar,         50),
             new SqlParameter("@Action",         SqlDbType.NVarChar,         50),
             new SqlParameter("@MatId",          SqlDbType.UniqueIdentifier, 16),
             new SqlParameter("@MatCode",        SqlDbType.NVarChar,         50),
             new SqlParameter("@MatName",        SqlDbType.NVarChar,         50),
             new SqlParameter("@UnitType",       SqlDbType.Char,             10),
             new SqlParameter("@UnitPrice",      SqlDbType.Decimal,           9),
             new SqlParameter("@DSQuantity",     SqlDbType.Decimal,           9),
             new SqlParameter("@RealQuantity",   SqlDbType.Decimal,           9),
             new SqlParameter("@TotalPrice",     SqlDbType.Decimal,           9),
             new SqlParameter("@DeviceId",       SqlDbType.UniqueIdentifier, 16),
             new SqlParameter("@DeviceName",     SqlDbType.NVarChar,         50),
             new SqlParameter("@PotCode",        SqlDbType.NVarChar,         50),
             new SqlParameter("@PotName",        SqlDbType.NVarChar,         50),
             new SqlParameter("@EntryDate",      SqlDbType.DateTime),
             new SqlParameter("@EntryFilterYMD", SqlDbType.NVarChar, 50)
         };
         parameters[0].Value  = model.DSType;
         parameters[1].Value  = model.BarCode;
         parameters[2].Value  = model.Action;
         parameters[3].Value  = model.MatId;
         parameters[4].Value  = model.MatCode;
         parameters[5].Value  = model.MatName;
         parameters[6].Value  = model.UnitType;
         parameters[7].Value  = model.UnitPrice;
         parameters[8].Value  = model.DSQuantity;
         parameters[9].Value  = model.RealQuantity;
         parameters[10].Value = model.TotalPrice;
         parameters[11].Value = model.DeviceId;
         parameters[12].Value = model.DeviceName;
         parameters[13].Value = model.PotCode;
         parameters[14].Value = model.PotName;
         parameters[15].Value = model.EntryDate;
         parameters[16].Value = model.EntryFilterYMD;
         SQLHelper.RunProcPrams(strSql.ToString(), parameters);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 2
0
        public static void RecordAdd(int dsType, string barCode, string potCode, DsRecord dsRecord, DsMaterial dsMaterial)
        {
            View_DeviceInfoModel viewModel = deviceDAL.GetDeviceInfoByPotCode(potCode);


            DS_RecordModel recordModel = new DS_RecordModel();

            recordModel.DSType       = dsType;
            recordModel.Action       = dsRecord.ActionName;
            recordModel.BarCode      = barCode;
            recordModel.MatId        = new Guid(dsMaterial.MaterialId);
            recordModel.MatCode      = dsMaterial.MaterialCode;
            recordModel.MatName      = dsMaterial.MaterialName;
            recordModel.DSQuantity   = dsMaterial.MaterialQuantity;
            recordModel.RealQuantity = dsRecord.DSQuantity;
            recordModel.UnitType     = dsMaterial.Unit;
            recordModel.UnitPrice    = dsMaterial.Price;
            recordModel.TotalPrice   = recordModel.RealQuantity * recordModel.UnitPrice;

            recordModel.DeviceId       = viewModel.DeviceId;
            recordModel.DeviceName     = viewModel.DeviceName;
            recordModel.PotCode        = viewModel.PotCode;
            recordModel.PotName        = viewModel.PotName;
            recordModel.EntryDate      = DateTime.Now;
            recordModel.EntryFilterYMD = DateTime.Now.ToString("yyyyMMdd");
            recordDAL.Add(recordModel);
        }