如何更新员工的记录 [英] how to update the record of employee

查看:68
本文介绍了如何更新员工的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的HTML代码

 <   div     class   =  form-horizo​​ntal >  
< div class = form-group >
< label class = col-sm-2 control-label >
Roll No < span class = 需要符号 > ; < / span >
< / label > ;
< div class = col-sm-3 >
< asp:DropDownList CssClass = form-control search-select runat = server MaxLength = 7 ID = ddlRollNo < span class =code-attribute> / >
< asp:RequiredFieldValidator ValidationGroup = vgEmployee runat = server ID = rfvrOLL ControlToValidate = ddlRollNo 必需 = < span class =code-keyword> required > < / asp:RequiredFieldValidator >
< / div >
< label class = col -sm-2 control-label >
Rank < < span class =code-leadattribute> span class = 需要符号 > < / span >
< / label >
< div class = col-sm-3 >
< asp:DropDownList CssClass = form-control ID = ddlRank runat = server / >
< asp:RegularExpressionValidator runat = server ID = revddlRank ControlToValidate = ddlRank 必需 = 必需 显示 = 动态 > < / asp:RegularExpressionValidator >
< / div >
< < span class =code-leadattribute> / div >
< div class = form-group >
< span class =code-keyword>< label class = col-sm-2 control-label >
开始日期:
< / label > ;
< div class = col-sm-3 >
< asp:TextBox ID = txtStartDate runat = server MaxLength = 10 必需 = required data-date-viewmode = years
< span class =code-attribute> CssClass = 表单控制日期选择器 data-date-format = dd-mm-yyyy > < span class =code-keyword>< / asp:TextBox >
< / div >
< label class = col-sm-2 control-label >
开始时间:
< / label >
< div class = input-group input-append bootstrap-timepicker col- sm-3 >
< 我nput id = txtstartTime runat = server type = text class = 表格控制时间选择器 / >
< span class = input-group-addon add-on > < / span >
< / div >
< / div >
< div class = form-group >
< label class = col-sm-2 control-label >
结束日期:
< / label >
< div class = col-sm-3 >
< asp:TextBox ID < span class =code-keyword> = txtEndDate runat = server 显示 = 动态 < span class =code-attribute>
< span class =code-attribute> CssClass = 表单控制日期选择器 OnTextChanged = txtStartDate_TextChanged AutoPostBack = true data-date-viewmode = years < span class =code-attribute> 必需 = required MaxLength = 10 < span class =code-attribute> data-date-format = dd-mm-yyyy > < / asp:TextBox >
< / div >
< label class = col-sm-2 control-标签 >
结束时间:
< < span class =code-leadattribute> / label >
< div class = input-group input-append bootstrap-timepicker col-sm-3 >
< input id = txtEndTime runat = 服务器 type = text class = 表单控制时间选择器 / >
< span class = input-group-addon add-on > < / span >
< / div >
< / div >
< div class = form-group >
< label class = col-sm- 2控制标签 >
Durtion:
< / label >
< div class = col-sm-3 >
< asp:TextBox CssClass = 表单控制 runat = 服务器 ID = txtDurtion
必需 = required < span class =code-attribute> / >
< asp:RegularExpressionValidator runat = server ID = revDurtion ControlToValidate = txtDurtion > < / asp:RegularExpressionValidator > < br / >
< / div
< label class < span class =code-keyword> = col-sm-2 control-label >
选择行业:
< / label >
< div class = col-sm-3 >
< asp:DropDownList CssClass = 表单控件 ID = ddlSelectSector runat = server / >
< asp:RegularExpressionValidator runat = server ID = revSelectSector ControlToValidate = ddlSelectSector 必需 = required 显示 = 动态 > < / asp:RegularExpressionValidator >
< ; / div >



后面的代码是:

< pre lang =c#> 尝试
{
string [] temp = txtstartTime.Value.Split( new char [] {' '' :'});
DateTime startDate = SafeConvert.ToDateTime(txtStartDate.Text).AddHours(temp [ 2 ] == PM?SafeConvert.ToInt32(temp [ 0 ])+ 12 :SafeConvert.ToInt32(temp [ 0 ]))
.AddMinutes(SafeConvert.ToInt32(temp [ 1 ]));

temp = txtEndTime.Value.Split( new char [] {< span class =code-string>'
'' :'});
DateTime endDate = SafeConvert.ToDateTime(txtEndDate.Text).AddHours(temp [ 2 ] == PM?SafeConvert.ToInt32(temp [ 0 ])+ 12 :SafeConvert.ToInt32(temp [ 0 ]))
.AddMinutes(SafeConvert.ToInt32(temp [ 1 ]));

EmployeeAbsent empAbsent = new EmployeeAbsent();
empAbsent.UserName = MyUser.UserName;
empAbsent.EntryDate = DateTime.Now;
empAbsent.Emlopyee_Id = ddlRollNo.Text;
empAbsent.Rank_Id = SafeConvert.ToByte(ddlRank.SelectedValue);
empAbsent.StartDate = startDate;
empAbsent.EndDate = endDate;
empAbsent.Durtion = txtDurtion.Text;
empAbsent.Sector_Id = SafeConvert.ToByte(ddlSelectSector.SelectedValue);
_service.InsertEmployeeAbsent(empAbsent);
_queryStatus = empAbsent.Id > 0 ;





i想要一个同一页面上的按钮,使用户能够编辑该员工的最后一条记录。如果可能的话使用rollno作为主键

解决方案

制作一个功能,选择最新记录并填写提交按钮上的相关控件点击。

请注意 - 在数据成功插入时应用。


Here is my html code

<div class="form-horizontal">
               <div class="form-group">
                   <label class="col-sm-2 control-label">
                       Roll No <span class="symbol required"></span>
                   </label>
                   <div class="col-sm-3">
                      <asp:DropDownList CssClass="form-control search-select" runat="server" MaxLength="7" ID="ddlRollNo"  />
                      <asp:RequiredFieldValidator ValidationGroup="vgEmployee" runat="server" ID="rfvrOLL" ControlToValidate="ddlRollNo" Required="required"></asp:RequiredFieldValidator>
                    </div>
                   <label class="col-sm-2 control-label">
                       Rank <span class="symbol required"></span>
                   </label>
                   <div class="col-sm-3">
                       <asp:DropDownList CssClass="form-control" ID="ddlRank" runat="server"  />
                       <asp:RegularExpressionValidator runat="server" ID="revddlRank" ControlToValidate="ddlRank" Required="required" Display="Dynamic"></asp:RegularExpressionValidator>
                   </div>
               </div>
               <div class="form-group">
                   <label class="col-sm-2 control-label">
                       Start Date:
                   </label>
                   <div class="col-sm-3">
                       <asp:TextBox ID="txtStartDate" runat="server" MaxLength="10" Required="required" data-date-viewmode="years"
                           CssClass="form-control date-picker" data-date-format="dd-mm-yyyy"></asp:TextBox>
                    </div>
                   <label class="col-sm-2 control-label">
                       Start Time:
                   </label>
                   <div class="input-group input-append bootstrap-timepicker col-sm-3">
                       <input id="txtstartTime" runat="server" type="text" class="form-control time-picker" />
                       <span class="input-group-addon add-on"></span>
                   </div>
                   </div>
               <div class="form-group">
                   <label class="col-sm-2 control-label">
                       End Date:
                   </label>
                   <div class="col-sm-3">
                       <asp:TextBox ID="txtEndDate" runat="server"  Display="Dynamic"
                           CssClass="form-control date-picker" OnTextChanged="txtStartDate_TextChanged" AutoPostBack="true" data-date-viewmode="years" Required="required" MaxLength="10" data-date-format="dd-mm-yyyy"></asp:TextBox>
                      </div>
                   <label class="col-sm-2 control-label">
                       End Time:
                   </label>
                   <div class="input-group input-append bootstrap-timepicker col-sm-3">
                       <input id="txtEndTime" runat="server" type="text" class="form-control time-picker"  />
                       <span class="input-group-addon add-on"></span>
                   </div>
               </div>
               <div class="form-group">
                   <label class="col-sm-2 control-label">
                       Durtion:
                   </label>
                   <div class="col-sm-3">
                       <asp:TextBox CssClass="form-control"  runat="server" ID="txtDurtion" Required="required" />
                       <asp:RegularExpressionValidator runat="server" ID="revDurtion" ControlToValidate="txtDurtion" ></asp:RegularExpressionValidator><br />
                   </div
                       <label class="col-sm-2 control-label">
                       Select Sector:
                   </label>
                   <div class="col-sm-3">
                       <asp:DropDownList CssClass="form-control" ID="ddlSelectSector" runat="server"  />
                       <asp:RegularExpressionValidator runat="server" ID="revSelectSector" ControlToValidate="ddlSelectSector" Required="required" Display="Dynamic"></asp:RegularExpressionValidator>
                   </div>


code behind is:

try
          {
              string[] temp = txtstartTime.Value.Split(new char[] { ' ', ':' });
              DateTime startDate = SafeConvert.ToDateTime(txtStartDate.Text).AddHours(temp[2] == "PM" ? SafeConvert.ToInt32(temp[0]) + 12 : SafeConvert.ToInt32(temp[0]))
                  .AddMinutes(SafeConvert.ToInt32(temp[1]));

              temp = txtEndTime.Value.Split(new char[] { ' ', ':' });
              DateTime endDate = SafeConvert.ToDateTime(txtEndDate.Text).AddHours(temp[2] == "PM" ? SafeConvert.ToInt32(temp[0]) + 12 : SafeConvert.ToInt32(temp[0]))
                  .AddMinutes(SafeConvert.ToInt32(temp[1]));

              EmployeeAbsent empAbsent = new EmployeeAbsent();
              empAbsent.UserName = MyUser.UserName;
              empAbsent.EntryDate = DateTime.Now;
              empAbsent.Emlopyee_Id = ddlRollNo.Text;
              empAbsent.Rank_Id = SafeConvert.ToByte(ddlRank.SelectedValue);
              empAbsent.StartDate = startDate;
              empAbsent.EndDate = endDate;
              empAbsent.Durtion = txtDurtion.Text;
              empAbsent.Sector_Id = SafeConvert.ToByte(ddlSelectSector.SelectedValue);
              _service.InsertEmployeeAbsent(empAbsent);
              _queryStatus = empAbsent.Id > 0;



i want a button on same page which enable the user to edit the last record of that employee.how is it possible using rollno that is primary key

解决方案

make a function which Select latest Records and fill related control on submit button Click .
please note - apply when data successful insert.


这篇关于如何更新员工的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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