BeginEdit() private method

private BeginEdit ( ) : void
return void
示例#1
0
        private void GridConfig_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.F8)
            {
                GridColumn Colum = ((SfDataGrid)sender).CurrentColumn as GridColumn;

                if (Colum.MappingName == "bod_doc")
                {
                    int     idr = 0; string code = ""; string nombre = "";
                    dynamic xx = SiaWin.WindowBuscar("InMae_bod", "cod_bod", "nom_bod", "cod_bod", "idrow", "Maestra de Bodegas", cnEmp, true, "", idEmp: idemp);
                    xx.ShowInTaskbar = false;
                    xx.Owner         = Application.Current.MainWindow;
                    xx.Height        = 500;
                    xx.ShowDialog();
                    idr    = xx.IdRowReturn;
                    code   = xx.Codigo;
                    nombre = xx.Nombre;
                    if (idr > 0)
                    {
                        System.Data.DataRow dr = dt_doc.Rows[GridConfig.SelectedIndex];
                        dr.BeginEdit();
                        dr["bod_doc"] = code;
                        dr.EndEdit();
                    }
                }
            }
        }
示例#2
0
    private void SearchOnCustomerAdapterShowDialog()
    {
        // Wizard Generated Search Method
        // You will need to call this method from another method in custom code
        // For example, [Form]_Load or [Button]_Click

        bool   recSelected;
        string whereClause = string.Empty;

        System.Data.DataSet dsCustomerAdapter = Ice.UI.FormFunctions.SearchFunctions.listLookup(this.oTrans, "CustomerAdapter", out recSelected, true, whereClause);
        if (recSelected)
        {
            System.Data.DataRow adapterRow = dsCustomerAdapter.Tables[0].Rows[0];

            // Map Search Fields to Application Fields
            EpiDataView         custDataView    = ((EpiDataView)(this.oTrans.EpiDataViews["Customer"]));
            System.Data.DataRow custDataViewRow = custDataView.CurrentDataRow;
            if ((custDataViewRow != null))
            {
                custDataViewRow.BeginEdit();
                custDataViewRow["ParentCustNum_c"] = adapterRow["CustNum"];
                custDataViewRow["ParentCustID_c"]  = adapterRow["CustID"];
                custDataViewRow.EndEdit();
            }
        }
    }
 private void addNewRecord()
 {
     _drwRecord = _dst.Tables[_strTableName].NewRow();
     _drwRecord.BeginEdit();
     _drwRecord["Description"] = Description;
     _drwRecord.EndEdit();
     _dst.Tables[_strTableName].Rows.Add(_drwRecord);
 }
示例#4
0
 private void addNewRecord()
 {
     _drwRecord = _dst.Tables[_strTableName].NewRow();
     _drwRecord.BeginEdit();
     _drwRecord["BookName"] = BookName;
     _drwRecord["BookAvailable"] = BookAvailable;
     _drwRecord.EndEdit();
     _dst.Tables[_strTableName].Rows.Add(_drwRecord);
 }
示例#5
0
 private void addNewRecord()
 {
     _drwRecord = _dst.Tables[_strTableName].NewRow();
     _drwRecord.BeginEdit();
     _drwRecord["BranchOffice"] = BranchOffice;
     _drwRecord["Active"] = Active;
     _drwRecord.EndEdit();
     _dst.Tables[_strTableName].Rows.Add(_drwRecord);
 }
 private void addNewRecord()
 {
     _drwRecord = _dst.Tables[_strTableName].NewRow();
     _drwRecord.BeginEdit();
     _drwRecord["IngredientName"] = IngredientName;
     _drwRecord["Price"] = Price;
     _drwRecord["Active"] = Active;
     _drwRecord.EndEdit();
     _dst.Tables[_strTableName].Rows.Add(_drwRecord);
 }
 private void addNewRecord()
 {
     _drwRecord = _dst.Tables[_strTableName].NewRow();
     _drwRecord.BeginEdit();
     _drwRecord["FirstName"] = FirstName;
     _drwRecord["LastName"] = LastName;
     _drwRecord["DocNumber"] = DocNumber;
     _drwRecord.EndEdit();
     _dst.Tables[_strTableName].Rows.Add(_drwRecord);
 }
 private void addNewRecord()
 {
     _drwRecord = _dst.Tables[_strTableName].NewRow();
     _drwRecord.BeginEdit();
     _drwRecord["DonorID"] = DonorID;
     _drwRecord["BookID"] = BookID;
     _drwRecord["BookSent"] = BookSent;
     _drwRecord.EndEdit();
     _dst.Tables[_strTableName].Rows.Add(_drwRecord);
 }
示例#9
0
 private void addNewRecord()
 {
     _drwRecord = _dst.Tables[_strTableName].NewRow();
     _drwRecord.BeginEdit();
     _drwRecord["ProdustsName"] = ProductsName;
     _drwRecord["ProductsQty"] = ProductsQty;
     _drwRecord["ProductsCost"] = ProductsCost;
     _drwRecord.EndEdit();
     _dst.Tables[_strTableName].Rows.Add(_drwRecord);
 }
示例#10
0
 private void addNewRecord()
 {
     _drwRecord = _dst.Tables[_strTableName].NewRow();
     _drwRecord.BeginEdit();
     _drwRecord["ProductName"] = ProductName;
     _drwRecord["QuantityInStock"] = QuantityInStock;
     _drwRecord["Price"] = Price;
     _drwRecord["Active"] = Active;
     _drwRecord.EndEdit();
     _dst.Tables[_strTableName].Rows.Add(_drwRecord);
 }
示例#11
0
 /// <summary>
 ///Pre-Condition:All properties have an assigned value
 ///Post-Condition:a new record is added to the table associated with the class 
 ///Description:Adds a new record to the table associated with the class
 /// </summary>
 public void addNewRecord()
 {
     _drwRecord = _dataset.Tables[_strTableName].NewRow();
     _drwRecord.BeginEdit();
     _drwRecord["OrderNumber"] = OrderNumber;
     _drwRecord["IngNumber"] = IngNumber;
     _drwRecord["IngPrice"] = IngPrice;
     _drwRecord["OrderLineQty"] = OrderLineQty;
     _drwRecord["OrderLineSubTotal"] = OrderLineSubTotal;
     _drwRecord.EndEdit();
     _dataset.Tables[_strTableName].Rows.Add(_drwRecord);
     _lngPKID = long.Parse(_drwRecord["ID"].ToString());
 }
示例#12
0
        /// <summary>
        ///Pre-Condition:All properties have an assigned value
        ///Post-Condition:a new record is added to the table associated with the class 
        ///Description:Adds a new record to the table associated with the class
        /// </summary>
        private void addNewRecord()
        {
            _drwRecord = _dataset.Tables[_strTableName].NewRow();
            _drwRecord.BeginEdit();
            _drwRecord["ProductName"] = Name;
            _drwRecord["ProductCode"] = Code;
            _drwRecord["ProductPrice"] = Price;
            _drwRecord["ProductQtyOnHand"] = QtyOnHand;
            _drwRecord["ProductQtyOnOrder"] = QtyOnOrder;

            _drwRecord.EndEdit();
            _dataset.Tables[_strTableName].Rows.Add(_drwRecord);
        }
示例#13
0
        public void AddNewRecord()
        {
            // creates a new data row, and inserts our properties into it
            // another way of explaining this method is converting our data object into
            // a real record
            _dataRow = _dataSet.Tables[TABLE_NAME].NewRow();
            _dataRow.BeginEdit();

            _dataRow["Description"] = Description;
            _dataRow["ProductPrice"] = Price;

            _dataRow.EndEdit();
            _dataSet.Tables[TABLE_NAME].Rows.Add(_dataRow);
        }
示例#14
0
 /// <summary>
 ///Pre-Condition:All properties have an assigned value
 ///Post-Condition:a new record is added to the table associated with the class 
 ///Description:Adds a new record to the table associated with the class
 /// </summary>
 private void addNewRecord()
 {
     _drwRecord = _dataset.Tables[_strTableName].NewRow();
     _drwRecord.BeginEdit();
     _drwRecord["ContactName"] = Name;
     _drwRecord["PhoneNumber"] = PhoneNumber;
     _drwRecord["BuildingNumber"] = BuildingNumber;
     _drwRecord["StreetName"] = StreetName;
     _drwRecord["Suburb"] = Suburb;
     _drwRecord["State"] = State;
     _drwRecord["Postcode"] = Postcode;
     _drwRecord["IsASupplier"] = IsASupplier;
     _drwRecord["ContactPerson"] = ContactPerson;
     _drwRecord.EndEdit();
     _dataset.Tables[_strTableName].Rows.Add(_drwRecord);
 }
