using System; |
using System.Collections.Generic; |
using System.ComponentModel; |
using System.Data; |
using System.Drawing; |
using System.Text; |
using System.Windows.Forms; |
using Common; |
namespace Pos |
{ |
public partial class frmDuty : Form |
{ |
public frmDuty() |
{ |
InitializeComponent(); |
} |
private void btnClose_Click( object sender, EventArgs e) |
{ |
this .Close(); |
} |
private void btnOk_Click( object sender, EventArgs e) |
{ |
try |
{ |
if (PUser.dutyID != "0" ) |
{ |
MessageBox.Show( "你还未交班!" , "友好提示" ); |
this .Close(); |
return ; |
} |
if ( txtMoney.Text == "" ) |
{ |
MessageBox.Show( "金额不能为空!" , "友好提示" ); |
return ; |
} |
//string year = ""+DateTime.Now.Year; |
//string month = ""+DateTime.Now.Month; |
//string day = ""+DateTime.Now.Day; |
string date = DateTime.Now.ToString(); |
float money = float .Parse(txtMoney.Text); |
string sql = string .Format( "insert into front_duty(User_code,Duty_time,Duty_InitMoney,Com_Name,duty_id) values('{0}','{1}',{2},'{3}','{4}')" , PUser.UserCode, date, money, SQLHelper.CompanyName, GetCode.getCode( "db1" , "front_duty" , "duty_id" )); |
int n = SQLHelper.ExecuteNonQuery(sql); |
string sql2 = string .Format( "select * from front_duty where User_code='{0}' and Duty_endTime is null" , PUser.UserCode); |
DataTable dt2 = SQLHelper.ExecuteDataSet(sql2).Tables[0]; |
if (dt2.Rows.Count > 0) |
{ |
PUser.dutyID = dt2.Rows[0][ "duty_id" ].ToString(); |
} |
MessageBox.Show( "操作员" + PUser.UserCode + "当班成功!" ); |
this .Close(); |
} |
catch (Exception ex) |
{ |
MessageBox.Show(ex.Message); |
} |
} |
private void txtMoney_KeyPress( object sender, KeyPressEventArgs e) |
{ |
if (e.KeyChar >= '0' && e.KeyChar <= '9' || e.KeyChar == ( char )Keys.Back) |
{ |
e.Handled = false ; |
} |
else |
{ |
e.Handled = true ; |
} |
} |
private void frmDuty_Load( object sender, EventArgs e) |
{ |
txtMoney.Focus(); |
} |
} |
} |