using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Configuration;
using System.Globalization;
using mojoPortal.Web.Framework;
using mojoPortal.Business;
using mojoPortal.Business.WebHelpers;
namespace mojoPortal.Web.AdminUI
{
public partial class ConsignFormAdmin : mojoBasePage
{
protected void Page_Load(object sender, EventArgs e)
{
//if (Session["UserName"] == null)
//{
// Response.Redirect("../Secure/Login.aspx");
//}
if (!IsPostBack)
{
GridViewBind();
}
}
protected void GrdConsignFrom_PageIndexChanging (object sender, GridViewPageEventArgs e)
{
//GridView GrdConsignFrom = (GridView)sender;
GrdConsignFrom.PageIndex = e.NewPageIndex;
GridViewBind();
}
private void GridViewBind()
{
string strconn = "server=.;database=Mojo_Tianzhuju;uid=sa;pwd=p@ssw0rd";
SqlConnection Conn = new SqlConnection(strconn);
Conn.Open();
//GridView GrdConsignFrom = (GridView)sender;
string SqlStr = "SELECT Id,weituolx,fangwulx,fangyuanqy,huxing,fangyuandd,jianzhumj,nidingjg,changquangs,jianzhund,fangwuzhx,jiaotongzhk,buchongshm,lianxir,dianhua,chuanzhen,Time_log FROM [mp_ConsignForm]";
SqlDataAdapter sda = new SqlDataAdapter(SqlStr, strconn);
DataSet ds = new DataSet();
try
{
SqlConnection conn = new SqlConnection(strconn);
if (conn.State.ToString() == "Closed") conn.Open();
SqlDataAdapter da = new SqlDataAdapter(SqlStr, conn);
da.Fill(ds, "mp_ConsignForm");
if (conn.State.ToString() == "Open") conn.Close();
GrdConsignFrom.DataSource = ds.Tables[0].DefaultView;
GrdConsignFrom.DataBind();
}
catch (Exception ex)
{
Response.Write("数据库错误,错误原因:" + ex.Message);
Response.End();
}
}
protected void GrdConsignFrom_RowEditing(object sender, GridViewEditEventArgs e)
{
//GridView GrdConsignFrom = (GridView)sender;
GrdConsignFrom.EditIndex = e.NewEditIndex;
GridViewBind();
}
protected void GrdConsignFrom_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
//GridView GrdConsignFrom = (GridView)sender;
GrdConsignFrom.EditIndex = -1;
GridViewBind();
}
protected void GrdConsignFrom_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string strconn = "server=.;database=Mojo_tianzhuju_sourcecode;uid=sa;pwd=p@ssw0rd";
SqlConnection Conn = new SqlConnection(strconn);
Conn.Open();
//GridView GrdConsignFrom = (GridView)sender;
string id = GrdConsignFrom.DataKeys[e.RowIndex].Values[0].ToString();
string ddlConsignType = ((TextBox)(GrdConsignFrom.Rows[e.RowIndex].Cells[0].Controls[0])).Text.Trim();
string rbthouse = ((TextBox)(GrdConsignFrom.Rows[e.RowIndex].Cells[1].Controls[0])).Text.Trim();
string ddlavaireg = ((TextBox)(GrdConsignFrom.Rows[e.RowIndex].Cells[2].Controls[0])).Text.Trim();
string strhuxing = ((TextBox)(GrdConsignFrom.Rows[e.RowIndex].Cells[3].Controls[0])).Text.Trim();
string stravalot = ((TextBox)(GrdConsignFrom.Rows[e.RowIndex].Cells[4].Controls[0])).Text.Trim();
string strconarea = ((TextBox)(GrdConsignFrom.Rows[e.RowIndex].Cells[5].Controls[0])).Text.Trim();
string strpreprice = ((TextBox)(GrdConsignFrom.Rows[e.RowIndex].Cells[6].Controls[0])).Text.Trim();
string strproowner = ((TextBox)(GrdConsignFrom.Rows[e.RowIndex].Cells[7].Controls[0])).Text.Trim();
string strbuilding = ((TextBox)(GrdConsignFrom.Rows[e.RowIndex].Cells[8].Controls[0])).Text.Trim();
string strhousren = ((TextBox)(GrdConsignFrom.Rows[e.RowIndex].Cells[9].Controls[0])).Text.Trim();
string strtracondition = ((TextBox)(GrdConsignFrom.Rows[e.RowIndex].Cells[10].Controls[0])).Text.Trim();
string strsupinfor = ((TextBox)(GrdConsignFrom.Rows[e.RowIndex].Cells[11].Controls[0])).Text.Trim();
string strcontact = ((TextBox)(GrdConsignFrom.Rows[e.RowIndex].Cells[12].Controls[0])).Text.Trim();
string strtel = ((TextBox)(GrdConsignFrom.Rows[e.RowIndex].Cells[13].Controls[0])).Text.Trim();
string strfax = ((TextBox)(GrdConsignFrom.Rows[e.RowIndex].Cells[14].Controls[0])).Text.Trim();
string strdate = DateTime.Now.ToString();
//string connStr = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;
string SqlStr = "update mp_ConsignForm set weituolx=N'" + ddlConsignType + "',fangwulx=N'" + rbthouse + "',fangyuanqy=N'" + ddlavaireg + "',huxing=N'" + strhuxing + "',fangyuandd=N'" + stravalot + "',jianzhumj=N'" + strconarea + "',nidingjg=N'" + strpreprice + "',";
SqlStr += "changquangs=N'" + strproowner + "',jianzhund=N'" + strbuilding + "',fangwuzhx=N'" + strhousren + "',jiaotongzhk=N'" + strtracondition + "',buchongshm=N'" + strsupinfor + "',lianxir=N'" + strcontact + "',dianhua=N'" + strtel + "',chuanzhen=N'" + strfax + "',Time_log='" + strdate + "'where id=" + id;
try
{
string strconn1 = "server=.;database=Mojo_tianzhuju_sourcecode;uid=sa;pwd=p@ssw0rd";
SqlConnection conn = new SqlConnection(strconn1);
if (conn.State.ToString() == "Closed") conn.Open();
SqlCommand comm = new SqlCommand(SqlStr, conn);
comm.ExecuteNonQuery();
comm.Dispose();
if (conn.State.ToString() == "Open") conn.Close();
GrdConsignFrom.EditIndex = -1;
GridViewBind();
}
catch (Exception ex)
{
Response.Write("数据库错误,错误原因:" + ex.Message);
Response.End();
}
}
protected void GrdConsignFrom_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
//GridView GrdConsignFrom = (GridView)sender;
string id = GrdConsignFrom.DataKeys[e.RowIndex].Values[0].ToString();
string connStr = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;
string SqlStr = "delete from mp_ConsignForm where id=" + id;
try
{
SqlConnection conn = new SqlConnection(connStr);
if (conn.State.ToString() == "Closed") conn.Open();
SqlCommand comm = new SqlCommand(SqlStr, conn);
comm.ExecuteNonQuery();
comm.Dispose();
if (conn.State.ToString() == "Open") conn.Close();
GrdConsignFrom.EditIndex = -1;
GridViewBind();
}
catch (Exception ex)
{
Response.Write("数据库错误,错误原因:" + ex.Message);
Response.End();
}
}
}
}
When I set breakpoints on the cs code, it has no response. So I think something wrong of the Gridview, I have changed the <asp:GridView to <mp:mojoGridView . But it no use, can you help me check this?