为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

coolite gridpanel 添加新行保存数据

2010-12-13 12页 doc 197KB 8阅读

用户头像

is_097980

暂无简介

举报
coolite gridpanel 添加新行保存数据coolite gridpanel 添加新行保存数据 coolite 版本是1.0.0.19823,以下是页面截图 GridPanel.aspx页面代码                                                                          ...
coolite gridpanel 添加新行保存数据
coolite gridpanel 添加新行保存数据 coolite 版本是1.0.0.19823,以下是页面截图 GridPanel.aspx页面代码   <%@ Page Language="C#" AutoEventWireup="true" CodeFile="GridPanel.aspx.cs" Inherits="GridPanel" %> <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>        
   
                                                                                                                                                                                                    <%----%>                                                                                                                                                             <%----%>             <%----%>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <%--                                                                                                                         --%>                                                         <%--                                                                                     --%>                                                                                                                                                                                                                                                                                                                                                                                                                                         <%--                             --%>                                                                            
   
Default.aspx.cs代码   using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using DBOperator.Data; using System.Data; using Ext.Net; using System.Data.SqlClient; public partial class GridPanel : System.Web.UI.Page {     DataSet ds = null;     Mydbop.Mydata data = new Mydbop.Mydata();     protected void Page_Load(object sender, EventArgs e)     {         if (!IsPostBack)         {             ds = osdData.DataSet("select * from TestTable", 0, 0, "dsTable");             Store1.DataSource = ds;             Store1.DataBind();             Window1.Hidden = true;             Window1.Title = "sdfsdfsdf";         }         if (!X.IsAjaxRequest)         {             string str = Request["data"];             if (str != null)             {                 Response sr = new Response(true);                 try                 {                     StoreDataHandler dataHandler = new StoreDataHandler(Request["data"]);                     ChangeRecords data = dataHandler.ObjectData();                     ConfirmationList confirmlist = dataHandler.BuildConfirmationList("age");                     foreach (TestTable test in data.Created)                     {                         str = str + test.mark + test.name + test.age + test.occupation;                         Addinfo(test.name, Convert.ToInt32(test.age), test.occupation, test.mark);                     }                     StoreResponseData response = new StoreResponseData();                     response.Confirmation = confirmlist;                     sr.Data = response.ToString();                     sr.Message = "已经通过";                 }                 catch (Exception ex)                 {                     sr.Success = false;                     sr.Message = ex.Message;                 }                 sr.Write();                 Response.Buffer = true;                 Response.ExpiresAbsolute = System.DateTime.Now.AddSeconds(-1);                 Response.Expires = 0;                 Response.CacheControl = "no-cache";                 Response.AddHeader("Pragma", "No-Cache");                   //Response.Write("");             }         }     }     protected void Refresh_data(object sender, StoreRefreshDataEventArgs e)     {         ds = osdData.DataSet("select * from TestTable", 0, 0, "dsTable");         Store1.DataSource = ds;         Store1.DataBind();     }         protected void Row_Dbclick(object sender,DirectEventArgs e)     {         //MessageBox box = new MessageBox();         //box.Show(new Ext.Net.MessageBoxConfig         //{         //    Title = "图标标题",         //    Message = e.ExtraParams["OrderID"],         //    Buttons = MessageBox.Button.OK,         //    Icon = MessageBox.Icon.INFO,         //}         //);         //Num.Text = e.ExtraParams["OrderID"].ToString();         Window1.Hidden=false;     }     protected void Aedit(object sender, DirectEventArgs e)     {         MessageBox box = new MessageBox();         box.Show(new Ext.Net.MessageBoxConfig         {             Title = "图标标题",             Message = e.ExtraParams["OrderID"],             Buttons = MessageBox.Button.OK,             Icon = MessageBox.Icon.INFO,         }         );     }     protected void Button1_Click(object sender, DirectEventArgs e)     {         //Response.Write(Window1.Attributes.Count.ToString());         //MessageBox box = new MessageBox();         //box.Show(new Ext.Net.MessageBoxConfig         //{         //    Title = "图标标题",         //    Message = Window1.Attributes.Count.ToString(),         //    Buttons = MessageBox.Button.OK,         //    Icon = MessageBox.Icon.INFO,         //}         //);         Window1.Hidden = false;         Window1.Title = "sdfsdfsdf";     }     protected void Add_record(object sender,DirectEventArgs e)     {         //MessageBox box = new MessageBox();         //box.Show(new Ext.Net.MessageBoxConfig         //{         //    Title = "图标标题",         //    Message = "g",         //    Buttons = MessageBox.Button.OK,         //    Icon = MessageBox.Icon.INFO,         //}         //);                     }     protected void Store1_beforeRecordInserted(object sender, BeforeStoreChangedEventArgs e)     {         ChangeRecords data = e.DataHandler.ObjectData();         foreach (TestTable test in data.Created)         {             Response.Write(test.LsID);         }             }     public partial class TestTable     {         public int LsID { get; set; }         public string name { get; set; }         public int age { get; set; }         public string occupation { get; set; }         public string mark { get; set; }         public DateTime Addtime { get; set; }     }     public void on_btAddClick(GridPanel g1)     {         CellSelectionModel sm = this.GridPanel1.SelectionModel.Primary as CellSelectionModel;         Response.Write(sm.SelectedCell.RowIndex.ToString());     }     public void InsertBefore(object sender, MenuDirectEvents e)     {             }     private bool cancel;     private string message;     protected void Store1_AfterDirectEvent(object sender,AfterDirectEventArgs e)     {         if (e.Response.Success)         {             // set to .Success to false if we want to return a failure             e.Response.Success = !cancel;             e.Response.Message = message;         }     }     protected void Store1_BeforeRecordInserted(object sender, BeforeRecordInsertedEventArgs e)     {         object region = e.NewValues["Region"];         if (region == null || region.ToString() != "Alabama (AL)")         {             e.Cancel = true;             this.cancel = true;             this.message = "The Region must be 'AL'";         }     }     protected void Store1_AfterRecordInserted(object sender, AfterRecordInsertedEventArgs e)     {         //The deleted and updated records confirms automatic (depending AffectedRows field)         //But you can override this in AfterRecordUpdated and AfterRecordDeleted event         //For insert we should set new id for refresh on client         //If we don't set new id then old id will be used         if (e.Confirmation.Confirm && !string.IsNullOrEmpty(insertedValue))         {             e.Confirmation.ConfirmRecord(insertedValue);             insertedValue = "";         }     }     private string insertedValue;     protected void Store1_BeforeAjaxEvent(object sender,BeforeDirectEventArgs e)     {         string emulError = e.Parameters["EmulateError"];         if (emulError == "1")         {             throw new Exception("Emulating error");         }             }     public bool Addinfo(string name,int age,string job,string mark)     {         bool flag = false;         int path = Convert.ToInt32(Request["direction"].ToString());         int Lsid = Convert.ToInt32(Request["Lsid"].ToString());         SqlParameter[] sp =         {             new SqlParameter("@path",SqlDbType.Int),             new SqlParameter("@Lid",SqlDbType.Int),             new SqlParameter("@name",SqlDbType.VarChar),             new SqlParameter("@age",SqlDbType.Int),             new SqlParameter("@occupation",SqlDbType.VarChar),             new SqlParameter("@mark",SqlDbType.VarChar),             new SqlParameter("@Addtime",SqlDbType.DateTime),         };         data.SetValue = path;         data.SetValue = Lsid;         data.SetValue = name;         data.SetValue = age;         data.SetValue = job;         data.SetValue = mark;         data.SetValue = DateTime.Now.ToString();         try         {             if (data.ExecuteReturn("Addinfo", sp, false).ToString().Length != 0)             {                 return true;             }             else             {                 return false;             }         }         catch (Exception ex)         {             return false;         }     } } Addinfo 存储过程   create procedure Addinfo ( @path int, @Lid int, @name varchar(100), @age int, @occupation varchar(100), @mark varchar(100), @Addtime datetime, @Revalue varchar(100) out ) as Begin Transaction declare @ID int,@direction int set @ID=@Lid --待插入行的行号--- set @direction=@path ---插入的方向是插入行之后还是之前,0之前 1之后-- if @direction=0  begin   select LsID,[name],age,occupation,mark,Addtime into T1 from TestTable where LsID>=@ID   delete from TestTable where LsID>=@ID  end else  begin   select LsID,[name],age,occupation,mark,Addtime into T1 from TestTable where LsID>@ID   delete from TestTable where LsID>@ID   set @ID=@ID+1  end update T1 set LsID=LsID+1 insert into TestTable(LsID,[name],age,occupation,mark,Addtime)values(@ID,@name,@age,@occupation,@mark,@Addtime) insert into TestTable(LsID,[name],age,occupation,mark,Addtime)select LsID,[name],age,occupation,mark,Addtime from T1 drop table T1 set @Revalue='true' commit Transaction --------------------------------------------
/
本文档为【coolite gridpanel 添加新行保存数据】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索