示例#1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                //添加一行数据,对相应数据进行填充
                DataRow newrow = dsEnergyData.Tables[0].NewRow();
                newrow["ProductionDate"] = DateTime.Now.ToString("yyyyMMdd");
                newrow["CreateTime"]     = DateTime.Now;

                newrow["TagValue"]   = 0;
                newrow["DayValue"]   = 0;
                newrow["MonthValue"] = 0;
                newrow["Operator"]   = Adapter.Session.User;

                dsEnergyData.Tables[0].Rows.Add(newrow);

                bsEnergyData.MoveFirst();
                while ((bsEnergyData.Current as System.Data.DataRowView).Row != newrow || bsEnergyData.Position < dsEnergyData.Tables[0].Rows.Count - 1)
                {
                    bsEnergyData.MoveNext();
                }
                EnergyDataAddModFrm frm = new EnergyDataAddModFrm();
                frm.ShowDialogEx(Adapter.Session, bsEnergyData.Position, strSort, ref dsEnergyData);

                GC.Collect();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "异常", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
示例#2
0
        private void dvEnergyData_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex >= 0 && dsEnergyData.Tables[0].Rows.Count > 0)
                {
                    bsEnergyData.Position = e.RowIndex;

                    EnergyDataAddModFrm frm = new EnergyDataAddModFrm();
                    frm.ShowDialogEx(Adapter.Session, bsEnergyData.Position, strSort, ref dsEnergyData);

                    GC.Collect();
                }
            }
            catch { }
        }