示例#15
0
 public void MyTestInitialize()
 {
     DataTable DT = new DataTable();
     DT.Columns.Add("First", typeof (int));
     DT.Columns.Add("Next", typeof (string));
     DT.Columns.Add("Another", typeof (string));
     DT.Columns.Add("Last", typeof (string));
     DT.AcceptChanges();
     dataRow = DT.NewRow();
     dataRow.BeginEdit();
     dataRow["First"] = 42;
     dataRow["Next"] = "Look at your man, now back to me,";
     dataRow["Another"] = "Now back at your man, now back to me.";
     dataRow["Last"] = "I'm on a horse...";
     dataRow.EndEdit();
     DT.AcceptChanges();
 }
示例#16
0
 public void Row()
 {
     if (_table == null)
       {
     _headers = new List<string>();
     _values = new List<object>();
       }
       else
       {
     if (!_loadingData)
     {
       _table.BeginLoadData();
       _loadingData = true;
     }
     _row = _table.NewRow();
     _row.BeginEdit();
       }
 }
 void onPickValueByButton(object Sender, object Value)
 {
     if (_query != null && _query.Adapter != null && currentCellInSynch())
     {
         try
         {
             System.Data.DataRow dw = CurrentRow;
             if (dw != null)
             {
                 dw.BeginEdit();
                 dw[nCurrentCellColumn] = Value;
                 dw.EndEdit();
                 _query.Adapter.Update(_query);
             }
         }
         catch (Exception er)
         {
             FormLog.NotifyException(er);
         }
     }
 }
示例#18
0
        public void DeletedRow(DataRow row, string column)
        {
            if (row == null)
             {
            return;
             }

             string strCheckDel = "";

             if (row.RowState == DataRowState.Added)
            strCheckDel = ConstRowDeleted.LOCAL_DELETE;
             else if(row.RowState == DataRowState.Modified | row.RowState == DataRowState.Unchanged)
            strCheckDel = ConstRowDeleted.DELETE;

             row.BeginEdit();
             if (row[column].ToString() == strCheckDel)
            row[column] = ConstRowDeleted.ACTIVE;
             else
            row[column] = strCheckDel;

             row.EndEdit();
        }
 /// <summary>
 /// Pre-condition:  true
 /// Post-condition: Will add a new record in the dataset.
 /// Description:    This method will add a new record in the dataset.
 /// </summary>
 private void addNewRecord()
 {
     _drwRecord = _dst.Tables[_strTableName].NewRow();
     _drwRecord.BeginEdit();
     _drwRecord["PurchaseCode"] = PurchaseCode;
     _drwRecord["BranchID"] = BranchID;
     _drwRecord["DatePurchased"] = DatePurchased;
     _drwRecord["SupplierID"] = SupplierID;
     _drwRecord["PurchaseTotal"] = PurchaseTotal;
     _drwRecord.EndEdit();
     _dst.Tables[_strTableName].Rows.Add(_drwRecord);
     _lngPKID = long.Parse(_drwRecord["PurchaseID"].ToString());
 }
 /// <summary>
 /// Pre-condition:  true
 /// Post-condition: Will update the selected record in the dataset.
 /// Description:    This method will update the selected record in the dataset.
 /// </summary>
 private void updateRecord()
 {
     _drwRecord = _dst.Tables[_strTableName].Rows.Find(_lngPKID);
     _drwRecord.BeginEdit();
     _drwRecord["PurchaseCode"] = PurchaseCode;
     _drwRecord["BranchID"] = BranchID;
     _drwRecord["DatePurchased"] = DatePurchased;
     _drwRecord["SupplierID"] = SupplierID;
     _drwRecord["PurchaseTotal"] = PurchaseTotal;
     _drwRecord.EndEdit();
 }
 protected void btnBuscar3_Click(object sender, ImageClickEventArgs e)
 {
     try
     {
         string ART1 = (string)Session["ART"];
         string cantiText = txtCan.Text.Trim();
         if ((cantiText != "") && (cantiText != "0"))
         {
             if (ART1.Length > 0)
             {
                 string[] ART = ART1.Split('►');
                 txtArticulo.Text = ART[0].Trim();
                 txtDesArt.Text = ART[1].Trim();
                 vCodigoProd = ART[0].Trim();
                 vDescripcion = ART[1].Trim();
                 vStockC = Convert.ToDecimal(ART[3].Trim());
                 vStockD = Convert.ToDecimal(ART[4].Trim());
                 vUndMed = ART[2].Trim();
                 vPrecioSoles = Convert.ToDecimal(ART[5].Trim());
                 vPrecioDolares = Convert.ToDecimal(ART[6].Trim());
                 vUbicacion = ART[7].Trim();
                 vCuentaCargo = Convert.ToDecimal(ART[8].Trim());
                 vCtaAlmacen = Convert.ToDecimal(ART[10].Trim());
                 vProcedencia = Convert.ToDecimal(ART[9].Trim());
             }
             CalcularDatarow();
             tbldetalle = (DataTable)Session["CARRITO"];
             dr = tbldetalle.NewRow();
             dr["codProd"] = vCodigoProd;
             dr["desProd"] = vDescripcion;
             dr["PrecioS"] = vPrecioSoles;
             dr["PrecioD"] = vPrecioDolares;
             dr["Cantidad"] = Cantidad;
             dr["UndMeda"] = vUndMed;
             dr["TotalS"] = TotalS;
             dr["TotalD"] = TotalD;
             dr["stockD"] = vStockD;
             dr["stockC"] = vStockC;
             dr["vProcedencia"] = vProcedencia;
             dr["vCtaAlmacen"] = vCtaAlmacen;
             dr["vCuentaCargo"] = vCuentaCargo;
             tbldetalle.Rows.Add(dr);
             tbldetalle.AcceptChanges();
             Session["CARRITO"] = tbldetalle;
             dgvDetReq.DataSource = tbldetalle;
             dgvDetReq.DataBind();
             limpiar();
             CalcularTotal();
         }
         else
         {
             txtCan.Text = "";
             txtCan.Focus();
         }
     }
     catch
     {
         //btnBuscar3.OnClientClick = "return confirm('¿desea Actualizar los datos estos datos?')";
         dr = tbldetalle.Rows.Find(vCodigoProd.Trim());
         dr.BeginEdit();
         dr["codProd"] = vCodigoProd.Trim();
         dr["desProd"] = vDescripcion;
         dr["PrecioS"] = vPrecioSoles;
         dr["PrecioD"] = vPrecioDolares;
         dr["Cantidad"] = Cantidad;
         dr["UndMeda"] = vUndMed;
         dr["TotalS"] = TotalS;
         dr["TotalD"] = TotalD;
         dr["stockD"] = vStockD;
         dr["stockC"] = vStockC;
         dr["vProcedencia"] = vProcedencia;
         dr["vCtaAlmacen"] = vCtaAlmacen;
         dr["vCuentaCargo"] = vCuentaCargo;
         dr.EndEdit();
         tbldetalle.AcceptChanges();
         Session["CARRITO"] = tbldetalle;
         dgvDetReq.DataSource = tbldetalle;
         dgvDetReq.DataBind();
         limpiar();
         CalcularTotal();
     }
 }
示例#22
0
 private void UpdateLocalSummaryData(DataRow row, string AFieldName, string ADataValue)
 {
     try
     {
         //DataRow row = gridViewSummary.GetDataRow(ARowHandle);
         row.BeginEdit();
         row[AFieldName] = ADataValue;
         row.AcceptChanges();
         row.EndEdit();
     }
     catch (Exception ex)
     {
         throw new Exception("An error occurred while attempting to update the: " + AFieldName + " field" + Environment.NewLine +
             "of the local Summary Grid with a data value of: " + ADataValue + "." + Environment.NewLine +
             "Error CNF-067 in " + FORM_NAME + ".UpdateLocalSummaryData(): " + ex.Message);
     }
 }
