private void btn_Hist_Clicked(object sender, EventArgs e) { Button button = (Button)sender; Grid G1 = (Grid)button.Parent; E1 = (Entry)G1.FindByName("txt_pri"); E2 = (Entry)G1.FindByName("txt_qty"); L1 = (Label)G1.FindByName("lbl_damt"); var lvElement = (orddet)((Button)sender).BindingContext; string _citem = lvElement.od_id; string _CustID = Preferences.Get("CustID", "XXXX"); string _UserID = Preferences.Get("UserID", "XXXX"); string sql = $@"SELECT * FROM invdet WHERE i_bill = '{_CustID}' AND i_item = '{_citem}' ORDER BY i_id DESC LIMIT 3"; var list = LocalDb.db.QueryAsync <invdet>(sql).Result.ToList(); List <invdet> invdetList = new List <invdet>(); foreach (invdet dr in list) { invdet h = new invdet(); h.i_id = dr.i_id; h.i_bill = dr.i_bill; h.i_invdate = dr.i_invdate; h.i_item = dr.i_item; h.i_pri = dr.i_pri; h.i_qty = dr.i_qty; invdetList.Add(h); } detHistoryView.ItemsSource = string.Empty; detHistoryView.ItemsSource = invdetList; if (invdetList.Count() > 0) { popupDetHistoryView.IsVisible = true; } else { DisplayAlert("History", "No sold history found", "Cancel"); } }
private void SaveDetailsRecord(bool?isNew = false) { using (igortransDBcontext db = new igortransDBcontext()) { if (isNew == true) { int ln = 1; if (db.invdets.Count(x => x.invoiceid == SelectedInvoice.invoiceid) > 0) { ln = db.invdets.Where(x => x.invoiceid == SelectedInvoice.invoiceid).Max(x => x.line) + 1; } invdet selectedInvdet = new invdet { line = ln, invoiceid = db.invoices.Max(x => x.invoiceid), delivery_date = dateTimePickerAdv3.Value, line_ref = textBoxExt1.Text, comments = textBoxExt4.Text, delivery_from = textBoxExt2.Text, delivery_to = textBoxExt3.Text, @ref = richTextBox1.Text, line_total = currencyTextBox1.DecimalValue }; db.Entry(selectedInvdet).State = System.Data.Entity.EntityState.Added; db.SaveChanges(); } else { int currentInvdetid = Convert.ToInt32(listView2.SelectedItems[0].Tag); invdet selectedInvdet = db.invdets.Where(x => x.invdetid == currentInvdetid ).FirstOrDefault(); selectedInvdet.invoiceid = SelectedInvoice.invoiceid; selectedInvdet.delivery_date = dateTimePickerAdv3.Value; selectedInvdet.line_ref = textBoxExt1.Text; selectedInvdet.comments = textBoxExt4.Text; selectedInvdet.delivery_from = textBoxExt2.Text; selectedInvdet.delivery_to = textBoxExt3.Text; selectedInvdet.@ref = richTextBox1.Text; selectedInvdet.line_total = Convert.ToDecimal(currencyTextBox1.Text); db.Entry(selectedInvdet).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } } }
private void LoadDetailLine() { int lineId = Convert.ToInt32(listView2.SelectedItems[0].Tag); using (igortransDBcontext db = new igortransDBcontext()) { invdet selectedInvdet = db.invdets.Where(x => x.invdetid == lineId).FirstOrDefault(); if (selectedInvdet != null) { dateTimePickerAdv3.Value = selectedInvdet.delivery_date; textBoxExt1.Text = selectedInvdet.line_ref; textBoxExt2.Text = selectedInvdet.delivery_from; textBoxExt3.Text = selectedInvdet.delivery_to; textBoxExt4.Text = selectedInvdet.comments; richTextBox1.Text = selectedInvdet.@ref; currencyTextBox1.DecimalValue = selectedInvdet.line_total; } } }
private void DeleteDetailsLine() { int lineid = Convert.ToInt32(listView2.SelectedItems[0].Tag); using (igortransDBcontext db = new igortransDBcontext()) { invdet selectedInvdet = db.invdets.Where(x => x.invdetid == lineid).FirstOrDefault(); if (selectedInvdet != null) { db.invdets.Remove(selectedInvdet); ReloadInvoices(); ReloadInvoicesList(); LockFields(true, true); FormHelper.ViewModeButtons(BtnList, FormHelper.ViewMode.View, this.Name); panel1.BackColor = Color.Gainsboro; panel2.BackColor = Color.Gainsboro; RecalcAsyncSingleCaller(); } } }