コード例 #1
0
ファイル: purchasemodel.cs プロジェクト: sumit10/BMS
 public List<purchaseitem> getorderedetail(int sid)
 {
     List<purchaseitem> sd = new List<purchaseitem>();
     query = "select   s.po_id, s.com_id, s.com_quantity, s.com_uom, s.p_total, s.com_rate, c.com_name";
     query += " from  (purchaseorder_detail s INNER JOIN stock c ON s.com_id = c.com_id)";
     query += " where s.po_id = @sid";
     OleDbCommand cmd = new OleDbCommand(query, con);
     cmd.Parameters.AddWithValue("sid", sid);
     try
     {
         con.Open();
         OleDbDataReader dr = cmd.ExecuteReader();
         while (dr.Read())
         {
             purchaseitem s = new purchaseitem()
             {
                 pid = int.Parse(dr.GetValue(0).ToString()),
                 pcomid = int.Parse(dr.GetValue(1).ToString()),
                 pqnty = double.Parse(dr.GetValue(2).ToString()),
                 puom = dr.GetValue(3).ToString(),
                 pamt = double.Parse(dr.GetValue(4).ToString()),
                 prate = dr.GetValue(5).ToString(),
                 pcomname = dr.GetValue(6).ToString()
             };
             sd.Add(s);
         }
         return sd;
     }
     catch (Exception e)
     {
         MessageBox.Show(e.ToString());
         return sd;
     }
     finally
     {
         con.Close();
     }
 }
コード例 #2
0
ファイル: purchasemodel.cs プロジェクト: sumit10/BMS
 public ObservableCollection<purchaseitem> getinvoicedetail(int pid)
 {
     ObservableCollection<purchaseitem> pd = new  ObservableCollection<purchaseitem>();
     query = "select   p.p_id, p.com_id, p.com_quantity, p.com_uom ,p.p_total, p.com_rate, c.com_name";
     query += " from  (purchase_detail p INNER JOIN stock c ON p.com_id = c.com_id)";
     query += " where p.p_id = @pid";
     OleDbCommand cmd = new OleDbCommand(query,con);
     cmd.Parameters.AddWithValue("pid",pid);
     try
     {
         con.Open();
         OleDbDataReader dr = cmd.ExecuteReader();
         while (dr.Read())
         {
             purchaseitem p = new purchaseitem()
             {
                 pid = int.Parse(dr.GetValue(0).ToString()),
                 pcomid = int.Parse(dr.GetValue(1).ToString()),
                 pqnty = double.Parse(dr.GetValue(2).ToString()),
                 puom = dr.GetValue(3).ToString(),
                 pamt = double.Parse(dr.GetValue(4).ToString()),
                 prate = dr.GetValue(5).ToString(),
                 pcomname = dr.GetValue(6).ToString()
             };
             pd.Add(p);
         }
         return pd;
     }
     catch (Exception e)
     {
         MessageBox.Show(e.ToString());
         return pd;
     }
     finally
     {
         con.Close();
     }
 }