示例#23
0
		/// <summary>
		/// Adds the specified DataRow to the DataRowCollection object.
		/// </summary>
		public void Add (DataRow row)
		{
			//TODO: validation
			if (row == null)
				throw new ArgumentNullException ("row", "'row' argument cannot be null.");

			if (row.Table != this.table)
				throw new ArgumentException ("This row already belongs to another table.");

			// If row id is not -1, we know that it is in the collection.
			if (row.RowID != -1)
				throw new ArgumentException ("This row already belongs to this table.");

			row.BeginEdit ();

			row.Validate ();

			AddInternal (row);
		}
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (action == ActionState.New)
            {
                try
                {
                    System.Data.DataRow newRow = phoneNumbersDataSet.PhoneNumbers.NewRow();
                    newRow.BeginEdit();
                    newRow["Phonenum"]   = txtPhoneNumber.Text.Trim();
                    newRow["Subscriber"] = txtSubscriber.Text.Trim();
                    newRow.EndEdit();
                    phoneNumbersDataSet.PhoneNumbers.Rows.Add(newRow);
                    tblPhoneNumbersAdapter.Update(phoneNumbersDataSet.PhoneNumbers);
                    phoneNumbersDataSet.AcceptChanges();
                }
                catch (DataException ex)
                {
                    phoneNumbersDataSet.RejectChanges();
                    MessageBox.Show(ex.Message);
                }
                btnNew.IsEnabled         = true;
                btnEdit.IsEnabled        = true;
                btnSave.IsEnabled        = false;
                btnCancel.IsEnabled      = false;
                lstPhones.IsEnabled      = true;
                btnPrevious.IsEnabled    = true;
                btnNext.IsEnabled        = true;
                txtPhoneNumber.IsEnabled = false;
                txtSubscriber.IsEnabled  = false;
            }
            else
            if (action == ActionState.Edit)
            {
                try
                {
                    System.Data.DataRow editRow = phoneNumbersDataSet.PhoneNumbers.Rows[lstPhones.SelectedIndex];
                    editRow.BeginEdit();
                    editRow["Phonenum"]   = txtPhoneNumber.Text.Trim();
                    editRow["Subscriber"] = txtSubscriber.Text.Trim();
                    editRow.EndEdit();
                    tblPhoneNumbersAdapter.Update(phoneNumbersDataSet.PhoneNumbers);
                    phoneNumbersDataSet.AcceptChanges();
                }
                catch (DataException ex)
                {
                    phoneNumbersDataSet.RejectChanges();
                    MessageBox.Show(ex.Message);
                }
                btnNew.IsEnabled         = true;
                btnEdit.IsEnabled        = true;
                btnDelete.IsEnabled      = true;
                btnSave.IsEnabled        = false;
                btnCancel.IsEnabled      = false;
                lstPhones.IsEnabled      = true;
                btnPrevious.IsEnabled    = true;
                btnNext.IsEnabled        = true;
                txtPhoneNumber.IsEnabled = false;
                txtSubscriber.IsEnabled  = false;
                txtPhoneNumber.SetBinding(TextBox.TextProperty, txtPhoneNumberBinding);
                txtSubscriber.SetBinding(TextBox.TextProperty, txtSubscriberBinding);
            }
            else
            if (action == ActionState.Delete)
            {
                try
                {
                    DataRow deleterow = phoneNumbersDataSet.PhoneNumbers.Rows[lstPhones.SelectedIndex];
                    deleterow.Delete();

                    tblPhoneNumbersAdapter.Update(phoneNumbersDataSet.PhoneNumbers);
                    phoneNumbersDataSet.AcceptChanges();
                }
                catch (DataException ex)
                {
                    phoneNumbersDataSet.RejectChanges(); MessageBox.Show(ex.Message);
                    MessageBox.Show(ex.Message);
                }
                btnNew.IsEnabled         = true;
                btnEdit.IsEnabled        = true;
                btnDelete.IsEnabled      = true;
                btnSave.IsEnabled        = false;
                btnCancel.IsEnabled      = false;
                lstPhones.IsEnabled      = true;
                btnPrevious.IsEnabled    = true;
                btnNext.IsEnabled        = true;
                txtPhoneNumber.IsEnabled = false;
                txtSubscriber.IsEnabled  = false;
                txtPhoneNumber.SetBinding(TextBox.TextProperty, txtPhoneNumberBinding);
                txtSubscriber.SetBinding(TextBox.TextProperty, txtSubscriberBinding);
            }
        }
 /// <summary>
 /// Pre-condition:  true
 /// Post-condition: Will update the selected record in the dataset.
 /// Description:    This method will update the selected record in the dataset.
 /// </summary>
 private void updateRecord()
 {
     _drwRecord = _dataset.Tables[_strTableName].Rows.Find(_lngPKID);
     _drwRecord.BeginEdit();
     _drwRecord["OrderDate"] = OrderDate;
     _drwRecord["OrderExpectedDeliveryDate"] = OrderExpectedDeliveryDate;
     _drwRecord["SupplierNumber"] = SupplierNumber;
     _drwRecord["OrderTotal"] = OrderTotal;
     _drwRecord["Branch"] = Branch;
     _drwRecord.EndEdit();
 }
示例#26
0
 public void BeginEdit()
 {
     _dataRow.BeginEdit();
 }
示例#27
0
 private DataRow SetData(DataRow dr)
 {
     dr.BeginEdit();
     dr["CardName"] = txtCardName.Text.Trim();
     dr["PunishFactor"] = txtPunishFactor.Text.Trim();
     dr["Note"] = txtNote.Text;
     dr.EndEdit();
     return dr;
 }
示例#28
0
        private void LoadRowData(DataRow row, XmlElement rowElement) {
            XmlNode n;
            DataTable table = row.Table;
            if (FromInference)
                table.Prefix = rowElement.Prefix;

            // keep a list of all columns that get updated
            Hashtable foundColumns = new Hashtable();

            row.BeginEdit();

            // examine all children first
            n = rowElement.FirstChild;

            // Look for data to fill the TextOnly column
            DataColumn column = GetTextOnlyColumn( row );
            if (column != null) {
                foundColumns[column] = column;
                string text = GetValueForTextOnlyColums( n ) ;
                if (XMLSchema.GetBooleanAttribute(rowElement, Keywords.XSI_NIL, Keywords.XSINS, false) && Common.ADP.IsEmpty(text) )
                    row[column] = DBNull.Value;
                else
                    SetRowValueFromXmlText( row, column, text );
            }

            // Walk the region to find elements that map to columns
            while (n != null && n != rowElement) {
                if (n.NodeType == XmlNodeType.Element) {
                    XmlElement e = (XmlElement) n;

                    object schema = nodeToSchemaMap.GetSchemaForNode( e, FIgnoreNamespace(e) );
                    if (schema is DataTable) {
                        if (FColumnElement(e))
                            schema = nodeToSchemaMap.GetColumnSchema( e, FIgnoreNamespace(e) );
                    }
                    
                    // if element has its own table mapping, it is a separate region
                    if (schema == null || schema is DataColumn) {
                        // descend to examine child elements
                        n = e.FirstChild;

                        if (schema != null && schema is DataColumn) {
                            DataColumn c = (DataColumn) schema;

                            if (c.Table == row.Table && c.ColumnMapping != MappingType.Attribute && foundColumns[c] == null) {
                                foundColumns[c] = c;
                                string text = GetValueForTextOnlyColums( n ) ;
                                if (XMLSchema.GetBooleanAttribute(e, Keywords.XSI_NIL, Keywords.XSINS, false) && Common.ADP.IsEmpty(text) )
                                    row[c] = DBNull.Value;
                                else
                                    SetRowValueFromXmlText( row, c, text );
                            }
                        } 
                        else if ((schema == null) && (n!=null)) {
                            continue;
                        }


                        // nothing left down here, continue from element
                        if (n == null)
                            n = e;
                    }
                }

                // if no more siblings, ascend back toward original element (rowElement)
                while (n != rowElement && n.NextSibling == null) {
                    n = n.ParentNode;
                }

                if (n != rowElement)
                    n = n.NextSibling;
            }

            //
            // Walk the attributes to find attributes that map to columns.
            //
            foreach( XmlAttribute attr in rowElement.Attributes ) {
                object schema = nodeToSchemaMap.GetColumnSchema( attr, FIgnoreNamespace(attr) );
                if (schema != null && schema is DataColumn) {
                    DataColumn c = (DataColumn) schema;

                    if (c.ColumnMapping == MappingType.Attribute && foundColumns[c] == null) {
                        foundColumns[c] = c;
                        n = attr.FirstChild;
                        SetRowValueFromXmlText( row, c, GetInitialTextFromNodes( ref n ) );
                    }
                }
            }

            // Null all columns values that aren't represented in the tree
            foreach( DataColumn c in row.Table.Columns ) {
                if (foundColumns[c] == null && XmlToDatasetMap.IsMappedColumn(c)) {
                    if (!c.AutoIncrement) {
                        if (c.AllowDBNull)  {
                            row[c] = DBNull.Value;
                        }
                        else {
                            row[c] = c.DefaultValue;
                        }
                    }
                    else {
                        c.Init(row.tempRecord);
                    }
                }
            }       

            row.EndEdit();
        }
