Пример #1
0
 /// <summary>
 /// 查找重复VCU信息
 /// </summary>
 /// <param name="item"></param>
 public static int RepeatVCUconfig(T_VCUConfig item)
 {
     try
     {
         return(_sqlSugar.Queryable <T_VCUConfig>().Where(t => t.mtoc == item.mtoc).Count());
     }
     catch (Exception ex)
     {
         Log.Error($"查询记录失败!\r\n mtoc={item.mtoc}", ex);
     }
     return(0);
 }
Пример #2
0
 /// <summary>
 /// 删除VCU配置信息
 /// </summary>
 /// <param name="item"></param>
 public async static Task <int> DeleteVCUconfig(T_VCUConfig item)
 {
     try
     {
         return(await _sqlSugar.Deleteable <T_VCUConfig>().Where(t => t.id == item.id).ExecuteCommandAsync());
     }
     catch (Exception ex)
     {
         Log.Error($"删除记录失败!\r\n id={item.id}", ex);
     }
     return(0);
 }
Пример #3
0
 /// <summary>
 /// 保存VCU相关信息
 /// </summary>
 /// <param name="item"></param>
 public async static Task <int> SaveVCUconfig(T_VCUConfig item)
 {
     try
     {
         return(await _sqlSugar.Insertable(item).ExecuteCommandAsync());
     }
     catch (Exception ex)
     {
         string jsonstr = Newtonsoft.Json.JsonConvert.SerializeObject(item);
         Log.Error($"添加记录失败!\r\n {jsonstr}", ex);
     }
     return(0);
 }
