Exemplo n.º 1
0
 public List<salesitem> getorderedetail(int sid)
 {
     List<salesitem> sd = new List<salesitem>();
     query = "select   s.so_id, s.com_id, s.com_quantity, s.com_uom, s.s_total, s.com_rate, c.com_name";
     query += " from  (saleorder_detail s INNER JOIN stock c ON s.com_id = c.com_id)";
     query += " where s.so_id = @sid";
     OleDbCommand cmd = new OleDbCommand(query, con);
     cmd.Parameters.AddWithValue("sid", sid);
     try
     {
         con.Open();
         OleDbDataReader dr = cmd.ExecuteReader();
         while (dr.Read())
         {
             salesitem s = new salesitem()
             {
                 sid = int.Parse(dr.GetValue(0).ToString()),
                 scomid = int.Parse(dr.GetValue(1).ToString()),
                 sqnty = double.Parse(dr.GetValue(2).ToString()),
                 suom = dr.GetValue(3).ToString(),
                 samt = double.Parse(dr.GetValue(4).ToString()),
                 srate = dr.GetValue(5).ToString(),
                 scomname = dr.GetValue(6).ToString()
             };
             sd.Add(s);
         }
         return sd;
     }
     catch (Exception e)
     {
         MessageBox.Show(e.ToString());
         return sd;
     }
     finally
     {
         con.Close();
     }
 }
Exemplo n.º 2
0
        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)
            {
                if (int.Parse(lbl_remainingbal.Content.ToString()) <= 0)
                {
                    Show("insufficient balance ",2);
                    txtquantity.Focus();
                    return;
                }
                int sid;
                if (order)
                {
                    sid = int.Parse(txtorderno.Text);
                }
                else
                {
                    sid = int.Parse(txtvno.Text);
                }
                salesitem s = new salesitem()
                {
                    sid = sid,
                    scomname = txtcomname.Text,
                    scomid = int.Parse(cid.ToString()),
                    sqnty = Double.Parse(txtquantity.Text),
                    suom = cmb_uom.SelectedValue.ToString(),
                    srate = txtrate.Text,
                    samt = Double.Parse(txtamount.Text),
                };
                sc.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;
            }
        }
Exemplo n.º 3
0
 public salesitemmodel(salesitem s)
 {
     this.s = s;
 }
Exemplo n.º 4
0
        private void lst_report_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (lst_report.SelectedValue != null)
            {

                lbl_header.Content = "Sales Invoice";
                salesreport sr = (salesreport)lst_report.SelectedValue;
                sales s;
                if (invoicedetail)
                {
                    listBox2.ItemsSource = new salesitemmodel().getinvoicedetail(int.Parse(sr.vid));
                    s = new salesmodel().getinvoicedetail(int.Parse(sr.vid));
                    rp_datePicker.Text = s.sdate;
                    rp_customer.Content = s.lname;
                    rp_round.Content = s.roundof;
                    rp_tnsp.Content = s.tnsp_chg;
                    rp_total.Content = s.stotal;
                    rp_vatrate.Content = s.vat_chg;
                    rp_vno.Content = s.sid.ToString();
                    lid = s.lid;
                    rp_vat.Content = (Math.Round(double.Parse(s.vat_chg) / s.stotal * 100, 2)).ToString();
                    sales_report.Visibility = Visibility.Hidden;
                    invoice_details.Visibility = Visibility.Visible;
                }
                else
                {
                    reset();
                    List<salesitem> soc = new salesitemmodel().getorderedetail(int.Parse(sr.vid));
                    foreach (var item in soc)
                    {

                        salesitem sa = new salesitem()
                        {
                            sid = int.Parse(txtvno.Text),
                            scomname = item.scomname,
                            scomid = item.scomid,
                            sqnty = item.sqnty,
                             suom = item.suom,
                            srate = item.srate,
                            samt = item.samt,
                        };
                        sc.Add(sa);
                    }
                    s = new salesmodel().getorderdetail(int.Parse(sr.vid));
                    sales_report.Visibility = Visibility.Hidden;
                    ((Storyboard)this.Resources["common_sale"]).Begin();
                    invoicenumber();
                    btncomitorder.Visibility = Visibility.Visible;
                    button1.Visibility = Visibility.Hidden;
                    txtcustomer.Text = s.lname;
                    txttotalamount.Text = s.nettotal.ToString();
                    total = s.stotal;
                    lid = s.lid;
                    comitoid = s.sid;
                    txtacrate.Focus();
                }
            }
        }