示例#29
0
 /// <summary>
 /// Pre-condition:  true
 /// Post-condition: Will update the selected record in the dataset.
 /// Description:    This method will update the selected record in the dataset.
 /// </summary>
 public void updateRecord()
 {
     try
     {
         _drwRecord = _dst.Tables[_strTableName].Rows.Find(_lngPKID);
         _drwRecord.BeginEdit();
         _drwRecord["ProductID"] = ProductID;
         _drwRecord["Price"] = ProductPrice;
         _drwRecord["OrderLineQty"] = OrderLineQty;
         _drwRecord["OrderNumber"] = OrderNumber;
         _drwRecord["OrderLineSubTotal"] = OrderLineSubTotal;
         _drwRecord["ProductName"] = ProductName;
         _drwRecord.EndEdit();
     }
     catch (System.NullReferenceException)
     { }
 }
示例#30
0
        private void LoadRowData(DataRow row, XmlElement rowElement)
        {
            DataTable table = row.Table;

            if (this.FromInference)
            {
                table.Prefix = rowElement.Prefix;
            }
            Hashtable hashtable = new Hashtable();

            row.BeginEdit();
            XmlNode    firstChild     = rowElement.FirstChild;
            DataColumn textOnlyColumn = this.GetTextOnlyColumn(row);

            if (textOnlyColumn != null)
            {
                hashtable[textOnlyColumn] = textOnlyColumn;
                string valueForTextOnlyColums = this.GetValueForTextOnlyColums(firstChild);
                if (XMLSchema.GetBooleanAttribute(rowElement, "nil", "http://www.w3.org/2001/XMLSchema-instance", false) && ADP.IsEmpty(valueForTextOnlyColums))
                {
                    row[textOnlyColumn] = DBNull.Value;
                }
                else
                {
                    this.SetRowValueFromXmlText(row, textOnlyColumn, valueForTextOnlyColums);
                }
            }
            while ((firstChild != null) && (firstChild != rowElement))
            {
                if (firstChild.NodeType == XmlNodeType.Element)
                {
                    XmlElement node          = (XmlElement)firstChild;
                    object     schemaForNode = this.nodeToSchemaMap.GetSchemaForNode(node, this.FIgnoreNamespace(node));
                    if ((schemaForNode is DataTable) && this.FColumnElement(node))
                    {
                        schemaForNode = this.nodeToSchemaMap.GetColumnSchema(node, this.FIgnoreNamespace(node));
                    }
                    if ((schemaForNode == null) || (schemaForNode is DataColumn))
                    {
                        firstChild = node.FirstChild;
                        if ((schemaForNode != null) && (schemaForNode is DataColumn))
                        {
                            DataColumn col = (DataColumn)schemaForNode;
                            if (((col.Table == row.Table) && (col.ColumnMapping != MappingType.Attribute)) && (hashtable[col] == null))
                            {
                                hashtable[col] = col;
                                string str = this.GetValueForTextOnlyColums(firstChild);
                                if (XMLSchema.GetBooleanAttribute(node, "nil", "http://www.w3.org/2001/XMLSchema-instance", false) && ADP.IsEmpty(str))
                                {
                                    row[col] = DBNull.Value;
                                }
                                else
                                {
                                    this.SetRowValueFromXmlText(row, col, str);
                                }
                            }
                        }
                        else if ((schemaForNode == null) && (firstChild != null))
                        {
                            continue;
                        }
                        if (firstChild == null)
                        {
                            firstChild = node;
                        }
                    }
                }
                while ((firstChild != rowElement) && (firstChild.NextSibling == null))
                {
                    firstChild = firstChild.ParentNode;
                }
                if (firstChild != rowElement)
                {
                    firstChild = firstChild.NextSibling;
                }
            }
            foreach (XmlAttribute attribute in rowElement.Attributes)
            {
                object columnSchema = this.nodeToSchemaMap.GetColumnSchema(attribute, this.FIgnoreNamespace(attribute));
                if ((columnSchema != null) && (columnSchema is DataColumn))
                {
                    DataColumn column3 = (DataColumn)columnSchema;
                    if ((column3.ColumnMapping == MappingType.Attribute) && (hashtable[column3] == null))
                    {
                        hashtable[column3] = column3;
                        firstChild         = attribute.FirstChild;
                        this.SetRowValueFromXmlText(row, column3, this.GetInitialTextFromNodes(ref firstChild));
                    }
                }
            }
            foreach (DataColumn column in row.Table.Columns)
            {
                if ((hashtable[column] == null) && XmlToDatasetMap.IsMappedColumn(column))
                {
                    if (!column.AutoIncrement)
                    {
                        if (column.AllowDBNull)
                        {
                            row[column] = DBNull.Value;
                        }
                        else
                        {
                            row[column] = column.DefaultValue;
                        }
                    }
                    else
                    {
                        column.Init(row.tempRecord);
                    }
                }
            }
            row.EndEdit();
        }
