Ejemplo n.º 1
0
        private void btnSaveProductFile_Click(object sender, EventArgs e)
        {
            try
            {
                int i = 0;
                ProductFileManager man = new ProductFileManager();
                foreach (DataRow row in dtProductFile.Rows)
                {
                    switch (row.RowState)
                    {
                    case DataRowState.Added:
                        i += man.AddProductFile(row);
                        break;

                    case DataRowState.Modified:
                        i += man.UpdateProductFile(row);
                        break;

                    case DataRowState.Deleted:
                        i += man.DeleteProductFile(row);
                        break;
                    }
                }
                dtProductFile.AcceptChanges();
                MessageBox.Show(string.Format("保存成功,更新【{0}】条数据!", i), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存失败!" + ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 2
0
 private void LoadSourcePorductFile()
 {
     try
     {
         string product_code = string.Empty;
         if (this.dgvProduct.CurrentRow != null)
         {
             product_code = this.dgvProduct.CurrentRow.Cells["PRODUCT_CODE"].Value.ToString();
         }
         ProductFileManager man = new ProductFileManager();
         dtProductFile = man.GetProductFileList(product_code);
         this.dgvProductFile.DataSource = dtProductFile;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 加载升级文件清单
        /// </summary>
        private void LoadProductFile()
        {
            if (dtVersionFile != null)
            {
                dtVersionFile.Clear();
            }
            else
            {
                VersionFileManager versionMan = new VersionFileManager();
                dtVersionFile = versionMan.GetList("1=2");
                DataColumn col = new DataColumn("bCheck", typeof(bool));
                dtVersionFile.Columns.Add(col);
                this.dgvVERSIONFILE.DataSource = dtVersionFile;
            }
            string folder = txt_ProductFolder.Text.Trim();

            if (folder.Trim().Length == 0)
            {
                return;
            }
            ProductFileManager pfMan = new ProductFileManager();
            DataTable          dtPF  = pfMan.GetProductFileList(this.cmdProduct.SelectedValue.ToString());

            foreach (DataRow row in dtPF.Rows)
            {
                //[OBJ_NO],[PRODUCT_CODE],[FILE_VERSION],[FILE_VERSION2],[FILE_NAME],[FILE_PATH],[FILE_DATA],[OBJ_DATE],[REMARK]
                string fileName = folder + @"\" + row["PRODUCT_FILENAME"].ToString();
                if (File.Exists(fileName))
                {
                    DataRow newRow = dtVersionFile.NewRow();
                    newRow["bCheck"]       = 1;
                    newRow["OBJ_NO"]       = Guid.NewGuid().ToString();
                    newRow["PRODUCT_CODE"] = this.cmdProduct.SelectedValue.ToString();
                    string   product_Filename = row["PRODUCT_FILENAME"].ToString();
                    string[] names            = product_Filename.Split('\\');
                    newRow["FILE_NAME"] = names[names.Length - 1];
                    newRow["FILE_PATH"] = @"\" + product_Filename;
                    newRow["FILE_DATA"] = getFileByte(fileName);
                    dtVersionFile.Rows.Add(newRow);
                }
            }
        }