📄 frmwarrantinfo.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using property.control.warrantInfo;
using property.model.Warrant;
using property.control.Subject;
using property.view.SystemInfo;
using property.model.SubjectInfo;
namespace property.view.WarrantInfo
{
public partial class frmWarrantInfo : Form
{
public frmWarrantInfo()
{
InitializeComponent();
}
public string P_str_id;
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void frmWarrantInfo_Load(object sender, EventArgs e)
{
}
//凭证编号
private void txtWarrrntID_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar != 8 && !char.IsDigit(e.KeyChar))
{
MessageBox.Show("凭证编号只能输入数字");
e.Handled = true;
}
}
//贷方金额
private void txtLenMoney_KeyPress(object sender, KeyPressEventArgs e)
{
txtGoodMoney.Text = "0";
txtGoodMoney.Enabled = false;
if (e.KeyChar != 8 && !char.IsDigit(e.KeyChar))
{
MessageBox.Show("借方金额只能输入数字");
e.Handled = true;
}
}
private void txtGoodMoney_KeyPress(object sender, KeyPressEventArgs e)
{
txtLenMoney.Text = "0";
txtLenMoney.Enabled = false;
if (e.KeyChar != 8 && !char.IsDigit(e.KeyChar))
{
MessageBox.Show("贷方金额只能输入数字");
e.Handled = true;
}//
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
this.txtWarrrntID.Text = "";
this.txtWarrrntID.Enabled = true;
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
if (radId.Checked == true)
{
this.txtWarrrntID.Enabled = true;
GetWarInfo war = new GetWarInfo();
this.txtWarrrntID.Text = Convert.ToString(war.GetWarrantID());
txtWarrrntID.Enabled = false;
}
}
//查索科目
private void bntSelectSubject_Click(object sender, EventArgs e)
{
frmSubInfo frmsub = new frmSubInfo();
// frmsub.ShowDialog();
if (frmsub.ShowDialog() == DialogResult.OK)
{ //全局变量P_str_id
P_str_id = frmSubInfo.G_str_subID;
GetSubject sub = new GetSubject();
SubInfo info = new SubInfo();
info.setsubId(Convert.ToInt32(P_str_id));
sub.GetdDataGrid(this.DataGridWarratn, info);
}// END BLOCK IF
}// end block menthod
// 取消退出
private void BntEsce_Click(object sender, EventArgs e)
{
DialogResult a = MessageBox.Show("是否要退出?", "退出", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (Convert.ToString(a) == "Yes")
{
this.Close();
}// end block
}
//保存
private void bntSave_Click(object sender, EventArgs e)
{
if (P_str_id ==null)
{
MessageBox.Show("请先检索科目信息", "友情提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}// END BLOCK IF
GetWarInfo war = new GetWarInfo();
string P_str_date = war.GetWarrdDate("zhy");
if (DatePick.Value < Convert.ToDateTime(P_str_date))
{
MessageBox.Show("当前会计时间是" + Convert.ToDateTime(P_str_date).Year.ToString() + "年" + Convert.ToDateTime(P_str_date).Month.ToString() + "月" + "\n" + "请输入正确的时间", "会计时间提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.DatePick.Focus();
return;
}// END BLOCK IF
if (txtWarrrntID.Text == "")
{
MessageBox.Show("凭证编号不能为空", "友情提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}// end block if
if (txtGoodMoney.Text == "" || txtLenMoney.Text == "")
{
MessageBox.Show("借方金额/货方金额必须填写一项 ", "友情提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
if (txtGoodMoney.Text == "")
{
txtGoodMoney.Focus();
return;
}// end block
if (txtLenMoney.Text == "")
{
txtLenMoney.Focus();
return;
}// end block
}// end block if
GetWarInfo warinfo = new GetWarInfo();
Warrant info = new Warrant();
info.setP_date_warrantDate(this.DatePick.Value);
info.setP_str_subId(this.P_str_id);
info.setP_int_subGoodsMoney(Convert.ToInt32(this.txtGoodMoney.Text.Trim()));
info.setP_int_subLendmoney(Convert.ToInt32(txtLenMoney.Text.Trim()));
info.setP_int_warrantId(Convert.ToInt32(this.txtWarrrntID.Text.Trim()));
string P_str_insert = warinfo.getwarrantAdd(info);//调用方法添加信息
if(P_str_insert=="insetOk")
{
MessageBox.Show("添加成功 ", "友情提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.ClearText();//调用方法
this.radId.Checked = false;
this.radioButton1.Checked = false;
P_str_id = null;
}// end block if
if(P_str_insert=="insetNo")
{
MessageBox.Show("添加失败 ", "友情提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.ClearText();//调用方法
}// end block if
if(P_str_insert=="addError")
{
MessageBox.Show("对不起,操作出现异常\n"+"请重新操作", "友情提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.ClearText();//调用方法
}// end block if
}// end block mehtod
// 方法清空文本
public void ClearText()
{
txtWarrrntID.Text = "";
txtWarrrntID.Enabled = false;
txtGoodMoney.Text = "";
txtLenMoney.Enabled = true;
txtGoodMoney.Enabled = true;
txtLenMoney.Text = "";
}// end block void ClearText()
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
this.P_str_id = null;
this.txtGoodMoney.Text = "";
txtGoodMoney.Enabled = true;
this.txtLenMoney.Text = "";
txtLenMoney.Enabled = true;
txtWarrrntID.Text = "";
this.txtWarrrntID.Enabled = false;
}
private void button1_Click(object sender, EventArgs e)
{
this.txtGoodMoney.Text = DatePick.Value.ToString();
}// END BLOCK MEHTOD
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -