public int Add(BaseProductionDrawingTable model) { int result = 0; try { List <CommandInfo> listSql = new List <CommandInfo>(); StringBuilder strSql = new StringBuilder(); foreach (BaseProductionDrawingTable lineModel in model.Items) { strSql = new StringBuilder(); strSql.Append("insert into BLL_PRODUCTION_DRAWING_UPLOAD("); strSql.Append("SLIP_NUMBER,DRAWING_CODE,LOCATION_FILE_NAME,SERVER_FILE_NAME)"); strSql.Append(" values ("); strSql.Append(" @SLIP_NUMBER,@DRAWING_CODE,@LOCATION_FILE_NAME,@SERVER_FILE_NAME)"); SqlParameter[] lineDrawingParameters = { new SqlParameter("@SLIP_NUMBER", SqlDbType.VarChar, 250), new SqlParameter("@DRAWING_CODE", SqlDbType.VarChar, 250), new SqlParameter("@LOCATION_FILE_NAME", SqlDbType.VarChar, 250), new SqlParameter("@SERVER_FILE_NAME", SqlDbType.VarChar, 250) }; lineDrawingParameters[0].Value = lineModel.SLIPNUMBER; lineDrawingParameters[1].Value = lineModel.DRAWINGCODE; lineDrawingParameters[2].Value = lineModel.FILENAME; lineDrawingParameters[3].Value = lineModel.SERVERFILENAME; listSql.Add(new CommandInfo(strSql.ToString(), lineDrawingParameters)); } result = DbHelperSQL.ExecuteSqlTran(listSql); } catch (SqlException ex) { } return(result); }
public int Add(BaseProductionDrawingTable model) { return(dal.Add(model)); }
private void btnUpLoad_Click(object sender, EventArgs e) { string _tmpAttachedDirectoryName = SLIPNUMBER; string _attachedDirectory = CCacheData.GetAttacheDirectory(CConstant.ATTACHE_DIRECTORY_PRODUCTION); if (txtFileName.Text.Trim() == "") { MessageBox.Show("文件名不能为空!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } try { if (!Directory.Exists(_attachedDirectory + _tmpAttachedDirectoryName + "\\")) { Directory.CreateDirectory(_attachedDirectory + _tmpAttachedDirectoryName + "\\"); //Directory.CreateDirectory(_attachedDirectory + _tmpAttachedDirectoryName); Czzd.Common.Library.FTPOperate myftp = new Czzd.Common.Library.FTPOperate("112.82.245.2", "YS_ERP\\production", "FTP_user", "czzd", 21); myftp.MkDir(_tmpAttachedDirectoryName); } foreach (DataRow dr in _currentDt.Rows) { if (openFileDialog.SafeFileName.Equals(dr["NAME"])) { MessageBox.Show("文件己经存在,请确认!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } AddAttached(new FileInfo(openFileDialog.FileName)); File.Copy(openFileDialog.FileName, _attachedDirectory + _tmpAttachedDirectoryName + "\\" + openFileDialog.SafeFileName); if (Directory.Exists(_attachedDirectory + _tmpAttachedDirectoryName)) { DirectoryInfo di = new DirectoryInfo(_attachedDirectory + _tmpAttachedDirectoryName); FileInfo[] files = di.GetFiles(); Czzd.Common.Library.FTPOperate myftp1 = new Czzd.Common.Library.FTPOperate("112.82.245.2", "YS_ERP\\production\\" + _tmpAttachedDirectoryName, "FTP_user", "czzd", 21); foreach (FileInfo file in files) { myftp1.Put("\\YY模具\\bin\\production\\" + _tmpAttachedDirectoryName + "\\" + file); } if (di.Exists) { DirectoryInfo[] childs = di.GetDirectories(); foreach (DirectoryInfo child in childs) { child.Delete(true); } di.Delete(true); } } } catch (IOException ex) { } int result = 0; productionDrawing.Items.Clear(); for (int i = 0; i < this.clbDrawing.Items.Count; i++) { BaseProductionDrawingTable productionDrawing1 = new BaseProductionDrawingTable(); if (clbDrawing.GetItemChecked(i)) { productionDrawing1.SLIPNUMBER = SLIPNUMBER; string[] sArray = Regex.Split(txtFileName.Text.Trim(), @"\\", RegexOptions.IgnoreCase); //productionDrawing1.FILENAME = txtFileName.Text.Trim(); //productionDrawing1.SERVERFILENAME = sArray[sArray.Length - 1]; productionDrawing1.FILENAME = sArray[sArray.Length - 1]; productionDrawing1.SERVERFILENAME = sArray[sArray.Length - 1] + "_" + DateTime.Now.ToString("yyyyMMddHHmmss"); clbDrawing.SelectedIndex = i; productionDrawing1.DRAWINGCODE = clbDrawing.SelectedValue.ToString(); productionDrawing.AddItem(productionDrawing1); } } result = bProductionDrawing.Add(productionDrawing); if (result < 1) { MessageBox.Show("上传失败!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { MessageBox.Show("上传成功!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); txtFileName.Text = ""; DataTable dt = new DataTable(); clbDrawing.DataSource = dt; dgvData.DataSource = dt; DataSet ds = bProductionDrawing.GetProductionDrawing(" PSDL_SLIP_NUMBER = '" + SLIPNUMBER + "'" + " AND PSDL_STATUS_FLAG= '0'"); clbDrawing.DataSource = ds.Tables[0]; clbDrawing.ValueMember = "PSDL_DRAWING_CODE"; clbDrawing.DisplayMember = "NAME"; DataSet dsUpload = bProductionDrawing.GetProductionDrawingUpload(" SLIP_NUMBER = '" + SLIPNUMBER + "'" + " AND DRAWING_CODE= '" + DRAWING_CODE + "'"); dgvData.DataSource = dsUpload.Tables[0]; } }