呵呵呵呵

呵呵呵呵```csharp using System; using System.Collections.Generic; using
System.ComponentModel; using System.Data; using System.Drawing; using
System.Linq; using System.Text; using System.Windows.Forms; using
SMALLERP.ComClass; using SMALLERP.DataClass; using System.Data.SqlClient;

namespace SMALLERP.BS { public partial class FormBSInven : Form {
DataBase db = new DataBase(); CommonUse commUse = new CommonUse();

    public FormBSInven()
{
InitializeComponent();
}

/// <summary>
/// 用于切换控件状态
/// </summary>
private void ControlStatus()
{
//工具栏按钮状态切换
this.toolSave.Enabled = !this.toolSave.Enabled;
this.toolCancel.Enabled = !this.toolCancel.Enabled;
commUse.CortrolButtonEnabled(toolAdd, this);
commUse.CortrolButtonEnabled(toolAmend, this);
commUse.CortrolButtonEnabled(toolDelete, this);
//窗体控件状态切换
this.txtInvenCode.ReadOnly = !this.txtInvenCode.ReadOnly;
this.txtInvenName.ReadOnly = !this.txtInvenName.ReadOnly;
this.cbxInvenTypeCode.Enabled = !this.cbxInvenTypeCode.Enabled;
this.txtSpecsModel.ReadOnly = !this.txtSpecsModel.ReadOnly;
this.txtMeaUnit.ReadOnly = !this.txtMeaUnit.ReadOnly;
this.txtSelPrice.ReadOnly = !this.txtSelPrice.ReadOnly;
this.txtPurPrice.ReadOnly = !this.txtPurPrice.ReadOnly;
this.txtSmallStockNum.ReadOnly = !this.txtSmallStockNum.ReadOnly;
this.txtBigStockNum.ReadOnly = !this.txtBigStockNum.ReadOnly;
}

/// <summary>
/// 将控件恢复到原始状态
/// </summary>
private void ClearControls()
{
this.txtInvenCode.Text = "";
this.txtInvenName.Text = "";
this.cbxInvenTypeCode.SelectedIndex = -1;
this.txtSpecsModel.Text = "";
this.txtMeaUnit.Text = "";
this.txtSelPrice.Text = "";
this.txtPurPrice.Text = "";
this.txtSmallStockNum.Text = "";
this.txtBigStockNum.Text = "";
}

/// <summary>
/// 用于设置查询字段
/// </summary>
private void BindToolStripComboBox()
{
this.cbxCondition.Items.Add("存货名称");
this.cbxCondition.Items.Add("规格型号");
}

/// <summary>
/// 设置控件的显示值
/// </summary>
private void FillControls()
{
this.txtInvenCode.Text = this.dgvInvenInfo[0, this.dgvInvenInfo.CurrentCell.RowIndex].Value.ToString();
this.txtInvenName.Text = this.dgvInvenInfo[1, this.dgvInvenInfo.CurrentCell.RowIndex].Value.ToString();
this.cbxInvenTypeCode.SelectedValue = this.dgvInvenInfo[2, this.dgvInvenInfo.CurrentCell.RowIndex].Value;
this.txtSpecsModel.Text = this.dgvInvenInfo[3, this.dgvInvenInfo.CurrentCell.RowIndex].Value.ToString();
this.txtMeaUnit.Text = this.dgvInvenInfo[4, this.dgvInvenInfo.CurrentCell.RowIndex].Value.ToString();
this.txtSelPrice.Text = this.dgvInvenInfo[5, this.dgvInvenInfo.CurrentCell.RowIndex].Value.ToString();
this.txtPurPrice.Text = this.dgvInvenInfo[6, this.dgvInvenInfo.CurrentCell.RowIndex].Value.ToString();
this.txtSmallStockNum.Text = this.dgvInvenInfo[7, this.dgvInvenInfo.CurrentCell.RowIndex].Value.ToString();
this.txtBigStockNum.Text = this.dgvInvenInfo[8, this.dgvInvenInfo.CurrentCell.RowIndex].Value.ToString();
}

/// <summary>
/// DataGridView控件绑定到数据源
/// </summary>
/// <param name="strWhere">Where条件子句</param>
private void BindDataGridView(string strWhere)
{
string strSql = null;

strSql = "SELECT * FROM BSInven " + strWhere;

try
{
this.dgvInvenInfo.DataSource = db.GetDataSet(strSql, "BSInven").Tables["BSInven"];
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "软件提示");
throw ex;
}
}

/// <summary>
/// 设置参数值
/// </summary>
private void ParametersAddValue()
{
db.Cmd.Parameters.Clear();
db.Cmd.Parameters.AddWithValue("@InvenCode", txtInvenCode.Text.Trim());
db.Cmd.Parameters.AddWithValue("@InvenName", txtInvenName.Text.Trim());

if (cbxInvenTypeCode.SelectedValue == null)
{
db.Cmd.Parameters.AddWithValue("@InvenTypeCode", DBNull.Value);
}
else
{
db.Cmd.Parameters.AddWithValue("@InvenTypeCode", cbxInvenTypeCode.SelectedValue.ToString());
}

db.Cmd.Parameters.AddWithValue("@SpecsModel", txtSpecsModel.Text.Trim());
db.Cmd.Parameters.AddWithValue("@MeaUnit", txtMeaUnit.Text.Trim());

if (String.IsNullOrEmpty(txtSelPrice.Text.Trim()))
{
//把null对象化为DBNull
db.Cmd.Parameters.AddWithValue("@SelPrice", DBNull.Value);
}
else
{
db.Cmd.Parameters.AddWithValue("@SelPrice", Convert.ToDecimal(txtSelPrice.Text.Trim()));
}

if (String.IsNullOrEmpty(txtPurPrice.Text.Trim()))
{
//把null对象化为DBNull
db.Cmd.Parameters.AddWithValue("@PurPrice", DBNull.Value);
}
else
{
db.Cmd.Parameters.AddWithValue("@PurPrice", Convert.ToDecimal(txtPurPrice.Text.Trim()));
}

if (String.IsNullOrEmpty(txtSmallStockNum.Text.Trim()))
{
//把null对象化为DBNull
db.Cmd.Parameters.AddWithValue("@SmallStockNum", DBNull.Value);
}
else
{
db.Cmd.Parameters.AddWithValue("@SmallStockNum", Convert.ToInt32(txtSmallStockNum.Text.Trim()));
}

if (String.IsNullOrEmpty(txtBigStockNum.Text.Trim()))
{
//把null对象化为DBNull
db.Cmd.Parameters.AddWithValue("@BigStockNum", DBNull.Value);
}
else
{
db.Cmd.Parameters.AddWithValue("@BigStockNum", Convert.ToInt32(txtBigStockNum.Text.Trim()));
}
}

private void FormInven_Load(object sender, EventArgs e)
{
//权限
commUse.CortrolButtonEnabled(toolAdd, this);
commUse.CortrolButtonEnabled(toolAmend, this);
commUse.CortrolButtonEnabled(toolDelete, this);
//ComboBox绑定到数据源
commUse.BindComboBox(cbxInvenTypeCode, "InvenTypeCode", "InvenTypeName", " Select * From BSInvenType", "BSInvenType");
//DataGridViewComboBoxColumn绑定到数据源
commUse.BindComboBox(this.dgvInvenInfo.Columns[2], "InvenTypeCode", "InvenTypeName", " Select * From BSInvenType", "BSInvenType");
//
this.BindDataGridView("");
this.BindToolStripComboBox();
this.cbxCondition.SelectedIndex = 0;
toolStrip1.Tag = "";
}

private void txtSelPrice_KeyPress(object sender, KeyPressEventArgs e)
{
commUse.InputNumeric(e, sender as Control);
}

private void txtPurPrice_KeyPress(object sender, KeyPressEventArgs e)
{
commUse.InputNumeric(e, sender as Control);
}

private void txtSmallStockNum_KeyPress(object sender, KeyPressEventArgs e)
{
commUse.InputInteger(e);
}

private void txtBigStockNum_KeyPress(object sender, KeyPressEventArgs e)
{
commUse.InputInteger(e);
}

private void toolAdd_Click(object sender, EventArgs e)
{
ControlStatus();
ClearControls();
toolStrip1.Tag = "ADD"; //添加状态
txtInvenCode.Enabled = true;
}

private void toolAmend_Click(object sender, EventArgs e)
{
ControlStatus();
ClearControls();
toolStrip1.Tag = "EDIT"; //修改状态
txtInvenCode.Enabled = false;
}

private void toolCancel_Click(object sender, EventArgs e)
{
ControlStatus();
ClearControls();
toolStrip1.Tag = "";
}

private void dgvInvenInfo_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (toolStrip1.Tag.ToString() == "EDIT")
{
if (dgvInvenInfo.RowCount > 0)
{
//判断当前记录的主键值是否存在外键约束
if (commUse.IsExistConstraint("BSInven", dgvInvenInfo[0, dgvInvenInfo.CurrentCell.RowIndex].Value.ToString()))
{
txtInvenCode.Enabled = false;
}
else
{
txtInvenCode.Enabled = true;
}

FillControls();
}
}
}

private void toolSave_Click(object sender, EventArgs e)
{
string strCode = null;
SqlDataReader sdr = null;

if (String.IsNullOrEmpty(txtInvenCode.Text.Trim()))
{
MessageBox.Show("存货编号不许为空!", "软件提示");
txtInvenCode.Focus();
return;
}

if (String.IsNullOrEmpty(txtInvenName.Text.Trim()))
{
MessageBox.Show("存货名称不许为空!", "软件提示");
txtInvenName.Focus();
return;
}

if (cbxInvenTypeCode.SelectedValue == null)
{
MessageBox.Show("存货类别不许为空!", "软件提示");
cbxInvenTypeCode.Focus();
return;
}

if (!String.IsNullOrEmpty(txtBigStockNum.Text.Trim()) && !String.IsNullOrEmpty(txtSmallStockNum.Text.Trim()))
{
if (Convert.ToInt32(txtSmallStockNum.Text.Trim()) > Convert.ToInt32(txtBigStockNum.Text.Trim()))
{
MessageBox.Show("最低库存不许大于最高库存!", "软件提示");
txtSmallStockNum.Focus();
return;
}
}

//添加
if (toolStrip1.Tag.ToString() == "ADD")
{
strCode = "select * from BSInven where InvenCode = ‘" + txtInvenCode.Text.Trim() + "‘";
try
{
sdr = db.GetDataReader(strCode);
sdr.Read();
if (!sdr.HasRows)
{
sdr.Close();

strCode = "INSERT INTO BSInven(InvenCode,InvenName,InvenTypeCode,SpecsModel,MeaUnit,SelPrice,PurPrice,SmallStockNum,BigStockNum) ";
strCode += "VALUES(@InvenCode,@InvenName,@InvenTypeCode,@SpecsModel,@MeaUnit,@SelPrice,@PurPrice,@SmallStockNum,@BigStockNum)";

ParametersAddValue();

if (db.ExecDataBySql(strCode) > 0)
{
MessageBox.Show("保存成功!", "软件提示");
this.BindDataGridView("");
ControlStatus();
}
else
{
MessageBox.Show("保存失败!", "软件提示");
}
}
else
{
MessageBox.Show("编码重复,请重新设置", "软件提示");
this.txtInvenCode.Focus();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "软件提示");
throw ex;
}
finally
{
sdr.Close();
}
}

//修改
if (toolStrip1.Tag.ToString() == "EDIT")
{
string strOldInvenCode = null;

//未修改之前的存货代码
strOldInvenCode = this.dgvInvenInfo[0, this.dgvInvenInfo.CurrentCell.RowIndex].Value.ToString();

//存货代码被修改过
if (strOldInvenCode != txtInvenCode.Text.Trim())
{
strCode = "select * from BSInven where InvenCode = ‘" + txtInvenCode.Text.Trim() + "‘";

try
{
sdr = db.GetDataReader(strCode);
sdr.Read();
if (sdr.HasRows)
{
MessageBox.Show("编码重复,请重新设置", "软件提示");
this.txtInvenCode.Focus();
sdr.Close();
return;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "软件提示");
throw ex;
}
finally
{
sdr.Close();
}
}

//更新数据库
try
{
strCode = "UPDATE BSInven SET InvenCode = @InvenCode,InvenName = @InvenName,";
strCode += "InvenTypeCode = @InvenTypeCode,SpecsModel = @SpecsModel,MeaUnit = @MeaUnit,";
strCode += "SelPrice = @SelPrice,PurPrice = @PurPrice,SmallStockNum = @SmallStockNum,BigStockNum = @BigStockNum ";
strCode += "WHERE InvenCode = ‘" + strOldInvenCode + "‘";

ParametersAddValue();

if (db.ExecDataBySql(strCode) > 0)
{
MessageBox.Show("保存成功!", "软件提示");
this.BindDataGridView("");
ControlStatus();
}
else
{
MessageBox.Show("保存失败!", "软件提示");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "软件提示");
throw ex;
}
}

toolStrip1.Tag = "";
}

private void toolDelete_Click(object sender, EventArgs e)
{
string strInvenCode = null;
string strSql = null;

if (this.dgvInvenInfo.RowCount == 0)
{
return;
}

strInvenCode = this.dgvInvenInfo[0, this.dgvInvenInfo.CurrentCell.RowIndex].Value.ToString();

//判断当前记录的主键值是否存在外键约束
if (commUse.IsExistConstraint("BSInven", strInvenCode))
{
MessageBox.Show("已发生业务关系,无法删除", "软件提示");
return;
}

strSql = "DELETE FROM BSInven WHERE InvenCode = ‘" + strInvenCode + "‘";

if (MessageBox.Show("确定要删除吗?", "软件提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
{
try
{
if (db.ExecDataBySql(strSql) > 0)
{
MessageBox.Show("删除成功!", "软件提示");
}
else
{
MessageBox.Show("删除失败!", "软件提示");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "软件提示");
throw ex;
}

this.BindDataGridView("");
}
}

private void txtOK_Click(object sender, EventArgs e)
{
string strWhere = String.Empty;
string strConditonName = String.Empty;

strConditonName = this.cbxCondition.Items[this.cbxCondition.SelectedIndex].ToString();

switch (strConditonName)
{
case "存货名称":

strWhere = " WHERE InvenName LIKE ‘%" + txtKeyWord.Text.Trim() + "%‘";
this.BindDataGridView(strWhere);
break;

case "规格型号":

strWhere = " WHERE SpecsModel LIKE ‘%" + txtKeyWord.Text.Trim() + "%‘";
this.BindDataGridView(strWhere);
break;

default:
break;
}
}

private void toolreflush_Click(object sender, EventArgs e)
{
this.BindDataGridView("");
}

private void toolExit_Click(object sender, EventArgs e)
{
this.Close();
}
}


}

```