Пример #4
0
        /// <summary>
        /// 单机表格显示
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvStandard_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex >= 0)
                {
                    //VCUItem = new VCUconfig();
                    //VCUItem.Id = int.Parse(this.dgvStandard.Rows[e.RowIndex].Cells[0].Value + "");
                    //VCUItem.MTOC = this.dgvStandard.Rows[e.RowIndex].Cells[1].Value + "";
                    //VCUItem.DriverName = this.dgvStandard.Rows[e.RowIndex].Cells[2].Value + "";
                    //VCUItem.DriverPath = this.dgvStandard.Rows[e.RowIndex].Cells[3].Value + "";
                    //VCUItem.BinName = this.dgvStandard.Rows[e.RowIndex].Cells[4].Value + "";
                    //VCUItem.BinPath = this.dgvStandard.Rows[e.RowIndex].Cells[5].Value + "";
                    //VCUItem.CalName = this.dgvStandard.Rows[e.RowIndex].Cells[6].Value + "";
                    //VCUItem.CalPath = this.dgvStandard.Rows[e.RowIndex].Cells[7].Value + "";
                    //VCUItem.SoftWareVersion = this.dgvStandard.Rows[e.RowIndex].Cells[8].Value + "";
                    //VCUItem.ElementNum = this.dgvStandard.Rows[e.RowIndex].Cells[9].Value + "";
                    //VCUItem.HardWareCode = this.dgvStandard.Rows[e.RowIndex].Cells[10].Value + "";
                    //VCUItem.HW = this.dgvStandard.Rows[e.RowIndex].Cells[11].Value + "";
                    //VCUItem.SW = this.dgvStandard.Rows[e.RowIndex].Cells[12].Value + "";
                    //VCUItem.Sign = this.dgvStandard.Rows[e.RowIndex].Cells[13].Value + "";

                    t_VCUConfig                 = new T_VCUConfig();
                    t_VCUConfig.id              = int.Parse(this.dgvStandard.Rows[e.RowIndex].Cells[0].Value + "");
                    t_VCUConfig.mtoc            = this.dgvStandard.Rows[e.RowIndex].Cells[1].Value + "";
                    t_VCUConfig.drivername      = this.dgvStandard.Rows[e.RowIndex].Cells[2].Value + "";
                    t_VCUConfig.driverpath      = this.dgvStandard.Rows[e.RowIndex].Cells[3].Value + "";
                    t_VCUConfig.binname         = this.dgvStandard.Rows[e.RowIndex].Cells[4].Value + "";
                    t_VCUConfig.binpath         = this.dgvStandard.Rows[e.RowIndex].Cells[5].Value + "";
                    t_VCUConfig.calname         = this.dgvStandard.Rows[e.RowIndex].Cells[6].Value + "";
                    t_VCUConfig.calpath         = this.dgvStandard.Rows[e.RowIndex].Cells[7].Value + "";
                    t_VCUConfig.softwareversion = this.dgvStandard.Rows[e.RowIndex].Cells[8].Value + "";
                    t_VCUConfig.elementNum      = this.dgvStandard.Rows[e.RowIndex].Cells[9].Value + "";
                    t_VCUConfig.hardwarecode    = this.dgvStandard.Rows[e.RowIndex].Cells[10].Value + "";
                    t_VCUConfig.HW              = this.dgvStandard.Rows[e.RowIndex].Cells[11].Value + "";
                    t_VCUConfig.SW              = this.dgvStandard.Rows[e.RowIndex].Cells[12].Value + "";
                    t_VCUConfig.sign            = this.dgvStandard.Rows[e.RowIndex].Cells[13].Value + "";
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #5
0
        public AddConfig(T_VCUConfig VCUItem)
        {
            InitializeComponent();

            this.t_VCUConfig = VCUItem;
        }
Пример #6
0
 public AddConfig()
 {
     InitializeComponent();
     t_VCUConfig = null;
 }
Пример #7
0
        /// <summary>
        /// 保存数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void button2_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(this.tbMTOC.Text.Trim()) ||
                    string.IsNullOrEmpty(this.tbHardwareCode.Text.Trim()) ||
                    string.IsNullOrEmpty(this.tbsoftwareVersion.Text.Trim()) ||
                    string.IsNullOrEmpty(this.tbHW.Text.Trim()) ||
                    string.IsNullOrEmpty(this.tbElementCode.Text.Trim()) ||
                    string.IsNullOrEmpty(this.tbSW.Text.Trim()) ||
                    string.IsNullOrEmpty(this.tbDriver.Text.Trim()) ||
                    string.IsNullOrEmpty(this.tbWrite.Text.Trim()) ||
                    string.IsNullOrEmpty(this.tbCal.Text.Trim()))
                {
                    MessageBox.Show("请填写全部信息", "提示");
                    return;
                }

                string   localConnectionString = ConfigurationManager.ConnectionStrings["localCnnStr"] + "";
                Configer Conbll = new Configer(localConnectionString);
                if (t_VCUConfig == null)
                {
                    if (this.btDriver.Text != "已导入" || this.btWrite.Text != "已导入" || this.btCal.Text != "已导入")
                    {
                        MessageBox.Show("请导入文件", "提示");
                        return;
                    }

                    // VCUconfig item = new VCUconfig();
                    // item.MTOC = this.tbMTOC.Text.ToUpper();
                    // item.HardWareCode = this.tbHardwareCode.Text.ToUpper();
                    // item.HW = this.tbHW.Text;
                    // item.SoftWareVersion = this.tbsoftwareVersion.Text;
                    // item.SW = this.tbSW.Text; ;
                    // item.ElementNum = this.tbElementCode.Text;
                    // item.Sign = this.tbSign.Text;

                    // item.DriverName = this.tbDriver.Text;
                    // item.BinName = this.tbWrite.Text;
                    // item.CalName = this.tbCal.Text;
                    // item.DriverPath = System.Configuration.ConfigurationManager.AppSettings["driverPos"];
                    // //item.DriverPath = System.Configuration.ConfigurationSettings.AppSettings["driver"];
                    // item.BinPath = System.Configuration.ConfigurationManager.AppSettings["writePos"];
                    //// item.BinPath = System.Configuration.ConfigurationSettings.AppSettings["bin"];
                    // item.CalPath = System.Configuration.ConfigurationManager.AppSettings["calPos"];

                    //int isRep = Conbll.RepeatVCUconfig(item);
                    // if (isRep > 0)
                    // {
                    //     MessageBox.Show("已经拥有该车型的数据了,请重新命名", "提示");
                    //     return;
                    // }
                    // else
                    // {
                    //     Conbll.SaveVCUconfig(item);
                    //     MessageBox.Show("新增成功");
                    // }
                    T_VCUConfig item = new T_VCUConfig();
                    item.mtoc            = this.tbMTOC.Text.ToUpper();
                    item.hardwarecode    = this.tbHardwareCode.Text.ToUpper();
                    item.HW              = this.tbHW.Text;
                    item.softwareversion = this.tbsoftwareVersion.Text;
                    item.SW              = this.tbSW.Text;;
                    item.elementNum      = this.tbElementCode.Text;
                    item.sign            = this.tbSign.Text;
                    item.drivername      = this.tbDriver.Text;
                    item.binname         = this.tbWrite.Text;
                    item.calname         = this.tbCal.Text;
                    item.driverpath      = System.Configuration.ConfigurationManager.AppSettings["driverPos"];
                    item.binpath         = System.Configuration.ConfigurationManager.AppSettings["writePos"];
                    item.calpath         = System.Configuration.ConfigurationManager.AppSettings["calPos"];
                    int tmpK = Comm.SqlComm.RepeatVCUconfig(item);
                    if (tmpK > 0)
                    {
                        MessageBox.Show("已经拥有该车型的数据了,请重新命名", "提示");
                        return;
                    }
                    int tmpAddCount = await Comm.SqlComm.SaveVCUconfig(item);

                    string msg = tmpAddCount > 0 ? "新增成功" : "新增失败";
                    MessageBox.Show(msg);
                }
                else
                {
                    //VCUconfig item = new VCUconfig();
                    //item.Id = VCUItem.Id;
                    //item.MTOC = this.tbMTOC.Text.ToUpper();
                    //item.HardWareCode = this.tbHardwareCode.Text.ToUpper();
                    //item.HW = this.tbHW.Text;
                    //item.SoftWareVersion = this.tbsoftwareVersion.Text;
                    //item.SW = this.tbSW.Text; ;
                    //item.ElementNum = this.tbElementCode.Text;
                    //item.Sign = this.tbSign.Text;

                    //item.DriverName = this.tbDriver.Text;
                    //item.BinName = this.tbWrite.Text;
                    //item.CalName = this.tbCal.Text;
                    //item.DriverPath = System.Configuration.ConfigurationManager.AppSettings["driverPos"];
                    ////item.DriverPath = System.Configuration.ConfigurationSettings.AppSettings["driver"];
                    //item.BinPath = System.Configuration.ConfigurationManager.AppSettings["writePos"];
                    //// item.BinPath = System.Configuration.ConfigurationSettings.AppSettings["bin"];
                    //item.CalPath = System.Configuration.ConfigurationManager.AppSettings["calPos"];
                    //Conbll.UpdateVCUconfig(item);
                    //MessageBox.Show("修改成功");

                    t_VCUConfig.mtoc            = this.tbMTOC.Text.ToUpper();
                    t_VCUConfig.hardwarecode    = this.tbHardwareCode.Text.ToUpper();
                    t_VCUConfig.HW              = this.tbHW.Text;
                    t_VCUConfig.softwareversion = this.tbsoftwareVersion.Text;
                    t_VCUConfig.SW              = this.tbSW.Text;;
                    t_VCUConfig.elementNum      = this.tbElementCode.Text;
                    t_VCUConfig.sign            = this.tbSign.Text;
                    t_VCUConfig.drivername      = this.tbDriver.Text;
                    t_VCUConfig.binname         = this.tbWrite.Text;
                    t_VCUConfig.calname         = this.tbCal.Text;
                    t_VCUConfig.driverpath      = System.Configuration.ConfigurationManager.AppSettings["driverPos"];
                    t_VCUConfig.binpath         = System.Configuration.ConfigurationManager.AppSettings["writePos"];
                    t_VCUConfig.calpath         = System.Configuration.ConfigurationManager.AppSettings["calPos"];

                    int tmpK = await Comm.SqlComm.UpdateVCUconfig(t_VCUConfig);

                    string msg = tmpK > 0 ? "修改成功" : "修改失败";
                    MessageBox.Show(msg);
                }

                this.Dispose();
                this.Close();
            }
            catch (Exception)
            {
                throw;
            }
        }