private void iNVOICE_HEADERBindingNavigatorSaveItem_Click(object sender, EventArgs e) { DataView dvn = new DataView(dataSet2.invoice_items); foreach (DataRowView r in dvn) { if (r.Row["prod_id"].ToString().Length < 2) { r.Row.Delete(); } } doTotal(); this.invoice_unpaidTextBox.Text = this.totalTextBox.Text; this.Validate(); ((DataRowView)iNVOICE_HEADERBindingSource.Current).Row["invoice_date"] = Convert.ToDateTime(((DataRowView)iNVOICE_HEADERBindingSource.Current).Row["invoice_date"]).ToString("dd/MM/yyyy"); ((DataRowView)iNVOICE_HEADERBindingSource.Current).Row["sort_date"] = Convert.ToDateTime(((DataRowView)iNVOICE_HEADERBindingSource.Current).Row["invoice_date"]).ToString("yyyyMMdd"); this.Validate(); this.iNVOICE_HEADERBindingSource.EndEdit(); this.invoice_itemsBindingSource.EndEdit(); this.tableAdapterManager.UpdateAll(this.dataSet2); Vectra.DataSet2TableAdapters.configurationTableAdapter da = new Vectra.DataSet2TableAdapters.configurationTableAdapter(); string acnt_period = da.getCurrentAcntPeriod().ToString(); DataRowView dv = (DataRowView)this.iNVOICE_HEADERBindingSource.Current; string cmd = @"update customer_trans set t_amount = {0}, t_unpaid = {0}, t_week_id = '{4}', t_src_dckt_id = '{5}', t_date = '{6}' where t_type = '{1}' and t_cust_id = {2} and t_src_id = {3}"; this.sqLiteConnection1.ConnectionString = myConfig.connstr; this.sqLiteConnection1.Open(); this.sqLiteCommand1.CommandText = String.Format(cmd, dv.Row["invoice_amount"].ToString(), "Invoice", dv.Row["cust_id"], dv.Row["invoice_number"], acnt_period.ToString(), dv.Row["docket_number"].ToString(), dv.Row["invoice_date"].ToString()); this.sqLiteCommand1.ExecuteNonQuery(); this.sqLiteConnection1.Close(); foreach (DataRowView r in dvn) { if (r.Row["prod_id"].ToString().Length < 2) { r.Row.Delete(); } } Close(); //close the form }
private string getAcntPeriod() { Vectra.DataSet2TableAdapters.configurationTableAdapter da = new Vectra.DataSet2TableAdapters.configurationTableAdapter(); return da.getCurrentAcntPeriod().ToString(); }