呵呵呵呵,布布扣,bubuko.com

时间: 2024-10-12 22:35:41

呵呵呵呵的相关文章

个呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵喝喝酒

http://yc.58.com/jdyd/jh_%E7%A3%90%E7%9F%B3%E6%89%BE%E5%B0%8F%E5%A7%90%E5%BE%AE%E4%BF%A1%E7%94%B5%E8%AF%9D186-0138-3322/ http://yc.58.com/jdyd/jh_%E5%BA%84%E6%B2%B3%E6%89%BE%E5%B0%8F%E5%A7%90%E5%BE%AE%E4%BF%A1%E7%94%B5%E8%AF%9D186-0138-3322/ http://y

为USD呵呵呵呵呵呵

 http://www.ebay.com/cln/gl2-ecgi/20150130/164374102015 http://www.ebay.com/cln/jwmco6fegkmlyob/20150130/164266384013 http://www.ebay.com/cln/py1fdyw-njr2l/20150130/164284778011 http://www.ebay.com/cln/gndl8937.h7zagw/20150130/164069368018 http://w

CONTEST45 呵呵呵呵呵

题目质量差评!为什么不给数据范围! A.乘积最大3 题目:http://dev.luogu.org/problem/show?pid=2172 题解:sb题,均值定理. 代码: 1 #include<cstdio> 2 #include<cstdlib> 3 #include<cmath> 4 #include<cstring> 5 #include<algorithm> 6 #include<iostream> 7 #include

