tijian_jichuang/Code/BasicSettings/frmSetFenDian.cs

104 lines
3.0 KiB
C#
Raw Normal View History

2025-02-20 11:54:48 +08:00
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 SOH.Window;
using SOH.Kernel;
using EAS;
using EAS.Services;
using SOH.BLL;
using SOH.Data;
namespace SOH.BasicSettings
{
[ModuleAttribute(ModuleID = "4372AF94-0445-449E-9D56-CDE67614A1D9", ModuleName = "分店管理")]
public partial class frmSetFenDian : baseChildForm
{
List<Entities.FenDian> fendians;
public frmSetFenDian()
{
InitializeComponent();
}
private void frmSetFenDian_Load(object sender, EventArgs e)
{
initdata();
initSearch();
}
private void initdata()
{
//throw new NotImplementedException();
var vservice = ServiceContainer.GetService<IFenDian>();
fendians = vservice.getAllFenDian();
}
private void initSearch()
{
//throw new NotImplementedException();
fenDianBindingSource.DataSource = fendians.Where(p => p.fdmc.Contains(txt_key.Text.Trim()) || p.fdmc.ToPinYin().Contains(txt_key.Text.ToPinYin())).ToList();
}
private void btn_add_Click(object sender, EventArgs e)
{
frmFenDianAdd fdadd = new frmFenDianAdd();
fdadd.ShowDialog();
if (fdadd.DialogResult == DialogResult.OK)
{
//fendians.Add();
//dgv_fdlist.Refresh();
fenDianBindingSource.Add(fdadd.getfd());
}
}
private void btn_search_Click(object sender, EventArgs e)
{
initSearch();
}
private void btn_modify_Click(object sender, EventArgs e)
{
if (selectedrow())
{
Entities.FenDian fd = dgv_fdlist.SelectedRows[0].DataBoundItem as Entities.FenDian;
frmFenDianAdd fdadd = new frmFenDianAdd();
fdadd.init(fd);
fdadd.ShowDialog();
}
}
private bool selectedrow()
{
//throw new NotImplementedException();
if (dgv_fdlist.SelectedRows.Count <= 0)
{
MessageBox.Show("请选择要操作的数据!");
}
return dgv_fdlist.SelectedRows.Count > 0;
}
private void btn_delete_Click(object sender, EventArgs e)
{
if (selectedrow())
{
var vservice = ServiceContainer.GetService<IFenDian>();
Entities.FenDian fd = dgv_fdlist.SelectedRows[0].DataBoundItem as Entities.FenDian;
OperationResult or= vservice.Delete(fd);
MessageBox.Show(or.Message);
if (or.State == 1)
{
//fendians.Remove(fd);
//dgv_fdlist.Refresh();
fenDianBindingSource.Remove(fd);
}
}
}
}
}