473,386 Members | 1,943 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

condition for add new row in datagridview

I have two table the first is called Imprrests and the second is called ]IprestsPays. There is an Imprest_ID column that is primary key in [icode]Imprests[/code] table and foreign key in ImprestsPays table

Imprests table consists the following columns:
Expand|Select|Wrap|Line Numbers
  1. Imprest_ID,  Impres_value,  Imprest_date,    Employee_ID
Where Employee_ID column is primary key in Employees table and foreign key in Imprests table.

ImprestsPays table consists the following columns:
Expand|Select|Wrap|Line Numbers
  1. ID,  Payment_value,  Payment_date,  Imprest_ID
My problem is in the buttonadd_click event in Imprsts form.

I want to prevent user from insert any new imprest for employee in Imprests table if employee haven't paid all payments in ImprestsPays table for old imprest

How can I solve this problem?
What is the code to do that?
Sep 13 '14 #1
1 1515
Frinavale
9,735 Expert Mod 8TB
I would write a SQL stored procedure that would return a true/false value that do the work to determine whether or not the employee has paid all payments (in your ImprestsPays table).

If it returns true, do the insert, otherwise do not do the insert.

It may actually be better to do the whole "create" in a stored procedure that does all the work for you in SQL instead of C#.

-Frinny
Sep 22 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Matt | last post by:
I have been searching all over the web for a way to sort a DataGridView based on the actual text being shown in a ComboBox column as opposed to the underlying value (an ID in this case). Can anyone...
1
by: martin1 | last post by:
Hi, All, DataGridView is populated with all coumns from database since i need some columns data for condition statement, after that I want to show rest of column in the DataGridView, so how to...
7
by: Ryan | last post by:
I have a DataGridView which displays numeric (Int32) data from an underlying database. I want the numbers to be displayed in numeric format "#,###" (with commas). I want to also limit the user so...
2
by: =?Utf-8?B?VG9jbw==?= | last post by:
Hello. My goal is to pain the entire row fore color as Red. If the value of column 24 is true (boolean), I wish to paint the row as Red. Otherwise, leave row as default (no formatting). The...
1
by: ravitunk | last post by:
hello..am developing a windows application which has a datagridview control with many columns.......i have a problem with changing the backcolor of a particular cell based on a specific...
5
by: BabliS1 | last post by:
I am using Vb.net2005. I have a datagridview which displays some data. I want to filter the records based on some criteria given by the user at runtime. How can I do this. Please Help. Thanks in...
0
by: Benniit | last post by:
Am using vb.net 08 and i have a datagridview with 3 columns. The first column has a button as the columntype with the name "UserName". Now, i want if the user clicks only on the UserName which is the...
0
by: fastestindian | last post by:
Hi, I am working on the DataGridView. I want to add the image and the text in the same cell depending upon the specific condition. I am not sure how to do that,so pls help me. Thanks in...
3
by: Parameswar Nayak | last post by:
Hi every one I am using datagridview in a win application.I need to validate the different cells according to condition like one cell for entering only numeric value. Can some one help me?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.