示例#31
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            string strType;
            string strLength = "3000";

            switch (combo_DataType.Text.Trim())
            {
            default:
                strType = "varchar";
                break;
            }

            // 添加字段
            m_parent.m_conn.Open();
            try
            {
                SqlCommand cmd = m_parent.m_conn.CreateCommand();
                cmd.CommandText = string.Format("alter table {0} add {1} {2} ({3}) NULL",
                                                edit_TableName.Text.Trim(), edit_FieldName.Text.Trim(), strType, strLength);
                //cmd.ExecuteNonQuery();
                Helper.ExecuteCommand(edit_TableName.Text.Trim(), cmd.CommandText, m_parent.m_conn);
            }
            catch (Exception ex)
            {
                string str = string.Format("在添加字段时发生错误。\r\n\r\n错误信息:{0}", ex.Message);
                System.Windows.Forms.MessageBox.Show(str);
            }
            m_parent.m_conn.Close();

            // 添加一条metaInfo

            string sqltxt = "SELECT * FROM sys_meta_info WHERE tablename = '" + edit_TableName.Text + "'";

            /* remoting
             * SqlDataAdapter adp = new SqlDataAdapter(sqltxt, m_parent.m_conn);
             * System.Data.DataSet DS = new System.Data.DataSet();
             * adp.Fill(DS);
             * System.Data.DataTable tbl = DS.Tables[0];
             */

            string    filter = "tablename = '" + edit_TableName.Text + "'";
            DataTable tbl    = Helper.GetDataTableProxy("sys_meta_info", filter, null, m_parent.m_conn);

            System.Data.DataRow dataRow = tbl.NewRow();
            dataRow.BeginEdit();
            dataRow["tablename"]     = edit_TableName.Text.Trim();
            dataRow["fieldname"]     = edit_FieldName.Text.Trim();
            dataRow["fieldcnname"]   = m_paramMetaInfo.m_strFieldNameCN;
            dataRow["editortype"]    = m_paramMetaInfo.m_strEditType;
            dataRow["catname"]       = m_paramMetaInfo.m_strCatName;
            dataRow["orderno"]       = "0";
            dataRow["description"]   = m_paramMetaInfo.m_strDescription;
            dataRow["listtable"]     = m_paramMetaInfo.m_strListTable;
            dataRow["listcondition"] = m_paramMetaInfo.m_strCondition;
            dataRow["keyfield"]      = m_paramMetaInfo.m_strKeyField;
            dataRow["listfield"]     = m_paramMetaInfo.m_strListField;
            dataRow["listvalues"]    = m_paramMetaInfo.m_strTextCombo;
            dataRow["relativepath"]  = m_paramMetaInfo.m_strRelativePath;
            dataRow["visible"]       = m_paramMetaInfo.m_bVisible ? 1 : 0;
            dataRow["readonly"]      = m_paramMetaInfo.m_bReadOnly ? 1 : 0;
            tbl.Rows.Add(dataRow);
            dataRow.EndEdit();
            try
            {
                /* remoting
                 * SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(adp);
                 * adp.InsertCommand = cmdBuilder.GetInsertCommand();
                 * int val = adp.Update(tbl);
                 * tbl.AcceptChanges();
                 */

                int val = Helper.SaveTable(tbl, sqltxt, m_parent.m_conn);

                // 更新类别名下拉框
                m_parent.FillCatNames(edit_TableName.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            DialogResult = DialogResult.OK;
            Close();
        }
示例#32
0
        private void _Toolbar1_Guardar_Click(System.Object sender, System.EventArgs e)
        {
            OleDbDataAdapter dbClientes = new OleDbDataAdapter();

            System.Data.DataSet dbRegistros = null;
            System.Data.DataRow fila        = null;

            string NombreTabla = "tblFactura";



            //Antes de cargar nada fijamos si puede guardarlo en la AFIP sino no sigue con el guardado de la factura
            //ESP La funcion EnviarFacturaAFIP esta en el modulo de AFIP.
            bool bolFactEnAFIP = AFIP.EnviarFacturaAFIP(Imprimir.CargarFactura(gridDatos.Rows.Count - 1), lblToken.Text, lblSign.Text);

            if (bolFactEnAFIP != true)
            {
                Interaction.MsgBox("NO se pudo cargar la factura en AFIP. Intentelo nuevamente", MsgBoxStyle.Information);
                return;
            }



            //Cargo la tabla en la base
            //Facturas A
            if (lblCod_cbe.Text == "01")
            {
                dbClientes = BaseDeDatos.rstTabla("Facturas", "Fecha", "");
                //Facturas B
            }
            else if (lblCod_cbe.Text == "06")
            {
                dbClientes = BaseDeDatos.rstTabla("FacturasB", "Fecha", "");
                //Notas de Credito
            }
            else if (lblCod_cbe.Text == "03")
            {
                dbClientes = BaseDeDatos.rstTabla("NotaCredito", "Fecha", "");
                //Notas de Debito
            }
            else if (lblCod_cbe.Text == "02")
            {
                dbClientes = BaseDeDatos.rstTabla("NotaDebito", "Fecha", "");
            }


            //Asigno un nuevo Data Set
            dbRegistros = new System.Data.DataSet();

            try {
                dbClientes.Fill(dbRegistros, NombreTabla);
            } catch (Exception ex) {
                MessageBox.Show("Error en el llenado:" + Constants.vbCrLf + ex.Message);
            }



            OleDbCommandBuilder cb = new OleDbCommandBuilder(dbClientes);



            miFactura = Imprimir.CargarFactura(gridDatos.Rows.Count - 1);



            fila = dbRegistros.Tables[NombreTabla].NewRow();
            fila.BeginEdit();


            //Cargo el valor del "DOCUMENTO"
            //Facturas A
            if (lblCod_cbe.Text == "01")
            {
                fila["Documento"] = "FC A " + Strings.Format(miFactura.intSucursal, "0000") + "-" + Strings.Format(miFactura.dblNumFact, "00000000");
                //Facturas B
            }
            else if (lblCod_cbe.Text == "06")
            {
                fila["Documento"] = "FC B " + Strings.Format(miFactura.intSucursal, "0000") + "-" + Strings.Format(miFactura.dblNumFact, "00000000");
                //Notas de Credito
            }
            else if (lblCod_cbe.Text == "03")
            {
                fila["Documento"] = "NC " + Strings.Format(miFactura.intSucursal, "0000") + "-" + Strings.Format(miFactura.dblNumFact, "00000000");
                //Notas de Debito
            }
            else if (lblCod_cbe.Text == "02")
            {
                fila["Documento"] = "ND " + Strings.Format(miFactura.intSucursal, "0000") + "-" + Strings.Format(miFactura.dblNumFact, "00000000");
            }

            fila["Sucursal"] = miFactura.intSucursal;
            fila["NumFact"]  = miFactura.dblNumFact;
            fila["Fecha"]    = miFactura.dtFecha;
            //
            fila["IDCliente"]    = miFactura.Cliente.strid;
            fila["Nombre"]       = miFactura.Cliente.strNombre;
            fila["Direccion"]    = miFactura.Cliente.strDireccion;
            fila["Localidad"]    = miFactura.Cliente.strLocalidad;
            fila["Provincia"]    = miFactura.Cliente.strProvincia;
            fila["Tipodecambio"] = miFactura.dblTipoCambio;
            fila["Descuento"]    = Conversion.Str(miFactura.Cliente.dblDescuento);

            fila["Cant1"]           = miFactura.Producto1.intCantidad;
            fila["Detalle1"]        = miFactura.Producto1.strDescripcion;
            fila["PrecioUnitario1"] = miFactura.Producto1.curPrecioNeto;
            fila["PrecioFinal1"]    = miFactura.Producto1.curPrecioTotal;

            fila["Cant2"]           = miFactura.Producto2.intCantidad;
            fila["Detalle2"]        = miFactura.Producto2.strDescripcion;
            fila["PrecioUnitario2"] = miFactura.Producto2.curPrecioNeto;
            fila["PrecioFinal2"]    = miFactura.Producto2.curPrecioTotal;

            fila["Cant3"]           = miFactura.Producto3.intCantidad;
            fila["Detalle3"]        = miFactura.Producto3.strDescripcion;
            fila["PrecioUnitario3"] = miFactura.Producto3.curPrecioNeto;
            fila["PrecioFinal3"]    = miFactura.Producto3.curPrecioTotal;

            fila["Cant4"]           = miFactura.Producto4.intCantidad;
            fila["Detalle4"]        = miFactura.Producto4.strDescripcion;
            fila["PrecioUnitario4"] = miFactura.Producto4.curPrecioNeto;
            fila["PrecioFinal4"]    = miFactura.Producto4.curPrecioTotal;

            fila["Cant5"] = miFactura.Producto5.intCantidad;
            //Cantidad 5
            fila["Detalle5"] = miFactura.Producto5.strDescripcion;
            //Detalle5
            fila["PrecioUnitario5"] = miFactura.Producto5.curPrecioNeto;
            //Precio Unitario 5
            fila["PrecioFinal5"] = miFactura.Producto5.curPrecioTotal;
            //Precio Final 5

            fila["Cant6"] = 0;
            //Cantidad 6
            fila["Detalle6"] = " ";
            //Detalle6
            fila["PrecioUnitario6"] = 0;
            //Precio Unitario 6
            fila["PrecioFinal6"] = 0;
            //Precio Final 6

            fila["SubTotal"] = miFactura.curSubTotal;
            //Sub Total $
            fila["IVA"] = miFactura.curIVA;
            //IVA $
            fila["ImporteFinal"] = miFactura.curTotal;
            //Importe Final $

            fila["Recibo1"] = 0;
            fila["Recibo2"] = 0;
            //Recibo2
            fila["Recibo3"] = 0;
            //Recibo3
            fila["Recibo4"] = 0;
            //Recibo4
            fila["Recibo5"] = 0;
            //Recibo5

            fila["ClienteDe"] = " ";
            //Cliente De

            fila["Remito1"] = miFactura.intRemito1;
            //
            fila["Remito2"] = miFactura.intRemito2;
            //Remito2
            fila["Remito3"] = miFactura.intRemito3;
            //Remito3
            fila["Remito4"] = miFactura.intRemito4;
            //Remito4
            fila["Remito5"] = 0;
            //Remito5

            fila["Observaciones"] = " ";
            //Observaciones

            fila["SubTotalUSS"] = miFactura.curSubTotalUSD;
            //Sub Total USS
            fila["IVAUSS"] = miFactura.curIVAUSD;
            //IVA USS
            fila["ImporteFinalUSS"] = miFactura.curTotalUSD;
            //Importe Final USS

            fila["EnDolar"] = 0.0;
            //En Dolar

            fila["Saldo"] = Strings.Replace(Conversion.Str(miFactura.curTotal), ".", ",");
            //Saldo
            fila["SaldoUSS"] = miFactura.curTotalUSD;
            //SaldoUSS

            fila["Pagado"] = false;

            fila["Dólar"] = true;
            fila["Peso"]  = false;


            fila["Promocion"] = 0;

            fila["CAE"]          = miFactura.strCAE;
            fila["FechaVencCAE"] = miFactura.strFechVtoCAE;


            //Finaliza la edicion
            fila.EndEdit();

            //Añade la fila a la tabla
            dbRegistros.Tables[NombreTabla].Rows.Add(fila);



            //Actualiza la base de datos
            dbClientes.Update(dbRegistros, NombreTabla);


            //acepta los cambios
            dbRegistros.AcceptChanges();



            //MsgBox(miFactura.strTipoFc)
            //MsgBox(miFactura.intSucursal)
            //MsgBox(miFactura.dtFecha)
            Interaction.MsgBox("Factura Cargada");

            //Este modulo edita la tabla de remitos y asigna el valor de la factura y su respectiva
            //sucursal al remito en cuestion
            //eso lo saca de los desplegables de remitos
            ModDocFiscales.EditarRemitos((cmbSucursal.Text), Convert.ToDouble(txtNumFact.Text), Convert.ToDouble(cmbRemito1.Text));
            Interaction.MsgBox("Remito: " + cmbRemito1.Text + ". Modificado");


            //Esto permite que se pueda imprimir
            _Toolbar1_Imprimir.Enabled = true;

            //Esto impide que se vuelva a guardar
            _Toolbar1_Guardar.Enabled = false;
        }
示例#33
0
        private void LoadTable(DataTable table, bool isNested)
        {
            DataColumn           xmlText;
            DataRow              row     = null;
            int                  depth   = this.dataReader.Depth;
            int                  count   = this.childRowsStack.Count;
            DataColumnCollection columns = table.Columns;

            object[] foundColumns = new object[columns.Count];
            int      pos          = -1;
            string   str3         = string.Empty;
            string   str2         = null;
            bool     flag         = false;

            for (int i = this.dataReader.AttributeCount - 1; i >= 0; i--)
            {
                this.dataReader.MoveToAttribute(i);
                xmlText = this.nodeToSchemaMap.GetColumnSchema(table, this.dataReader, this.FIgnoreNamespace(this.dataReader)) as DataColumn;
                if ((xmlText != null) && (xmlText.ColumnMapping == MappingType.Attribute))
                {
                    foundColumns[xmlText.Ordinal] = xmlText.ConvertXmlToObject(this.dataReader.Value);
                }
                if (this.isDiffgram)
                {
                    if (!(this.dataReader.NamespaceURI == "urn:schemas-microsoft-com:xml-diffgram-v1"))
                    {
                        goto Label_0161;
                    }
                    string localName = this.dataReader.LocalName;
                    if (localName != null)
                    {
                        if (!(localName == "id"))
                        {
                            if (localName == "hasChanges")
                            {
                                goto Label_0124;
                            }
                            if (localName == "hasErrors")
                            {
                                goto Label_0136;
                            }
                        }
                        else
                        {
                            str3 = this.dataReader.Value;
                        }
                    }
                }
                continue;
Label_0124:
                str2 = this.dataReader.Value;
                continue;
Label_0136:
                flag = (bool)Convert.ChangeType(this.dataReader.Value, typeof(bool), CultureInfo.InvariantCulture);
                continue;
Label_0161:
                if (this.dataReader.NamespaceURI == "urn:schemas-microsoft-com:xml-msdata")
                {
                    if (this.dataReader.LocalName == "rowOrder")
                    {
                        pos = (int)Convert.ChangeType(this.dataReader.Value, typeof(int), CultureInfo.InvariantCulture);
                    }
                    else if (this.dataReader.LocalName.StartsWith("hidden", StringComparison.Ordinal))
                    {
                        xmlText = columns[XmlConvert.DecodeName(this.dataReader.LocalName.Substring(6))];
                        if ((xmlText != null) && (xmlText.ColumnMapping == MappingType.Hidden))
                        {
                            foundColumns[xmlText.Ordinal] = xmlText.ConvertXmlToObject(this.dataReader.Value);
                        }
                    }
                }
            }
            if (this.dataReader.Read() && (depth < this.dataReader.Depth))
            {
                while (depth < this.dataReader.Depth)
                {
                    DataTable table3;
                    object    obj2;
                    switch (this.dataReader.NodeType)
                    {
                    case XmlNodeType.Element:
                    {
                        obj2    = this.nodeToSchemaMap.GetColumnSchema(table, this.dataReader, this.FIgnoreNamespace(this.dataReader));
                        xmlText = obj2 as DataColumn;
                        if (xmlText == null)
                        {
                            goto Label_02DE;
                        }
                        if (foundColumns[xmlText.Ordinal] != null)
                        {
                            break;
                        }
                        this.LoadColumn(xmlText, foundColumns);
                        continue;
                    }

                    case XmlNodeType.Text:
                    case XmlNodeType.CDATA:
                    case XmlNodeType.Whitespace:
                    case XmlNodeType.SignificantWhitespace:
                    {
                        string s = this.dataReader.ReadString();
                        xmlText = table.xmlText;
                        if ((xmlText != null) && (foundColumns[xmlText.Ordinal] == null))
                        {
                            foundColumns[xmlText.Ordinal] = xmlText.ConvertXmlToObject(s);
                        }
                        continue;
                    }

                    case XmlNodeType.EntityReference:
                        throw ExceptionBuilder.FoundEntity();

                    default:
                        goto Label_0379;
                    }
                    this.dataReader.Read();
                    continue;
Label_02DE:
                    table3 = obj2 as DataTable;
                    if (table3 != null)
                    {
                        this.LoadTable(table3, true);
                    }
                    else if (!this.ProcessXsdSchema())
                    {
                        DataTable tableForNode = this.nodeToSchemaMap.GetTableForNode(this.dataReader, this.FIgnoreNamespace(this.dataReader));
                        if (tableForNode != null)
                        {
                            this.LoadTable(tableForNode, false);
                        }
                        else
                        {
                            this.dataReader.Read();
                        }
                    }
                    continue;
Label_0379:
                    this.dataReader.Read();
                }
                this.dataReader.Read();
            }
            if (this.isDiffgram)
            {
                row = table.NewRow(table.NewUninitializedRecord());
                row.BeginEdit();
                for (int j = foundColumns.Length - 1; j >= 0; j--)
                {
                    xmlText = columns[j];
                    xmlText[row.tempRecord] = (foundColumns[j] != null) ? foundColumns[j] : DBNull.Value;
                }
                row.EndEdit();
                table.Rows.DiffInsertAt(row, pos);
                if (str2 == null)
                {
                    row.oldRecord = row.newRecord;
                }
                if ((str2 == "modified") || flag)
                {
                    table.RowDiffId[str3] = row;
                }
            }
            else
            {
                for (int k = foundColumns.Length - 1; k >= 0; k--)
                {
                    if (foundColumns[k] == null)
                    {
                        xmlText = columns[k];
                        if ((xmlText.AllowDBNull && (xmlText.ColumnMapping != MappingType.Hidden)) && !xmlText.AutoIncrement)
                        {
                            foundColumns[k] = DBNull.Value;
                        }
                    }
                }
                row = table.Rows.AddWithColumnEvents(foundColumns);
            }
            while (count < this.childRowsStack.Count)
            {
                DataRow row2  = (DataRow)this.childRowsStack.Pop();
                bool    flag2 = row2.RowState == DataRowState.Unchanged;
                row2.SetNestedParentRow(row, false);
                if (flag2)
                {
                    row2.oldRecord = row2.newRecord;
                }
            }
            if (isNested)
            {
                this.childRowsStack.Push(row);
            }
        }
 /// <summary>
 ///Pre-Condition:All properties have an assigned value
 ///Post-Condition:a new record is added to the table associated with the class 
 ///Description:Adds a new record to the table associated with the class
 /// </summary>
 private void addNewRecord()
 {
     _drwRecord = _dataset.Tables[_strTableName].NewRow();
     _drwRecord.BeginEdit();
     _drwRecord["OrderDate"] = OrderDate;
     _drwRecord["OrderExpectedDeliveryDate"] = OrderExpectedDeliveryDate;
     _drwRecord["SupplierNumber"] = SupplierNumber;
     _drwRecord["OrderTotal"] = OrderTotal;
     _drwRecord["Branch"] = Branch;
     _drwRecord.EndEdit();
     _dataset.Tables[_strTableName].Rows.Add(_drwRecord);
     _lngPKID = long.Parse(_drwRecord["ID"].ToString());
 }
        void onLookupSelected(object sender, System.EventArgs e)
        {
//			int xx= 0;

            ComboLook cb = (ComboLook)sender;

            if (cb.bNoEvent)
            {
                return;
            }
            int n = cb.SelectedIndex;

            if (n >= 0)
            {
                object Value = cb.GetLookupData();
                if (currentCellInSynch())
                {
                    bool bMatch = false;
                    if (cbx != null && nCurrentCellColumn >= 0 && nCurrentCellColumn < cbx.Length)
                    {
                        bMatch = (cbx[nCurrentCellColumn] == sender);
                    }
                    try
                    {
                        System.Data.DataRow dw = CurrentRow;
                        if (bMatch && dw != null && _query.Fields[nCurrentCellColumn].editor != null)
                        {
                            DataBind           databind = null;
                            DataEditorLookupDB lk       = _query.Fields[nCurrentCellColumn].editor as DataEditorLookupDB;
                            if (lk != null)
                            {
                                databind = lk.valuesMaps;
                            }
                            DataRow rv = Value as DataRow;
                            if (databind != null && rv != null)
                            {
                                if (databind.AdditionalJoins != null && databind.AdditionalJoins.StringMaps != null)
                                {
                                    for (int i = 0; i < databind.AdditionalJoins.StringMaps.Length; i++)
                                    {
                                        dw[databind.AdditionalJoins.StringMaps[i].Field1] = rv[databind.AdditionalJoins.StringMaps[i].Field2];
                                    }
                                }
                                onLookup();
                            }
                            else
                            {
                                if (rv != null)
                                {
                                    Value = rv[1];
                                }
                                bool bEQ  = false;
                                int  nPos = cb.GetUpdateFieldIndex();
                                if (nPos < 0)
                                {
                                    nPos = nCurrentCellColumn;
                                }
                                if (Value == null)
                                {
                                    if (dw[nPos] == null)
                                    {
                                        bEQ = true;
                                    }
                                }
                                else if (Value == System.DBNull.Value)
                                {
                                    bEQ = (dw[nPos] == System.DBNull.Value);
                                }
                                else if (Value.Equals(dw[nPos]))
                                {
                                    bEQ = true;
                                }
                                if (!bEQ)
                                {
                                    dw.BeginEdit();
                                    dw[nPos] = Value;
                                    dw.EndEdit();
                                    dw[nCurrentCellColumn] = ValueConvertor.ToObject(cb.Text, _query.Tables[0].Columns[nCurrentCellColumn].DataType);
                                }
                                //							if(xx>=0)
                                //								return;
                                //							bNoEvents = true;
                                //							cb.Visible = false;
                                //							bNoEvents = false;
                                //							onRowIndexChanged();

                                if (!bEQ)
                                {
                                    onLookup();
                                }
                            }
                        }
                    }
                    catch (Exception er)
                    {
                        FormLog.NotifyException(er);
                    }
                }
            }
        }
示例#36
0
文件: RecordLock.cs 项目: viticm/pap2
        private bool UpdateRow(DataTable tbl, DataRow row, int nLastVer, DateTime dtLock, DateTime dtUnLock, int nModId, bool bLock)
        {
            int val = 0;

            try
            {
                row.BeginEdit();

                row["tablename"] = m_strTableName;
                row["fieldnames"] = m_strKeys;
                row["fieldvalues"] = m_strValues;
                row["lastversion"] = nLastVer;

                if (bLock)
                {
                    row["lockip"] = m_strIP;
                    row["lockhostname"] = m_strHostName;
                    row["lockusername"] = m_strHostName;

                    if (dtLock == DateTime.MinValue)
                        row["locktime"] = DBNull.Value;
                    else
                        row["locktime"] = dtLock;

                    if (dtUnLock == DateTime.MinValue)
                        row["unlocktime"] = DBNull.Value;
                    else
                        row["unlocktime"] = dtUnLock;

                    if (nModId == -1)
                        row["modid"] = DBNull.Value;
                    else
                        row["modid"] = nModId;
                }
                else
                {
                    row["lockip"] = DBNull.Value;
                    row["lockhostname"] = DBNull.Value;
                    row["lockusername"] = DBNull.Value;

                    row["locktime"] = DBNull.Value;
                    if (dtUnLock == DateTime.MinValue)
                        row["unlocktime"] = DBNull.Value;
                    else
                        row["unlocktime"] = dtUnLock;

                    row["modid"] = DBNull.Value;
                }

                row.EndEdit();

                SqlCommandBuilder cmdBuilder = m_cmdBuilder;// new SqlCommandBuilder(m_adp);
                m_adp.UpdateCommand = cmdBuilder.GetUpdateCommand();
                val = m_adp.Update(tbl);

                tbl.AcceptChanges();
                return val > 0;
            }
            catch (Exception ex)
            {
                if (val == 0)
                {
                    string[] keynames = new string[3];
                    keynames[0] = "tablename";
                    keynames[1] = "fieldnames";
                    keynames[2] = "fieldvalues";
                    string[] keys = new string[3];
                    keys[0] = m_strTableName;
                    keys[1] = m_strKeys;
                    keys[2] = m_strValues;
                    string[] fields = new string[7];
                    fields[0] = "lastversion";
                    fields[1] = "lockip";
                    fields[2] = "lockhostname";
                    fields[3] = "lockusername";
                    fields[4] = "locktime";
                    fields[5] = "unlocktime";
                    fields[6] = "modid";
                    string[] values = new string[7];
                    values[0] = nLastVer.ToString();
                    values[1] = m_strIP;
                    values[2] = m_strHostName;
                    values[3] = m_strHostName;
                    values[4] = row["locktime"] == DBNull.Value ? "<NULL>" : row["locktime"].ToString().Trim();
                    values[5] = row["unlocktime"] == DBNull.Value ? "<NULL>" : row["unlocktime"].ToString().Trim();
                    values[6] = row["modid"].ToString().Trim();
                    return SqlUpdateRecord("sys_lock_record", keynames, keys, fields, values, m_conn);
                }
                else
                {
                    tbl.RejectChanges();
                    throw ex;
                }
            }
        }
示例#37
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            //if (edit_TableName.Text == null || edit_TableName.Text.Trim() == "")
            //{
            //    MessageBox.Show("必须指定虚拟字段下子字段所属的表名", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button2); ;
            //    return;
            //}

            //if (edit_FieldName.Text == null || edit_FieldName.Text.Trim() == "")
            //{
            //    MessageBox.Show("必须指定虚拟字段名", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button2); ;
            //    return;
            //}

            //if (edit_FieldCNName.Text == null || edit_FieldCNName.Text.Trim() == "")
            //{
            //    edit_FieldCNName.Text = edit_FieldName.Text;
            //}

            // 添加一条metaInfo
            string sqltxt = "SELECT * FROM sys_meta_info WHERE tablename = '" + edit_TableName.Text + "'";

            /* remoting
             * SqlDataAdapter adp = new SqlDataAdapter(sqltxt, m_parent.m_conn);
             * System.Data.DataSet DS = new System.Data.DataSet();
             * adp.Fill(DS);
             * System.Data.DataTable tbl = DS.Tables[0];
             */

            DataTable tbl = Helper.GetDataTableProxy("sys_meta_info", "tablename = '" + edit_TableName.Text + "'", null, m_parent.m_conn);

            System.Data.DataRow dataRow = tbl.NewRow();
            dataRow.BeginEdit();
            dataRow["fieldtype"]      = m_paramMetaInfo.m_nFieldType;
            dataRow["parentfield"]    = m_paramMetaInfo.m_nParentField;
            dataRow["subtablefilter"] = m_paramMetaInfo.m_strSubTableFilter;
            if (m_paramMetaInfo.m_nFieldType != 1)
            {
                dataRow["tablename"] = edit_TableName.Text.Trim();
                dataRow["fieldname"] = FieldName_comboBox.Text.Trim();
            }
            else
            {
                string strTableName = TableName_comboBox.Text.Trim();
                if (strTableName == "")
                {
                    MessageBox.Show("请指定一张表名!");
                    return;
                }
                dataRow["tablename"] = strTableName;
                dataRow["fieldname"] = edit_FieldName.Text.Trim();

                // 虚拟字段不能与它所在同层其他字段同名
                if (m_paramMetaInfo.m_nParentField > 0)
                {
                    string strSQL =
                        string.Format("SELECT * FROM sys_meta_info WHERE parentfield = {0} and fieldname = '{1}'",
                                      m_paramMetaInfo.m_nParentField, edit_FieldName.Text.Trim());

                    string filter = string.Format("parentfield = {0} and fieldname = '{1}'",
                                                  m_paramMetaInfo.m_nParentField, edit_FieldName.Text.Trim());

                    //DataTable table = m_parent.QueryData(strSQL);

                    DataTable table = Helper.GetDataTableProxy("sys_meta_info", filter, null, m_parent.m_conn);
                    if (table != null && table.Rows.Count > 0)
                    {
                        MessageBox.Show("虚拟字段英文名与该字段所在同一级某个字段同名,请换个名字!");
                        return;
                    }

                    DataTable metaInfo  = m_paramMetaInfo.m_DicMetaInfo;
                    DataRow   parentRow = metaInfo.Rows.Find(m_paramMetaInfo.m_nParentField);
                    if (parentRow == null)
                    {
                        return;
                    }

                    if (parentRow["fieldtype"].ToString().Trim() == "1")
                    {
                        string strParentTable = parentRow["tablename"].ToString().Trim();
                        bool   bRetCode       = m_parent.CheckFieldExist(strParentTable, edit_FieldName.Text.Trim());
                        if (bRetCode)
                        {
                            MessageBox.Show("虚拟字段英文名与父虚拟字段对应的表中的某个字段重名,请换个名字!");
                            return;
                        }
                    }
                }
                else // 标签下的虚拟字段检查
                {
                    string strSQL =
                        string.Format("SELECT * FROM sys_meta_info WHERE parentfield = 0 and modtabid = {0} and fieldname = '{1}'",
                                      m_paramMetaInfo.m_nModTableID, edit_FieldName.Text.Trim());
                    //DataTable table = m_parent.QueryData(strSQL);
                    string filter = string.Format("parentfield = 0 and modtabid = {0} and fieldname = '{1}'",
                                                  m_paramMetaInfo.m_nModTableID, edit_FieldName.Text.Trim());
                    DataTable table = Helper.GetDataTableProxy("sys_meta_info", filter, null, m_parent.m_conn);
                    if (table != null && table.Rows.Count > 0)
                    {
                        MessageBox.Show("虚拟字段英文名与该字段所在同一级某个字段同名,请换个名字!");
                        return;
                    }

                    strSQL = string.Format("SELECT * FROM sys_modl_tab_def WHERE modtabid = {0}", m_paramMetaInfo.m_nModTableID);
                    filter = string.Format("modtabid = {0}", m_paramMetaInfo.m_nModTableID);

                    //table = m_parent.QueryData(strSQL);
                    table = Helper.GetDataTableProxy("sys_modl_tab_def", filter, null, m_parent.m_conn);

                    string tablename = table.Rows[0]["tablename"].ToString().Trim();
                    bool   bRetCode  = m_parent.CheckFieldExist(tablename, edit_FieldName.Text.Trim());
                    if (bRetCode)
                    {
                        MessageBox.Show("虚拟字段英文名与主表中某个字段同名,请换个名字!");
                        return;
                    }
                }
            }

            dataRow["modtabid"]      = m_paramMetaInfo.m_nModTableID;
            dataRow["fieldcnname"]   = edit_FieldCNName.Text.Trim();
            dataRow["editortype"]    = "text"; // 默认为文本类型
            dataRow["catname"]       = m_paramMetaInfo.m_strCatName;
            dataRow["orderno"]       = "0";
            dataRow["description"]   = m_paramMetaInfo.m_strDescription;
            dataRow["listtable"]     = m_paramMetaInfo.m_strListTable;
            dataRow["listcondition"] = m_paramMetaInfo.m_strCondition;
            dataRow["keyfield"]      = m_paramMetaInfo.m_strKeyField;
            dataRow["listfield"]     = m_paramMetaInfo.m_strListField;
            dataRow["listvalues"]    = m_paramMetaInfo.m_strTextCombo;
            dataRow["relativepath"]  = m_paramMetaInfo.m_strRelativePath;
            dataRow["visible"]       = m_paramMetaInfo.m_bVisible ? 1 : 0;
            dataRow["readonly"]      = m_paramMetaInfo.m_bReadOnly ? 1 : 0;
            tbl.Rows.Add(dataRow);
            dataRow.EndEdit();
            try
            {
                /* remoting
                 * SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(adp);
                 * adp.InsertCommand = cmdBuilder.GetInsertCommand();
                 * int val = adp.Update(tbl);
                 * tbl.AcceptChanges();
                 */

                int val = Helper.SaveTable(tbl, sqltxt, m_parent.m_conn);

                m_parent.m_conn.Open();

                /* remoting
                 * SqlCommand sqlcmd = m_parent.m_conn.CreateCommand();
                 *
                 * sqlcmd.CommandText = "SELECT max(fieldid) FROM sys_meta_info";
                 * int nID = (int)sqlcmd.ExecuteScalar();
                 */

                string sql = "SELECT max(fieldid) FROM sys_meta_info";
                int    nID = (int)Helper.ExecuteScalar("sys_meta_info", sql, m_parent.m_conn, false);


                dataRow["fieldid"] = nID;
                val = Helper.SaveTable(tbl, sqltxt, m_parent.m_conn);
                tbl.AcceptChanges();
                m_parent.m_conn.Close();

                // 更新类别名下拉框
                //m_parent.FillCatNames(edit_TableName.Text);
                TreeNode newNode      = null;
                string   strFieldName = dataRow["fieldname"].ToString().Trim();
                if (m_paramMetaInfo.m_nFieldType == 1)
                {
                    newNode = m_parent.AddTreeNode(m_parent.treeView.SelectedNode, edit_FieldCNName.Text + " [" + strFieldName + "]", nID, "virtualfield");
                }
                else
                {
                    newNode = m_parent.AddTreeNode(m_parent.treeView.SelectedNode, edit_FieldCNName.Text + " [" + strFieldName + "]", nID, "text");
                }

                m_parent.LoadDicMetaInfoTable();
                m_parent.SetTreeViewSelectNode(newNode);
            }
            catch (Exception ex)
            {
                m_parent.m_conn.Close();
                MessageBox.Show(ex.Message);
            }

            DialogResult = DialogResult.OK;
            Close();
        }
