当前位置: 首页>>代码示例>>C#>>正文


C# BindingSource.AddNew方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:hprog,项目名称:exchange,代码行数:46,代码来源:CustomForm.cs

示例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();
                }
            }
        }
开发者ID:itmpanda,项目名称:sunrise-erp,代码行数:40,代码来源:frmCommSelectForm.cs

示例3: Form1

        public Form1()
        {
            InitializeComponent();

            BindingSource bs = new BindingSource();
            bs.DataSource = typeof(bab);
            bs.AddNew();

            dataLayoutControl1.AutoRetrieveFields = true;
            dataLayoutControl1.DataSource = bs;
        }
开发者ID:EgafBackOffice,项目名称:app.main,代码行数:11,代码来源:Form1.cs

示例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";
            }
        }
开发者ID:hprog,项目名称:exchange,代码行数:36,代码来源:CustomForm.cs

示例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;
        }
开发者ID:huamanhtuyen,项目名称:All2Object_CSVBJAVA,代码行数:22,代码来源:clsDalOLE.cs

示例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";
 }
开发者ID:Fucmeo,项目名称:ou-qlns,代码行数:10,代码来源:QLNS_DonVi.cs

示例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();
        }
开发者ID:INGENIUSCuba,项目名称:c--code,代码行数:20,代码来源:mia.cs

示例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];
        }
开发者ID:INGENIUSCuba,项目名称:c--code,代码行数:15,代码来源:mia.cs

示例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();
        }
开发者ID:DelLitt,项目名称:opmscoral,代码行数:23,代码来源:GoodsSaleReturnForm.cs


注:本文中的System.Windows.Forms.BindingSource.AddNew方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。