本文整理汇总了C#中System.Windows.Forms.BindingSource.AddNew方法的典型用法代码示例。如果您正苦于以下问题:C# BindingSource.AddNew方法的具体用法?C# BindingSource.AddNew怎么用?C# BindingSource.AddNew使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.BindingSource
的用法示例。
在下文中一共展示了BindingSource.AddNew方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenericEditEvent
public bool GenericEditEvent(IEditable _geditForm, BindingSource actualEvents, bool isNew = false)
{
ulog = UserLog.Instance;
try
{
DataRowView eventDataRowView;
eventDataRowView = (isNew == false) ? (DataRowView)actualEvents.Current : (DataRowView)actualEvents.AddNew();
if (eventDataRowView == null)
throw new Exception("Нет записей для редактирования.");
using (IEditable editForm = _geditForm)
{
if (editForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
actualEvents.EndEdit();
DateTime dt;
string _edit = (isNew == false) ? "Изменено " : "Добавлено ";
if (eventDataRowView.Row.Table.Columns.Contains("ActionDate"))
{
dt = Convert.ToDateTime(eventDataRowView["ActionDate"]);
_edit += "мероприятие на " + dt.ToShortDateString() + ".";
}
else if (eventDataRowView.Row.Table.Columns.Contains("DayID"))
{
_edit += "календарное мероприятие. День недели: " + DatabaseConstant.LocalDayOfWeek[Convert.ToInt32(eventDataRowView["DayID"]) - 1] + ".";
}
ulog.Message(_edit, UserLogMessageLevel.Warning);
return true;
}
else
{
actualEvents.CancelEdit();
return false;
}
}
}
catch (Exception ex)
{
ulog.Message(ex.Message, UserLogMessageLevel.Error);
return false;
}
}
示例2: SelectData
/// <summary>
/// 选择导入数据
/// </summary>
/// <param name="dsDetail">导入目标数据源</param>
/// <param name="reportno">查询编号</param>
/// <param name="fields">导入的字段,e.g: a=b,c=d 其中a和c为目标数据源中的字段,b和d为选择数据源中的字段,多个用英文逗号“,”进行分割</param>
/// <param name="where">选择数据源的过滤条件</param>
/// <param name="isautoselect">是否默认选中所有数据</param>
public void SelectData(BindingSource dsDetail, string reportno, string fields, string where,bool isautoselect)
{
//数据选择窗体
frmCommSelectForm frm = new frmCommSelectForm(reportno, where, isautoselect);
frm.StartPosition = FormStartPosition.CenterParent;
frm.WindowState = FormWindowState.Normal;
frm.ReportNo = reportno;
if (frm.ShowDialog() == DialogResult.OK)
{
//解析需要设置值的字段
string[] fieldstring = Public.GetSplitString(fields, ",");
List<string> ValueFields = new List<string>();
List<string> DataFields = new List<string>();
foreach (string s in fieldstring)
{
string[] ss = Public.GetSplitString(s, "=");
DataFields.Add(ss[0]);
ValueFields.Add(ss[1]);
}
//插入数据
foreach (DataRow dr in frm.ResultData)
{
dsDetail.AddNew();
for (int i = 0; i < DataFields.Count; i++)
{
((DataRowView)dsDetail.Current).Row[DataFields[i]] = dr[ValueFields[i]];
}
dsDetail.EndEdit();
}
}
}
示例3: Form1
public Form1()
{
InitializeComponent();
BindingSource bs = new BindingSource();
bs.DataSource = typeof(bab);
bs.AddNew();
dataLayoutControl1.AutoRetrieveFields = true;
dataLayoutControl1.DataSource = bs;
}
示例4: GenericEditAction
public bool GenericEditAction(IEditable _geditForm, BindingSource actualActions, BindingSource groupHeadersList, bool isNew = false)
{
ulog = UserLog.Instance;
try
{
DataRowView actionDataRowView;
actionDataRowView = (isNew == false) ? (DataRowView)actualActions.Current : (DataRowView)actualActions.AddNew();
if (actionDataRowView == null)
throw new Exception("Нет записей для редактирования.");
using (IEditable editActForm = _geditForm)
{//открываем форму и сохраняем изменения
if (editActForm.ShowDialog() == DialogResult.OK)
{
actualActions.EndEdit();
return true;
}
else
{
actualActions.CancelEdit();
return false;
}
}
}
catch (Exception ex)
{
actualActions.CancelEdit();
ulog.Message(ex.Message, UserLogMessageLevel.Error);
return false;
}
finally
{
groupHeadersList.RemoveFilter();
groupHeadersList.Filter = "[InList] = 1";
}
}
示例5: GetBindBox
public static BindingSource GetBindBox(string TSQL, IDbConnection myConn)
{
bool mustClose = false;
if (myConn == null)
{
mustClose = true;
myConn = clsConn.getConnOLE();
}
if (myConn.State != ConnectionState.Open)
myConn.Open();
DataSet myDS = GetDataSet(TSQL, myConn as OleDbConnection);
if (mustClose) myConn.Close();
BindingSource myBind = new BindingSource();
//
myBind.DataSource = myDS;
myBind.DataMember = myDS.Tables[0].ToString();
myBind.AddNew();
//Thêm 1 dòng trắng cuối cùng của list
//
return myBind;
}
示例6: LoadCboDonViTrucThuoc
private void LoadCboDonViTrucThuoc()
{
DataTable dvlist = donvi.GetActiveDonVi();
BindingSource bs = new BindingSource();
bs.DataSource = dvlist;
bs.AddNew();
comB_TrucThuoc.DataSource = bs;
comB_TrucThuoc.DisplayMember = "ten_don_vi";
comB_TrucThuoc.ValueMember = "id";
}
示例7: inserta_persona
// el Bs de persona, el bs del elemento a tratar, el dgv del elemento a tratar
// el maximo del id de el elemento a tratar
// el elemnto donde quiro pararme al adicionar un elemento(nombre)
// el nombre del id que tiene el dgv a tratar(id)
// el nombre q tiene id id perosna en la tabla especifica
public static void inserta_persona(BindingSource persona, BindingSource bs, DataGridView dgv, int max, string nombre, string id, string id_detalle)
{
if (dgv.Rows.Count > 0) dgv.CurrentCell = dgv.CurrentRow.Cells[nombre];
if (max >= 10000) max = max + 1;
else max = Convert.ToInt32(Convert.ToString(mia.id_centro) + "0001");
bs.AddNew();
dgv.Rows[dgv.Rows.Count - 1].Cells[id].Value = max;
dgv.CurrentCell = dgv.CurrentRow.Cells[nombre];
DataRowView view = (DataRowView)persona.Current;
dgv.Rows[dgv.Rows.Count - 1].Cells[id_detalle].Value = view["id"].ToString();
dgv.Focus();
}
示例8: inserta_asesoria
public static void inserta_asesoria(BindingSource bs, DataGridView dgv, ToolStripButton bn, int max, string nombre, string id)
{
if (dgv.Rows.Count > 0)
{
bn.Enabled = true;
dgv.CurrentCell = dgv.CurrentRow.Cells[nombre];
}
if (max >= 10000) max = max + 1;
else max = Convert.ToInt32(Convert.ToString(mia.id_centro) + "0001");
bs.AddNew();
dgv.Rows[dgv.Rows.Count - 1].Cells[id].Value = max;
dgv.CurrentCell = dgv.CurrentRow.Cells[nombre];
}
示例9: CreateNewBlankPurchaseOrderDetail
private void CreateNewBlankPurchaseOrderDetail(BindingSource bill)
{
PurchaseOrderDetail orderDetail = (PurchaseOrderDetail)bill.AddNew();
orderDetail.CreateId = ClientInfo.getInstance().LoggedUser.Name;
orderDetail.CreateDate = DateTime.Now;
orderDetail.UpdateDate = DateTime.Now;
orderDetail.UpdateId = orderDetail.CreateId;
orderDetail.DelFlg = 0;
orderDetail.DepartmentId = CurrentDepartment.Get().DepartmentId;
orderDetail.Quantity = 1;
PurchaseOrderDetailPK purchaseOrderDetailPK = new PurchaseOrderDetailPK();
purchaseOrderDetailPK.DepartmentId = CurrentDepartment.Get().DepartmentId;
orderDetail.PurchaseOrderDetailPK = purchaseOrderDetailPK;
// new product to test
ProductMaster productMaster = new ProductMaster();
orderDetail.ProductMaster = productMaster;
Product product = new Product();
product.ProductMaster = orderDetail.ProductMaster;
orderDetail.Product = product;
bill.EndEdit();
}