using Mesnac.Action.ChemicalWeighing.Entity ;
using Mesnac.Codd.Session ;
using System ;
using System.Collections.Generic ;
using System.Data ;
using System.Linq ;
using System.Text ;
using System.Threading.Tasks ;
namespace Mesnac.Action.ChemicalWeighing.Report
{
/// <summary>
/// 小料数据库帮助类
/// </summary>
public class XlDbHelper
{
#region 拼音检索配方物料列表
/// <summary>
/// 拼音检索配方物料列表
/// </summary>
/// <returns>返回配方列表</returns>
public static List < SimplePmtRecipe > GetRecipeMaterialListPY ( )
{
DbHelper dbHelper = Mesnac . Basic . DataSourceFactory . Instance . GetDbHelper ( Mesnac . Basic . DataSourceFactory . MCDbType . Local ) ;
if ( dbHelper = = null )
{
throw new Exception ( Mesnac . Basic . LanguageHelper . DataBaseConnectError ) ;
}
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
string sqlstr = "select ROW_NUMBER() OVER(Order by GETDATE()) ID, recipe_Name from(select distinct recipe_Name from xl_recipe where Recipe_Verify=1) t " ;
dbHelper . CommandText = sqlstr ;
DataTable table = dbHelper . ToDataTable ( ) ;
List < SimplePmtRecipe > lst = new List < SimplePmtRecipe > ( ) ;
SimplePmtRecipe recipe = null ;
foreach ( DataRow row in table . Rows )
{
recipe = new SimplePmtRecipe ( ) ;
recipe . ID = Mesnac . Basic . DataProcessor . RowValue ( row , "ID" , String . Empty ) ;
//recipe.Recipe_Code = Mesnac.Basic.DataProcessor.RowValue(row, "recipe_Id", String.Empty);
recipe . Recipe_Name = Mesnac . Basic . DataProcessor . RowValue ( row , "recipe_Name" , String . Empty ) ;
//recipe.Recipe_type = Mesnac.Basic.DataProcessor.RowValue(row, "recipe_Type", String.Empty);
lst . Add ( recipe ) ;
}
return lst ;
}
# endregion
#region 获取LR_plan
/// <summary>
/// 获取LR_plan
/// </summary>
/// <param name="planID">计划号</param>
/// <returns>返回符合条件List<LR_weigh></returns>
public static LR_plan GetLrPlan ( string planID , int realNum )
{
LR_plan entity = new LR_plan ( ) ;
DbHelper dbHelper = Mesnac . Basic . DataSourceFactory . Instance . GetDbHelper ( Mesnac . Basic . DataSourceFactory . MCDbType . Local ) ;
if ( dbHelper = = null )
{
throw new Exception ( Mesnac . Basic . LanguageHelper . DataBaseConnectError ) ;
}
dbHelper . CommandType = CommandType . Text ;
string strSql = "SELECT top 1 * FROM LR_plan where Plan_Id = @Plan_Id and Real_Num=@Real_Num" ;
dbHelper . CommandText = strSql ;
dbHelper . ClearParameter ( ) ;
dbHelper . AddParameter ( "@Plan_Id" , planID ) ;
dbHelper . AddParameter ( "@Real_Num" , realNum ) ;
DataTable table = dbHelper . ToDataTable ( ) ;
if ( table ! = null & & table . Rows . Count > 0 )
{
foreach ( DataRow dr in table . Rows )
{
entity = ConvertDataRowToLR_Plan ( dr ) ;
}
}
return entity ;
}
# endregion
#region 获取List<LR_recipe>
/// <summary>
/// 获取List<LR_recipe>
/// </summary>
/// <param name="recipeId">计划号</param>
/// <returns>返回符合条件List<LR_recipe></returns>
public static List < LR_recipe > GetLR_recipeList ( string planID )
{
List < LR_recipe > lR_Recipes = new List < LR_recipe > ( ) ;
DbHelper dbHelper = Mesnac . Basic . DataSourceFactory . Instance . GetDbHelper ( Mesnac . Basic . DataSourceFactory . MCDbType . Local ) ;
if ( dbHelper = = null )
{
throw new Exception ( Mesnac . Basic . LanguageHelper . DataBaseConnectError ) ;
}
dbHelper . CommandType = CommandType . Text ;
string strSql = "SELECT * FROM LR_recipe where Plan_id = @Plan_id order by Weight_ID" ;
dbHelper . CommandText = strSql ;
dbHelper . ClearParameter ( ) ;
dbHelper . AddParameter ( "@Plan_id" , planID ) ;
DataTable table = dbHelper . ToDataTable ( ) ;
if ( table ! = null & & table . Rows . Count > 0 )
{
LR_recipe entity = null ;
foreach ( DataRow dr in table . Rows )
{
entity = ConvertDataRowToLR_recipe ( dr ) ;
lR_Recipes . Add ( entity ) ;
}
}
return lR_Recipes ;
}
# endregion
#region 获取List<LR_weigh>
/// <summary>
/// 获取List<LR_weigh>
/// </summary>
/// <param name="recipeId">计划号</param>
/// <returns>返回符合条件List<LR_weigh></returns>
public static List < LR_weigh > GetLR_weighList ( string planID )
{
List < LR_weigh > lR_Weighs = new List < LR_weigh > ( ) ;
DbHelper dbHelper = Mesnac . Basic . DataSourceFactory . Instance . GetDbHelper ( Mesnac . Basic . DataSourceFactory . MCDbType . Local ) ;
if ( dbHelper = = null )
{
throw new Exception ( Mesnac . Basic . LanguageHelper . DataBaseConnectError ) ;
}
dbHelper . CommandType = CommandType . Text ;
string strSql = "SELECT * FROM LR_weigh where Plan_id = @Plan_id order by ID" ;
dbHelper . CommandText = strSql ;
dbHelper . ClearParameter ( ) ;
dbHelper . AddParameter ( "@Plan_id" , planID ) ;
DataTable table = dbHelper . ToDataTable ( ) ;
if ( table ! = null & & table . Rows . Count > 0 )
{
LR_weigh entity = null ;
foreach ( DataRow dr in table . Rows )
{
entity = ConvertDataRowToLR_weigh ( dr ) ;
lR_Weighs . Add ( entity ) ;
}
}
return lR_Weighs ;
}
# endregion
#region 获取List
/// <summary>
///
/// </summary>
/// <param name="Plan_Id">计划号</param>
/// <param name="Dosing_Id">批次</param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public static DataTable GetLRWeighDataTable ( string Plan_Id , string Dosing_Id )
{
List < LR_weigh > lR_Weighs = new List < LR_weigh > ( ) ;
DbHelper dbHelper = Mesnac . Basic . DataSourceFactory . Instance . GetDbHelper ( Mesnac . Basic . DataSourceFactory . MCDbType . Local ) ;
if ( dbHelper = = null )
{
throw new Exception ( Mesnac . Basic . LanguageHelper . DataBaseConnectError ) ;
}
dbHelper . CommandType = CommandType . Text ;
string strSql = "SELECT * FROM LR_weigh where Plan_Id=@Plan_Id and Dosing_Id = @Dosing_Id order by ID" ;
dbHelper . CommandText = strSql ;
dbHelper . ClearParameter ( ) ;
dbHelper . AddParameter ( "@Plan_Id" , Dosing_Id ) ;
dbHelper . AddParameter ( "@Dosing_Id" , Dosing_Id ) ;
DataTable table = dbHelper . ToDataTable ( ) ;
if ( table ! = null & & table . Rows . Count > 0 )
{
return table ;
}
return null ;
}
# endregion
#region 把DataRow数据行转换为LR_weigh实体对象
/// <summary>
/// 把DataRow数据行转换为LR_weigh实体对象
/// </summary>
/// <param name="dr">要转换的数据行</param>
/// <returns>返回转换后的计划实体对象</returns>
public static LR_plan ConvertDataRowToLR_Plan ( DataRow dr )
{
if ( dr ! = null )
{
LR_plan lR_Plan = new LR_plan ( ) ;
lR_Plan . ID = Mesnac . Basic . DataProcessor . RowValue ( dr , "ID" , 0 ) ;
lR_Plan . Dosing_Id = Mesnac . Basic . DataProcessor . RowValue ( dr , "Dosing_Id" , String . Empty ) ;
lR_Plan . Plan_Id = Mesnac . Basic . DataProcessor . RowValue ( dr , "Plan_Id" , String . Empty ) ;
lR_Plan . Equip_Code = Mesnac . Basic . DataProcessor . RowValue ( dr , "Equip_Code" , String . Empty ) ;
lR_Plan . Plan_Serial = Mesnac . Basic . DataProcessor . RowValue ( dr , "Plan_Serial" , 0 ) ;
lR_Plan . Recipe_ID = Mesnac . Basic . DataProcessor . RowValue ( dr , "Recipe_ID" , String . Empty ) ;
lR_Plan . Recipe_Code = Mesnac . Basic . DataProcessor . RowValue ( dr , "Recipe_Code" , String . Empty ) ;
lR_Plan . Recipe_Name = Mesnac . Basic . DataProcessor . RowValue ( dr , "Recipe_Name" , String . Empty ) ;
lR_Plan . Version = Mesnac . Basic . DataProcessor . RowValue ( dr , "Version" , 0 ) ;
lR_Plan . Recipe_Type = Mesnac . Basic . DataProcessor . RowValue ( dr , "Recipe_Type" , 0 ) ;
lR_Plan . Shift_Id = Mesnac . Basic . DataProcessor . RowValue ( dr , "Shift_Id" , 0 ) ;
lR_Plan . Shift_Class = Mesnac . Basic . DataProcessor . RowValue ( dr , "Shift_Class" , String . Empty ) ;
lR_Plan . Plan_Num = Mesnac . Basic . DataProcessor . RowValue ( dr , "Plan_Num" , 0 ) ;
lR_Plan . Real_Num = Mesnac . Basic . DataProcessor . RowValue ( dr , "Real_Num" , 0 ) ;
lR_Plan . Duration_Time = Mesnac . Basic . DataProcessor . RowValue ( dr , "Duration_Time" , 0 ) ;
lR_Plan . Start_Date = Mesnac . Basic . DataProcessor . RowValue ( dr , "Start_Date" , String . Empty ) ;
lR_Plan . End_Date = Mesnac . Basic . DataProcessor . RowValue ( dr , "End_Date" , String . Empty ) ;
lR_Plan . Weight_Man = Mesnac . Basic . DataProcessor . RowValue ( dr , "Weight_Man" , String . Empty ) ;
lR_Plan . Stock_Man = Mesnac . Basic . DataProcessor . RowValue ( dr , "Stock_Man" , String . Empty ) ;
lR_Plan . Plan_Batch = Mesnac . Basic . DataProcessor . RowValue ( dr , "Plan_Batch" , String . Empty ) ;
lR_Plan . Plan_State = Mesnac . Basic . DataProcessor . RowValue ( dr , "Plan_State" , 0 ) ;
lR_Plan . Plan_Date = Mesnac . Basic . DataProcessor . RowValue ( dr , "Plan_Date" , String . Empty ) ;
lR_Plan . Total_Weight = Mesnac . Basic . DataProcessor . RowValue ( dr , "Total_Weight" , 0 ) ;
lR_Plan . Total_Error = Mesnac . Basic . DataProcessor . RowValue ( dr , "Total_Error" , 0 ) ;
lR_Plan . IF_FLAG = Mesnac . Basic . DataProcessor . RowValue ( dr , "IF_FLAG" , 0 ) ;
lR_Plan . IsRetransmission = Mesnac . Basic . DataProcessor . RowValue ( dr , "IsRetransmissionv" , 0 ) ;
return lR_Plan ;
}
else
{
return null ;
}
}
# endregion
#region 把DataRow数据行转换为LR_recipe实体对象
/// <summary>
/// 把DataRow数据行转换为LR_recipe实体对象
/// </summary>
/// <param name="dr">要转换的数据行</param>
/// <returns>返回转换后的计划实体对象</returns>
public static LR_recipe ConvertDataRowToLR_recipe ( DataRow dr )
{
if ( dr ! = null )
{
LR_recipe lR_Recipe = new LR_recipe ( ) ;
lR_Recipe . Plan_id = Mesnac . Basic . DataProcessor . RowValue ( dr , "Plan_id" , String . Empty ) ;
lR_Recipe . Equip_Code = Mesnac . Basic . DataProcessor . RowValue ( dr , "Equip_code" , String . Empty ) ;
lR_Recipe . Weight_ID = Mesnac . Basic . DataProcessor . RowValue ( dr , "Weight_ID" , 0 ) ;
lR_Recipe . Material_Code = Mesnac . Basic . DataProcessor . RowValue ( dr , "Material_Code" , String . Empty ) ;
lR_Recipe . Material_Name = Mesnac . Basic . DataProcessor . RowValue ( dr , "Material_Name" , String . Empty ) ;
lR_Recipe . Set_Weight = Mesnac . Basic . DataProcessor . RowValue ( dr , "Set_Weight" , 0.0f ) ;
lR_Recipe . Set_Error = Mesnac . Basic . DataProcessor . RowValue ( dr , "Set_Error" , 0.0f ) ;
lR_Recipe . CPK_Error = Mesnac . Basic . DataProcessor . RowValue ( dr , "CPK_Error" , decimal . Zero ) ;
lR_Recipe . Batch_number = Mesnac . Basic . DataProcessor . RowValue ( dr , "Batch_number" , String . Empty ) ;
lR_Recipe . remark = Mesnac . Basic . DataProcessor . RowValue ( dr , "remark" , String . Empty ) ;
return lR_Recipe ;
}
else
{
return null ;
}
}
# endregion
#region 把DataRow数据行转换为LR_weigh实体对象
/// <summary>
/// 把DataRow数据行转换为LR_weigh实体对象
/// </summary>
/// <param name="dr">要转换的数据行</param>
/// <returns>返回转换后的计划实体对象</returns>
public static LR_weigh ConvertDataRowToLR_weigh ( DataRow dr )
{
if ( dr ! = null )
{
LR_weigh lR_Weigh = new LR_weigh ( ) ;
lR_Weigh . ID = Mesnac . Basic . DataProcessor . RowValue ( dr , "ID" , 0 ) ;
lR_Weigh . Dosing_ID = Mesnac . Basic . DataProcessor . RowValue ( dr , "Dosing_ID" , String . Empty ) ;
lR_Weigh . Recipe_ID = Mesnac . Basic . DataProcessor . RowValue ( dr , "Recipe_ID" , String . Empty ) ;
lR_Weigh . Material_ID = Mesnac . Basic . DataProcessor . RowValue ( dr , "Material_ID" , String . Empty ) ;
lR_Weigh . Material_Name = Mesnac . Basic . DataProcessor . RowValue ( dr , "Material_Name" , String . Empty ) ;
lR_Weigh . Set_Weight = Convert . ToDecimal ( Mesnac . Basic . DataProcessor . RowValue ( dr , "Set_Weight" , String . Empty ) ) ;
lR_Weigh . Set_Error = Convert . ToDecimal ( Mesnac . Basic . DataProcessor . RowValue ( dr , "Set_Error" , String . Empty ) ) ;
lR_Weigh . Real_Weight = Convert . ToDecimal ( Mesnac . Basic . DataProcessor . RowValue ( dr , "Real_Weight" , String . Empty ) ) ;
lR_Weigh . Real_Error = Convert . ToDecimal ( Mesnac . Basic . DataProcessor . RowValue ( dr , "Real_Error" , String . Empty ) ) ;
lR_Weigh . EndTime = Mesnac . Basic . DataProcessor . RowValue ( dr , "EndTime" , String . Empty ) ;
return lR_Weigh ;
}
else
{
return null ;
}
}
# endregion
#region 添加报表数据( LR_recipe)
/// <summary>
/// 添加报表数据( LR_recipe)
/// </summary>
/// <param name="lrPlan">LR_recipe实体类</param>
/// <returns>返回新加计划的计划号</returns>
public static string AddLRRecipe ( LR_recipe lrRecipe )
{
DbHelper dbHelper = Mesnac . Basic . DataSourceFactory . Instance . GetDbHelper ( Mesnac . Basic . DataSourceFactory . MCDbType . Local ) ;
if ( dbHelper = = null )
{
throw new Exception ( Mesnac . Basic . LanguageHelper . DataBaseConnectError ) ;
}
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
//添加计划的SQL语句
string strSql3 = @ "INSERT INTO LR_recipe(Plan_id,Equip_code,Weight_ID,Material_Code,Material_Name,Set_Weight,Set_Error,CPK_Error,Batch_number,remark)
VALUES ( @Plan_id , @Equip_code , @Weight_ID , @Material_Code , @Material_Name , @Set_Weight , @Set_Error , @CPK_Error , @Batch_number , @remark ) ";
dbHelper . CommandText = strSql3 ;
dbHelper . AddParameter ( "@Plan_id" , lrRecipe . Plan_id ) ;
dbHelper . AddParameter ( "@Equip_code" , lrRecipe . Equip_Code ) ;
dbHelper . AddParameter ( "@Weight_ID" , lrRecipe . Weight_ID ) ;
dbHelper . AddParameter ( "@Material_Code" , lrRecipe . Material_Code ) ;
dbHelper . AddParameter ( "@Material_Name" , lrRecipe . Material_Name ) ;
dbHelper . AddParameter ( "@Set_Weight" , lrRecipe . Set_Weight ) ;
dbHelper . AddParameter ( "@Set_Error" , lrRecipe . Set_Error ) ;
dbHelper . AddParameter ( "@CPK_Error" , lrRecipe . CPK_Error ) ;
dbHelper . AddParameter ( "@Batch_number" , lrRecipe . Batch_number ) ;
dbHelper . AddParameter ( "@remark" , lrRecipe . remark ) ;
dbHelper . ExecuteNonQuery ( ) ;
return lrRecipe . Plan_id ;
}
# endregion
#region 添加生产计划报表( LR_plan)
/// <summary>
/// 添加生产计划
/// </summary>
/// <param name="lrPlan">LR_plan实体类</param>
/// <returns>返回新加计划的计划号</returns>
public static bool LRAddPlan ( LR_plan lrPlan )
{
DbHelper dbHelper = Mesnac . Basic . DataSourceFactory . Instance . GetDbHelper ( Mesnac . Basic . DataSourceFactory . MCDbType . Local ) ;
if ( dbHelper = = null )
{
throw new Exception ( Mesnac . Basic . LanguageHelper . DataBaseConnectError ) ;
}
try
{
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
//添加计划的SQL语句
string strSql3 = @ "INSERT INTO LR_plan(Dosing_Id,Plan_Id,Equip_Code,Plan_Serial,Recipe_ID,Recipe_Code,Recipe_Name,Version,Recipe_Type,Shift_Id,Shift_Class,Plan_Num,Real_Num,Duration_Time,Start_Date,End_Date,Weight_Man,Stock_Man,Plan_Batch,Plan_State,Plan_Date,Total_Weight,Total_Error,IF_FLAG,IsRetransmission)
VALUES ( @Dosing_Id , @Plan_Id , @Equip_Code , @Plan_Serial , @Recipe_ID @Recipe_Code , @Recipe_Name , @Version , @Recipe_Type , @Shift_Id , @Shift_Class , @Plan_Num , @Real_Num , @Duration_Time , @Start_Date , @End_Date , @Weight_Man , @Stock_Man , @Plan_Batch , @Plan_State , @Plan_Date , @Total_Weight , @Total_Error , @IF_FLAG , @IsRetransmission ) ";
dbHelper . CommandText = strSql3 ;
dbHelper . AddParameter ( "@Dosing_Id" , 0 ) ;
dbHelper . AddParameter ( "@Plan_Id" , lrPlan . Plan_Id ) ; //计划号
dbHelper . AddParameter ( "@Equip_Code" , lrPlan . Equip_Code ) ; //机台号
dbHelper . AddParameter ( "@Plan_Serial" , lrPlan . Plan_Serial ) ; //排序字段( 优先级, 在此与ActionOrder相同)
dbHelper . AddParameter ( "@Recipe_ID" , lrPlan . Recipe_ID ) ;
dbHelper . AddParameter ( "@Recipe_Code" , lrPlan . Recipe_Code ) ; //配方编码
dbHelper . AddParameter ( "@Recipe_Name" , lrPlan . Recipe_Name ) ; //配方别名
dbHelper . AddParameter ( "@Version" , lrPlan . Version ) ; //配方版本号
//dbHelper.AddParameter("@Mixer_Line", lrPlan.Mixer_Line); //配方版本号
dbHelper . AddParameter ( "@Recipe_Type" , lrPlan . Recipe_Type ) ; //配方类型
dbHelper . AddParameter ( "@Shift_Id" , lrPlan . Shift_Id ) ; //班次ID
dbHelper . AddParameter ( "@Shift_Class" , 0 ) ; //班组ID
dbHelper . AddParameter ( "@Plan_Num" , lrPlan . Plan_Num ) ; //计划数
dbHelper . AddParameter ( "@Real_Num" , lrPlan . Real_Num ) ; //完成数量
dbHelper . AddParameter ( "@Duration_Time" , lrPlan . Duration_Time ) ; //持续时间
dbHelper . AddParameter ( "@Start_Date" , lrPlan . Start_Date ) ; //开始时间
dbHelper . AddParameter ( "@End_Date" , lrPlan . End_Date ) ; //结束时间
dbHelper . AddParameter ( "@Weight_Man" , lrPlan . Weight_Man ) ; //称量工
dbHelper . AddParameter ( "@Stock_Man" , lrPlan . Stock_Man ) ; //投料工
dbHelper . AddParameter ( "@Plan_Batch" , lrPlan . Plan_Batch ) ; //批次号,不同的现场有不同的命令规则。
dbHelper . AddParameter ( "@Plan_State" , lrPlan . Plan_State ) ; //计划状态
dbHelper . AddParameter ( "@Plan_Date" , lrPlan . Plan_Date ) ; //计划日期
dbHelper . AddParameter ( "@IF_FLAG" , lrPlan . IF_FLAG ) ; //暂时无用
dbHelper . AddParameter ( "@Total_Weight" , lrPlan . Total_Weight ) ;
dbHelper . AddParameter ( "@Total_Error" , lrPlan . Total_Error ) ;
dbHelper . AddParameter ( "@IsRetransmission" , lrPlan . IsRetransmission ) ;
dbHelper . ExecuteNonQuery ( ) ;
return true ;
}
catch ( Exception )
{
return false ;
}
}
# endregion
#region 添加物料报表( LR_weigh)
/// <summary>
/// 添加物料报表
/// </summary>
/// <param name="lrPlan">LR_plan实体类</param>
/// <returns>返回新加计划的计划号</returns>
public static bool LRAddWeigh ( LR_weigh lrWeigh )
{
DbHelper dbHelper = Mesnac . Basic . DataSourceFactory . Instance . GetDbHelper ( Mesnac . Basic . DataSourceFactory . MCDbType . Local ) ;
if ( dbHelper = = null )
{
throw new Exception ( Mesnac . Basic . LanguageHelper . DataBaseConnectError ) ;
}
try
{
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
//添加计划的SQL语句
string strSql3 = @ "INSERT INTO LR_weigh(Dosing_ID,Plan_Id,Recipe_ID,Material_ID,Material_Name,Set_Weight,Set_Error,Real_Weight,Real_Error,EndTime)
VALUES ( @Dosing_ID , @Plan_id , @Recipe_ID , @Material_ID , @Material_Name , @Set_Weight , @Set_Error , @Real_Weight , @Real_Error , @EndTime ) ";
dbHelper . CommandText = strSql3 ;
dbHelper . AddParameter ( "@Dosing_ID" , lrWeigh . Dosing_ID ) ;
dbHelper . AddParameter ( "@Plan_ID" , lrWeigh . Plan_ID ) ; //计划号
dbHelper . AddParameter ( "@Recipe_ID" , lrWeigh . Recipe_ID ) ; //配方号
dbHelper . AddParameter ( "@Material_ID" , lrWeigh . Material_ID ) ; //物料号
dbHelper . AddParameter ( "@Material_Name" , lrWeigh . Material_Name ) ; //物料名称
dbHelper . AddParameter ( "@Set_Weight" , lrWeigh . Set_Weight ) ; //设置重量
dbHelper . AddParameter ( "@Set_Error" , lrWeigh . Set_Error ) ; //设置误差
dbHelper . AddParameter ( "@Real_Weight" , lrWeigh . Real_Weight ) ; //称量重量
dbHelper . AddParameter ( "@Real_Error" , lrWeigh . Real_Error ) ; //称量误差
dbHelper . AddParameter ( "@EndTime" , DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss" ) ) ; //完成时间
dbHelper . ExecuteNonQuery ( ) ;
return true ;
}
catch ( Exception ex )
{
return false ;
}
}
# endregion
#region 更新计划状态
/// <summary>
/// 更新计划状态
/// </summary>
/// <param name="planId">计划号</param>
/// <param name="state">任务状态 3:正在运行; 4:已下传;5:未启动; 7: 已终止;8:已完成</param>
/// <param name="IfFlag">是否完成</param>
/// <returns></returns>
public static bool UpdateLrPlan ( string planId , decimal total_Weight , decimal total_Error )
{
try
{
DbHelper dbHelper = Mesnac . Basic . DataSourceFactory . Instance . GetDbHelper ( Mesnac . Basic . DataSourceFactory . MCDbType . Local ) ;
if ( dbHelper = = null )
{
throw new Exception ( Mesnac . Basic . LanguageHelper . DataBaseConnectError ) ;
}
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
string strSql = "update LR_plan set Total_Weight = @Total_Weight, Total_Error = @Total_Error where Plan_Id = @PlanID" ;
dbHelper . CommandText = strSql ;
dbHelper . AddParameter ( "@Total_Weight" , total_Weight ) ;
dbHelper . AddParameter ( "@Total_Error" , total_Error ) ;
dbHelper . AddParameter ( "@PlanID" , planId ) ;
dbHelper . ExecuteNonQuery ( ) ;
return true ;
}
catch ( Exception )
{
return false ;
}
}
# endregion
}
}