Click here to Skip to main content
15,913,587 members
Home / Discussions / C#
   

C#

 
GeneralRe: Asynchronous NetworkStream Pin
Judah Gabriel Himango21-Feb-08 4:51
sponsorJudah Gabriel Himango21-Feb-08 4:51 
GeneralC# Library needed Pin
Knowledgestudent20-Feb-08 22:44
Knowledgestudent20-Feb-08 22:44 
GeneralRe: C# Library needed Pin
Pete O'Hanlon21-Feb-08 3:02
mvePete O'Hanlon21-Feb-08 3:02 
GeneralRe: C# Library needed Pin
Knowledgestudent21-Feb-08 9:06
Knowledgestudent21-Feb-08 9:06 
GeneralRe: C# Library needed Pin
Pete O'Hanlon21-Feb-08 9:12
mvePete O'Hanlon21-Feb-08 9:12 
GeneralFocus+Validation Summary Pin
razanabanu20-Feb-08 21:03
razanabanu20-Feb-08 21:03 
GeneralRe: Focus+Validation Summary Pin
phannon8620-Feb-08 21:58
professionalphannon8620-Feb-08 21:58 
GeneralReading Data from XML Pin
nivasinfotech20-Feb-08 20:20
nivasinfotech20-Feb-08 20:20 
// ASCX file

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class PresentationLayer_Controls_ManagePaymentDetailsControl : System.Web.UI.UserControl
{
Payment ObjXMLData = new Payment();
public static int editstatus =0;
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!IsPostBack)
{
Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString()); // to avoid page refresh problem
//string opno = "0p005";
//txtOpno.Text = opno;
txtDate.Text = ObjXMLData.ConvertDate(DateTime.Today.Date.ToString().Substring(0, 10));
txtDate.Text = txtDate.Text.Substring(3, 2) + "/" + txtDate.Text.Substring(0, 2) + "/" + txtDate.Text.Substring(6, 4);
try
{
//GetData(opno, Server.MapPath("Amount.xml").ToString());
BindGrid();
}
catch (Exception ex)
{
lbl_Error.Text = ex.Message;
}
}
}
catch (Exception ex)
{
string s = ex.Message;
}
}

public void GetData(string opno, string path,int estatus)
{
try
{
DataSet ds;
DataTable dt = ObjXMLData.GetByOpNo(opno, path);
if (dt.Columns.Count > 0)
{
if (estatus == 1)
{
txtOpno.Text = dt.Rows[0].Table.Rows[0]["OpNo"].ToString();
txtName.Text = dt.Rows[0].Table.Rows[0]["Name"].ToString();
txtPaidAmount.Text = dt.Rows[0].Table.Rows[0]["PaidAmount"].ToString();
txtTotalAmount.Text = dt.Rows[0].Table.Rows[0]["TotalAmount"].ToString();
txtBalanceAmount.Text = dt.Rows[0].Table.Rows[0]["BalanceAmount"].ToString();
}
else
{
txtOpno.Text = dt.Rows[0].Table.Rows[0]["OpNo"].ToString();
txtName.Text = dt.Rows[0].Table.Rows[0]["Name"].ToString();
//txtPaidAmount.Text = dt.Rows[0].Table.Rows[0]["PaidAmount"].ToString();
//txtTotalAmount.Text = dt.Rows[0].Table.Rows[0]["TotalAmount"].ToString();
txtBalanceAmount.Text = dt.Rows[0].Table.Rows[0]["BalanceAmount"].ToString();
}
}
else
{
string msg = "<script type='text/javascript'>alert('No Records Found');</script> ";
Page.ClientScript.RegisterStartupScript(this.GetType(),"msg",msg);
}

}
catch (Exception ex)
{
string s = ex.Message;
}
}

public void BindGrid()
{
try
{
DataTable dt = null;
dt = ObjXMLData.GetAll(Server.MapPath("Amount.xml").ToString());
if (dt.Rows.Count != 0)
{
DataGrid1.DataSource = dt;
DataGrid1.DataBind();
lblcount.Text = "Total No of Records:" + dt.Rows.Count;
int pindex = DataGrid1.CurrentPageIndex + 1;
lblpageindex.Text = "Page" + pindex + " of " + DataGrid1.PageCount.ToString();
}
else
PageList.Attributes.Add("style", "display:none");
}
catch (Exception ex)
{
lbl_Error.Text = ex.Message;
}

}

