Example #1
0
 private void dataGridVendor_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     cc.OpenConnection();
     try
     {
         if (MainWindow.userName == "admin")
         {
             if (checkBoxGST.IsChecked == true)
             {
                 vendorId = ((DataRowView)dataGridVendor.SelectedItem).Row["Vid"].ToString();
                 if (cc.BillPreview("select Count(*) from TransactionDetails where Vid=@vid and BillType='GST'", "@vid", vendorId, vidExist) > 0)
                 {
                     VendorPurchases vp = new VendorPurchases();
                     vp.ShowDialog();
                 }
                 else
                 {
                     MessageBox.Show("Transaction not found");
                 }
             }
             else
             {
                 vendorId = ((DataRowView)dataGridVendor.SelectedItem).Row["Vid"].ToString();
                 if (cc.BillPreview("select Count(*) from TransactionDetails where Vid=@vid and BillType='NON_GST'", "@vid", vendorId, vidExist) > 0)
                 {
                     VendorPurchases vp = new VendorPurchases();
                     vp.ShowDialog();
                 }
                 else
                 {
                     MessageBox.Show("Transaction not found");
                 }
             }
         }
         else
         {
             vendorId = ((DataRowView)dataGridVendor.SelectedItem).Row["Vid"].ToString();
             if (cc.BillPreview("select Count(*) from TransactionDetails where Vid=@vid and BillType='GST'", "@vid", vendorId, vidExist) > 0)
             {
                 VendorPurchases vp = new VendorPurchases();
                 vp.ShowDialog();
             }
             else
             {
                 MessageBox.Show("Transaction not found");
             }
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Click on the Vendor");
     }
     cc.CloseConnection();
 }
        private void comboBoxCustomerName_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                comboName     = comboBoxCustomerName.SelectedItem.ToString();
                customerPhone = Regex.Split(comboName, "  ");
                cc.OpenConnection();
                if (MainWindow.userName == "admin")
                {
                    if (cc.BillPreview("select count(*) from CustomerTransactions where CustomerPhone=@phone", "@phone", customerPhone[1], count) > 0)
                    {
                        calculateBillAmount();
                        calculateTotalPayment();
                        calculateSpecialDiscount();
                        balanceAmount   = (billAmount - paymentAmount) - specialDiscount;
                        txtBalance.Text = Convert.ToString(balanceAmount);
                        txtPayment.Text = "";
                    }
                    else
                    {
                        MessageBox.Show("No transactions with " + comboName);
                    }
                }
                else
                {
                    if (cc.BillPreview("select count(*) from CustomerTransactions where CustomerPhone=@phone and BillType='GST'", "@phone", customerPhone[1], count) > 0)
                    {
                        calculateBillAmount();
                        calculateTotalPayment();
                        calculateSpecialDiscount();
                        balanceAmount   = (billAmount - paymentAmount) - specialDiscount;
                        txtBalance.Text = Convert.ToString(balanceAmount);
                        txtPayment.Text = "";
                    }
                    else
                    {
                        MessageBox.Show("No transactions with " + comboName);
                    }
                }
            }

            catch
            {
                comboBoxCustomerName.SelectedItem = null;
            }
            cc.CloseConnection();
            comboBoxCustomerName.IsDropDownOpen = true;
            txtPayment.Focus();
        }
