Exemplo n.º 1
0
 /// <summary>
 /// 生成燃料消耗量数据
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void barBtnGenerate_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (!this.CheckAllDataReady())
     {
         return;
     }
     try
     {
         DataSet     ds          = this.GetReadyDataFromLocalCoc();
         NissanUtils nissanUtils = new NissanUtils();
         string      msg         = nissanUtils.SaveParam(ds);
         if (string.IsNullOrEmpty(msg))
         {
             this.ShowLocalReadyData();
             MessageBox.Show("生成成功", "生成成功");
         }
         else
         {
             MessageForm mf = new MessageForm("以下数据已经存在\r\n" + msg);
             Utils.SetFormMid(mf);
             mf.Text = "生成结果";
             mf.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("燃料消耗量数据生成失败:" + ex.Message, "生成失败");
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 更新主表关联燃料数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            string    message = string.Empty;
            string    strCon  = AccessHelper.conn;
            DataTable dtCtny  = this.GetMainData("CTNY");
            DataTable dtFcds  = this.GetMainData("FCDS");
            DataTable dtCdd   = this.GetMainData("CDD");

            NissanUtils nissanUtil = new NissanUtils();
            DataTable   dtCtnyPam  = nissanUtil.GetRllxData("传统能源");
            DataTable   dtFcdsPam  = nissanUtil.GetRllxData("非插电式混合动力");
            DataTable   dtCddPam   = nissanUtil.GetRllxData("纯电动");

            using (OleDbConnection con = new OleDbConnection(strCon))
            {
                con.Open();
                try
                {
                    foreach (string vin in vinList)
                    {
                        DataRow[] drCtny = dtCtny.Select(String.Format("MAIN_ID='{0}'", this.dictVinMainId[vin]));
                        DataRow[] drFcds = dtFcds.Select(String.Format("MAIN_ID='{0}'", this.dictVinMainId[vin]));
                        DataRow[] drCdd  = dtCdd.Select(String.Format("MAIN_ID='{0}'", this.dictVinMainId[vin]));

                        if (drCtny.Length > 0)
                        {
                            message += this.UpdateFuelData(vin, dictStatus[vin], drCtny[0], dtCtnyPam, con);
                        }
                        if (drFcds.Length > 0)
                        {
                            message += this.UpdateFuelData(vin, dictStatus[vin], drFcds[0], dtFcdsPam, con);
                        }
                        if (drCdd.Length > 0)
                        {
                            message += this.UpdateFuelData(vin, dictStatus[vin], drCdd[0], dtCddPam, con);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(String.Format("更新失败:{0}\r\n", ex.Message));
                }
                if (string.IsNullOrEmpty(message))
                {
                    MessageBox.Show("全部更新成功");
                }
                else
                {
                    MessageForm mf = new MessageForm(message);
                    Utils.SetFormMid(mf);
                    mf.Text = "更新结果";
                    mf.ShowDialog();
                }
                this.SearchLocal(this.mainIds);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 导入VIN
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnImportVin_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            NissanUtils  utils      = new NissanUtils();
            FolderDialog openFolder = new FolderDialog();

            try
            {
                if (openFolder.DisplayDialog() == DialogResult.OK)
                {
                    // 获取用户选择的文件夹路径
                    string folderPath = openFolder.Path;

                    // 获取folderPath下以格式为utils.CocFileName的所有文件
                    List <string> fileNameList = utils.GetFileName(folderPath, utils.VinFileName);
                    if (fileNameList.Count > 0)
                    {
                        string fileNameMsg = string.Empty;
                        string returnMsg   = string.Empty;

                        // 获取全部主表数据,用作合并VIN数据
                        bool IsMainDataExist = utils.GetMainData();
                        if (!IsMainDataExist)
                        {
                            MessageBox.Show("系统中不存在主表数据,请首先导入主表数据", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }

                        // 遍历读所有文件fileNameList
                        foreach (string fileName in fileNameList)
                        {
                            // fileNameMsg += Path.GetFileName(fileName) + "\r\n";

                            // 导入filename文件信息
                            returnMsg += utils.ImportVinData(fileName, folderPath);
                        }

                        MessageForm mf = new MessageForm(returnMsg);
                        Utils.SetFormMid(mf);
                        mf.Text = "导入结果";
                        mf.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show(String.Format("目录{0}下没有文件{1}", folderPath, utils.VinFileName));
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("导入失败:" + ex.Message);
            }
        }
Exemplo n.º 4
0
        // 更新主表关联数据
        private void btnUpdateRelData_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            // 获取主表编号
            string      mainIds    = string.Empty;
            NissanUtils nissanUtil = new NissanUtils();

            try
            {
                List <string> ctnyList = nissanUtil.GetMainIdFromControl(this.gvCtny, (DataTable)this.dgvCtny.DataSource);
                List <string> fcdsList = nissanUtil.GetMainIdFromControl(this.gvFcds, (DataTable)this.dgvFcds.DataSource);
                List <string> cddList  = nissanUtil.GetMainIdFromControl(this.gvCdd, (DataTable)this.dgvCdd.DataSource);


                if (ctnyList.Count + fcdsList.Count + cddList.Count < 1)
                {
                    MessageBox.Show("请选择主表信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                foreach (string ctnyId in ctnyList)
                {
                    mainIds += string.Format(",'{0}'", ctnyId);
                }
                foreach (string fcdsId in fcdsList)
                {
                    mainIds += string.Format(",'{0}'", fcdsId);
                }

                foreach (string cddId in cddList)
                {
                    mainIds += string.Format(",'{0}'", cddId);
                }

                if (!string.IsNullOrEmpty(mainIds))
                {
                    mainIds = mainIds.Substring(1);
                }

                using (ReviewUpdateVinForm reviewVinForm = new ReviewUpdateVinForm(mainIds))
                {
                    reviewVinForm.ShowDialog();
                }
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 5
0
 private void btnGenFuelData_Click(object sender, EventArgs e)
 {
     try
     {
         NissanUtils nissanUtils = new NissanUtils();
         string      msg         = nissanUtils.SaveParam(ds);
         if (string.IsNullOrEmpty(msg))
         {
             this.DialogResult = DialogResult.OK;
             MessageBox.Show("生成成功", "生成成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             MessageForm mf = new MessageForm("以下数据已经存在\r\n" + msg);
             Utils.SetFormMid(mf);
             mf.Text = "生成结果";
             mf.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("燃料消耗量数据生成失败:" + ex.Message, "生成失败");
     }
 }
Exemplo n.º 6
0
        protected void ImportMainData(string importType)
        {
            string operateType = string.Empty;

            if (importType == "IMPORT")
            {
                operateType = "导入";
            }
            else if (importType == "UPDATE")
            {
                operateType = "修改";
            }

            NissanUtils  utils      = new NissanUtils();
            FolderDialog openFolder = new FolderDialog();

            try
            {
                if (openFolder.DisplayDialog() == DialogResult.OK)
                {
                    // 获取用户选择的文件夹路径
                    string folderPath = openFolder.Path;

                    // 获取folderPath下以格式为utils.CocFileName的所有文件
                    List <string> fileNameList = utils.GetFileName(folderPath, utils.MainFileName);
                    if (fileNameList.Count > 0)
                    {
                        string        fileNameMsg    = string.Empty;
                        string        returnMsg      = string.Empty;
                        List <string> mainUpdateList = new List <string>();

                        // 遍历读所有文件fileNameList
                        foreach (string fileName in fileNameList)
                        {
                            fileNameMsg += Path.GetFileName(fileName) + Environment.NewLine;

                            // 导入filename文件信息
                            returnMsg += utils.ImportMainData(fileName, folderPath, importType, mainUpdateList);
                        }

                        if (string.IsNullOrEmpty(returnMsg))
                        {
                            MessageForm mf = new MessageForm(String.Format("以下文件{0}成功:\r\n{1}", operateType, fileNameMsg));
                            Utils.SetFormMid(mf);
                            mf.Text = operateType + "成功";
                            mf.ShowDialog();
                        }
                        else
                        {
                            MessageForm mf = new MessageForm(returnMsg);
                            Utils.SetFormMid(mf);
                            mf.Text = operateType + "结果";
                            mf.ShowDialog();
                        }

                        if (importType == "IMPORT")
                        {
                            this.ShowMainData();
                        }
                        else if (importType == "UPDATE")
                        {
                            this.ShowUpdatedMainData(mainUpdateList);
                        }
                    }
                    else
                    {
                        MessageBox.Show(String.Format("目录{0}下没有文件{1}", folderPath, utils.MainFileName));
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("{0}失败:{1}", operateType, ex.Message), "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }