表格录入_selectlookup控件选择

标签:vat   ons   nta   material   position   dev   send   unit   and   

public partial class MaterialsForm : Form
{
DataTable dtMaterial = new DataTable();
DataTable dtMaterialBill = new DataTable();
public MaterialsForm()
{
InitializeComponent();
InitMaterial();
InitMaterialBill();
}
/// <summary>
/// 初始化物料
/// </summary>
private void InitMaterial()
{
//dtMaterial.Columns.Add("FId", typeof(string));
dtMaterial.Columns.Add("FCode", typeof(string));
dtMaterial.Columns.Add("FName", typeof(string));
dtMaterial.Columns.Add("FUnit", typeof(string));
for (int i = 1; i < 11; i++)
{
DataRow drNew = dtMaterial.NewRow();
//drNew["FId"] = Guid.NewGuid().ToString();
drNew["FName"] = "测试物料" + i;
string FCode = i.ToString();
while (FCode.Length < 4)
{
FCode = "0" + FCode;
}
drNew["FCode"] = FCode;
drNew["FUnit"] = "个";
dtMaterial.Rows.Add(drNew);
}
this.repSearchLookUpEdit.DataSource = dtMaterial;
}
/// <summary>
/// 初始化物料单
/// </summary>
private void InitMaterialBill()
{
dtMaterialBill.Columns.Add("FId", typeof(string));
dtMaterialBill.Columns.Add("FCode", typeof(string));
dtMaterialBill.Columns.Add("FName", typeof(string));
dtMaterialBill.Columns.Add("FCount", typeof(int));
dtMaterialBill.Columns.Add("FUnit", typeof(string));

this.gcMaterials.DataSource = dtMaterialBill;
}

private void gvMaterials_ShowingEditor(object sender, CancelEventArgs e)
{
//object FId = this.gvMaterials.GetRowCellValue(this.gvMaterials.FocusedRowHandle, "FId");
//if (FId != null && FId.ToString() != Guid.Empty.ToString())
//{
// e.Cancel = true;
//}

}

private void gvMaterials_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
{
if (e.Column.FieldName == "FCode")
{
string FCode = e.Value.ToString();
DataRow[] dr = dtMaterial.Select(string.Format("FCode = ‘{0}‘", FCode));
if (dr != null && dr.Length > 0)
{
DataRow row = dr[0];
string FName = row["FName"].ToString();
gvMaterials.SetRowCellValue(e.RowHandle, "FName", FName);

string FUnit= row["FUnit"].ToString();
gvMaterials.SetRowCellValue(e.RowHandle, "FUnit", FUnit);
}
}
}

/// <summary>
/// 保存
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
dtMaterialBill.Clear();
gcMaterials.RefreshDataSource();
}

/// <summary>
/// 保存
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
dtMaterialBill.Clear();
gcMaterials.RefreshDataSource();
}

private void gcMaterials_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
popupMenu1.ShowPopup(Control.MousePosition);
}
}
}

表格录入_selectlookup控件选择

标签:vat   ons   nta   material   position   dev   send   unit   and   

原文地址:https://www.cnblogs.com/dengronghua/p/14127949.html

版权声明:完美者 发表于 2020-12-18 12:26:46。
转载请注明:表格录入_selectlookup控件选择 | 完美导航

暂无评论

暂无评论...