123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578 |
- using LabelManager2;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.IO;
- using System.Drawing;
- using System.Text;
- using System.Threading;
- using System.Windows.Forms;
- using UAS_MES.CustomControl.TextBoxWithIcon;
- using UAS_MES.DataOperate;
- using UAS_MES.Properties;
- using UAS_MES.PublicForm;
- using UAS_MES.PublicMethod;
- namespace UAS_MES.SystemSetting
- {
- public partial class SystemSetting_LabelMaintain : Form
- {
- DataHelper dh;
- DataTable dt;
- //设置Grid中Combox的静态数据,这个格式是必须的,#前面是展示值,#后面是实际值
- string[] labeltype = { "机身标#机身标", "彩盒标#彩盒标", "卡通箱标#卡通箱标", "大箱标#大箱标", "栈板标#栈板标", "SN标签#SN标签", "自定义#自定义"};
- string[] defaultype = { "是#1", "否#0" };
- Dictionary<string, string> dic = new Dictionary<string, string>();
- //用于拼接条件查询
- StringBuilder condition = new StringBuilder();
- LogStringBuilder sql = new LogStringBuilder();
- /*CodeSoft新建打印机引擎*/
- ApplicationClass lbl;
- Document doc;
- /*BarTender新建打印机引擎*/
- //private Engine engine = null;
- //private LabelFormatDocument format ;
- //点击行的LabelCode
- string LabelCode = "";
- //模板的路径
- string LabelPath = "";
- //参数个数
- int ParamNum;
- //标签参数的数组
- string[] ParamName;
- //模板编号的ID
- string pl_id1;
- //用于保存更新的模板ID
- string pl_id2 = "";
- //用于保存更新的产品编号
- string pr_code_1 = "";
- //用于保存更新的标签名
- string la_type_1 = "";
- //用于保存更新的模板默认值
- string pl_default = "";
- //Label表的主键,用于弹窗的传参
- string La_id1;
- //添加在grid末列的操作列
- DataTable dbfind;
- ftpOperater ftp;
- Thread InitPrint;
- DataGridViewImageColumn PerviewColumn = new DataGridViewImageColumn
- {
- Image = Resources.preview_16px_25980_easyicon_net,
- Width = 40,
- Name = "预览",
- ToolTipText = "预览模板参数",
- Tag = "Read",
- AutoSizeMode = DataGridViewAutoSizeColumnMode.None
- };
- DataGridViewImageColumn OperateColumn = new DataGridViewImageColumn
- {
- Image = Resources.write_15_893687707641px_1181413_easyicon_net,
- Width = 40,
- Name = "编辑",
- ToolTipText = "编辑模板",
- Tag = "Read",
- AutoSizeMode = DataGridViewAutoSizeColumnMode.None
- };
- Thread thread;
- AutoSizeFormClass asc = new AutoSizeFormClass();
- public SystemSetting_LabelMaintain()
- {
- InitializeComponent();
- }
-
- private void 条码维护_Load(object sender, EventArgs e)
- {
- asc.controllInitializeSize(this);
- dh = new DataHelper();
- condition.Append(" ");
- LoadData();
- //加loading框
- InitPrint = new Thread(InPrint);
- SetLoadingWindow stw = new SetLoadingWindow(InitPrint, "初始化打印程序");
- BaseUtil.SetFormCenter(stw);
- stw.ShowDialog();
- pr_code.FormName = Name;
- pr_code.SetValueField = new string[] { "pr_code" };
- pr_code.TableName = "product";
- pr_code.SelectField = "pr_code # 物料编号,pr_detail # 物料名称,pr_kind # 物料种类,pr_spec # 物料规格";
- pr_code.DbChange += Pr_code_DbChange;
- la_code.FormName = Name;
- la_code.SetValueField = new string[] { "la_code" };
- la_code.TableName = "label";
- la_code.SelectField = "la_code # 标签编号,la_name # 标签名称";
- la_code.DbChange += La_code_DbChange;
- //加载下拉框的静态值
- BaseUtil.SetDgvColumnComboxData((DataGridViewComboBoxColumn)LabelDataGridView.Columns["pl_labeltype"], "pl_labeltype", "display", "value", labeltype);
- BaseUtil.SetDgvColumnComboxData((DataGridViewComboBoxColumn)LabelDataGridView.Columns["pl_isdefault"], "pl_isdefault", "display", "value", defaultype);
- ChooseAll.ChooseAll(LabelDataGridView);
- pr_code2.KeyDown += ScreenEvent;
- pr_detail.KeyDown += ScreenEvent;
- pr_spec.KeyDown += ScreenEvent;
- SavePath.Text = Properties.Settings.Default.Properties["FTPAddress"].DefaultValue.ToString();
- //BaseUtil.SetCacheData("SavePath", SavePath.Text);
- ftp = new ftpOperater();
- }
- private void InPrint()
- {
- try
- {
- lbl = new ApplicationClass();
- BaseUtil.WriteLbl();
- }
- catch (Exception ex)
- {
- MessageBox.Show("未正确安装codesoft");
- }
- }
- private void La_code_DbChange(object sender, EventArgs e)
- {
- dbfind = la_code.ReturnData;
- BaseUtil.SetFormValue(this.Controls, dbfind);
- }
- private void Pr_code_DbChange(object sender, EventArgs e)
- {
- dbfind = pr_code.ReturnData;
- BaseUtil.SetFormValue(this.Controls, dbfind);
- }
- private void LabelDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
- if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
- {
- if (LabelDataGridView.Columns[e.ColumnIndex].HeaderText == "预览")
- {
- //获取路径和标签名称
- LabelPath = LabelDataGridView.Rows[e.RowIndex].Cells["pl_labelurl"].Value.ToString();
- LabelCode = LabelDataGridView.Rows[e.RowIndex].Cells["pl_labelcode"].Value.ToString();
- pl_id1 = LabelDataGridView.Rows[e.RowIndex].Cells["pl_id"].Value.ToString();
- La_id1 = LabelDataGridView.Rows[e.RowIndex].Cells["la_id"].Value.ToString();
- if (CodeSoft.Checked)
- {
- string LabelName = LabelDataGridView.Rows[e.RowIndex].Cells["pl_labelname"].Value.ToString();
- doc = lbl.Documents.Open(BaseUtil.GetLabelUrl(LabelPath, LabelName));
- if (doc == null)
- {
- MessageBox.Show("指定位置文件不存在");
- return;
- }
- ParamNum = doc.Variables.FreeVariables.Count;
- //去除之前添加的控件
- for (int i = 0; i < (ParamName == null ? 0 : ParamName.Length); i++)
- {
- if (this.Controls["LabelParam"].Controls[ParamName[i] + "_label"] != null)
- {
- this.Controls["LabelParam"].Controls.Remove(this.Controls["LabelParam"].Controls[ParamName[i] + "_label"]);
- this.Controls["LabelParam"].Controls.Remove(this.Controls["LabelParam"].Controls[ParamName[i]]);
- }
- }
- ParamName = new string[ParamNum];
- for (int i = 0; i < ParamNum; i++)
- {
- ParamName[i] = doc.Variables.FreeVariables.Item(i + 1).Name;
- }
- int y = 20;
- for (int i = 0; i < ParamName.Length; i++)
- {
- //变量的名称Label
- Label Param = new Label();
- Param.Text = ParamName[i];
- Param.Name = ParamName[i] + "_label";
- Param.AutoSize = true;
- Param.Anchor = AnchorStyles.Left;
- Param.Anchor = AnchorStyles.Top;
- Param.Location = new Point(30, y + 5);
- this.Controls["LabelParam"].Controls.Add(Param);
- //维护变量的打印测试参数
- EnterTextBox TempParam = new EnterTextBox();
- TempParam.Anchor = AnchorStyles.Left;
- TempParam.Anchor = AnchorStyles.Top;
- TempParam.Name = ParamName[i];
- TempParam.Location = new Point(110, y);
- y = y + 30;
- TempParam.Size = new Size(170, 22);
- this.Controls["LabelParam"].Controls.Add(TempParam);
- y = y + 30;
- }
- doc.Close();
- }
- }
- if (LabelDataGridView.Columns[e.ColumnIndex].HeaderText == "编辑")
- {
- if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
- {
- LabelPath = LabelDataGridView.Rows[e.RowIndex].Cells["pl_labelurl"].Value.ToString();
- string LabelName = LabelDataGridView.Rows[e.RowIndex].Cells["pl_labelname"].Value.ToString();
- pr_code.Text = LabelDataGridView.Rows[e.RowIndex].Cells["pr_code1"].Value.ToString();
- la_code.Text = LabelDataGridView.Rows[e.RowIndex].Cells["pl_labelcode"].Value.ToString();
- la_name.Text = LabelDataGridView.Rows[e.RowIndex].Cells["pl_labelname"].Value.ToString();
- la_type.Text = LabelDataGridView.Rows[e.RowIndex].Cells["pl_labeltype"].Value.ToString();
- FolderPath.Text = ftpOperater.DownLoadTo;
- pl_id2 = LabelDataGridView.Rows[e.RowIndex].Cells["pl_id"].Value.ToString();
- pr_code_1 = LabelDataGridView.Rows[e.RowIndex].Cells["pr_code1"].Value.ToString();
- la_type_1 = LabelDataGridView.Rows[e.RowIndex].Cells["pl_labeltype"].Value.ToString();
- pl_default = LabelDataGridView.Rows[e.RowIndex].Cells["pl_isdefault"].Value.ToString();
- System.Diagnostics.Process.Start(BaseUtil.GetLabelUrl(LabelPath, LabelName));
- }
- }
- }
- }
- private void Screen_Click(object sender, EventArgs e)
- {
- sql.Clear();
- condition.Clear();
- //如果条件全部为空的时候
- if (pr_code2.Text == "" && pr_detail.Text == "" && pr_spec.Text == "")
- {
- LoadData();
- }
- else
- {
- sql.Append("select pl_labelurl,pl_labeltype,pl_labelname,pl_isdefault,pl_prodcode,pl_id,pl_labelcode,pl_detno,pl_labelsoft,pr_detail,pr_spec,pr_code from productlabel left join product on pl_prodcode=pr_code");
- //设置筛选的条件
- condition.Append(BaseUtil.GetScreenSqlCondition(pr_code2, pr_detail, pr_spec));
- //最终刷选条件拼接成的sql
- LoadData();
- }
- }
- private void Update_Click(object sender, EventArgs e)
- {
- string LabelSoft = "";
- //需要处理新增的行和原有数据然后更新的行
- if (CodeSoft.Checked)
- {
- LabelSoft = "CodeSoft";
- }
- DataTable dt = (DataTable)LabelDataGridView.DataSource;
- //如果有改变的行才传递到后台
- if (dt.GetChanges() != null)
- {
-
- for (int i = 0; i < LabelDataGridView.Rows.Count; i++)
- {
- //如果是新增的默认加上Radio当前选中的打印软件
- if (LabelDataGridView.Rows[i].Cells["pl_labelsoft"].Value.ToString() == "")
- {
- LabelDataGridView.Rows[i].Cells["pl_labelsoft"].Value = LabelSoft;
- }
- //从表格判断一个产品以及对应的打印模板是否存在默认选项
- if (!dic.ContainsKey(LabelDataGridView.Rows[i].Cells["pl_prodcode"].Value.ToString() + LabelDataGridView.Rows[i].Cells["pl_labeltype"].Value.ToString()))
- {
- dic.Add(LabelDataGridView.Rows[i].Cells["pl_prodcode"].Value.ToString() + LabelDataGridView.Rows[i].Cells["pl_labeltype"].Value.ToString(), LabelDataGridView.Rows[i].Cells["pl_isdefault"].Value.ToString());
- }
- else
- {
- string outvalue = dic[LabelDataGridView.Rows[i].Cells["pl_prodcode"].Value.ToString() + LabelDataGridView.Rows[i].Cells["pl_labeltype"].Value.ToString()];
- if (outvalue == "0")
- {
- dic[LabelDataGridView.Rows[i].Cells["pl_prodcode"].Value.ToString() + LabelDataGridView.Rows[i].Cells["pl_labeltype"].Value.ToString()] = LabelDataGridView.Rows[i].Cells["pl_isdefault"].Value.ToString();
- }
- else if (LabelDataGridView.Rows[i].Cells["pl_isdefault"].Value.ToString() == "1" && (LabelDataGridView.Rows[i].Cells["pl_prodcode"].Value.ToString() == LabelDataGridView.Rows[i - 1].Cells["pl_prodcode"].Value.ToString()) && (LabelDataGridView.Rows[i].Cells["pl_labeltype"].Value.ToString() == LabelDataGridView.Rows[i - 1].Cells["pl_labeltype"].Value.ToString()))
- {
- MessageBox.Show("产品"+LabelDataGridView.Rows[i].Cells["pr_detail1"].Value.ToString() +" "+ LabelDataGridView.Rows[i].Cells["pl_labeltype"].Value.ToString()+ " 保存的模板之前具有默认模板");
- LabelDataGridView.Rows[i].Cells["pl_isdefault"].Value = "0";
- }
- }
- //从数据库核对是否同时存在一个产品以及对应打印模板是否存在默认选项
- DataTable table = (DataTable)dh.ExecuteSql("select pl_isdefault from productlabel where pl_id = '" + LabelDataGridView.Rows[i].Cells["pl_id"].Value.ToString() + " '", "select");
- if (LabelDataGridView.Rows[i].Cells["pl_isdefault"].Value.ToString() == "1" && table.Rows[0][0].ToString() == "0")
- {
- int is_defualt = isdefault(LabelDataGridView.Rows[i].Cells["pl_prodcode"].Value.ToString(), LabelDataGridView.Rows[i].Cells["pl_labeltype"].Value.ToString());
- if (is_defualt == 0)
- {
- MessageBox.Show("产品" + LabelDataGridView.Rows[i].Cells["pr_detail1"].Value.ToString()+" "+ LabelDataGridView.Rows[i].Cells["pl_labeltype"].Value.ToString()+ " 保存的模板之前具有默认模板");
- LabelDataGridView.Rows[i].Cells["pl_isdefault"].Value = is_defualt;
- }
- }
- }
- string sql = "Insert into productlabel (PL_ID,PL_PRODCODE,PL_LABELTYPE,PL_LABELCODE,PL_LABELURL,PL_DETNO,PL_LABELSOFT,PL_ISDEFAULT) values( ProductLabel_seq.nextval,'" + pr_code.Text + "',:PL_LABELTYPE,:PL_LABELCODE,:PL_LABELURL,:PL_DETNO,:PL_LABELSOFT,:PL_ISDEFAULT )";
- dh.SaveDataTable(dt.GetChanges(), "productlabel", "pl_id", sql.ToLower());
- LoadData();
- dic.Clear();
- }
- }
- private void DeleteDetail_Click(object sender, EventArgs e)
- {
- string[] deleteid = new string[LabelDataGridView.RowCount];
- for (int i = 0; i < LabelDataGridView.RowCount; i++)
- {
- deleteid[i] = LabelDataGridView.Rows[i].Cells["pl_id"].Value.ToString();
- }
- dh.DeleteDataByID("productlabel", "pl_id", deleteid);
- LoadData();
- }
- private void OpenFolder_Click(object sender, EventArgs e)
- {
- //根据勾选的不同设置不同的文件后缀过滤
- if (CodeSoft.Checked)
- {
- openFileDialog1.Filter = "(*.lab)|*.lab";
- }
- DialogResult result = openFileDialog1.ShowDialog();
- if (result == DialogResult.OK)
- {
- string FullPath = openFileDialog1.FileName;
- FolderPath.Text = FullPath.Substring(0, FullPath.LastIndexOf("\\"));
- la_name.Text = FullPath.Substring(FullPath.LastIndexOf("\\") + 1);
- //for (int i = 0; i < LabelDataGridView.Rows.Count; i++)
- //{
- // if (LabelDataGridView.Rows[i].Cells["Choose"].Value != null)
- // {
- // if ((bool)LabelDataGridView.Rows[i].Cells["Choose"].Value == true)
- // {
- // LabelDataGridView.Rows[i].Cells["pl_labelurl"].Value = FolderPath.Text;
- // }
- // }
- //}
- }
- }
- private void LabelDataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
- {
- if (LabelDataGridView.Columns[e.ColumnIndex].Name == "pl_isdefault")
- {
- if (e.Value != null)
- {
- switch (e.Value.ToString())
- {
- case "0":
- e.Value = "否";
- break;
- case "1":
- e.Value = "是";
- break;
- default:
- break;
- }
- }
- }
- }
- private void LabelDataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e)
- {
- //覆盖参数错误的事件,使得不会报错
- }
- //判断与维护标签相同ID是否具有默认模板
- private int isdefault(string pl_prodcode, string pl_labeltype)
- {
- LogStringBuilder sql2 = new LogStringBuilder();
- sql2.Append("select la_id,pl_labelname,pl_labelurl,pl_labeltype,pl_isdefault,pl_prodcode,pl_id,pl_labelcode,pl_detno,pl_labelsoft,pr_detail,pr_spec,");
- sql2.Append("pr_code from productlabel left join product on pl_prodcode=pr_code left join label on pl_labelcode=la_code");
- sql2.Append(" where pl_isdefault = '1' and pl_prodcode = '" + pl_prodcode + "' and pl_labeltype = '" + pl_labeltype + "'");
- dt = (DataTable)dh.ExecuteSql(sql2.GetString(), "select");
- if (dt.Rows.Count > 0)
- {
- sql2.Clear();
- return 0;
- }
- else
- {
- sql2.Clear();
- return 1;
- }
- }
- //判断与标签保存时是否已经有同类型标签存在
- private Boolean isSameLabel(string pl_prodcode, string pl_labeltype, string pl_labelname,string pl_labelcode)
- {
- sql.Clear();
- sql.Append("select la_id,pl_labelname,pl_labelurl,pl_labeltype,pl_isdefault,pl_prodcode,pl_id,pl_labelcode,pl_detno,pl_labelsoft,pr_detail,pr_spec,");
- sql.Append("pr_code from productlabel left join product on pl_prodcode=pr_code left join label on pl_labelcode=la_code");
- sql.Append(" where pl_prodcode = '" + pl_prodcode + "' and pl_labeltype = '" + pl_labeltype + "' and pl_labelname = '" + pl_labelname + "' and pl_labelcode = '"+ pl_labelcode + "'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count > 0)
- {
- sql.Clear();
- return true;
- }
- else
- {
- sql.Clear();
- return false;
- }
- }
- private void LoadData()
- {
- //如果没有任何筛选条件直接选取productlabel的数据
- if (sql.GetString().Length == 0)
- {
- sql.Clear();
- sql.Append("select la_id,pl_labelname,pl_labelurl,pl_labeltype,pl_isdefault,pl_prodcode,pl_id,pl_labelcode,pl_detno,pl_labelsoft,pr_detail,pr_spec,");
- sql.Append("pr_code from productlabel left join product on pl_prodcode=pr_code left join label on pl_labelcode=la_code");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- }
- else
- {
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- }
- BaseUtil.FillDgvWithDataTable(LabelDataGridView, dt, PerviewColumn, OperateColumn);
- string Field = BaseUtil.GetGridViewSelectContent(LabelDataGridView);
- pagination1.BindDataToNavigator(LabelDataGridView, "productlabel left join product on pl_prodcode=pr_code left join label on pl_labelcode=la_code", Field, "pl_id", "", condition.Replace("where", "").ToString(), PerviewColumn, OperateColumn);
- }
- private void PrintTest_Click(object sender, EventArgs e)
- {
- if (LabelCode != "")
- {
- doc.Save();
- doc.PrintDocument();
- doc.Close();
- }
- }
- private void 产品标签维护_FormClosing(object sender, FormClosingEventArgs e)
- {
- //关闭所有的打印文件
- BaseUtil.ClosePrint(lbl);
- }
- private void Save_Click(object sender, EventArgs e)
- {
- if (la_code.Text != "" && la_type.Text != "" && FolderPath.Text != "" && pr_code.Text != "")
- {
- if (FTPShare.Checked)
- {
- string SoftWare = "CodeSoft";
-
- ftp.UpLoadFile(FolderPath.Text, la_name.Text,SavePath.Text);
- if (pl_id2 != "")
- {
- if (!isSameLabel(pr_code.Text, la_type.Text, la_name.Text,la_code.Text)&&(((isdefault(pr_code.Text, la_type.Text)==1)&& (pl_default == "1")||(pr_code.Text ==pr_code_1 && la_type.Text == la_type_1))|| (pl_default == "0")))
- {
- sql.Clear();
- sql.Append("update productlabel set pl_labelcode=:pl_labelcode,pl_labeltype=:pl_labeltype,pl_labelurl=:pl_labelurl,pl_labelname=:pl_labelname,");
- sql.Append("pl_prodcode=:pl_prodcode,pl_indate=sysdate where pl_id='" + pl_id2 + "'");
- dh.ExecuteSql(sql.GetString(), "update", la_code.Text, la_type.Text,SavePath.Text + @"\" + la_name.Text,la_name.Text, pr_code.Text);
- }
- else
- {
- MessageBox.Show("编号" + pr_code.Text + "商品已有相同标签或已有默认值");
- sql.Clear();
- LoadData();
- return;
- }
- }
- else
- {
- if (!isSameLabel(pr_code.Text, la_type.Text, la_name.Text,la_code.Text))
- {
- sql.Clear();
- sql.Append("insert into productlabel (pl_id,pl_labelcode,pl_labeltype,pl_isdefault,pl_labelurl,pl_labelsoft,pl_labelname,pl_prodcode,pl_indate) values( productlabel_seq.nextval, ");
- sql.Append("'" + la_code.Text + "','" + la_type.Text + "','" + isdefault(pr_code.Text, la_type.Text) + "','" + SavePath.Text + @"\" + la_name.Text + "','" + SoftWare + "','" + la_name.Text + "','" + pr_code.Text + "',sysdate)");
- dh.ExecuteSql(sql.GetString(), "insert");
- }
- else
- {
- MessageBox.Show("编号" + pr_code.Text + "商品已有相同标签或已有默认值");
- sql.Clear();
- LoadData();
- return;
- }
- }
- pl_id2 = "";
- la_type_1 = "";
- pr_code_1 = "";
- MessageBox.Show("保存成功!");
- sql.Clear();
- LoadData();
- }
- }
- else
- MessageBox.Show("所有参数必须填写");
- }
- private void 产品标签维护_SizeChanged(object sender, EventArgs e)
- {
- asc.controlAutoSize(this);
- }
- private void ScreenEvent(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- Screen.PerformClick();
- }
- private void Delete_Click(object sender, EventArgs e)
- {
- string[] deleteid = new string[LabelDataGridView.RowCount];
- string[] deletelabel = new string[LabelDataGridView.RowCount];
- string[] deletelabname = new string[LabelDataGridView.RowCount];
- for (int i = 0; i < LabelDataGridView.RowCount; i++)
- {
- if (LabelDataGridView.Rows[i].Cells["Choose"].Value != null)
- {
- if (LabelDataGridView.Rows[i].Cells["Choose"].Value is Boolean)
- {
- if ((bool)LabelDataGridView.Rows[i].Cells["Choose"].Value == true)
- {
- deleteid[i] = LabelDataGridView.Rows[i].Cells["pl_id"].Value.ToString();
- deletelabname[i] = LabelDataGridView.Rows[i].Cells["pl_labelname"].Value.ToString();
- deletelabel[i] = LabelDataGridView.Rows[i].Cells["pl_labelurl"].Value.ToString();
- }
- }
- }
- }
- dh.DeleteDataByID("productlabel", "pl_id", deleteid);
- for (int i = 0; i < deletelabname.Length; i++)
- {
- if (deletelabname[i] != null)
- {
- sql.Clear();
- sql.Append("select pl_labelname from productlabel left join product on pl_prodcode=pr_code left join label on pl_labelcode=la_code where pl_labelname = '" + deletelabname[i] + "'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count == 0)
- {
- try
- {
- // ftp.Delete(deletelabname[i]);
- File.Delete(deletelabel[i]);
- }
- catch{
-
- }
- }
- }
- }
- sql.Clear();
- LoadData();
- }
- private void OpernSaveFolder_Click(object sender, EventArgs e)
- {
- FolderBrowserDialog folder = new FolderBrowserDialog();
- folder.Description = "选择文件夹";
- DialogResult result = folder.ShowDialog();
- if (result == DialogResult.OK)
- {
-
- SavePath.Text = folder.SelectedPath;
- if (SavePath.Text.LastIndexOf('\\') != SavePath.Text.Length-1) {
- SavePath.Text += ("\\");
- }
- }
- BaseUtil.SetCacheData("SavePath", SavePath.Text);
- }
- }
- }
|