<%@ Page Language="C#" MasterPageFile="~/Admin/AdminMasterPage.master" AutoEventWireup="true" CodeFile="EditPlans1.aspx.cs" Inherits="Admin_EditPlans" %>
<%@ Register TagPrefix="asp" Namespace="Saplin.Controls" Assembly="DropDownCheckBoxes" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<script type="text/javascript" >
function Validate() {
}
function onlyNumbers(event) {
var charCode = (event.which) ? event.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
return true;
}
</script>
<script type="text/javascript">
function SetSelectedText(plantype) {
var selectedText = plantype.options[plantype.selectedIndex].innerHTML;
document.getElementById("pType2").value = selectedText;
}
</script>
<div class="maincontent">
<div class="contentheading">Plans</div>
<div class="contentheading2">Add Plans</div>
<div>All fields are mandatory</div>
<div class="tablerow1">
<span class="cell1">Plan Name / Code:</span>
<span class="cell2">
<asp:TextBox ID="planCode" runat="server"></asp:TextBox>
</span>
</div>
<div class="tablerow1">
<span class="cell1">Plan Type:</span>
<span class="cell2">
<select id="plantype" name="plantype" onchange="SetSelectedText(this)">
<option value="">Select anyone</option>
<option value="Single Country">Single Country</option>
<option value="Multi Countries">Multi Countries</option>
</select>
<asp:HiddenField ID="pType1" runat="server" />
<input id="pType2" name="pType2" type="hidden" />
<script type="text/javascript">
var ABPstate = $("#pType1").val();
$('#plantype option').filter(function () {
return $.trim($(this).text()) == ABPstate;
}).prop('selected', true);
</script>
</span>
</div>
<div class="tablerow1">
<span class="cell1">Incoming Calls:</span>
<span class="cell2">
<asp:TextBox ID="inCalls" runat="server"></asp:TextBox>
</span>
</div>
<div class="tablerow1">
<span class="cell1">Local Calls:</span>
<span class="cell2">
<asp:TextBox ID="lclCalls" runat="server"></asp:TextBox>
</span>
</div>
<div class="tablerow1">
<span class="cell1">Calls to India:</span>
<span class="cell2">
<asp:TextBox ID="indCalls" runat="server"></asp:TextBox>
</span>
</div>
<div class="tablerow1">
<span class="cell1">CUG:</span>
<span class="cell2">
<asp:TextBox ID="cug" runat="server"></asp:TextBox>
</span>
</div>
<div class="tablerow1">
<span class="cell1">Call Mode:</span>
<span class="cell2">
<asp:TextBox ID="callMode" runat="server"></asp:TextBox>
</span>
</div>
<div class="tablerow1">
<span class="cell1">Data at 4G:</span>
<span class="cell2">
<asp:TextBox ID="data4G" runat="server"></asp:TextBox>
</span>
</div>
<div class="tablerow1">
<span class="cell1">Data at Lower Speed:</span>
<span class="cell2">
<asp:TextBox ID="dataLS" runat="server"></asp:TextBox>
</span>
</div>
<div class="tablerow1">
<span class="cell1">Local SMS:</span>
<span class="cell2">
<asp:TextBox ID="lclSMS" runat="server"></asp:TextBox>
</span>
</div>
<div class="tablerow1">
<span class="cell1">SMS to India:</span>
<span class="cell2">
<asp:TextBox ID="indSMS" runat="server"></asp:TextBox>
</span>
</div>
<div class="tablerow1">
<span class="cell1">International SMS:</span>
<span class="cell2">
<asp:TextBox ID="intSMS" runat="server"></asp:TextBox>
</span>
</div>
<div class="tablerow1">
<span class="cell1">Price:</span>
<span class="cell2">
<asp:TextBox ID="pricecost" runat="server" onkeypress="return onlyNumbers(event)"></asp:TextBox>
</span>
</div>
<div class="tablerow1">
<span class="cell1">Validity:</span>
<span class="cell2">
<asp:TextBox ID="validityDays" runat="server"></asp:TextBox>
</span>
</div>
<div class="tablerow1">
<span class="cell1">Valid in Countries:</span>
<span class="cell2">
<asp:DropDownCheckBoxes ID="DropDownCheckBoxes1" runat="server" Width="180px" UseSelectAllNode="false" >
<Style SelectBoxWidth="195" DropDownBoxBoxWidth="180" DropDownBoxBoxHeight="150" SelectBoxCssClass="dropdownlist1" />
</asp:DropDownCheckBoxes>
</span>
</div>
<div class="tablerow1">
<span class="cell1">Extra Features:</span>
<span class="cell2">
<asp:TextBox ID="extFeatures" runat="server" TextMode="MultiLine" Width="200px" Height="100px"></asp:TextBox>
</span>
</div>
<div class="tablerow1">
<span class="cell1"> </span>
<span class="cell2">
<asp:Button ID="Button1" runat="server" Text="Add" OnClientClick="return Validate()" CausesValidation="true"
onclick="Button1_Click" /></span>
</div>
<br />
<div class="clear"></div>
</div>
</asp:Content>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using System.Web.DataAccess;
using System.Data.OleDb;
using System.Drawing;
using System.Linq;
public partial class Admin_EditPlans : System.Web.UI.Page
{
protected string prdID1;
protected string planName1;
protected string plantype1;
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.PopulateCountries();
if (this.Page.PreviousPage != null)
{
planName1 = Request.QueryString["RowIndex"];
OleDbConnection cn = new OleDbConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["globe"].ConnectionString);
OleDbCommand cmdschool = new OleDbCommand("select * from Productplans where productName=@productName", cn);
cmdschool.Parameters.AddWithValue("@productName", planName1);
cn.Open();
OleDbDataReader checkuser = cmdschool.ExecuteReader();
while (checkuser.Read())
{
planCode.Text = checkuser[1].ToString();
pType1.Value = checkuser[2].ToString();
inCalls.Text = checkuser[3].ToString();
lclCalls.Text = checkuser[4].ToString();
indCalls.Text = checkuser[5].ToString();
cug.Text = checkuser[6].ToString();
data4G.Text = checkuser[7].ToString();
dataLS.Text = checkuser[8].ToString();
lclSMS.Text = checkuser[9].ToString();
indSMS.Text = checkuser[10].ToString();
intSMS.Text = checkuser[11].ToString();
validityDays.Text = checkuser[12].ToString();
pricecost.Text = checkuser[13].ToString();
callMode.Text = checkuser[14].ToString();
extFeatures.Text = checkuser[15].ToString();
}
string plantype = pType1.Value;
string script1 = "window.onload = function() { SetSelectedText('" + plantype + "'); };";
ClientScript.RegisterStartupScript(this.GetType(), "UpdateTime", script1, true);
}
}
if (Session["sUserName"] == null)
{
Server.Transfer("Default.aspx");
}
}
private void PopulateCountries()
{
//String strQuery = "select ID, countryName from CountryTable order by countryName";
using (OleDbConnection con = new OleDbConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["globe"].ConnectionString))
{
using (OleDbCommand cmd = new OleDbCommand("select ID, countryName from CountryTable order by countryName"))
{
using (OleDbDataAdapter sda = new OleDbDataAdapter())
{
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
DropDownCheckBoxes1.DataSource = dt;
DropDownCheckBoxes1.DataTextField = "countryName";
DropDownCheckBoxes1.DataValueField = "ID";
DropDownCheckBoxes1.DataBind();
}
}
}
}
OleDbConnection cn1 = new OleDbConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["globe"].ConnectionString);
OleDbCommand selectcountries = new OleDbCommand("SELECT * FROM prdCountries where prdID=@prdID", cn1);
selectcountries.Parameters.AddWithValue("@prdID", planCode.Text);
cn1.Open();
OleDbDataAdapter sda1 = new OleDbDataAdapter(selectcountries);
DataTable dt1 = new DataTable();
sda1.Fill(dt1);
foreach (DataRow row in dt1.Rows)
{
DropDownCheckBoxes1.SelectedValue = row["ID"].ToString();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
}
}