protected void btnSave_Click(object sender, EventArgs e)
{
try
{
DataTable dt = ObjXMLData.GetByOpNo(txtOpno.Text.Trim().ToUpper(), Server.MapPath("Amount.xml").ToString());
Double Result;
string totalamount;
if (Session["update"].ToString() == ViewState["update"].ToString()) // to avoid page refresh problem
{
if (CheckBox1.Checked == false)
totalamount = dt.Rows[0].Table.Rows[0]["TotalAmount"].ToString();
else
totalamount = txtTotalAmount.Text;

if (Convert.ToDouble(totalamount) >= Convert.ToDouble(txtPaidAmount.Text))
{
if (CheckBox1.Checked == true)
{
Result = ObjXMLData.Update(txtOpno.Text.ToUpper(), DateTime.Now.ToString(), txtName.Text,
Convert.ToDouble(txtTotalAmount.Text) + Convert.ToDouble(txtBalanceAmount.Text), (Convert.ToDouble(dt.Rows[0].Table.Rows[0]["PaidAmount"].ToString()) + Convert.ToDouble(txtPaidAmount.Text)),
Convert.ToDouble(Convert.ToDouble(dt.Rows[0].Table.Rows[0]["TotalAmount"].ToString()) - (Convert.ToDouble(dt.Rows[0].Table.Rows[0]["PaidAmount"].ToString()) + Convert.ToDouble(txtPaidAmount.Text))), Server.MapPath("").ToString());
}
else
{
Result = ObjXMLData.Update(txtOpno.Text.ToUpper(), DateTime.Now.ToString(), txtName.Text,
Convert.ToDouble(dt.Rows[0].Table.Rows[0]["TotalAmount"].ToString()), (Convert.ToDouble(dt.Rows[0].Table.Rows[0]["PaidAmount"].ToString()) + Convert.ToDouble(txtPaidAmount.Text)),
Convert.ToDouble(Convert.ToDouble(dt.Rows[0].Table.Rows[0]["TotalAmount"].ToString()) - (Convert.ToDouble(dt.Rows[0].Table.Rows[0]["PaidAmount"].ToString()) + Convert.ToDouble(txtPaidAmount.Text))), Server.MapPath("").ToString());
}

if (Result >= 1)
{

lbl_Error.Text = " Trasaction Status : Success ";
BindGrid();
}
else
{
lbl_Error.Text = " Transaction Status : Fail ";
}
}
else
{
lbl_Error.Text = " Transaction Status : Fail ";
}
}
}
catch (Exception ex)
{
string s = ex.Message;
}
}

protected void Page_PreRender(Object s, System.EventArgs e)
{
ViewState["update"] = Session["update"];
}
protected void DataGrid1_ItemCommand(object source, DataGridCommandEventArgs e)
{
if (e.CommandName == "Editing")
{
editstatus = 1;
CheckBox1.Checked = true;
total.Attributes.Add("style", "Display:block");
GetData(e.CommandArgument.ToString(), Server.MapPath("Amount.xml").ToString(), editstatus);
}
}
protected void btnReset_Click(object sender, EventArgs e)
{
editstatus = 0;
txtBalanceAmount.Text = "";
txtOpno.Text = "";
txtPaidAmount.Text = "";
txtTotalAmount.Text = "";
txtName.Text = "";
}
protected void txtOpno_TextChanged(object sender, EventArgs e)
{
if (txtOpno.Text != "")
{
editstatus = 0;
GetData(txtOpno.Text.Trim().ToUpper(), Server.MapPath("Amount.xml").ToString(), editstatus);
}
}
protected void txtTotalAmount_TextChanged(object sender, EventArgs e)
{
DataTable dt = ObjXMLData.GetByOpNo(txtOpno.Text.Trim().ToUpper(), Server.MapPath("Amount.xml").ToString());
if (editstatus == 0)
{
if (txtTotalAmount.Text.Trim() != "" && txtPaidAmount.Text.Trim() != "" && CheckBox1.Checked == true)
txtBalanceAmount.Text = Convert.ToString((Convert.ToDouble(txtTotalAmount.Text) + Convert.ToDouble(dt.Rows[0].Table.Rows[0]["BalanceAmount"].ToString())) - Convert.ToDouble(txtPaidAmount.Text));
else if (txtPaidAmount.Text.Trim() != "")
txtBalanceAmount.Text = Convert.ToString(Convert.ToDouble(dt.Rows[0].Table.Rows[0]["BalanceAmount"].ToString()) - Convert.ToDouble(txtPaidAmount.Text));
else
txtBalanceAmount.Text = dt.Rows[0].Table.Rows[0]["BalanceAmount"].ToString();

}
else
{
if (txtTotalAmount.Text.Trim() != "" && txtPaidAmount.Text.Trim() != "")
txtBalanceAmount.Text = Convert.ToString(Convert.ToDouble(txtTotalAmount.Text) - Convert.ToDouble(txtPaidAmount.Text));
else
txtBalanceAmount.Text = dt.Rows[0].Table.Rows[0]["BalanceAmount"].ToString();
}
}
protected void txtPaidAmount_TextChanged(object sender, EventArgs e)
{
DataTable dt = ObjXMLData.GetByOpNo(txtOpno.Text.Trim().ToUpper(), Server.MapPath("Amount.xml").ToString());

if (editstatus == 0 )
{
if (txtTotalAmount.Text.Trim() != "" && txtPaidAmount.Text.Trim() != "" && CheckBox1.Checked == true)
txtBalanceAmount.Text = Convert.ToString((Convert.ToDouble(txtTotalAmount.Text) + Convert.ToDouble(dt.Rows[0].Table.Rows[0]["BalanceAmount"].ToString())) - Convert.ToDouble(txtPaidAmount.Text));
else if (txtPaidAmount.Text.Trim() != "")
txtBalanceAmount.Text = Convert.ToString(Convert.ToDouble(dt.Rows[0].Table.Rows[0]["BalanceAmount"].ToString()) - Convert.ToDouble(txtPaidAmount.Text));
else
txtBalanceAmount.Text = dt.Rows[0].Table.Rows[0]["BalanceAmount"].ToString();


}
else
{
if (txtTotalAmount.Text.Trim() != "" && txtPaidAmount.Text.Trim() != "")
txtBalanceAmount.Text = Convert.ToString(Convert.ToDouble(txtTotalAmount.Text) - Convert.ToDouble(txtPaidAmount.Text));
else
txtBalanceAmount.Text = dt.Rows[0].Table.Rows[0]["BalanceAmount"].ToString();
}

}
protected void DataGrid1_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
{
try
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
int pindex = DataGrid1.CurrentPageIndex + 1;
lblpageindex.Text = "Page" + pindex + " of " + DataGrid1.PageCount.ToString();
BindGrid();
}
catch (Exception ex)
{
string s = ex.Message;
}
}
protected void ddlpagecount_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
DataTable dt = null;
dt = ObjXMLData.GetAll(Server.MapPath("Amount.xml").ToString());
DataGrid1.CurrentPageIndex = 0;
if (ddlpagecount.SelectedValue == "All")
{
DataGrid1.PageSize = dt.Rows.Count;
}
else
{
DataGrid1.PageSize = Convert.ToInt32(ddlpagecount.SelectedValue);
}

