private void GetSQLData(SqlCeDataReader getdata, bool bShow) { //tableJournal.Clear(); //journalarray.Clear(); //while (getdata.Read()) //{ //} //BindTOGrid(); try { PoArray.Clear(); dt.Clear(); while (getdata.Read()) { Object[] array = new Object[5]; PurchaseOrderModule pomodule = new PurchaseOrderModule(); array[0] = getdata["ItemNo"].ToString(); pomodule.itemno = getdata["ItemNo"].ToString(); if (!String.IsNullOrEmpty(getdata["ItemNo"].ToString())) { ItemQH.ItemQH_Service itemsev = new QHMobile.ItemQH.ItemQH_Service(); itemsev.Url = WebServiceInstants.GetURL(ServiceType.ItemQH); itemsev.Credentials = nc; ItemQH.ItemQH itemdescription = itemsev.Read(getdata["ItemNo"].ToString()); string strItemDescription; strItemDescription = itemdescription.Description; pomodule.itemDescription = strItemDescription; array[1] = strItemDescription; } else { pomodule.itemDescription = ""; array[1] = ""; } array[2] = getdata["Loc"].ToString(); pomodule.location = getdata["Loc"].ToString(); array[3] = Convert.ToInt32(getdata["Quantity"]); pomodule.quantity = getdata["Quantity"].ToString(); array[4] = Convert.ToInt32(getdata["LineNo"]); PoArray.Add(pomodule); dt.Rows.Add(array); if (bShow) { txtVendorNo.Text = getdata["VendorNo"].ToString().Trim(); txtVendorName.Text = getdata["VendorName"].ToString().Trim(); } } GrdPO.DataSource = dt; txtItemNo.Text = ""; txtItemNo.Focus(); txtLocation.Enabled = false; txtRegDate.Enabled = false; txtQty.Enabled = false; } catch (Exception ex) { MessageBox.Show("Error:" + ex); } }
private void btnAdd_Click_1(object sender, EventArgs e) { try { Cursor.Current = Cursors.WaitCursor; Object[] array = new Object[4]; PurchaseOrderModule pomodule = new PurchaseOrderModule(); array[0] = txtItemNo.Text.Trim(); //SQL to save Object[] arraySQL = new Object[7]; pomodule.itemno = txtItemNo.Text.Trim(); arraySQL[0] = txtVendorNo.Text.Trim(); arraySQL[1] = txtVendorName.Text.Trim(); arraySQL[2] = txtRegDate.Text.Trim(); arraySQL[3] = txtLocation.Text.Trim(); arraySQL[4] = txtItemNo.Text.Trim(); arraySQL[6] = Convert.ToInt32(txtQty.Text.Trim()); if (!String.IsNullOrEmpty(txtItemNo.Text.Trim())) { ItemQH.ItemQH_Service itemsev = new QHMobile.ItemQH.ItemQH_Service(); itemsev.Url = WebServiceInstants.GetURL(ServiceType.ItemQH); itemsev.Credentials = nc; ItemQH.ItemQH itemdescription = itemsev.Read(txtItemNo.Text.Trim()); string strItemDescription; strItemDescription = itemdescription.Description; pomodule.itemDescription = strItemDescription; array[1] = strItemDescription; arraySQL[5] = strItemDescription; } else { arraySQL[5] = ""; pomodule.itemDescription = ""; array[1] = ""; } array[2] = txtLocation.Text.Trim(); pomodule.location = txtLocation.Text.Trim(); array[3] = txtQty.Text.Trim(); pomodule.quantity = txtQty.Text.Trim(); PoArray.Add(pomodule); dt.Rows.Add(array); CompactSQL comsql = new CompactSQL(); comsql.InsertRecord("PurchaseOrder", arraySQL); /* * GrdPO.DataSource = dt; * * * txtItemNo.Text = ""; * txtItemNo.Focus(); * txtLocation.Enabled = false; * txtRegDate.Enabled = false; * txtQty.Enabled = false; */ //dffd getdata = comsql.SelectRecord("PurchaseOrder"); GetSQLData(getdata, false); Cursor.Current = Cursors.Default; } catch (Exception ex) { MessageBox.Show("Error:" + ex); Cursor.Current = Cursors.Default; } }