示例#38
0
        public bool SetDataToDataRow()
        {
            if (_row == null)
            {
                if (_table == null) return false;

                _row = _table.NewRow();
                _row.BeginEdit();
                _row["objectId"] = _objectId;
                _row["ConfigObjectTypeId"] = _configObjectTypeId;
                _row.EndEdit();
                _table.Rows.Add(_row);
            }

            Byte[] bytes;
            try
            {
                bytes = ToBytes();
            }
            catch (Exception)
            {
                return false;
            }

            //var ms = new MemoryStream();
            //FileConfig fc;
            //CopyToFileConfig(out fc);

            //var d = new XmlSerializer(fc.GetType());
            //try
            //{
            //    d.Serialize(ms, fc);
            //}
            //catch (Exception ex)
            //{
            //    ms.Dispose();
            //    return false;
            //}
            //Byte[] bytes = ms.ToArray();

            //ms.Dispose();

            _row.BeginEdit();
            _row["ConfigFile"] = bytes;
            _row["ConfigFileDate"] = DateTime.Now;
            _row.EndEdit();
            return true;
        }
示例#39
0
        /// <summary>
        ///Pre-Condition: All properties have an assigned value
        ///Post-Condition:The current record is updated 
        ///Description:Updates the current record to the table associated with the class
        /// </summary>
        public void updateRecord()
        {
            try
            {
                _drwRecord = _dataset.Tables[_strTableName].Rows.Find(_lngPKID);
                _drwRecord.BeginEdit();
                _drwRecord["SaleNumber"] = SaleNumber;
                _drwRecord["ProductNumber"] = ProductNumber;
                _drwRecord["ProductCode"] = productCode;
                _drwRecord["ProductName"] = ProductName;
                _drwRecord["ProductPrice"] = ProductPrice;
                _drwRecord["SaleLineQty"] = SaleLineQty;
                _drwRecord["SaleLineTotal"] = SaleLineSubTotal;
                _drwRecord.EndEdit();
            }
            catch (System.NullReferenceException ex)
            {
         //       _errorCollection.writeErrorToFile(ex.Message);

            }
        }
