public testwindow() { InitializeComponent(); ledger l = new ledger() {Lname = "hello" , Lid = 45 }; listBox1.Items.Add(l); ledger l2 = new ledger() { Lname = "yo", Lid = 755252}; listBox1.Items.Add(l2); double a = 12050314; textBox1.Text = a.ToString("C2"); }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { ledgermodel l = new ledgermodel(); url = null; OleDbDataReader dr = l.getgroup(3); while (dr.Read()) { string img = @System.AppDomain.CurrentDomain.BaseDirectory + "\\images\\" + dr.GetValue(1).ToString() + ".jpg"; if (!File.Exists(img)) { img = @System.AppDomain.CurrentDomain.BaseDirectory + "\\images\\default.jpg"; } ledgerbalance x = (from a in application.tb where a.Lid == int.Parse(dr.GetValue(0).ToString()) select a).First<ledgerbalance>(); String y = x.Balance.ToString(); if (y == "0") { y = "Nil"; } ledger lb = new ledger() { Lid = int.Parse(dr.GetValue(0).ToString()), Lname = dr.GetValue(1).ToString(), Laddress = dr.GetValue(2).ToString(), Lphoneno = dr.GetValue(3).ToString(), Lemail = dr.GetValue(4).ToString(), Limage = img, Balance = y, BalanceType = x.BalanceType }; lc.Add(lb); } listBox1.ItemsSource = lc; }
private void button1_Click(object sender, RoutedEventArgs e) { ledgermodel l = new ledgermodel(txtlname.Text, 3, txtladd.Text, txtlno.Text, txtlmail.Text); //Hashtable error = l.checkvalid(); //int a = l. if (txtladd.Text.Trim().ToString() == "" || txtlmail.Text.Trim().ToString() == "" || txtlname.Text.Trim().ToString() == "" || txtlno.Text.Trim().ToString()=="") { Show("Please Enter all Data of Supplier",2); return; } if (!(Regex.IsMatch(txtlno.Text, @"^\+?(\d[\d-. ]+)?(\([\d-. ]+\))?[\d-. ]+\d$")) || txtlno.Text.Length < 6 || txtlno.Text.Length > 10) { Show("Please Enter Valid Phone No.",2); return; } if (!Regex.IsMatch(txtlmail.Text, @"^\S+@\S+$")) { Show("Please Enter Valid Email id No.",2); return; } if (l.insert(this)) { Show("Supplier Saved",1); txtlname.ClearValue(TextBox.BorderBrushProperty); int sid = l.lastid(); MessageBox.Show(sid.ToString()); ledger nlb = new ledger() { Lid = sid, Lname= txtlname.Text, Lgroup = 3, Laddress = txtladd.Text, Lphoneno = txtlno.Text, Lemail = txtlmail.Text }; ledgerbalance lb = new ledgerbalance() { Lid = sid, Lname = txtlname.Text, Balance = 0 }; application.tb.Add(lb); if (url != null) { string targetPath = @System.AppDomain.CurrentDomain.BaseDirectory + "\\images\\" + txtlname.Text + ".jpg"; System.IO.File.Copy(url, targetPath, true); nlb.Limage = targetPath; } else { nlb.Limage = @System.AppDomain.CurrentDomain.BaseDirectory + "\\images\\default.jpg"; } lc.Add(nlb); clr(); } else { Show("Supplier Not Saved",2); } // l.showerror(error,this); }
private void listBox1_MouseDoubleClick(object sender, MouseButtonEventArgs e) { textBox1.ClearValue(TextBox.BorderBrushProperty); l = (ledger)listBox1.SelectedValue; txtlname.Text = l.Lname; txtladd.Text = l.Laddress; txtlno.Text = l.Lphoneno; txtlmail.Text = l.Lemail; edittoggle(false); save.Visibility = Visibility.Hidden; can_edit.Visibility = Visibility.Visible; image1.Source = new BitmapImage(new Uri(l.Limage, UriKind.Absolute)); }
public ledger getprintdetail(int lid) { OleDbCommand cmd = new OleDbCommand("Select l_address from ledger where l_id = @lid", con); cmd.Parameters.AddWithValue("lid", lid); ledger l = new ledger(); try { con.Open(); OleDbDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { l.Laddress = dr.GetValue(0).ToString(); } return l; } catch (Exception) { return l; } finally { con.Close(); } }