BindGrid();
int pindex = DataGrid1.CurrentPageIndex + 1;
lblpageindex.Text = "Page" + pindex + " of " + DataGrid1.PageCount.ToString();
}
catch (Exception ex)
{
string s = ex.Message;
}
}
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
if(CheckBox1.Checked == true)
total.Attributes.Add("style","Display:block");
else
total.Attributes.Add("style", "Display:none");
}
}

srinivas

GeneralRe: Reading Data from XML Pin
nivasinfotech20-Feb-08 20:22
nivasinfotech20-Feb-08 20:22 
GeneralRe: Reading Data from XML Pin
Pete O'Hanlon21-Feb-08 0:56
mvePete O'Hanlon21-Feb-08 0:56 
GeneralRe: Reading Data from XML Pin
Le centriste21-Feb-08 6:20
Le centriste21-Feb-08 6:20 
GeneralScolling two listviews simeltaniously Pin
DnyanAnand20-Feb-08 19:35
professionalDnyanAnand20-Feb-08 19:35 
GeneralRe: Scolling two listviews simeltaniously Pin
Christian Graus20-Feb-08 20:14
protectorChristian Graus20-Feb-08 20:14 
GeneralRe: Scolling two listviews simeltaniously Pin
DnyanAnand20-Feb-08 20:36
professionalDnyanAnand20-Feb-08 20:36 
QuestionHelp Required in File Operations. Pin
deepaks320-Feb-08 18:47
deepaks320-Feb-08 18:47 
GeneralRe: Help Required in File Operations. Pin
Christian Graus20-Feb-08 20:06
protectorChristian Graus20-Feb-08 20:06 
GeneralRe: Help Required in File Operations. Pin
Vikram A Punathambekar20-Feb-08 21:26
Vikram A Punathambekar20-Feb-08 21:26 
GeneralRe: Help Required in File Operations. Pin
Guffa20-Feb-08 22:46
Guffa20-Feb-08 22:46 
GeneralDownloading files from FTP using C#.Net 1.1 Pin
pavya_Cool20-Feb-08 18:44
pavya_Cool20-Feb-08 18:44 
GeneralRe: Downloading files from FTP using C#.Net 1.1 Pin
N a v a n e e t h20-Feb-08 19:54
N a v a n e e t h20-Feb-08 19:54 
Questionfrozen column in Listview ? Pin
Xmen Real 20-Feb-08 18:26
professional Xmen Real 20-Feb-08 18:26 
AnswerRe: frozen column in Listview ? Pin
Dave Kreskowiak21-Feb-08 5:10
mveDave Kreskowiak21-Feb-08 5:10 
Generalwhy use | instead of || and same with & and && Pin
Xmen Real 20-Feb-08 18:06
professional Xmen Real 20-Feb-08 18:06 
GeneralRe: why use | instead of || and same with & and && Pin
mav.northwind20-Feb-08 19:27
mav.northwind20-Feb-08 19:27 
GeneralRe: why use | instead of || and same with & and && Pin
darkelv20-Feb-08 19:34
darkelv20-Feb-08 19:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.