Example #3
0
        private void comboBoxVendorName_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                cc.OpenConnection();
                if (MainWindow.userName == "admin")
                {
                    if (cc.BillPreview("select Count(*) from TransactionDetails where Vname=@vname", "@vname", comboBoxVendorName.SelectedItem.ToString(), vidExist) > 0)
                    {
                        calculateBillAmount();
                        calculateTotalPayment();
                        balanceAmount   = billAmount - paymentAmount;
                        txtBalance.Text = Convert.ToString(balanceAmount);
                        txtPayment.Text = "";
                    }
                    else
                    {
                        MessageBox.Show("No transaction with " + comboBoxVendorName.SelectedItem.ToString());
                    }
                }
                else
                {
                    if (cc.BillPreview("select Count(*) from TransactionDetails where Vname=@vname and GstAmount != 0", "@vname", comboBoxVendorName.SelectedItem.ToString(), vidExist) > 0)
                    {
                        calculateBillAmount();
                        calculateTotalPayment();
                        balanceAmount   = billAmount - paymentAmount;
                        txtBalance.Text = Convert.ToString(balanceAmount);
                        txtPayment.Text = "";
                    }
                    else
                    {
                        MessageBox.Show("No transaction with " + comboBoxVendorName.SelectedItem.ToString());
                    }
                }
            }

            catch
            {
                comboBoxVendorName.SelectedItem = null;
            }
            cc.CloseConnection();
            comboBoxVendorName.IsDropDownOpen = true;
            txtPayment.Focus();
        }
 private void DamageItemId_PreviewKeyDown(object sender, KeyEventArgs e)
 {
     try
     {
         if (e.Key == Key.Return)
         {
             cc.OpenConnection();
             if (cc.BillPreview("select COUNT(*) from Stock where itemid = @value ", "@value", DamageItemId.Text, isExist) > 0)
             {
                 cc.CloseConnection();
                 idCount = Convert.ToInt32(DamageItemId.Text);
                 GetFromStock();
                 if (id.list.Contains(DamageItemId.Text))
                 {
                     UpdateGridRow();
                 }
                 else
                 {
                     StoreId();
                     InsertNewRow();
                 }
                 DamageItemId.Text = "";
                 buttonDelete.Visibility = Visibility.Hidden;
                 buttonList.Visibility = Visibility.Visible;
                 buttonSaveDamaged.Visibility = Visibility.Visible;
             }
             else
             {
                 MessageBox.Show("Item does not exist in DB");
                 DamageItemId.Text = "";
                 DamageItemId.Focus();
             }
         }
     }
     catch (Exception)
     {
         if (DamageItemId.Text == "")
         {
             MessageBox.Show("Enter Item ID..!");
         }
     }
 }
 private void txtItemId_PreviewKeyDown(object sender, KeyEventArgs e)
 {
     try
     {
         if (e.Key == Key.Return)
         {
             cc.OpenConnection();
             if (cc.BillPreview("select COUNT(*) from Stock where itemid = @value ", "@value", txtItemId.Text, isExist) > 0)
             {
                 cc.CloseConnection();
                 GetFromStock();
                 idCount = Convert.ToInt32(txtItemId.Text);
                 if (id.list.Contains(txtItemId.Text))
                 {
                     UpdateGridRow();
                 }
                 else
                 {
                     StoreId();
                     InsertNewRow();
                 }
                 DisplayNetAmount();
                 txtItemId.Text = "";
             }
             else
             {
                 MessageBox.Show("Item does not exist in DB");
                 txtItemId.Text = "";
                 txtItemId.Focus();
             }
         }
     }
     catch (Exception)
     {
         if (txtItemId.Text == "")
         {
             MessageBox.Show("Enter Item ID..!");
         }
     }
 }
 private void dataGridVendor_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     cc.OpenConnection();
     try
     {
         expenseId = ((DataRowView)dataGridVendor.SelectedItem).Row["Eid"].ToString();
         if (cc.BillPreview("select Count(*) from ExpenseDetails where Eid=@Eid", "@Eid", expenseId, vidExist) > 0)
         {
             ExpenseListWindow elp = new ExpenseListWindow();
             elp.ShowDialog();
         }
         else
         {
             MessageBox.Show("Transaction not found");
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Click on the Vendor");
     }
     cc.CloseConnection();
 }