コード例 #3
0
ファイル: purchaseview.xaml.cs プロジェクト: sumit10/BMS
        private void txtquantity_KeyUp(object sender, KeyEventArgs e)
        {
            TextBox t = (TextBox)sender;

            Double a = -1, b = -1;
            Double n;
            if (txtquantity.Text == "") { a = 0; }
            if (txtrate.Text == "") { b = 0; }

            if (!(Double.TryParse(txtquantity.Text, out n)) && a != 0)
            {
                Show("Please Enter Number",2);
                txtquantity.Text = "0";
            }

            if (!(Double.TryParse(txtrate.Text, out n)) && b != 0)
            {
                Show("Please Enter Number",2);
                txtrate.Text = "0";
            }
            if (a != 0) { a = Double.Parse(txtquantity.Text); }
            if (b != 0) { b = Double.Parse(txtrate.Text); }
            Double c = Math.Round(a, 2) * Math.Round(b, 2);

            txtamount.Text = c.ToString();
            if (t.Name == txtquantity.Name)
            {
                Double bal = (combal + a);
                lbl_remainingbal.Content = bal.ToString();
                if (bal < 100)
                {
                    lbl_remainingbal.Foreground = Brushes.Red;
                }
                else
                {
                    lbl_remainingbal.Foreground = Brushes.Black;
                }
            }
            if (e.Key == Key.Enter && txtamount.Text != "0" && cmb_uom.SelectedItem != null)
            {
                int pid;
                if (order)
                {
                    pid = orderid;
                }
                else
                {
                    pid = vid;
                }
                purchaseitem s = new purchaseitem()
                {
                    pid = pid,
                    pcomname = txtcomname.Text,
                    pcomid = int.Parse(cid.ToString()),
                    pqnty = Double.Parse(txtquantity.Text),
                    puom = cmb_uom.SelectedValue.ToString(),
                    prate = txtrate.Text,
                    pamt = Double.Parse(txtamount.Text),
                };
                pc.Add(s);
                //listBox1.Items.Add(s);
                total += Double.Parse(txtamount.Text);
                txttotalamount.Text = total.ToString();
                txtamount.Text = "";
                txtcomname.Text = "";
                txtquantity.Text = "";
                txtrate.Text = "";
                txtcomname.Focus();
                toggelcom(false);
                lbl_remainingbal.Content = "";
                combal = 0;
                lbl_remainingbal.Foreground = Brushes.Red;
            }
        }
コード例 #4
0
ファイル: purchasemodel.cs プロジェクト: sumit10/BMS
 public purchaseitemmodel(purchaseitem p)
 {
     this.p = p;
 }
コード例 #5
0
ファイル: purchaseview.xaml.cs プロジェクト: sumit10/BMS
        private void lst_report_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (lst_report.SelectedValue != null)
            {

                lbl_header.Content = "Purchase Invoice";
                purchasereport sr = (purchasereport)lst_report.SelectedValue;
                purchase s;
                if (invoicedetail)
                {
                    listBox2.ItemsSource = new purchaseitemmodel().getinvoicedetail(int.Parse(sr.vid));
                    s = new purchasemodel().getinvoicedetail(int.Parse(sr.vid));
                    rp_datePicker.Text = s.pdate;
                    rp_customer.Content = s.lname;
                    rp_round.Content = s.roundof;
                    rp_tnsp.Content = s.tnsp_chg;
                    rp_total.Content = s.ptotal;
                    rp_vatrate.Content = s.vat_chg;
                    rp_vno.Content = s.pid.ToString();
                    rp_vat.Content = (Math.Round(double.Parse(s.vat_chg) / s.ptotal * 100, 2)).ToString();
                    purchase_report.Visibility = Visibility.Hidden;
                    invoice_details.Visibility = Visibility.Visible;
                }
                else
                {
                    reset();
                    List<purchaseitem> soc = new purchaseitemmodel().getorderedetail(int.Parse(sr.vid));
                    foreach (var item in soc)
                    {

                        purchaseitem sa = new purchaseitem()
                        {
                            pid = vid,
                            pcomname = item.pcomname,
                            pcomid = item.pcomid,
                            pqnty = item.pqnty,
                            puom = item.puom,
                            prate = item.prate,
                            pamt = item.pamt,
                        };
                        pc.Add(sa);
                    }
                    s = new purchasemodel().getorderdetail(int.Parse(sr.vid));
                    purchase_report.Visibility = Visibility.Hidden;
                    purchase.Visibility = Visibility.Visible;
                    invoicenumber();
                    btncomitorder.Visibility = Visibility.Visible;
                    button1.Visibility = Visibility.Hidden;
                    txtcustomer.Text = s.lname;
                    txttotalamount.Text = s.nettotal.ToString();
                    total = s.ptotal;
                    lid = s.lid;
                    comitoid = s.pid;
                    txtacrate.Focus();
                }
            }
        }