示例#40
0
        internal void InsertRow(DataRow row, long proposedID, int pos, bool fireEvent) {
            Exception deferredException = null;

            if (row == null) {
                throw ExceptionBuilder.ArgumentNull("row");
            }
            if (row.Table != this) {
                throw ExceptionBuilder.RowAlreadyInOtherCollection();
            }
            if (row.rowID != -1) {
                throw ExceptionBuilder.RowAlreadyInTheCollection();
            }
            row.BeginEdit(); // ensure something's there.            

            int record = row.tempRecord;
            row.tempRecord = -1;

            if (proposedID == -1) {
                proposedID = this.nextRowID;
            }

            bool rollbackOnException;
            if (rollbackOnException = (nextRowID <= proposedID)) { // WebData 109005
                nextRowID = checked(proposedID + 1);
            }

            try {
                try {
                    row.rowID = proposedID;
                    // this method may cause DataView.OnListChanged in which another row may be added
                    SetNewRecordWorker(row, record, DataRowAction.Add, false, false, pos, fireEvent, out deferredException); // now we do add the row to collection before OnRowChanged (RaiseRowChanged)
                }
                catch {
                    if (rollbackOnException && (nextRowID == proposedID+1)) {
                        nextRowID = proposedID;
                    }
                    row.rowID = -1;
                    row.tempRecord = record;
                    throw;
                }

                // since expression evaluation occurred in SetNewRecordWorker, there may have been a problem that
                // was deferred to this point.  If so, throw now since row has already been added.
                if (deferredException != null)
                    throw deferredException;

                if (EnforceConstraints && !inLoad ) { // if we are evaluating expression, we need to validate constraints
                    int columnCount = columnCollection.Count;
                    for (int i = 0; i < columnCount; ++i) {
                        DataColumn column = columnCollection[i];
                        if (column.Computed) {
                            column.CheckColumnConstraint(row, DataRowAction.Add);
                        }
                    }
                }
            }
            finally {
                row.ResetLastChangedColumn();// if expression is evaluated while adding, before  return, we want to clear it
            }
        }
 /// <summary>
 ///  Pre-condition:  true
 /// Post-condition: Will update the selected record in the dataset.
 /// Description:    This method will update the selected record in the dataset.
 /// </summary>
 private void updateRecord()
 {
     _drwRecord = _dst.Tables[_strTableName].Rows.Find(_lngPKID);
     _drwRecord.BeginEdit();
     _drwRecord["IngCode"] = IngCode;
     _drwRecord["IngredientName"] = IngredientName;
     _drwRecord["Price"] = Price;
     _drwRecord.EndEdit();
 }