Exemplo n.º 1
0
        private void cloneAndAdd(Sp_url_attr srcAttr, string urlCode)
        {
            srcAttr.Code    = "SUA_" + GetTimeStamp() + new Random().Next(10000, 99999);
            srcAttr.UrlCode = urlCode;

            try
            {
                new Sp_url_attrDAL().Insert(srcAttr);
            }
            catch (Exception ex)
            {
                MessageBox.Show("添加失败,错误代码为:" + ex.ToString());
            }
        }
Exemplo n.º 2
0
        public void Update(Sp_url_attr ud)
        {
            MySqlConnection mycon = new MySqlConnection();

            mycon.ConnectionString = url;
            string       sql2 = "update sp_url_attr set UrlCode='" + ud.UrlCode + "',HtmlTag='" + ud.HtmlTag + "',AttrName='" + ud.AttrName + "',Alias='" + ud.Alias + "',CalcWay='" + ud.CalcWay + "',ExternStr='" + ud.ExternStr + "',SubAttr='" + ud.SubAttr + "',AttachAttr='" + ud.AttachAttr + "',Code='" + ud.Code + "',IsUrl=" + ud.IsUrl + " where Id =" + ud.Id + "";
            MySqlCommand comm = new MySqlCommand(sql2, mycon);

            mycon.Open();
            int result = comm.ExecuteNonQuery();

            mycon.Close();
            if (result > 0)
            {
            }
        }
Exemplo n.º 3
0
        private Sp_url_attr ToSp_url_attr(DataRow row)
        {
            Sp_url_attr op = new Sp_url_attr();

            op.Id         = Convert.ToInt32(row["Id"]);
            op.UrlCode    = (string)row["UrlCode"];
            op.HtmlTag    = (string)row["HtmlTag"];
            op.AttrName   = (string)row["AttrName"];
            op.Alias      = (string)row["Alias"];
            op.CalcWay    = (string)row["CalcWay"];
            op.ExternStr  = (string)row["ExternStr"];
            op.SubAttr    = (string)row["SubAttr"];
            op.AttachAttr = (string)row["AttachAttr"];
            op.Code       = (string)row["Code"];
            op.IsUrl      = Convert.ToInt32(row["IsUrl"]);
            return(op);
        }
Exemplo n.º 4
0
        public void Insert(Sp_url_attr ud)
        {
            MySqlConnection mycon = new MySqlConnection();

            mycon.ConnectionString = url;
            string sql2 = string.Format("INSERT into sp_url_attr(UrlCode,HtmlTag,AttrName,Alias,CalcWay,ExternStr,SubAttr,AttachAttr,Code,IsUrl)values('{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}')", new object[]
            {
                ud.Id, ud.UrlCode, ud.HtmlTag, ud.AttrName, ud.Alias, ud.CalcWay, ud.ExternStr, ud.SubAttr, ud.AttachAttr, ud.Code, ud.IsUrl
            });
            MySqlCommand comm = new MySqlCommand(sql2, mycon);

            mycon.Open();
            int result = comm.ExecuteNonQuery();

            mycon.Close();
            if (result > 0)
            {
            }
        }
Exemplo n.º 5
0
        public Sp_url_attr[] GetAllData(string UrlCode)
        {
            MySql.Data.MySqlClient.MySqlConnection mycon = new MySqlConnection();
            mycon.ConnectionString = url;
            string           sql2 = "select * from sp_url_attr where UrlCode = '" + UrlCode + "'";
            MySqlDataAdapter mda  = new MySqlDataAdapter(sql2, mycon);
            DataSet          ds   = new DataSet();

            mda.Fill(ds, "table1");
            DataTable dt = ds.Tables[0];

            mycon.Close();
            Sp_url_attr[] operators = new Sp_url_attr[dt.Rows.Count];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                operators[i] = ToSp_url_attr(dt.Rows[i]);
            }
            return(operators);
        }
Exemplo n.º 6
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            for (int index = 0; index < tvAttr.Nodes.Count; index++)
            {
                TreeNode node = tvAttr.Nodes[index];

                if (!node.Checked)
                {
                    continue;
                }

                Sp_url_attr attr = (Sp_url_attr)node.Tag;
                if (attr == null)
                {
                    continue;
                }

                if (Result == null)
                {
                    _result = new Dictionary <string, List <string> >();
                }

                List <string> urlCodes;
                if (Result.ContainsKey(attr.UrlCode))
                {
                    urlCodes = Result[attr.UrlCode];
                }
                else
                {
                    urlCodes = new List <string>();
                }

                urlCodes.Add(attr.Code);

                Result[attr.UrlCode] = urlCodes;
            }

            if (Result == null)
            {
                MessageBox.Show("未选中任何需要拷贝的属性");
                this.DialogResult = System.Windows.Forms.DialogResult.None;
            }
        }