Example #7
0
 private void viewBill()
 {
     if (txtBillNo.Text != null)
     {
         if (MainWindow.userName == "admin")
         {
             cc.OpenConnection();
             string txtbn = Convert.ToString(txtBillNo.Text);
             if (checkBoxGST.IsChecked == true)
             {
                 if (cc.BillPreview("select COUNT(*) from BillStock where BillNo = @bno and BillType='GST'", "@bno", txtbn, billExistValue) > 0)
                 {
                     displayDetails();
                     int bn = Convert.ToInt32(txtBillNo.Text);
                     cc.DataGridDisplay("select ItemNo,Product,Price,ProductQuantity,gstPercent,gstRate,TotalPrice from BillStock where BillNo = " + bn + " and BillType='GST' ");
                     dataGrid1.ItemsSource = cc.dt.AsDataView();
                 }
                 else
                 {
                     MessageBox.Show("Bill does not exist");
                     txtBillNo.Text = currentBillNo;
                     txtBillNo.Focus();
                 }
             }
             else
             {
                 if (cc.BillPreview("select COUNT(*) from BillStock where BillNo = @bno and BillType='NON_GST'", "@bno", txtbn, billExistValue) > 0)
                 {
                     displayDetails();
                     int bn = Convert.ToInt32(txtBillNo.Text);
                     cc.DataGridDisplay("select ItemNo,Product,Price,ProductQuantity,gstPercent,gstRate,TotalPrice from BillStock where BillNo = " + bn + " and BillType='NON_GST'");
                     dataGrid1.ItemsSource = cc.dt.AsDataView();
                 }
                 else
                 {
                     MessageBox.Show("Bill does not exist");
                     txtBillNo.Text = currentBillNo;
                     txtBillNo.Focus();
                 }
             }
             cc.CloseConnection();
         }
         else
         {
             cc.OpenConnection();
             string txtbn = Convert.ToString(txtBillNo.Text);
             if (cc.BillPreview("select COUNT(*) from BillStock where BillNo = @bno and BillType='GST'", "@bno", txtbn, billExistValue) > 0)
             {
                 displayDetails();
                 int bn = Convert.ToInt32(txtBillNo.Text);
                 cc.DataGridDisplay("select ItemNo,Product,Price,ProductQuantity,gstPercent,gstRate,TotalPrice from BillStock where BillNo = " + bn + " and BillType='GST' ");
                 dataGrid1.ItemsSource = cc.dt.AsDataView();
             }
             else
             {
                 MessageBox.Show("Bill does not exist");
                 txtBillNo.Text = currentBillNo;
                 txtBillNo.Focus();
             }
             cc.CloseConnection();
         }
     }
 }
Example #8
0
 private void ViewBill()
 {
     if (txt_Bill_No.Text != null)
     {
         if (MainWindow.userName == "admin")
         {
             if (checkBoxGST.IsChecked == true)
             {
                 cc.OpenConnection();
                 string txtbn = Convert.ToString(txt_Bill_No.Text);
                 if (cc.BillPreview("select COUNT(*) from Stock where Bno = @bno and BillType='GST'", "@bno", txtbn, billExistValue) > 0)
                 {
                     displayVendorDetails();
                     int bn = Convert.ToInt32(txt_Bill_No.Text);
                     cc.DataGridDisplay("select itemid,iname,rate,purchaseQty,total,sprice,gst_percent,gst_amount from Stock where Bno = " + bn + " and BillType='GST'");
                     dataGridPurchase.ItemsSource = cc.dt.AsDataView();
                 }
                 else
                 {
                     MessageBox.Show("Bill does not exist");
                     txt_Bill_No.Text = currentBillNo;
                     txt_Bill_No.Focus();
                 }
                 cc.CloseConnection();
             }
             else
             {
                 cc.OpenConnection();
                 string txtbn = Convert.ToString(txt_Bill_No.Text);
                 if (cc.BillPreview("select COUNT(*) from Stock where Bno = @bno and BillType='NON_GST'", "@bno", txtbn, billExistValue) > 0)
                 {
                     displayVendorDetails();
                     int bn = Convert.ToInt32(txt_Bill_No.Text);
                     cc.DataGridDisplay("select itemid,iname,rate,purchaseQty,total,sprice,gst_percent,gst_amount from Stock where Bno = " + bn + " and BillType='NON_GST'");
                     dataGridPurchase.ItemsSource = cc.dt.AsDataView();
                 }
                 else
                 {
                     MessageBox.Show("Bill does not exist");
                     txt_Bill_No.Text = currentBillNo;
                     txt_Bill_No.Focus();
                 }
                 cc.CloseConnection();
             }
         }
         else
         {
             cc.OpenConnection();
             string txtbn = Convert.ToString(txt_Bill_No.Text);
             if (cc.BillPreview("select COUNT(*) from Stock where Bno = @bno and BillType='GST'", "@bno", txtbn, billExistValue) > 0)
             {
                 displayVendorDetails();
                 int bn = Convert.ToInt32(txt_Bill_No.Text);
                 cc.DataGridDisplay("select itemid,iname,rate,purchaseQty,total,sprice,gst_percent,gst_amount from Stock where Bno = " + bn + " and BillType='GST'");
                 dataGridPurchase.ItemsSource = cc.dt.AsDataView();
             }
             else
             {
                 MessageBox.Show("Bill does not exist");
                 txt_Bill_No.Text = currentBillNo;
                 txt_Bill_No.Focus();
             }
             cc.CloseConnection();
         }
     }
 }