標籤:des style blog io color os ar java for
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="batchassign.aspx.cs" Inherits="Demo.batchassign" %>
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using Microsoft.Xrm.Sdk.Client;using UploadFiles;using System.ServiceModel.Description;using Microsoft.Xrm.Sdk;using System.Data.SqlClient;using System.Data;namespace Demo{ public partial class batchassign : System.Web.UI.Page { private IOrganizationService orgService; string ownerid = string.Empty; private static string strConnectionString = null; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { orgService = GetCrmService(); BindGridView(); } } public void BindGridView() { string strOwnerId=Request.QueryString["ownerid"].ToString(); if (!string.IsNullOrEmpty(strOwnerId)) { Guid OwnerId = new Guid(strOwnerId); gvInfo.DataSource = GetSettingsByProcedure(orgService, OwnerId); gvInfo.DataBind(); } } protected void gvInfo_RowDataBound(object sender, GridViewRowEventArgs e) { try { //單選 CheckBox cb = (CheckBox)e.Row.FindControl("chkSelected"); if (cb != null) cb.Attributes.Add("onclick", "signcheck(" + cb.ClientID + ")"); //如果是綁定資料行 if (e.Row.RowType == DataControlRowType.DataRow) { //滑鼠經過時,行背景色變 e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor=‘#E6F5FA‘"); //滑鼠移出時,行背景色變 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=‘#FFFFFF‘"); } } catch { } } private OrganizationServiceProxy GetCrmService() { string filePath = MapPath(@"/ISV/Config.txt"); FileConfig config = new FileConfig(filePath); string crmUrl; string orgName = config.GetValue("orgName").ToLower(); if (Request.Url.Host.ToLower().StartsWith(orgName, StringComparison.CurrentCultureIgnoreCase)) { crmUrl = Request.Url.Scheme + "://" + Request.Url.Host + ":" + Request.Url.Port + "/XRMServices/2011/Organization.svc"; } else { crmUrl = Request.Url.Scheme + "://" + Request.Url.Host + ":" + Request.Url.Port + "/" + orgName + "/XRMServices/2011/Organization.svc"; } ClientCredentials credentials = new ClientCredentials(); credentials.UserName.UserName = config.GetValue("UserName"); credentials.UserName.Password = config.GetValue("Password"); OrganizationServiceProxy crmServiceProxy = new OrganizationServiceProxy(new Uri(crmUrl), null, credentials, null); return crmServiceProxy; } /// <summary> /// 依據指定的CRM服務,指定的OwnerId,擷取銷售顧問 /// </summary> /// <param name="service">指定的CRM服務</param> /// <param name="entityName">指定的OwnerId</param> /// <returns>流水號管理類</returns> public DataSet GetSettingsByProcedure(IOrganizationService service, Guid OwnerId) { DataSet ds = new DataSet(); if (string.IsNullOrEmpty(strConnectionString)) { SystemConfig config = new SystemConfig(service, "IDOSSales_ReadOnly"); strConnectionString = config.GetValue(); } using (SqlConnection sqlconn = new SqlConnection(strConnectionString)) { SqlCommand cmd = new SqlCommand(); cmd.Connection = sqlconn; cmd.CommandText = "[dbo].[GetSalesConsultant]"; cmd.CommandType = CommandType.StoredProcedure; sqlconn.Open(); IDataParameter[] parameters = { new SqlParameter("@ownerid", SqlDbType.UniqueIdentifier)}; parameters[0].Value = OwnerId; cmd.Parameters.Add(parameters[0]); SqlDataAdapter adapter = new SqlDataAdapter(cmd); adapter.Fill(ds); sqlconn.Close(); } return ds; } protected void chkSelected_CheckedChanged(object sender, EventArgs e) { CheckBox chk = sender as CheckBox; int index = ((GridViewRow)(chk.NamingContainer)).RowIndex; if (chk.Checked) { ownerid = gvInfo.Rows[index].Cells[3].Text.Trim(); } } protected void btnOK_Click(object sender, EventArgs e) { if (ownerid != null && ownerid != "") { Response.Write("<script>window.returnValue=‘" + ownerid + "‘;window.opener = \"\"; window.open(\"\", \"_self\"); window.close();</script>"); //Response.Write("<script>window.returnValue=‘" + ownerid + "‘;window.close();</script>"); } } protected void btnCancel_Click(object sender, EventArgs e) { //Response.Write("<script>window.returnValue=‘1‘;</script>"); Response.Write("<script>window.returnValue=‘" + ownerid + "‘;window.opener = \"\"; window.open(\"\", \"_self\"); window.close();</script>"); } }}
這是模態視窗的代碼,通過Response.Write始終關閉不了模態視窗,具體原因不明覺厲,希望大家各抒己見探討探討,請各位高手多多指教。。。。。。
CRM2011彈出asp.net模態視窗關閉的問題