呵呵呵呵。。。系统还原了,终于可以用IE登陆百度了

原文发布时间为:2009-12-19 -- 来源于本人的百度文章 [由搬家工具导入] 呵呵呵呵。。。今天终于有时间把系统还原了,终于可以用IE登陆百度了

sycCMS PHP V1.0---呵呵呵呵呵

闲的无聊,随便找了份代码看了看. //search.php 第17行 第49行 ...... $keyword=SafeRequest("keyword","post"); if($keyword==""){ $keyword=ReplaceStr(SafeRequest("keyword","get")," ",""); } if($keyword=="&

谷歌那让人“呵呵”的图像技术

其实,谷歌在图像技术方面没搞明白的,可不仅仅只是libjpeg的optimize_mode参数那么简单. 跟安卓系统在图像内存管理方面的“糊涂”比起来,图片品质还真算不上个事,质量差点大家还能忍,内存管理不当则会导致应用的崩溃(OOM :Out of Memory)可就真没人能忍了.   Bitmap很占内存,那到底会占多少内存呢?计算起来很简单,如果你需要显示一个长宽均为612个像素的正方形图片,对应的Bitmap对象需要612*612*4=1498176个字节的内存,即大约不到1.5MB的内

调侃985_不是我写的,我仅看过,呵呵

