使用表格进行添加和更新 [英] use a form for both add and update

查看:113
本文介绍了使用表格进行添加和更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我在此表上

我有一个表格,其中有10个文本框
与一个保存按钮,我想从
使用它 用于添加和都修改
打开进行修改时,然后从数据库填充文本框
并单击保存更新数据"时
当为新记录打开时,所有文本框均为空白,
当在文本框中填充数据并单击保存
将数据添加到数据库

please help me on this metter

i have a form which i have 10 textboxes
with a save button i want to use this from
for add & modfiy both
when opend for modify then textbox fill from database
and when click on save update data
when opend for new record all textbox blank and
when fill data on textbox and click on save
add data to database

推荐答案

您将知道此数据是要添加还是更新,将进入此表单.你必须!因此,请跟踪它,可以说一个标志-isUpdated.因此,在第一次创建记录时,此标志将为false-从而完成插入操作.从这里开始:

步骤:
1.按原样显示控件
2.用户填充它并单击保存后,基于isUpdated标志,您知道它是一个插入,因此触发插入查询并将其保存在DB
3.现在,一旦有记录并尝试对其进行更新,则isUpdate的标志为true.
4.因此,由于这是一个更新案例,请从DB
获取数据 5.在控件中设置检索到的数据
6.一旦用户填充它并根据isUpdated标志单击保存,就知道它是一个更新,因此触发更新查询并将其保存在DB

试试吧!
You will land on this form knowing if the data is being added or updated. You have to! So, keep track of it, lets say a flag - isUpdated. So, for the very first time when the record is to be created, this flag will be false - thus an insert to be done. Starting from here:

Steps:
1. Display the controls as is
2. Once user fills it and hit save, based on isUpdated flag, you know its an insert, so fire an insert query and save in DB
3. Now, once record is there and you try to update it, your flag is true for isUpdate.
4. So, since this is an update case, get the data from DB
5. Set the retrieved data in controls
6. Once user fills it and hit save, based on isUpdated flag, you know its an update, so fire an update query and save in DB

Try!


这篇关于使用表格进行添加和更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