Exemple #1
0
        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);
        }
Exemple #2
0
 private void btnac_Click(object sender, RoutedEventArgs e)
 {
     ledgermodel l = new ledgermodel(txtac.Text, 11, "", "", "");
     if (l.insert(this))
     {
         Show("Saved Susessfully",1);
         txtac.Text = "";
     }
 }