using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;
namespace SaleLog
{
///
/// Summary description for frmunitupdate.
///
public class frmunitupdate : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.DropDownList cbounit;
protected System.Web.UI.WebControls.Button cmdclear;
protected System.Web.UI.WebControls.Image Image2;
protected System.Web.UI.WebControls.TextBox txtupdateprice;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.Label Label3;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!IsPostBack)
{
BindUnitTypeCombo();
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.cmdclear.Click += new System.EventHandler(this.cmdclear_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void cmdclear_Click(object sender, System.EventArgs e)
{
string sqlQry = string.Empty;
int PurchasePrice = 0;
PurchasePrice = Convert.ToInt32(txtupdateprice.Text);
int UnitType = Convert.ToInt32(cbounit.SelectedValue);
sqlQry = "UPDATE Inventory SET Inventory.PurchasePrice = [PurchasePrice]+ " + PurchasePrice;
sqlQry = sqlQry + " WHERE Inventory.UnitType=" + UnitType;
OleDbConnection cn=new OleDbConnection(ConfigurationSettings.AppSettings["ConnectionString"].ToString());
cn.Open();
OleDbCommand cmdInsClient=new OleDbCommand(sqlQry,cn);
cmdInsClient.CommandType.ToString();
cmdInsClient.ExecuteNonQuery();
cmdInsClient.Dispose();
cn.Close();
Label4.Visible = true;
txtupdateprice.Text = "";
}
private void BindUnitTypeCombo()
{
String strCLQuery;
OleDbConnection cn=new OleDbConnection(ConfigurationSettings.AppSettings["ConnectionString"].ToString());
cn.Open();
strCLQuery="Select UnitTypeID,UnitTypeCode + ' ' + UnitType as myUnit from UnitType Where ProjectID=" + Convert.ToInt32(Session["ProjectID"]);
OleDbCommand cmdClientStatus=new OleDbCommand(strCLQuery,cn);
cmdClientStatus.ExecuteNonQuery();
OleDbDataAdapter DAStatus = new OleDbDataAdapter();
DAStatus.SelectCommand=cmdClientStatus;
DataSet dsStatus=new DataSet();
DAStatus.Fill(dsStatus);
DataRow row = dsStatus.Tables[0].NewRow();
row[0] = -1;
row[1] = "-- Select --";
dsStatus.Tables[0].Rows.Add(row);
cbounit.DataSource=dsStatus;
cbounit.DataTextField="myUnit";
cbounit.DataValueField="UnitTypeID";
cbounit.DataBind();
cn.Close();
}
}
}