private void buttonCreateBill_Click(object sender, EventArgs e)
{
var data = new BillData();
data.posNo = textBoxPosNo.Text;
data.amount = textBoxAmount.Text;
data.vat = textBoxVat.Text;
data.cashAmount = textBoxCash.Text;
data.nonCashAmount = textBoxNonCash.Text;
data.billIdSuffix = textBoxNumber.Text;
var lstBillStock = new List<BillDetail>();
foreach (DataGridViewRow row in dataGridViewStocks.Rows)
{
if (!row.IsNewRow)
{
var stock = new BillDetail();
stock.code = row.Cells["Code"].Value.ToString();
stock.name = row.Cells["ItemName"].Value.ToString();
stock.measureUnit = row.Cells["MeasureUnit"].Value.ToString();
stock.qty = row.Cells["Qty"].Value.ToString();
stock.unitPrice = row.Cells["UnitPriceNonVat"].Value.ToString();
stock.totalAmount = row.Cells["Amount"].Value.ToString();
stock.vat = row.Cells["Vat"].Value.ToString();
stock.barCode = row.Cells["BarCode"].Value.ToString();
stock.cityTax = row.Cells["CityTax"].Value.ToString();
lstBillStock.Add(stock);
}
}
data.cityTax = textBoxCityTax.Text;
data.bankTransactions = this.ListBankTranscation;
if (lstBillStock.Count == 0)
{
lstBillStock = null;
}
data.stocks = lstBillStock;
data.districtCode = textBoxDistrict.Text;
var json = new JavaScriptSerializer().Serialize(data);
var result = Program.put(json);
this.resultData = new JavaScriptSerializer().Deserialize<Result>(result);
if ("True".Equals(this.resultData.success.ToString()))
{
print();
}
else { MessageBox.Show(resultData.message); }
}