Esempio n. 1
0
        public static int AddSandMixSupp(SandMixSupp sandmixsupp)
        {
            int result = 0;

            try
            {
                result = DataFactory.UpdateEntity(sandmixsupp, "SandMixSID,Time,Batch,SetCompactability,SandTem,MSetCompactability,FirstWater,Bias,TotalWater,CircleTime,SetStrength,RealStrength,Bentonite,Additive,Support1,Support2,SandWeight,RealCompactability", "MW_SandMixSupp_INS");
            }
            catch (Exception ex)
            {
                result = 0;
            }
            return(result);
        }
Esempio n. 2
0
        //写入SQL
        private void updateSQL(DataTable dt, FileSystemEventArgs e)
        {
            int         rowsCount   = dt.Rows.Count;
            SandMix     sandMix     = new SandMix();
            SandMixSupp sandMixSupp = new SandMixSupp();

            sandMixSupp.SandMixSID = SandMixDAL.GetSandMixSID();
            int result  = 0;
            int success = 0;

            for (int i = 0; i < rowsCount; i++)
            {
                string time = DateTime.Now.ToString("yyyy-MM-dd ") + dt.Rows[i]["Heure"].ToString().Replace('.', ':');
                sandMixSupp.Time               = DateTime.Parse(time);                                                  //时间
                sandMixSupp.Batch              = Convert.ToInt32(dt.Rows[i]["N°Cycle"].ToString());                     //批次
                sandMixSupp.SetCompactability  = Convert.ToDouble(dt.Rows[i]["ASVisée"].ToString().Replace(',', '.'));  //设定紧实率
                sandMixSupp.SandTem            = Convert.ToDouble(dt.Rows[i]["°CSable"].ToString().Replace(',', '.'));  //旧沙温度
                sandMixSupp.MSetCompactability = Convert.ToDouble(dt.Rows[i]["ASCorr"].ToString().Replace(',', '.'));   //补偿紧实率
                sandMixSupp.FirstWater         = Convert.ToInt32(dt.Rows[i]["EauReg"].ToString());                      //第一次加水量
                sandMixSupp.Bias               = Convert.ToDouble(dt.Rows[i]["Ecart"].ToString().Replace(',', '.'));    //偏差(有正负)
                sandMixSupp.TotalWater         = Convert.ToInt32(dt.Rows[i]["EauTotal"].ToString());                    //总加水量
                sandMixSupp.CircleTime         = Convert.ToInt32(dt.Rows[i]["TpsCycle"].ToString());                    //循环时间
                sandMixSupp.SetStrength        = Convert.ToInt32(dt.Rows[i]["RCVisée"].ToString());                     //强度设定值
                sandMixSupp.RealStrength       = Convert.ToInt32(dt.Rows[i]["ValRC"].ToString());                       //实际强度值
                sandMixSupp.Bentonite          = Convert.ToDouble(dt.Rows[i]["Additif1"].ToString().Replace(',', '.')); //膨润土量
                sandMixSupp.Additive           = Convert.ToDouble(dt.Rows[i]["Additif2"].ToString().Replace(',', '.')); //综合添加剂
                sandMixSupp.Support1           = Convert.ToDouble(dt.Rows[i]["Additif3"].ToString().Replace(',', '.')); //其他辅料1
                sandMixSupp.Support2           = Convert.ToDouble(dt.Rows[i]["Additif3"].ToString().Replace(',', '.')); //其他辅料2
                sandMixSupp.SandWeight         = Convert.ToInt32(dt.Rows[i]["PoidsVS"].ToString());                     //旧沙重量
                sandMixSupp.RealCompactability = Convert.ToDouble(dt.Rows[i]["ValASFin"].ToString().Replace(',', '.')); //实际紧实率

                try
                {
                    result = 0;
                    result = SandMixSuppDAL.AddSandMixSupp(sandMixSupp);    //写入数据库
                    if (result == 1)
                    {
                        success++;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }

            #region 写日志文件
            string msg = "文件名:" + e.Name + "成功数:" + success + DateTime.Now.ToString("[yyyy-MM-dd]");
            if (!File.Exists("Log.txt"))
            {
                FileStream fileStream = new FileStream("Log.txt", FileMode.Create, FileAccess.Write);
                using (StreamWriter sw = new StreamWriter(fileStream))
                {
                    sw.WriteLine(msg);
                }
                fileStream.Close();
            }
            if (File.Exists("Log.txt"))
            {
                FileStream fileStream = new FileStream("Log.txt", FileMode.Append, FileAccess.Write);
                using (StreamWriter sw = new StreamWriter(fileStream))
                {
                    sw.WriteLine(msg);
                }
                fileStream.Close();
            }
            #endregion

            MessageBox.Show("成功数" + success);
        }