📄 frmsystemset.cs
字号:
txtName.Text = "";
}
else
{
MessageBox.Show("添加失败!","提示");
}
}
//删除类型
private void btnDeleteItemType_Click(object sender, EventArgs e)
{
if (txtTypeNum.Text.Equals("")||txtName.Text.Trim().Equals(""))
{
MessageBox.Show("未选中任何类型!","提示");
return;
}
DialogResult dr = MessageBox.Show("确定要删除 "+txtName.Text.Trim()+" 类型吗?","确认",
MessageBoxButtons.YesNo,MessageBoxIcon.Question);
if (dr == DialogResult.Yes)
{
int type=int.Parse(txtTypeNum.Text.Trim().ToString());
//检查是否存在该类型的商品,如果存在则不能删除
int k=objItemsPriceAccess.FindTypeItem(type);
if (k != 0)
{
MessageBox.Show("商品中存在与该类型关联,不能删除!", "提示");
return;
}
int ct = objItemsTypeAccess.DeleteItemType(type);
if (ct != 0)
{
MessageBox.Show("删除成功!", "提示");
//刷新房间各种类型
objItemsTypeAccess = new ItemsTypeAccess();
objItemsTypeAccess.GetTypeInfo(lsvItemsType);
//更新cboItemType
ArrayList arr = new ArrayList();
arr = objItemsTypeAccess.GetItemType();
cboItemType.Items.Clear();
cboItemType.Items.Add("所有商品");
foreach (string str in arr)
{
cboItemType.Items.Add(str);
}
//清空文本框
txtName.Text = "";
}
else
{
MessageBox.Show("删除失败!","提示");
}
}
}
private void btnItemExit_Click(object sender, EventArgs e)
{
this.Close();
}
//修改类型名称
private void btnModifiItemType_Click(object sender, EventArgs e)
{
if (txtTypeNum.Text.Trim().Equals(""))
{
MessageBox.Show("您还没有选中任何类型!","提示");
return;
}
objItemsTypeAccess=new ItemsTypeAccess();
int type=int.Parse(txtTypeNum.Text.Trim());
string name=txtName.Text.Trim();
int k = objItemsTypeAccess.ModifiTypeName(type, name);
if (k != 0)
{
MessageBox.Show("修改成功!", "提示");
//刷新房间各种类型
objItemsTypeAccess = new ItemsTypeAccess();
objItemsTypeAccess.GetTypeInfo(lsvItemsType);
//更新cboItemType
ArrayList arr = new ArrayList();
arr = objItemsTypeAccess.GetItemType();
cboItemType.Items.Clear();
cboItemType.Items.Add("所有商品");
foreach (string str in arr)
{
cboItemType.Items.Add(str);
}
//清空文本框
txtName.Text = "";
//刷新
//所有商品
objItemsPriceAccess = new ItemsPriceAccess();
objItemsPriceAccess.GetItems(lsvItems, "ItemsTypeID");
}
else
{
MessageBox.Show("修改失败","提示");
}
}
private void btnCarExit_Click(object sender, EventArgs e)
{
this.Close();
}
//添加会员卡类型
private void btnCarAdd_Click(object sender, EventArgs e)
{
//验证界面输入信息
if (txtCatName.Text.Trim().Equals(""))
{
MessageBox.Show("卡的类型名称不能为空!", "提示");
return;
}
if (txtCarRebate.Text.Trim().Equals(""))
{
MessageBox.Show("请设定该卡的折扣!", "提示");
return;
}
if (txtCarAmass.Text.Trim().Equals(""))
{
MessageBox.Show("还没有填写积分统计点!", "提示");
return;
}
string name = txtCatName.Text.Trim();
float re=0;
int am=0;
try
{
re= (float)((float.Parse(txtCarRebate.Text.Trim().ToString())) * 0.01);
}
catch
{
MessageBox.Show("折扣填写有误!","提示");
return;
}
try
{
am= int.Parse(txtCarAmass.Text.Trim());
}
catch
{
MessageBox.Show("积分点填表写错误!","提示");
return;
}
string rema = txtCarRemark.Text.Trim();
objAssociatorAccess = new AssociatorAccess();
ArrayList arr = new ArrayList();
arr= objAssociatorAccess.GetAllName();
foreach (string str in arr)
{
if (name == str)
{
MessageBox.Show("不能插入相同名称的类型!","提示");
return;
}
}
int k=objAssociatorAccess.AddAssociator(name, re, am, rema);
if (k != 0)
{
MessageBox.Show("添加成功!", "提示");
//更新会员卡类型信息到表
objAssociatorAccess = new AssociatorAccess();
objAssociatorAccess.GetAssociatorInfo(lsvCar);
}
else
{
MessageBox.Show("添加失败!","提示");
}
}
//修改会员卡信息
private void btnCarModifi_Click(object sender, EventArgs e)
{
int k = 0;
try
{
k = int.Parse(lsvCar.SelectedItems[0].Text.ToString());
}
catch
{
}
if (k == 0)
{
MessageBox.Show("请选中要修改的行!","提示");
return;
}
//验证界面输入信息
if (txtCatName.Text.Trim().Equals(""))
{
MessageBox.Show("卡的类型名称不能为空!", "提示");
return;
}
if (txtCarRebate.Text.Trim().Equals(""))
{
MessageBox.Show("请设定该卡的折扣!", "提示");
return;
}
if (txtCarAmass.Text.Trim().Equals(""))
{
MessageBox.Show("还没有填写积分统计点!", "提示");
return;
}
string name = txtCatName.Text.Trim();
float re = 0;
int am = 0;
try
{
re = (float)((float.Parse(txtCarRebate.Text.Trim().ToString())) * 0.01);
}
catch
{
MessageBox.Show("折扣填写有误!", "提示");
return;
}
try
{
am = int.Parse(txtCarAmass.Text.Trim());
}
catch
{
MessageBox.Show("积分点填表写错误!", "提示");
return;
}
string rema = txtCarRemark.Text.Trim();
objAssociatorAccess = new AssociatorAccess();
int num=objAssociatorAccess.ModifiInfo(name, re, am, rema, k);
if (num != 0)
{
MessageBox.Show("修改成功!", "提示");
//更新会员卡类型信息到表
objAssociatorAccess = new AssociatorAccess();
objAssociatorAccess.GetAssociatorInfo(lsvCar);
}
else
{
MessageBox.Show("修改失败!","提示");
}
}
//当选中时显示信息到文本框
private void lsvCar_SelectedIndexChanged(object sender, EventArgs e)
{
int k = 0;
try
{
k = int.Parse(lsvCar.SelectedItems[0].Text.ToString());
}
catch
{
}
objAssociatorAccess = new AssociatorAccess();
SqlDataReader dr = objAssociatorAccess.GetInfo(k);
dr.Read();
if (dr.HasRows)
{
txtCatName.Text = dr.GetValue(1).ToString();
float kk = (float.Parse(dr.GetValue(2).ToString()))*100;
txtCarRebate.Text = kk.ToString();
txtCarAmass.Text = dr.GetValue(3).ToString();
txtCarRemark.Text = dr.GetValue(4).ToString();
}
dr.Close();
}
//删除类型
private void btnCarDelete_Click(object sender, EventArgs e)
{
int k = 0;
try
{
k = int.Parse(lsvCar.SelectedItems[0].Text.ToString());
}
catch
{
}
if (k == 0)
{
MessageBox.Show("请选中要删除的行!","提示");
return;
}
DialogResult dr = MessageBox.Show("确定要删除 "+txtCatName.Text+" 类型吗?","确认",
MessageBoxButtons.YesNo,MessageBoxIcon.Question);
if (dr == DialogResult.Yes)
{
objAssociatorAccess = new AssociatorAccess();
int num = objAssociatorAccess.DeleteInfo(k);
if (num != 0)
{
MessageBox.Show("删除成功!", "提示");
//更新会员卡类型信息到表
objAssociatorAccess = new AssociatorAccess();
objAssociatorAccess.GetAssociatorInfo(lsvCar);
}
else
{
MessageBox.Show("删除失败!", "提示");
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -