Hello everyone : I'm creating an ASP.net project, here is the folder with a problem :
Dashboard :
--> DashboardIndex.cshtml
--> DashboardPage.cs
--> DashboardPageModel.cs
My page generates the following code
<div class="small-box bg-aqua">
<div class="inner">
<h3>#Model.OpenOrders</h3>
<p>Open Orders</p>
</div>
<div class="icon">
<i class="ion ion-bag"></i>
</div>
More info <i class="fa fa-arrow-circle-right"></i>
</div>
I click on the button, what leads me to http://localhost:21739/IP/1/11_2
Aaand.. Error 404 !
Yet, I coded what seems to be the appropriate function (I compared with another function I code (which works) and I didn't find any relevant differences)
namespace Serene7.Common.Pages
{
using Serenity;
using System;
using System.Linq;
using Serenity.Data;
using System.Collections.Generic;
using System.Web.Mvc;
using System.Data.SqlClient;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Web.UI;
using System.Web.UI.WebControls;
[RoutePrefix("Dashboard"), Route("{action=index}")]
public class DashboardController : Controller
{
[Authorize, HttpGet, Route("~/")]
public ActionResult Index()
{
return View(MVC.Views.Common.Dashboard.DashboardIndex, new DashboardPageModel());
}
[HttpGet]
[Route("IP/{Station=0}/{Timestp=0}")]
public ActionResult IP(int station, string timestp)
{
timestp = timestp.Replace("_", ":");
SqlConnection myConn = new SqlConnection(#"Server=(LocalDb)\MSSqlLocalDB;Integrated security=SSPI;database=Serene7_Default_v1");
List<string> listeIps = new List<string>();
string listDb = string.Format("SELECT DISTINCT (IpSource) FROM [Serene5_Default_v1].[tcpdump].[TCPDump] WHERE Station = '{0}' AND TimeStp = '{1}';",station,timestp);
SqlCommand myCommand = new SqlCommand(listDb, myConn);
string listDb2 = string.Format("SELECT DISTINCT (IpSource,IpDestination) FROM [Serene5_Default_v1].[tcpdump].[TCPDump] WHERE Station = '{0}' AND TimeStp = '{1}';", station, timestp);
SqlCommand myCommand2 = new SqlCommand(listDb2, myConn);
myConn.Open();
SqlDataReader reader = myCommand.ExecuteReader();
while (reader.Read())
{
listeIps.Add(reader[0].ToString());
}
reader.Close();
SqlDataReader reader2 = myCommand.ExecuteReader();
while (reader2.Read())
{
listeIps.Add(reader2[0].ToString());
}
List<string> noRepetitions = listeIps.Distinct().ToList();
int lengthList = noRepetitions.Count;
byte[] imageBuffer = new byte[400 * lengthList * lengthList * 4];
string listDb3 = string.Format("SELECT SUM(ToTheRight) FROM [Serene5_Default_v1].[tcpdump].[TCPDump] WHERE IdSource = #IdSource AND IdDestination = #IdDestination AND Station = '{0}' AND TimeStp = '{1}';", station, timestp);
string listDb4 = string.Format("SELECT SUM(ToTheLeft) FROM [Serene5_Default_v1].[tcpdump].[TCPDump] WHERE IdDestination = #IdSource AND IdSource = #IdDestination AND Station = '{0}' AND TimeStp = '{1}';", station, timestp);
SqlCommand myCommand3 = new SqlCommand(listDb3, myConn);
SqlCommand myCommand4 = new SqlCommand(listDb4, myConn);
IDbDataParameter param;
param = myCommand3.CreateParameter();
param.ParameterName = "#IdDestination";
param.Value = "''";
param = myCommand3.CreateParameter();
param.ParameterName = "#IdSource";
param.Value = "''";
param = myCommand4.CreateParameter();
param.ParameterName = "#IdDestination";
param.Value = "''";
param = myCommand4.CreateParameter();
param.ParameterName = "#IdSource";
param.Value = "''";
int[,] matrix = new int[lengthList, lengthList];
for (int x = 0; x < lengthList; x++)
{
for (int y = 0; y < lengthList; y++)
{
myCommand3.Parameters["#IdSource"].Value = "'" + noRepetitions[x] + "'";
myCommand3.Parameters["#IdDestination"].Value = "'" + noRepetitions[y] + "'";
myCommand4.Parameters["#IdSource"].Value = "'" + noRepetitions[x] + "'";
myCommand4.Parameters["#IdDestination"].Value = "'" + noRepetitions[y] + "'";
int total = 0;
SqlDataReader reader3 = myCommand3.ExecuteReader();
SqlDataReader reader4 = myCommand4.ExecuteReader();
while (reader3.Read())
{
total += (int)reader[0];
}
reader3.Close();
while (reader4.Read())
{
total += (int)reader[0];
}
reader4.Close();
matrix[x, y] = total;
}
}
int maximum = matrix.Cast<int>().Max();
double logMax = Math.Log(maximum);
for (int x = 0; x < 20 * lengthList; x++)
{
for (int y = 0; y < 20 * lengthList; y++)
{
int posX = x % 20;
int posY = y % 20;
int offset = ((20 * lengthList * 4) * y) + (x * 4);
int test = 0;
if (matrix[x, y] > 0)
{
test = 1;
}
int value = (int)(test * (10 + (245 * Math.Log(matrix[x, y]) / logMax)));
imageBuffer[offset] = (byte)value;
imageBuffer[offset + 1] = (byte)value;
imageBuffer[offset + 2] = (byte)value;
imageBuffer[offset + 3] = 255;
}
}
unsafe
{
fixed(byte* ptr = imageBuffer)
{
using (Bitmap image = new Bitmap(256, 100, 256 * 4,
PixelFormat.Format32bppRgb, new IntPtr(ptr)))
{
image.Save(#"C:\Users\FS091843\Desktop\Stations\Station1\greyscale.png");
}
}
}
DashboardPageModel dashboard = new DashboardPageModel();
return View(MVC.Views.Common.Dashboard.DashboardIndex, dashboard);
}
}
}
Anyone has an idea of what is going wrong ?
Related
if ((bool)Session["Conect"])
{
logdiv.Visible = false;
Usernamec.InnerHtml = (string)Session["CurentUserid"];
Connected.Visible = true;
SqlCommand exp = new SqlCommand("SELECT xp FROM[User] Where Username = #username", c);
exp.Parameters.AddWithValue("#username", (string)Session["CurentUserid"]);
c.Open();
Session["exp"] = (int)exp.ExecuteScalar();
c.Close();
int b = (int)Session["exp"] / 3;
string a = b + "%";
xp.Style.Add("width", a);
}
why it is not working?
(not an eror the width does not change...)
I am using ASP.Net C# with SQL Server 2012
My C# Code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
public partial class autorefresh_create_emi : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["paconn"].ToString());
con.Open();
SqlCommand com1 = new SqlCommand("select max(f_casenum) from c_detail", con);
string check_max = com1.ExecuteScalar().ToString();
if (check_max == "0")
{
}
else
{
string st_id = "";
Int64 st = 0;
string max_id = "";
Int64 en = 0;
SqlCommand com2 = new SqlCommand("select top 1(f_casenum) from c_emi where f_casenum not in (select top 1 (f_casenum) from c_detail order by f_casenum) order by f_casenum", con);
com2.CommandTimeout = 0;
st_id = com2.ExecuteScalar().ToString();
st_id = st_id.Substring(2);
st = Convert.ToInt64(st_id);
max_id = check_max;
max_id = max_id.Substring(2);
en = Convert.ToInt64(max_id);
for (Int64 i = st; i <= en; i++)
{
string f_casenum = "PA" + i;
string c_status = "";
string f_tenure = "";
SqlCommand com3 = new SqlCommand("select * from c_detail where f_casenum=#f_casenum", con);
com3.CommandTimeout = 0;
com3.Parameters.AddWithValue("#f_casenum", f_casenum);
SqlDataReader reader3 = com3.ExecuteReader();
if (reader3.Read())
{
f_tenure = reader3["f_tenure"].ToString().Trim();
c_status = reader3["c_status"].ToString();
}
reader3.Close();
if (c_status == "Full Paid")
{
}
else
{
string row_check = "";
SqlCommand com4 = new SqlCommand("select count(f_invoice) from c_emi where f_casenum=#f_casenum", con);
com4.CommandTimeout = 0;
com4.Parameters.AddWithValue("#f_casenum", f_casenum);
row_check = com4.ExecuteScalar().ToString().Trim();
if (f_tenure.Equals(row_check))
{
}
else
{
string st_id_invoice = "";
Int64 st_invoice = 0;
string max_id_invoice = "";
Int64 en_invoice = 0;
SqlCommand com5 = new SqlCommand("select min(f_invoice) from c_emi where f_casenum=#f_casenum", con);
com5.CommandTimeout = 0;
com5.Parameters.AddWithValue("#f_casenum", f_casenum);
st_id_invoice = com5.ExecuteScalar().ToString();
st_id_invoice = st_id_invoice.Substring(3);
st_invoice = Convert.ToInt64(st_id_invoice);
SqlCommand com6 = new SqlCommand("select max(f_invoice) from c_emi where f_casenum=#f_casenum", con);
com6.CommandTimeout = 0;
com6.Parameters.AddWithValue("#f_casenum", f_casenum);
max_id_invoice = com6.ExecuteScalar().ToString();
max_id_invoice = max_id_invoice.Substring(3);
en_invoice = Convert.ToInt64(max_id_invoice);
for (Int64 j = st_invoice; j <= en_invoice; j++)
{
string invoice_date = "";
string f_emi_due = "";
string f_total_emi = "";
string f_emi = "";
string f_b_curr = "";
string f_invoice = "PAI" + j;
string f_casenum1 = "";
SqlCommand com7 = new SqlCommand("select * from c_emi where f_invoice=#f_invoice", con);
com7.CommandTimeout = 0;
com7.Parameters.AddWithValue("#f_invoice", f_invoice);
SqlDataReader reader7 = com7.ExecuteReader();
if (reader7.Read())
{
f_casenum1 = reader7["f_casenum"].ToString();
f_emi = reader7["f_emi"].ToString();
f_emi_due = reader7["f_emi_due"].ToString();
f_total_emi = reader7["f_total_emi"].ToString();
f_b_curr = reader7["f_b_curr"].ToString();
invoice_date = reader7["invoice_date"].ToString();
}
reader7.Close();
if (f_casenum == f_casenum1)
{
DateTime currr = DateTime.Now;
DateTime INDIAN_ZONE = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(currr, "India Standard Time");
DateTime curr = INDIAN_ZONE;
string curr_invoicedate = curr.ToShortDateString();
DateTime check_invoicedate = Convert.ToDateTime(invoice_date);
check_invoicedate = check_invoicedate.AddDays(30);
check_invoicedate = Convert.ToDateTime(check_invoicedate);
string exit_date = check_invoicedate.ToShortDateString();
string f_emi_duedate = check_invoicedate.AddDays(10).ToShortDateString();
string invoice_date1 = check_invoicedate.ToShortDateString();
SqlCommand com8 = new SqlCommand("select f_casenum from c_emi where f_casenum=#f_casenum and CONVERT(date,invoice_date,101)=#invoice_date", con);
com8.CommandTimeout = 0;
com8.Parameters.AddWithValue("#f_casenum", f_casenum);
com8.Parameters.AddWithValue("#invoice_date", exit_date);
string check_exitdate = "";
SqlDataReader reader8 = com8.ExecuteReader();
if (reader8.Read())
{
check_exitdate = reader8["f_casenum"].ToString();
}
else
{
}
if (check_exitdate != "")
{
}
else
{
if (curr >= check_invoicedate)
{
string value = "0";
string owner = "";
string i_status = "Unlock";
SqlCommand com9 = new SqlCommand("select MAX(f_invoice) from c_emi", con);
com9.CommandTimeout = 0;
string maxid1 = com9.ExecuteScalar().ToString();
string id1 = maxid1;
Int64 code = 100000000001;
string c = "PAI";
if (id1.Substring(0, 1) != "P")
{
id1 = code.ToString();
id1 = c + id1.ToString();
}
else
{
id1 = id1.Substring(3);
Int64 a = Convert.ToInt64(id1);
a = a + 1;
id1 = c + a.ToString();
}
id1 = id1.ToString();
SqlCommand com11 = new SqlCommand("insert into c_emi values(#f_casenum,#f_b_amt,#f_emi,#f_emi_duedate,#f_invoice,#invoice_date,#f_overdue_amt,#f_emi_paid,#f_emi_due,#f_total_emi,#f_b_curr,#i_status,#owner,#convi_charges,#paidemi_date)", con);
com11.CommandTimeout = 0;
SqlParameter obj1 = new SqlParameter("#f_casenum", DbType.StringFixedLength);
obj1.Value = f_casenum;
com11.Parameters.Add(obj1);
SqlParameter obj2 = new SqlParameter("#f_overdue_amt", DbType.StringFixedLength);
obj2.Value = value;
com11.Parameters.Add(obj2);
SqlParameter obj3 = new SqlParameter("#f_emi_paid", DbType.StringFixedLength);
obj3.Value = value;
com11.Parameters.Add(obj3);
SqlParameter obj4 = new SqlParameter("#f_emi_due", DbType.StringFixedLength);
obj4.Value = value;
com11.Parameters.Add(obj4);
SqlParameter obj5 = new SqlParameter("#f_total_emi", DbType.StringFixedLength);
obj5.Value = f_emi;
com11.Parameters.Add(obj5);
SqlParameter obj6 = new SqlParameter("#f_emi", DbType.StringFixedLength);
obj6.Value = f_emi;
com11.Parameters.Add(obj6);
SqlParameter obj7 = new SqlParameter("#f_emi_duedate", DbType.StringFixedLength);
obj7.Value = f_emi_duedate;
com11.Parameters.Add(obj7);
SqlParameter obj8 = new SqlParameter("#f_invoice", DbType.StringFixedLength);
obj8.Value = id1;
com11.Parameters.Add(obj8);
SqlParameter obj9 = new SqlParameter("#invoice_date", DbType.StringFixedLength);
obj9.Value = invoice_date1;
com11.Parameters.Add(obj9);
SqlParameter obj10 = new SqlParameter("#f_b_amt", DbType.StringFixedLength);
obj10.Value = f_b_curr;
com11.Parameters.Add(obj10);
SqlParameter obj11 = new SqlParameter("#f_b_curr", DbType.StringFixedLength);
obj11.Value = f_b_curr;
com11.Parameters.Add(obj11);
SqlParameter obj12 = new SqlParameter("#i_status", DbType.StringFixedLength);
obj12.Value = i_status;
com11.Parameters.Add(obj12);
SqlParameter obj13 = new SqlParameter("#owner", DbType.StringFixedLength);
obj13.Value = owner;
com11.Parameters.Add(obj13);
SqlParameter obj14 = new SqlParameter("#convi_charges", DbType.StringFixedLength);
obj14.Value = value;
com11.Parameters.Add(obj14);
SqlParameter obj15 = new SqlParameter("#paidemi_date", DbType.StringFixedLength);
obj15.Value = owner;
com11.Parameters.Add(obj15);
com11.ExecuteNonQuery();
}
else
{
}
}
}
else
{
}
}
}
}
}
}
con.Close();
}
}
I have large database and my query is inserted many number of record on table when i run the web page
I recieve the following Error :
System.Data.SqlClient.SqlException: A transport-level error has
occurred when receiving results from the server. (provider: Session
Provider, error: 19 - Physical connection is not usable)
on the following Code
Line 111: com7.Parameters.AddWithValue("#f_invoice", f_invoice);
Line 112:
Line 113: SqlDataReader reader7 = com7.ExecuteReader();
Line 114: if (reader7.Read())
Line 115: {
My ErrorLog file says :
2015-01-13 11:27:23.96 Logon Error: 18456, Severity: 14, State:
8.
2015-01-13 11:27:23.96 Logon Login failed for user 'sa'.
Reason: Password did not match that for the login provided. [CLIENT:
108.171.243.19]
So what's the issue..??
I would like to minus the data from the database with the value that I give when I run the program. Everything works, but I keep stuck at the newVal. I already did it like this, but the newVal keep appear 0 (because I declared decimal newVal = 0, but on this question, I just used decimal newVal;). Two more problems: if I move the newVal = ... to the top, it is useless, because one of the calculations in the newVal is reading data from the database (since I want database minus with the new value given when i run the program, required dReader = cmd.ExecuteReader();), but if I put the newVal at the bottom after reading data, it is useless as well, because I set the Quantity = ? and the value of ? is newVal.. Well, here is the code:
private void AddObjects(object sender, EventArgs e, Form theForm)
{
button1.Visible = true;
textBoxQuantityContainer = new List<NumericUpDown>();
textBoxCodeContainer = new List<NumericTextBox>();
textBoxDescContainer = new List<TextBox>();
textBoxSubTotalContainer = new List<TextBox>();
textBoxTotalContainer = new List<TextBox>();
textBoxAllTotalContainer = new TextBox();
OleDbDataReader dReader;
OleDbConnection conn = new OleDbConnection(connectionString);
conn.Open();
OleDbCommand cmd = new OleDbCommand("SELECT [Code] FROM [Seranne]", conn);
dReader = cmd.ExecuteReader();
AutoCompleteStringCollection codesCollection = new AutoCompleteStringCollection();
while (dReader.Read())
{
string numString = dReader[0].ToString().PadLeft(4, '0');
codesCollection.Add(numString);
}
dReader.Close();
conn.Close();
if (firstForm.comboBox1.SelectedIndex == 0)
{
label1.Text = "Code:";
label1.Location = new Point(60, 125);
label2.Text = "Welcome to the Selling System.";
label2.Location = new Point(600, 30);
label3.Text = "Quantity:";
label3.Location = new Point(155, 125);
label4.Text = "Description:";
label4.Location = new Point(580, 125);
label5.Text = "Sub Total on Rp:";
label5.Location = new Point(1020, 125);
label6.Text = "Total on Rp:";
label6.Location = new Point(1210, 125);
label7.Text = "Total on Rp:";
label7.Location = new Point(1080, 580);
}
else if (firstForm.comboBox1.SelectedIndex == 1)
{
label1.Text = "Kode:";
label1.Location = new Point(60, 125);
label2.Text = "Selamat datang di Selling System.";
label2.Location = new Point(600, 30);
label3.Text = "Banyaknya:";
label3.Location = new Point(145, 125);
label4.Text = "Keterangan:";
label4.Location = new Point(580, 125);
label5.Text = "Sub Total di Rp:";
label5.Location = new Point(1020, 125);
label6.Text = "Total di Rp:";
label6.Location = new Point(1210, 125);
label7.Text = "Total di Rp:";
label7.Location = new Point(1080, 580);
}
//****TextBox for Code****
for (int y = 0; y <= 16; y++)
{
textBoxCodeContainer.Add(new NumericTextBox());
textBoxCodeContainer[y].Size = new Size(100, 50);
textBoxCodeContainer[y].Location = new Point(25, 150 + (y * 25));
textBoxCodeContainer[y].TextChanged += new System.EventHandler(this.textBox_TextChanged);
textBoxCodeContainer[y].AutoCompleteMode = AutoCompleteMode.Suggest;
textBoxCodeContainer[y].AutoCompleteSource = AutoCompleteSource.CustomSource;
textBoxCodeContainer[y].AutoCompleteCustomSource = codesCollection;
theForm.Controls.Add(textBoxCodeContainer[y]);
}
//****TextBox for Quantity****
for (int y = 0; y <= 16; y++)
{
textBoxQuantityContainer.Add(new NumericUpDown());
textBoxQuantityContainer[y].Size = new Size(100, 50);
textBoxQuantityContainer[y].Location = new Point(125, 150 + (y * 25));
textBoxQuantityContainer[y].TextChanged += new System.EventHandler(this.textBox_TextChanged);
textBoxQuantityContainer[y].Maximum = 1000;
theForm.Controls.Add(textBoxQuantityContainer[y]);
}
//****TextBox for Description****
for (int y = 0; y <= 16; y++)
{
textBoxDescContainer.Add(new TextBox());
textBoxDescContainer[y].Size = new Size(750, 50);
textBoxDescContainer[y].Location = new Point(225, 150 + (y * 25));
theForm.Controls.Add(textBoxDescContainer[y]);
}
//****TextBox for Sub Total****
for (int y = 0; y <= 16; y++)
{
textBoxSubTotalContainer.Add(new TextBox());
textBoxSubTotalContainer[y].Size = new Size(175, 50);
textBoxSubTotalContainer[y].Location = new Point(975, 150 + (y * 25));
theForm.Controls.Add(textBoxSubTotalContainer[y]);
}
//****TextBox for Total****
for (int y = 0; y <= 16; y++)
{
textBoxTotalContainer.Add(new TextBox());
textBoxTotalContainer[y].Size = new Size(175, 50);
textBoxTotalContainer[y].Location = new Point(1150, 150 + (y * 25));
textBoxTotalContainer[y].TextChanged += new System.EventHandler(this.textBox_TextChanged);
theForm.Controls.Add(textBoxTotalContainer[y]);
}
//****TextBox for Total All****
textBoxAllTotalContainer.Size = new Size(175, 50);
textBoxAllTotalContainer.Location = new Point(1150, 575);
textBoxAllTotalContainer.TextChanged += new System.EventHandler(this.textBox_TextChanged);
theForm.Controls.Add(textBoxAllTotalContainer);
}
private void UpdateDatas()
{
int codeValue = 0;
int index = 0;
string query = "SELECT [Quantity], [Description], [Price] FROM [Seranne] WHERE [Code] IN (";
OleDbConnection conn = new OleDbConnection(connectionString);
conn.Open();
if (int.TryParse(this.textBoxCodeContainer[0].Text, out codeValue))
{
query = query + codeValue.ToString();
}
for (int i = 1; i < 17; i++)
{
if (int.TryParse(this.textBoxCodeContainer[i].Text, out codeValue))
{
query = query + "," + codeValue.ToString();
}
}
query = query + ")";
OleDbCommand cmd = new OleDbCommand(query, conn);
OleDbDataReader dReader;
dReader = cmd.ExecuteReader();
while (dReader.Read())
{
if (textBoxCodeContainer[index].TextLength != 0)
{
this.textBoxQuantityContainer[index].Maximum = Convert.ToInt32(dReader["Quantity"].ToString());
this.textBoxDescContainer[index].Text = dReader["Description"].ToString();
this.textBoxSubTotalContainer[index].Text = dReader["Price"].ToString();
}
index += 1;
}
dReader.Close();
conn.Close();
}
private void UpdatePrice()
{
int totalPrice = 0;
int quantity = 0;
int price = 0;
for (int i = 0; i < 17; i++)
{
if (textBoxQuantityContainer[i].Value > 0)
{
quantity = (int)textBoxQuantityContainer[i].Value;
price = Convert.ToInt32(textBoxSubTotalContainer[i].Text);
textBoxTotalContainer[i].Text = (quantity * price).ToString();
}
else
{
textBoxSubTotalContainer[i].Text = "";
textBoxTotalContainer[i].Text = "";
}
}
for (int i = 0; i < 17; i++)
{
if (textBoxTotalContainer[i].TextLength != 0)
{
totalPrice += Convert.ToInt32(textBoxTotalContainer[i].Text);
}
}
textBoxAllTotalContainer.Text = totalPrice.ToString("n2");
}
private void UpdateQuantity()
{
int index = 0;
int codeValue = 0;
decimal newVal;
List<int> integers = new List<int>();
foreach (var tb in textBoxCodeContainer)
{
if (int.TryParse(tb.Text, out codeValue))
{
integers.Add(codeValue);
}
}
string command = "UPDATE [Seranne] SET [Quantity]=? WHERE [Code] IN(" + string.Join(", ", integers) + ")";
OleDbConnection conn = new OleDbConnection(connectionString);
OleDbCommand cmd = new OleDbCommand(command, conn);
cmd.Parameters.Add("Quantity", System.Data.OleDb.OleDbType.Integer);
cmd.Parameters["Quantity"].Value = this.newVal.ToString();
OleDbDataReader dReader;
conn.Open();
dReader = cmd.ExecuteReader();
while (dReader.Read())
{
if (textBoxQuantityContainer[index].Value != 0)
{
newVal = (Convert.ToInt32(dReader["Quantity"].ToString()) -
textBoxQuantityContainer[index].Value);
int numberOfRows = cmd.ExecuteNonQuery();
}
index += 1;
}
if (newVal == 0)
{
System.Media.SoundPlayer sounds = new System.Media.SoundPlayer(#"C:\Windows\Media\Windows Notify.wav");
sounds.Play();
MessageBox.Show("Cannot Update", "Error");
}
else
{
System.Media.SoundPlayer sound = new System.Media.SoundPlayer(#"C:\Windows\Media\Windows Notify.wav");
sound.Play();
MessageBox.Show("Was Updated Successfully", "Success");
}
dReader.Close();
conn.Close();
}
private void textBox_TextChanged(object sender, EventArgs e)
{
UpdateDatas();
UpdatePrice();
}
private void button1_Click(object sender, EventArgs e)
{
UpdateQuantity();
}
Thanks a bunch
Good day, i got several things here:
1) cmd.Parameters["Quantity"].Value = this.newVal.ToString(); conversion to string is not needed here, because the Value is an object. You already defined that it should be handled as integer.
2) Replace the ? within you query to #Quantity, so it will be filled by the query execution.
3) When updating you don't need to execute it as a reader. use the int numberOfRows = cmd.ExecuteNonQuery(); without the loop. It will update all items.
4) You should execute the if (textBoxQuantityContainer[index].Value != 0 && textBoxQuantityContainer[index].Value >=
Convert.ToInt32(dReader["Quantity"].ToString()))
{ when building the integers list, this way you are only updating the right quantities.
If you only want to update certain rows, you'll have to expand your where clause:
cmd.Parameters.Add("MinimumQuantity", System.Data.OleDb.OleDbType.Integer).Value = minimumQuantity;
string command = "UPDATE [Seranne]
SET [Quantity]=#Quantity
WHERE [Code] IN(" + string.Join(", ", integers) + ")
AND [Quantity] > #MinimumQuantity
The higest risk is: You assume that the order and count of the records are the same between your textBoxCodeContainer and the database.
What is the relation between a textbox and a row. How do you know what textbox links to which row?
I could give you a push in the right direction, if you show me some more code (like where/how is textBoxCodeContainer defined)
UPDATE:
I made some code the read and manipulate your database, this is not tested since i don't have any database here.
I would create these classes, 1 is a data class Product and one is a Handler class ProductHandler.
The data class only contains the data (not in presentation format) The data handler knows how to read and write them.
public class Product
{
public int Code { get; set; }
public string Description { get; set; }
public int Quantity { get; set; }
}
public class ProductHandler
{
public ProductHandler(string connectionString)
{
ConnectionString = connectionString;
}
public bool AddProduct(Product product)
{
return AddProducts(new Product[] { product }) > 0;
}
public int AddProducts(IEnumerable<Product> products)
{
int rowsInserted = 0;
using (OleDbConnection conn = new OleDbConnection(ConnectionString))
{
conn.Open();
string query = "INSERT INTO [Seranne] (Code, Description, Quantity) VALUES(#Code, #Description, #Quantity)";
using (OleDbCommand cmd = new OleDbCommand(query, conn))
{
cmd.Parameters.Add("Code", OleDbType.Integer);
cmd.Parameters.Add("Description", OleDbType.VarChar);
cmd.Parameters.Add("Quantity", OleDbType.Integer);
foreach (var product in products)
{
cmd.Parameters["Code"].Value = product.Code;
cmd.Parameters["Description"].Value = product.Description;
cmd.Parameters["Quantity"].Value = product.Quantity;
rowsInserted += cmd.ExecuteNonQuery();
}
}
}
return rowsInserted;
}
public bool UpdateProduct(Product product)
{
return UpdateProducts(new Product[] { product }) > 0;
}
public int UpdateProducts(IEnumerable<Product> products)
{
int rowsUpdated = 0;
using (OleDbConnection conn = new OleDbConnection(ConnectionString))
{
conn.Open();
string query = "UPDATE [Seranne] SET Description = #Description, Quantity = #Quantity WHERE [Code] == #Code)";
using (OleDbCommand cmd = new OleDbCommand(query, conn))
{
cmd.Parameters.Add("Code", OleDbType.Integer);
cmd.Parameters.Add("Description", OleDbType.VarChar);
cmd.Parameters.Add("Quantity", OleDbType.Integer);
foreach (var product in products)
{
cmd.Parameters["Code"].Value = product.Code;
cmd.Parameters["Description"].Value = product.Description;
cmd.Parameters["Quantity"].Value = product.Quantity;
rowsUpdated += cmd.ExecuteNonQuery();
}
}
}
return rowsUpdated;
}
public bool DeleteProduct(Product product)
{
return DeleteProducts(new int[] { productCode }) > 0;
}
public int DeleteProducts(IEnumerable<Product> products)
{
using (OleDbConnection conn = new OleDbConnection(ConnectionString))
{
conn.Open();
string productCodeStr = string.Join(", ", products.Select(item => item.Code));
string query = string.Format("DELETE FROM [Seranne] WHERE [Code] in ({0})", productCodeStr);
using (OleDbCommand cmd = new OleDbCommand(query, conn))
{
int rowsDeleted = cmd.ExecuteNonQuery();
return rowsDeleted;
}
}
}
public IEnumerable<Product> ReadAllProducts()
{
List<Product> result = new List<Product>();
using (OleDbConnection conn = new OleDbConnection(ConnectionString))
{
conn.Open();
using (OleDbCommand cmd = new OleDbCommand("SELECT [Code], [Description], [Quantity] FROM [Seranne]", conn))
using (OleDbDataReader dReader = cmd.ExecuteReader())
while (dReader.Read())
{
Product product = new Product();
product.Code = Convert.ToInt32(dReader["Code"]);
product.Description = Convert.ToString(dReader["Description"]);
product.Quantity = Convert.ToInt32(dReader["Quantity"]);
result.Add(product);
}
}
return result;
}
public string ConnectionString { get; private set; }
}
Some example code:
ProductHandler _productHandler = new ProductHandler("connectionstring here or from config");
public void Example()
{
_productList.Clear();
_productList.AddRange(_productHandler.ReadAllProducts());
// displaying
foreach (var product in _productList)
Trace.WriteLine(string.Format("code: {0}, description: {1}, quantity: {2}", product.Code, product.Description, product.Quantity);
// updating
var selectedProduct = _productList.FirstOrDefault(item => item.Code == 15);
if(selectedProduct!= null)
{
selectedProduct.Quantity = 50;
_productHandler.UpdateProduct(selectedProduct);
}
// deleting
_productHandler.DeleteProducts(_productList.Where(item => item.Quantity < 5));
}
How to link the textboxes to the right product:
I would create a UserControl that contains a Product property and the TextBoxes and handles when textbox_changed events occurs. Those event handlers manipulate the Product instance.
You only generate 16 controls and bind a product to it. When you press a button, you only need to save the changed products.
Hi I have 1000 latitudes , longitudes and want to display all of them on maps .
I tried several ways to do it but not luck.....I have a datagridview which has client,lat,long,region. each client has a region.I have a combobox when I click on combobox region 1 it should display all clients on region 1 on map can it be possible. please help.
if (comboBox5.SelectedIndex == 0)//(REGION 1)
{
String Query = " SELECT top Latitude,Longitude FROM[ICPS].[dbo].[Sheet3_kir] ";
SqlCommand cmdDatabase = new SqlCommand(Query, conDatabase);
SqlDataReader myReader;
gMapControl1.MapProvider = GMap.NET.MapProviders.BingMapProvider.Instance;
GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly;
GMapOverlay markersOverlay = new GMapOverlay("VCS MAP");
//gMapControl1.Overlays.Add(markersOverlay);
for (int i = 0; i <= dataGridView1.Rows.Count; i++)
{
foreach (DataGridViewRow row in dataGridView1.Rows)
{
var Latitude = double.Parse(dataGridView1.Columns[1].ToString());
var Longitude = double.Parse(dataGridView1.Columns[2].ToString());
gMapControl1.Position = new PointLatLng(Latitude, Longitude);
// GMarkerGoogle marker = new GMarkerGoogle(new PointLatLng(float.Parse(this.dataGridView1.Columns[1].ToString), float.Parse(this.textBox26.Text)),
// GMarkerGoogleType.green);
GMarkerGoogle m = new GMarkerGoogle(gMapControl1.Position, GMarkerGoogleType.green_pushpin);
//markersOverlay.Markers.Add(m);
}
}
MySqlDataAdapter da = new MySqlDataAdapter("select * from sinkhole where sinkhole_status = '" + "Active" + "'", Conn);
MySqlCommandBuilder cBuilder = new MySqlCommandBuilder(da);
DataTable dataTable = new DataTable();
DataSet ds = new DataSet();
da.Fill(dataTable);
for (int i = dataTable.Rows.Count - 1; i >= 0; i--)
{
double lng = double.Parse(dataTable.Rows[i][4].ToString());
double lat = double.Parse(dataTable.Rows[i][3].ToString());
string location = dataTable.Rows[i][2].ToString();
string name = dataTable.Rows[i][1].ToString();
string desciption = dataTable.Rows[i][5].ToString();
GMapOverlay markersOverlay = new GMapOverlay(map, "marker");
GMapMarkerGoogleGreen marker = new GMapMarkerGoogleGreen(new PointLatLng(lat, lng));
markersOverlay.Markers.Add(marker);
//marker.ToolTipMode = MarkerTooltipMode.Always;
marker.ToolTip = new GMapRoundedToolTip(marker);
marker.ToolTipText = "Coordinates: (" + Convert.ToString(lat) + "," + Convert.ToString(lng) + ")" + "\nLocation: " + location + "\nName: " + name;
map.Overlays.Add(markersOverlay);
for (int i = 0; i < dataGridView1.Rows.Count; ++i)
{
double lat = Convert.ToDouble(dataGridView1.Rows[i].Cells[9].Value) ;
double lng = Convert.ToDouble(dataGridView1.Rows[i].Cells[10].Value);
string Vehicle = Convert.ToString(dataGridView1.Rows[i].Cells[5].Value);
string name = Convert.ToString(dataGridView1.Rows[i].Cells[1].Value);
string Adress = Convert.ToString(dataGridView1.Rows[i].Cells[2].Value);
MapaContr.MapProvider = GMapProviders.GoogleHybridMap;
GMapOverlay markersOverlay = new GMapOverlay("markers");
GMarkerGoogle marker = new GMarkerGoogle(new PointLatLng(lat, lng), GMarkerGoogleType.lightblue);
markersOverlay.Markers.Add(marker);
marker.ToolTipMode = MarkerTooltipMode.Always;
marker.ToolTip = new GMapRoundedToolTip(marker);
marker.ToolTipText = "Adress: " + Adress + "\nIme: " + name + "\nVehicle:" + Vehicle ;
MapaContr.Overlays.Add(markersOverlay);
I am made solution for multiple markers on Gmap from MySql data base and datagridView(dataGridView1) solution. Its very precision and easy to manage.
I'm a rookie, as evinced by my question, and I'm using a datareader to find the rows associated with a certain subId value. I used a while(dr.read) loop and nested a switch case statement with other readers in each case (code below), but I threw the exception "already an open data reader associated with this command which must be closed first." Is there a way to store the results of the first datareader (the relevant rows where subId = x) in an array, or list, and then close that reader before I enter my switch statement? (I understand what an array is to the extent that I imagine it would work, but I haven't a clue what the syntax would look like).
string viewQuery = "SELECT ProductId FROM SubmissionProducts WHERE SubmissionId =" + x;
using (SqlCommand viewcmd = new SqlCommand(viewQuery, editConn))
{
SqlDataReader dr = viewcmd.ExecuteReader();
while (dr.Read())
{
switch(dr.GetInt32(0))
{
case 1:
PanelEplShow.Visible = true;
using (SqlCommand eplviewcmd = new SqlCommand(epl, editConn))
{
SqlDataReader epldr = eplviewcmd.ExecuteReader();
epldr.Read();
LblEplShowEntity.Text = epldr.GetString(0);
LblEplShowTotalEmpl.Text = epldr.GetInt32(1).ToString();
LblEplShowCalEmpl.Text = epldr.GetInt32(2).ToString();
LblEplShowMichEmpl.Text = epldr.GetInt32(3).ToString();
LblEplShowNyEmpl.Text = epldr.GetInt32(4).ToString();
LblEplShowNjEmpl.Text = epldr.GetInt32(5).ToString();
LblEplShowPrimEx.Text = epldr.GetInt32(6).ToString();
LblEplShowLim.Text = epldr.GetInt32(7).ToString();
LblEplShowPrem.Text = epldr.GetInt32(8).ToString();
LblEplShowWage.Text = epldr.GetInt32(9).ToString();
LblEplShowInvestCost.Text = epldr.GetInt32(10).ToString();
epldr.Close();
}
break;
case 2:
PanelProfShow.Visible = true;
using (SqlCommand profcmd1 = new SqlCommand(prof, editConn))
{
SqlDataReader profdr = profcmd1.ExecuteReader();
profdr.Read();
LblProfShowPrimEx.Text = profdr.GetInt32(0).ToString();
LblProfShowType.Text = profdr.GetInt32(1).ToString();
LblProfShowLim.Text = profdr.GetInt32(2).ToString();
LblProfShowRetention.Text = profdr.GetInt32(3).ToString();
LblProfShowAtt.Text = profdr.GetInt32(4).ToString();
LblProfShowPrem.Text = profdr.GetInt32(5).ToString();
LblProfShowSublim.Text = profdr.GetInt32(5).ToString();
LblProfShowEntity.Text = profdr.GetInt32(6).ToString();
profdr.Close();
}
break;
case 3:
PanelCrimeShow.Visible = true;
using (SqlCommand crimcmd = new SqlCommand(crim, editConn))
{
SqlDataReader crimdr = crimcmd.ExecuteReader();
crimdr.Read();
LblCrimeShowEntity.Text = crimdr.GetString(0);
LblCrimeShowEmpl.Text = crimdr.GetInt32(1).ToString();
LblCrimeShowPrimEx.Text = crimdr.GetInt32(2).ToString();
LblCrimeShowLimA.Text = crimdr.GetInt32(3).ToString();
LblCrimeShowDedA.Text = crimdr.GetInt32(4).ToString();
LblCrimeShowPremA.Text = crimdr.GetInt32(5).ToString();
LblCrimeShowLimB.Text = crimdr.GetInt32(6).ToString();
LblCrimeShowDedB.Text = crimdr.GetInt32(7).ToString();
LblCrimeShowPremB.Text = crimdr.GetInt32(8).ToString();
crimdr.Close();
}
break;
case 4:
PanelFidShow.Visible = true;
using (SqlCommand fidcmd = new SqlCommand(fid, editConn))
{
SqlDataReader fiddr = fidcmd.ExecuteReader();
fiddr.Read();
LblFidShowEntity.Text = fiddr.GetString(0);
LblFidShowPrimEx.Text = fiddr.GetInt32(1).ToString();
LblFidShowLim.Text = fiddr.GetInt32(2).ToString();
LblFidShowSir.Text = fiddr.GetInt32(3).ToString();
LblFidShowAtt.Text = fiddr.GetInt32(4).ToString();
LblFidShowPrem.Text = fiddr.GetInt32(5).ToString();
LblFidShowSublim.Text = fiddr.GetInt32(6).ToString();
fiddr.Close();
}
break;
case 5:
PanelNotShow.Visible = true;
using (SqlCommand notcmd = new SqlCommand(not, editConn))
{
SqlDataReader notdr = notcmd.ExecuteReader();
notdr.Read();
LblNotShowPrimEx.Text = notdr.GetInt32(0).ToString();
LblNotShowCov.Text = notdr.GetInt32(1).ToString();
LblNotShowSharedLim.Text = notdr.GetInt32(2).ToString();
LblNotShowTradLim.Text = notdr.GetInt32(3).ToString();
LblNotShowTradSir.Text = notdr.GetInt32(4).ToString();
LblNotShowEplLim.Text = notdr.GetInt32(5).ToString();
LblNotShowEplSir.Text = notdr.GetInt32(6).ToString();
LblNotShowEplPrem.Text = notdr.GetInt32(7).ToString();
LblNotShowSublim.Text = notdr.GetInt32(8).ToString();
notdr.Close();
}
break;
case 6:
PanelPrivShow.Visible = true;
using (SqlCommand privcmd = new SqlCommand(priv, editConn))
{
SqlDataReader privdr = privcmd.ExecuteReader();
privdr.Read();
LblPrivShowPrimEx.Text = privdr.GetInt32(0).ToString();
LblPrivShowSharedLim.Text = privdr.GetInt32(1).ToString();
LblPrivShowTradLim.Text = privdr.GetInt32(2).ToString();
LblPrivShowTradAtt.Text = privdr.GetInt32(3).ToString();
LblPrivShowTradSir.Text = privdr.GetInt32(4).ToString();
LblPrivShowTradPrem.Text = privdr.GetInt32(5).ToString();
LblPrivShowEplLim.Text = privdr.GetInt32(6).ToString();
LblPrivShowEplSir.Text = privdr.GetInt32(7).ToString();
LblPrivShowEplAtt.Text = privdr.GetInt32(8).ToString();
LblPrivShowEplPrem.Text = privdr.GetInt32(9).ToString();
LblPrivShowEplWage.Text = privdr.GetInt32(10).ToString();
LblPrivShowEplSublim.Text = privdr.GetInt32(11).ToString();
LblPrivShowFidLim.Text = privdr.GetInt32(12).ToString();
LblPrivShowFidSir.Text = privdr.GetInt32(13).ToString();
LblPrivShowFidAtt.Text = privdr.GetInt32(14).ToString();
LblPrivShowFidPrem.Text = privdr.GetInt32(15).ToString();
LblPrivShowFidSublim.Text = privdr.GetInt32(16).ToString();
privdr.Close();
}
break;
case 7:
PanelPubShow.Visible = true;
using (SqlCommand pubcmd = new SqlCommand(pub, editConn))
{
SqlDataReader pubdr = pubcmd.ExecuteReader();
pubdr.Read();
LblPubShowMark.Text = pubdr.GetInt32(0).ToString();
LblPubShowTick.Text = pubdr.GetInt32(1).ToString();
LblPubShowTrad.Text = pubdr.GetInt32(2).ToString();
LblPubShowDic.Text = pubdr.GetInt32(3).ToString();
LblPubShowLim.Text = pubdr.GetInt32(4).ToString();
LblPubShowSecSir.Text = pubdr.GetInt32(5).ToString();
LblPubShowAllSir.Text = pubdr.GetInt32(6).ToString();
LblPubShowPrem.Text = pubdr.GetInt32(7).ToString();
LblPubShowPrimEx.Text = pubdr.GetInt32(8).ToString();
LblPubShowAtt.Text = pubdr.GetInt32(9).ToString();
LblPubShowSublim.Text = pubdr.GetInt32(10).ToString();
pubdr.Close();
}
break;
default:
break;
}
}
dr.Close();`
Load it into a DataTable.
SqlDataReader pubdr = pubcmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(pubdr);
To expand on the comments:
foreach (DataRow dr in dt.Rows)
{
LblEplShowEntity.Text = dr["FIELDNAME"].ToString();
//...
}
Load a DataTable instead, which internally is a persisted DataReader anyway
For a DataReader you consume, use, discard. This is the nature of DataReaders. If you want the data to hang around, you'd use a DataTable. Simple, but a good rule of thumb.
Assuming SubmissionId is unique in the table SubmissionProducts , you don't need to use a data reader for the query. You can instead use the ExecuteScalar method of the command object.
If you want to get an array of all the collumn values in the current row from a DataReader you can use the GetValues method like this:
SqlDataReader reader; // assumming the data reader is already opened
object[] columns = new object[reader.FieldCount];
reader.GetValues(columns);// columns now contains all the values from the curent row
I found I had to adjust something in my connection string. I don't know if it's a .Net glitch or whether it's just a necessary adjustment when using nested readers, but I had to add MultipleActiveResultSets="true" to my stored connection string. Afterwards, everything worked properly, with no need for a datatable. Many thanks to everyone who answered. While I'm sure the answers above could also have worked, in case this question is of any utility to someone in the future, I'm posting the full code to show what worked for me. Word of caution: if you're new enough to coding to need this post, PARAMETERIZE your queries. This site was a training project where I was instructed to avoid parameterizing in the interest of learning other things first, but it's paramount. Bobby tables ftw.
Here's the code.
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class View : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string x = Request.QueryString["SubmissionId"];
string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;
string editCustQuery = "SELECT CustName, SicNaic, CustCity, CustAdd, CustState, CustZip FROM Customer WHERE SubId =" + x;
string editBroQuery = "SELECT BroName, BroAdd, BroCity, BroState, BroZip, EntityType FROM Broker WHERE SubId =" + x;
string editSubQuery = "SELECT Coverage, CurrentCoverage, PrimEx, Retention, EffectiveDate, Commission, Premium, Comments FROM Submission WHERE SubmissionId =" + x;
string epl = "SELECT Entity, Employees, CA, MI, NY, NJ, Primex, EplLim, EplSir, Premium, Wage, Sublim FROM EPL WHERE SubmissionId =" + x;
string prof = "SELECT Primex, EO, Limit, Retention, Att, Prem, Sublim, Entity FROM ProfessionalEO WHERE SubmissionId =" + x;
string crim = "SELECT Entity, Employees, PrimEx, LimA, DedA, PremA, LimitB, DedB, PremB FROM CrimeFidelity WHERE SubmissionId =" + x;
string fid = "SELECT Entity, PrimEx, Limit, SIR, Att, Premium, Sublim FROM Fiduciary WHERE SubmissionId =" + x;
string not = "SELECT PrimEx, Coverage, SharedSepLim, TradLim, TradDoSir, EplLim, EplSir, EplPrem, EplSublim FROM NotProfit WHERE SubmissionId =" + x;
string priv = "SELECT Primex, SharedSepLim, TradLim, TradAtt, TradDoSir, TradPrem, EplLim, EplSir, EplAtt, EplWage, EplPrem, EplInvest, FidLim, FidSir, FidAtt, FidPrem, FidSublim FROM PrivateCompany WHERE SubmissionId =" + x;
string pub = "SELECT Market, Ticker, TradABC, DIC, Limit, SecuritiesSir, OtherSir, Premium, PrimEx, Att, Sublim FROM PublicDO WHERE SubmissionId =" + x;
using (SqlConnection editConn = new SqlConnection(connectionString))
{
editConn.Open();
using (SqlCommand CustCommand = new SqlCommand(editCustQuery, editConn))
{
SqlDataReader dr = CustCommand.ExecuteReader();
dr.Read();
LblCustName.Text = dr.GetString(0);
LblSicNaic.Text = dr.GetString(1);
LblCustCity.Text = dr.GetString(2);
LblCustAddress.Text = dr.GetString(3);
LblCustState.Text = dr.GetString(4);
LblCustZip.Text = dr.GetInt32(5).ToString();
dr.Close();
}
using (SqlCommand BroCommand = new SqlCommand(editBroQuery, editConn))
{
SqlDataReader dr = BroCommand.ExecuteReader();
dr.Read();
LblBroName.Text = dr.GetString(0);
LblBroAddress.Text = dr.GetString(1);
LblBroCity.Text = dr.GetString(2);
LblBroState.Text = dr.GetString(3);
LblBroZip.Text = dr.GetInt32(4).ToString();
LblEntity.Text = dr.GetString(5);
dr.Close();
}
using (SqlCommand SubCommand = new SqlCommand(editSubQuery, editConn))
{
SqlDataReader dr = SubCommand.ExecuteReader();
dr.Read();
LblCoverage.Text = dr.GetInt32(0).ToString();
LblCurrentCoverage.Text = dr.GetInt32(1).ToString();
LblPrimEx.Text = dr.GetInt32(2).ToString();
LblRetention.Text = dr.GetInt32(3).ToString();
LblEffectDate.Text = dr.GetDateTime(4).ToString();
LblCommission.Text = dr.GetInt32(5).ToString();
LblPremium.Text = dr.GetInt32(6).ToString();
LblComments.Text = dr.GetString(7);
dr.Close();
HyperLink1.NavigateUrl = "~/ViewEdit.aspx?SubmissionId=" + x;
}
string viewQuery = "SELECT ProductId FROM SubmissionProducts WHERE SubmissionId =" + x;
SqlCommand viewcmd = new SqlCommand(viewQuery, editConn);
SqlDataReader drRows = viewcmd.ExecuteReader();
while (drRows.Read())
{
switch (drRows.GetInt32(0))
{
case 1:
PanelEplShow.Visible = true;
using (SqlCommand eplviewcmd = new SqlCommand(epl, editConn))
{
SqlDataReader epldr = eplviewcmd.ExecuteReader();
epldr.Read();
LblEplShowEntity.Text = epldr.GetString(0);
LblEplShowTotalEmpl.Text = epldr.GetInt32(1).ToString();
LblEplShowCalEmpl.Text = epldr.GetInt32(2).ToString();
LblEplShowMichEmpl.Text = epldr.GetInt32(3).ToString();
LblEplShowNyEmpl.Text = epldr.GetInt32(4).ToString();
LblEplShowNjEmpl.Text = epldr.GetInt32(5).ToString();
LblEplShowPrimEx.Text = epldr.GetInt32(6).ToString();
LblEplShowLim.Text = epldr.GetInt32(7).ToString();
LblEplShowSir.Text = epldr.GetInt32(8).ToString();
LblEplShowPrem.Text = epldr.GetInt32(9).ToString();
LblEplShowWage.Text = epldr.GetInt32(10).ToString();
LblEplShowInvestCost.Text = epldr.GetInt32(11).ToString();
epldr.Close();
}
break;
case 2:
PanelProfShow.Visible = true;
using (SqlCommand profcmd = new SqlCommand(prof, editConn))
{
SqlDataReader profdr = profcmd.ExecuteReader();
profdr.Read();
LblProfShowPrimEx.Text = profdr.GetInt32(0).ToString();
LblProfShowType.Text = profdr.GetString(1);
LblProfShowLim.Text = profdr.GetInt32(2).ToString();
LblProfShowRetention.Text = profdr.GetInt32(3).ToString();
LblProfShowAtt.Text = profdr.GetInt32(4).ToString();
LblProfShowPrem.Text = profdr.GetInt32(5).ToString();
LblProfShowSublim.Text = profdr.GetInt32(6).ToString();
LblProfShowEntity.Text = profdr.GetString(7);
profdr.Close();
}
break;
case 3:
PanelCrimeShow.Visible = true;
using (SqlCommand crimcmd = new SqlCommand(crim, editConn))
{
SqlDataReader crimdr = crimcmd.ExecuteReader();
crimdr.Read();
LblCrimeShowEntity.Text = crimdr.GetString(0);
LblCrimeShowEmpl.Text = crimdr.GetInt32(1).ToString();
LblCrimeShowPrimEx.Text = crimdr.GetInt32(2).ToString();
LblCrimeShowLimA.Text = crimdr.GetInt32(3).ToString();
LblCrimeShowDedA.Text = crimdr.GetInt32(4).ToString();
LblCrimeShowPremA.Text = crimdr.GetInt32(5).ToString();
LblCrimeShowLimB.Text = crimdr.GetInt32(6).ToString();
LblCrimeShowDedB.Text = crimdr.GetInt32(7).ToString();
LblCrimeShowPremB.Text = crimdr.GetInt32(8).ToString();
crimdr.Close();
}
break;
case 4:
PanelFidShow.Visible = true;
using (SqlCommand fidcmd = new SqlCommand(fid, editConn))
{
SqlDataReader fiddr = fidcmd.ExecuteReader();
fiddr.Read();
LblFidShowEntity.Text = fiddr.GetString(0);
LblFidShowPrimEx.Text = fiddr.GetInt32(1).ToString();
LblFidShowLim.Text = fiddr.GetInt32(2).ToString();
LblFidShowSir.Text = fiddr.GetInt32(3).ToString();
LblFidShowAtt.Text = fiddr.GetInt32(4).ToString();
LblFidShowPrem.Text = fiddr.GetInt32(5).ToString();
LblFidShowSublim.Text = fiddr.GetInt32(6).ToString();
fiddr.Close();
}
break;
case 5:
PanelNotShow.Visible = true;
using (SqlCommand notcmd = new SqlCommand(not, editConn))
{
SqlDataReader notdr = notcmd.ExecuteReader();
notdr.Read();
LblNotShowPrimEx.Text = notdr.GetInt32(0).ToString();
LblNotShowCov.Text = notdr.GetInt32(1).ToString();
LblNotShowSharedLim.Text = notdr.GetInt32(2).ToString();
LblNotShowTradLim.Text = notdr.GetInt32(3).ToString();
LblNotShowTradSir.Text = notdr.GetInt32(4).ToString();
LblNotShowEplLim.Text = notdr.GetInt32(5).ToString();
LblNotShowEplSir.Text = notdr.GetInt32(6).ToString();
LblNotShowEplPrem.Text = notdr.GetInt32(7).ToString();
LblNotShowSublim.Text = notdr.GetInt32(8).ToString();
notdr.Close();
}
break;
case 6:
PanelPrivShow.Visible = true;
using (SqlCommand privcmd = new SqlCommand(priv, editConn))
{
SqlDataReader privdr = privcmd.ExecuteReader();
privdr.Read();
LblPrivShowPrimEx.Text = privdr.GetInt32(0).ToString();
LblPrivShowSharedLim.Text = privdr.GetInt32(1).ToString();
LblPrivShowTradLim.Text = privdr.GetInt32(2).ToString();
LblPrivShowTradAtt.Text = privdr.GetInt32(3).ToString();
LblPrivShowTradSir.Text = privdr.GetInt32(4).ToString();
LblPrivShowTradPrem.Text = privdr.GetInt32(5).ToString();
LblPrivShowEplLim.Text = privdr.GetInt32(6).ToString();
LblPrivShowEplSir.Text = privdr.GetInt32(7).ToString();
LblPrivShowEplAtt.Text = privdr.GetInt32(8).ToString();
LblPrivShowEplPrem.Text = privdr.GetInt32(9).ToString();
LblPrivShowEplWage.Text = privdr.GetInt32(10).ToString();
LblPrivShowEplSublim.Text = privdr.GetInt32(11).ToString();
LblPrivShowFidLim.Text = privdr.GetInt32(12).ToString();
LblPrivShowFidSir.Text = privdr.GetInt32(13).ToString();
LblPrivShowFidAtt.Text = privdr.GetInt32(14).ToString();
LblPrivShowFidPrem.Text = privdr.GetInt32(15).ToString();
LblPrivShowFidSublim.Text = privdr.GetInt32(16).ToString();
privdr.Close();
}
break;
case 7:
PanelPubShow.Visible = true;
using (SqlCommand pubcmd = new SqlCommand(pub, editConn))
{
SqlDataReader pubdr = pubcmd.ExecuteReader();
pubdr.Read();
LblPubShowMark.Text = pubdr.GetInt32(0).ToString();
LblPubShowTick.Text = pubdr.GetInt32(1).ToString();
LblPubShowTrad.Text = pubdr.GetInt32(2).ToString();
LblPubShowDic.Text = pubdr.GetString(3);
LblPubShowLim.Text = pubdr.GetInt32(4).ToString();
LblPubShowSecSir.Text = pubdr.GetInt32(5).ToString();
LblPubShowAllSir.Text = pubdr.GetInt32(6).ToString();
LblPubShowPrem.Text = pubdr.GetInt32(7).ToString();
LblPubShowPrimEx.Text = pubdr.GetInt32(8).ToString();
LblPubShowAtt.Text = pubdr.GetInt32(9).ToString();
LblPubShowSublim.Text = pubdr.GetInt32(10).ToString();
pubdr.Close();
}
break;
default:
break;
}
}
drRows.Close();
}
}
}