Advertisement
Advertisement
| 07.07.2008 at 07:38AM PDT, ID: 23543494 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: |
private void btnServiceSave_Click(object sender, EventArgs e)
{
//Populate Service Types Combo Box
string commandString =
"SELECT AccountNo, ServiceNo,LinkNo, ContractStart, ContractEnd " +
"FROM dbo.TAS_ServicesTemp " +
"WHERE AccountNo IS NULL ";
// create the data set command object
// and the DataSet
DataAdapter = new SqlDataAdapter(commandString, ConnectString);
DataSet = new DataSet();
// fill the data set object
DataAdapter.Fill(DataSet, "TempServices");
// Get the one table from the DataSet
DataTable = DataSet.Tables["TempServices"];
// create a new row, populate it
for (int indexNo = 2; indexNo < lstBxServices.Items.Count; indexNo++)
{
Item ServiceItem = (Item) lstBxServices.Items[indexNo];
DataRow newRow = DataTable.NewRow();
newRow["AccountNo"] = 2;
newRow["LinkNo"] = 5;
newRow["ServiceNo"] = ServiceItem.ServiceNo;
newRow["ContractStart"] = ServiceItem.ContractStart;
newRow["ContractEnd"] = ServiceItem.ContractEnd;
DataTable.Rows.Add(newRow);
}
// update the db
DataAdapter.Update(DataSet, "TempServices");
// inform the user and accept the changes
//lblMessage.Text = DataAdapter.UpdateCommand.CommandText;
Application.DoEvents();
DataSet.AcceptChanges();
}
private class Item
{
public int ServiceNo;
public string ServiceDescription;
public string ContractStart;
public string ContractEnd;
public string Charge;
public Item(string Description, int No, string Start, string End, string Charge)
{
ServiceNo = No;
ServiceDescription = Description;
ContractStart = Start;
ContractEnd = End;
this.Charge = Charge;
}
public override string ToString()
{
return ServiceDescription;
}
public string ToString(Boolean Full)
{
if (Full)
return ServiceNo + " " + ServiceDescription + " " + ContractStart + " " + ContractEnd + " " + "R" +Charge;
else
return ServiceDescription;
}
}
|