Esempio n. 1
0
        public void DeleteItem()
        {
            TreeNode nodedelete = this.SelectedNode;
            if (nodedelete != null)
            {
                if (nodedelete.ChildNodes.Count > 0)
                {
                    this.Page.Response.Write("<script>window.alert('delete the childnode first!')</script>");
                }
                else
                {
                    WebDataSource ds = (WebDataSource)GetObjByID(this.WebDataSourceID);

                    DataSet dataset = ds.InnerDataSet;
                    WebDataSet wds = new WebDataSet();
                    wds.RemoteName = ds.RemoteName;
                    wds.RealDataSet = dataset;

                    DataTable dt = wds.RealDataSet.Tables[ds.DataMember];

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (dt.Rows[i][this.KeyField].ToString() == nodedelete.Value)
                        {
                            dt.Rows[i].Delete();
                        }
                    }
                    wds.ApplyUpdates();
                    this.Page.Response.Redirect(this.Page.Request.Path);
                }
            }
        }
Esempio n. 2
0
        public bool ApplyUpdates()
        {
            WebDataSet dataSet = new WebDataSet();
            dataSet.RemoteName = RemoteName;
            dataSet.ServerModify = ServerModify;

            dataSet.RealDataSet = InnerDataSet;

            //add by ccm do AutoSeq
            List<WebAutoSeq> wAutoSeq = new List<WebAutoSeq>();
            foreach (Control ctrl in this.Page.Form.Controls)
            {

                if (ctrl is WebAutoSeq && ((WebAutoSeq)ctrl).MasterDataSourceID == this.ID && ((WebAutoSeq)ctrl).ReNumber && ((WebAutoSeq)ctrl).Active)
                {
                    wAutoSeq.Add((WebAutoSeq)ctrl);
                }
            }
            if (wAutoSeq.Count > 0)
            {
                foreach (WebAutoSeq was in wAutoSeq)
                {
                    was.ResetDetail();
                }

            }
            //End AutoSeq

            // End Add 2006/08/22
            dataSet.ApplyError += delegate(object sender, ApplyErrorEventArgs e)
            {
                OnApplyError(e);
            };
            bool b = dataSet.ApplyUpdates();
            if (!b)
                return false;
            else
            {
                this.RemoveLock();
                InnerDataSet = dataSet.RealDataSet;
                if (wAutoSeq.Count > 0)
                {
                    foreach (WebAutoSeq was in wAutoSeq)
                    {
                        foreach (Control ctrl in this.Page.Form.Controls)
                        {
                            if (ctrl is WebGridView && ((WebGridView)ctrl).DataSourceID == was.DataSourceID)
                            {
                                ((WebGridView)ctrl).DataBind();
                            }
                        }
                    }
                }
                return true;
            }
        }