Exemplo n.º 7
0
        private void btnCopyUrl_Click(object sender, EventArgs e)
        {
            if (dgvShowUrl.SelectedRows.Count <= 0)
            {
                MessageBox.Show("未选中目标URL,请先添加或选中一个");
                return;
            }
            CopyUrlWnd wnd = new CopyUrlWnd();

            wnd.UrlCode = dgvShowUrl.SelectedRows[0].Cells["记录的唯一索引"].Value.ToString();

            if (wnd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Dictionary <string, List <string> > result = wnd.Result;
                foreach (var key in result.Keys)
                {
                    // 有且只有一个
                    string        urlCode   = key.ToString();
                    List <string> attrCopys = result[key];

                    Sp_url_attr[]      spUrlAttrs = new Sp_url_attrDAL().GetAllData(urlCode);
                    List <Sp_url_attr> attrs      = spUrlAttrs.ToList();

                    for (int index = 0; index < attrs.Count; index++)
                    {
                        Sp_url_attr attr = attrs[index];

                        if (!attrCopys.Contains(attr.Code))
                        {
                            continue;
                        }
                        Console.WriteLine(attr.ToString());

                        cloneAndAdd(attr, wnd.UrlCode);
                    }

                    ShowDGVUrl_Attr();
                    MessageBox.Show("拷贝成功");
                }
            }
        }
Exemplo n.º 8
0
        private void btnAddUrl_Attr_Click(object sender, EventArgs e)
        {
            if (txtHtmlTag.Text.Trim() == "" || txtAttrName.Text.Trim() == "" || txtAttrAlias.Text.Trim() == "" || txtAttrCode.Text.Trim() == "")
            {
                MessageBox.Show("HTML标签等信息为必填项!");
                return;
            }
            Sp_url_attr spUrl = new Sp_url_attr();

            //Sp_url_attr[] spUrlAll = new Sp_url_attrDAL().GetAllData();
            //spUrl.Id = spUrlAll.Length + 1;
            spUrl.HtmlTag    = txtHtmlTag.Text.Trim();
            spUrl.Alias      = txtAttrAlias.Text.Trim();
            spUrl.ExternStr  = txtExternStr.Text.Trim();
            spUrl.AttrName   = txtAttrName.Text.Trim();
            spUrl.SubAttr    = txtSubAttr.Text.Trim();
            spUrl.Code       = txtAttrCode.Text.Trim();
            spUrl.UrlCode    = txtUrlCode.Text.Trim();
            spUrl.AttachAttr = txtAttachAttr.Text.Trim();
            if (cBoxCalcWay.Text == "替换")
            {
                spUrl.CalcWay = "00";
            }
            if (cBoxCalcWay.Text == "前缀")
            {
                spUrl.CalcWay = "10";
            }
            if (cBoxCalcWay.Text == "后缀")
            {
                spUrl.CalcWay = "11";
            }
            if (cBoxCalcWay.Text == "原字符")
            {
                spUrl.CalcWay = "99";
            }
            if (cBoxCalcWay.Text == "静态字符(通过子属性绑定)")
            {
                spUrl.CalcWay = "12";
            }
            if (cBoxIsUrl.Text == "是")
            {
                spUrl.IsUrl = 1;
            }
            else
            {
                spUrl.IsUrl = 0;
            }
            if (btnAddUrl_Attr.Text == "新  增")
            {
                try
                {
                    new Sp_url_attrDAL().Insert(spUrl);
                    MessageBox.Show("添加成功");
                    ShowDGVUrl_Attr();
                    txtAttrCode.Text   = "SUA_" + GetTimeStamp() + new Random().Next(10000, 99999);
                    txtHtmlTag.Text    = ""; txtAttrName.Text = ""; txtAttrAlias.Text = ""; txtExternStr.Text = ""; txtSubAttr.Text = "";
                    txtAttachAttr.Text = "";
                }
                catch (Exception ex)
                {
                    MessageBox.Show("添加失败,错误代码为:" + ex.ToString());
                }
            }
            else
            {
                try
                {
                    spUrl.Id = Convert.ToInt32(dgvShowUrl_Attr.SelectedRows[0].Cells["IdUrl_Attr"].Value);
                    new Sp_url_attrDAL().Update(spUrl);
                    MessageBox.Show("修改成功");
                    btnAddUrl_Attr.Text = "新  增";
                    ShowDGVUrl_Attr();
                    txtAttrCode.Text   = "SUA_" + GetTimeStamp() + new Random().Next(10000, 99999);
                    txtHtmlTag.Text    = ""; txtAttrName.Text = ""; txtAttrAlias.Text = ""; txtExternStr.Text = ""; txtSubAttr.Text = "";
                    txtAttachAttr.Text = "";
                }
                catch (Exception ex)
                {
                    MessageBox.Show("修改失败,错误代码为:" + ex.ToString());
                }
            }
        }