1 东方不败是清华, 朝上有人好提拔. (清华大学) 2 最敢放炮是北大, 媒介政坛爱自夸. (北京大学) 3 顾影自怜复旦花, 坐吃山空穷人家. (复旦大学) 4 来者不拒是浙大, 大杂烩里要数他. (浙江大学) 5 咸鱼翻身上交大, 拽着主席抬身价. (上海交通大学) 6 金玉其外是南大, 炮制论文网上挖. (南京大学) 7 党国大学中山大, 海外校友最庞大. (中山大学) 8 自以为是中科大, 崇洋媚外海外爬. (中国科技大学) 9 昙花一现华科大, 怨天尤人没身价. (华中科技大学) 1

做网站千万别找中企动力!如果非要找他们,我只能呵呵了!

大家好,我是一名公司的员工,我们公司官网是中企动力做的.本人从事网站运营.网站优化多年,以前从来没有接触过他们,所以我说说接触后的感想. 声明:这篇文章绝对不是黑中企动力,是我个人从网站运营平时遇到的问题,从而写这篇博文! 首先,他们不会给ftp,因为所有的网站是在他们的模板基础上生成.网站需要改动都要通过他们,(因为要收服务费,2000多一年).后台每个导航,每个产品可以是说每个页面的标题都得一个个手工去修改,默认的标题非常长,自动生成的url也特别长,非常不利于搜索引擎收录.要做seo的话,

嘻嘻哈哈呵呵

上周周一考MIS,没看. 周二考分布式,没看. 周三考计算机网络,没看. 明天考软件工程,没看. 周二考软件测试,没看. 到底该淡定呢?还是抓狂呢?(如何以鼠标移动最短的路线来玩连连看呢) 发的软件工程的书,满是经验之谈,看着瞌睡.(如何以最少的子弹来玩祖玛呢) 打开测试的书,找不到兴奋点.(如何按最少的键来修改像矩阵里所有的2呢) 百度来学习的资料也是千篇一律,没有自己的"灵".(完全图里面有多少圈呢) 谷歌连不上.(完全图压成一维的,边重合的厚度有没有什么隐藏信息呢) 和测试的老师