예제 #1
0
        /// <summary>
        /// 确定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void sb_ok_Click(object sender, EventArgs e)
        {
            if (!gridView1.PostEditor())
            {
                return;
            }
            if (!gridView1.UpdateCurrentRow())
            {
                return;
            }

            string  s_rg001   = string.Empty;
            int     i_ly002   = 0;
            decimal dec_price = decimal.Zero;

            //更新寄存号位价格
            for (int i = 0; i < gridView1.RowCount; i++)
            {
                s_rg001   = gridView1.GetRowCellValue(i, "RG001").ToString();
                i_ly002   = Convert.ToInt32(gridView1.GetRowCellValue(i, "LY002"));
                dec_price = Convert.ToDecimal(gridView1.GetRowCellValue(i, "PRICE"));
                CriteriaOperator    criteria = CriteriaOperator.Parse("RG001 ='" + s_rg001 + "' and BI005=" + i_ly002 + " and STATUS = '9' and BI007 = '0' ");
                XPCollection <BI01> xp_temp  = new XPCollection <BI01>(xpCollection_bi01.Session, xpCollection_bi01, criteria);
                foreach (BI01 bi01 in xp_temp)
                {
                    bi01.BI009 = dec_price;
                }
                xp_temp.Dispose();
            }


            DialogResult = DialogResult.OK;
            this.Close();
        }
예제 #2
0
        /// <summary>
#pragma warning disable 1574
        /// retrive a list of <see cref="DBObject.ClassInfo.KeyProperty"/> values (IDs)
#pragma warning restore 1574

        /// </summary>
        /// <param name="collection"></param>
        /// <returns></returns>
        public static SortedList GetIds(XPCollection collection)
        {
            var sortedList = new SortedList();

            foreach (IXPSimpleObject ixpSimpleObject in collection)
            {
                sortedList.Add(ixpSimpleObject.ClassInfo.KeyProperty.GetValue(ixpSimpleObject), ixpSimpleObject);
            }

            collection.Dispose();
            return(sortedList);
        }
예제 #3
0
        private void bbtnRegister_Click(object sender, EventArgs e)
        {
            clsBase64 base64 = new clsBase64();
            string regKey = "";
            try
            {
                regKey = base64.base64Decode(tbKey.Text);
            }
            catch (Exception)
            {
                XtraMessageBox.Show("Unable to decode the key, please check the key and try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (regKey != "")
            {
                string[] regDetails = regKey.Split('|');
                string regName = regDetails[0];
                string regCompany = regDetails[1];

                if (regName == tbName.Text && regCompany == tbCompany.Text)
                {
                    // Registration Details Match, Save Key...
                    XPCollection collection = new XPCollection(typeof(Database.Registration));
                    if (collection.Count > 0)
                    {
                        Session.DefaultSession.Delete(collection);
                        Session.DefaultSession.Save(collection);
                    }
                    collection.Dispose();

                    Database.Registration dbRegistration = new Database.Registration();
                    dbRegistration.Name = regName;
                    dbRegistration.Company = regCompany;
                    dbRegistration.Key = tbKey.Text;
                    dbRegistration.Save();

                    Close();
                }
                else
                {
                    XtraMessageBox.Show("The details you entered do not match the key, please check the details and try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                XtraMessageBox.Show("Registration Key cannot be blank, please enter a key and try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #4
0
        private void wizardControl1_SelectedPageChanging(object sender, DevExpress.XtraWizard.WizardPageChangingEventArgs e)
        {
            if (e.PrevPage == welcomeWizardPage1 && e.Direction == DevExpress.XtraWizard.Direction.Forward)
            {
                lblError.Text = "";
                // Verify all fields are filled in
                if (tbOffset.Text == "")
                {
                    lblError.Text = "Offset is a required field";
                    e.Page = welcomeWizardPage1;
                    return;
                }

                if (tbLength.Text == "")
                {
                    lblError.Text = "The offset length is a required field";
                    e.Page = welcomeWizardPage1;
                    return;
                }

                if (cbOffsetType.Text == "Bit")
                {
                    if (tbBit.Text == "")
                    {
                        lblError.Text = "You must specify the bit in which you wish to watch";
                        e.Page = welcomeWizardPage1;
                        return;
                    }
                }

                try
                {
                    int offsettest = Int32.Parse(tbOffset.Text, System.Globalization.NumberStyles.HexNumber);
                }
                catch (Exception)
                {
                    lblError.Text = "Offset needs to be just the offset number, for example 0x0D0C would be just 0D0C";
                    e.Page = welcomeWizardPage1;
                    return;
                }

                try
                {
                    int lengthtest = Convert.ToInt32(tbLength.Text);
                }
                catch (Exception)
                {
                    lblError.Text = "Offset length needs to be a number";
                    e.Page = welcomeWizardPage1;
                    return;
                }

                if (cbOffsetType.Text == "Bit")
                {
                    try
                    {
                        int bittest = Convert.ToInt32(tbBit.Text);
                    }
                    catch (Exception)
                    {
                        lblError.Text = "Bit needs to be a number";
                        e.Page = welcomeWizardPage1;
                        return;
                    }
                }

                if (Convert.ToInt32(tbLength.Text) > 8)
                {
                    lblError.Text = "Offset length needs to be between 1 and 8";
                    e.Page = welcomeWizardPage1;
                    return;
                }

                if (Convert.ToInt32(tbLength.Text) < 1)
                {
                    lblError.Text = "Offset length needs to be between 1 and 8";
                    e.Page = welcomeWizardPage1;
                    return;
                }

                if (cbOffsetType.Text == "Bit")
                {
                    if (Convert.ToInt32(tbBit.Text) < 0)
                    {
                        lblError.Text = "Bit cannot be a negative number";
                        e.Page = welcomeWizardPage1;
                        return;
                    }
                }

                if (cbOffsetType.Text == "Byte")
                {
                    XPCollection collection = new XPCollection(typeof(Database.AnalogOutputScripts), CriteriaOperator.Parse(String.Format("CardModel == '{0}' AND CardRevision == '{1}' AND CardSerial == {2} AND Offset == '{3}'", _CardModel, _CardRevision, _CardSerialNumber, tbOffset.Text)));
                    if (collection.Count > 0)
                    {
                        lblError.Text = "Offset already added";
                        e.Page = welcomeWizardPage1;
                        return;
                    }
                    collection.Dispose();
                }

                if (cbOffsetType.Text == "Bit")
                {
                    XPCollection collection = new XPCollection(typeof(Database.AnalogOutputScripts), CriteriaOperator.Parse(String.Format("CardModel == '{0}' AND CardRevision == '{1}' AND CardSerial == {2} AND Offset == '{3}' AND Bit == {4}", _CardModel, _CardRevision, _CardSerialNumber, tbOffset.Text, tbBit.Text)));
                    if (collection.Count > 0)
                    {
                        lblError.Text = "Offset and Bit already added";
                        e.Page = welcomeWizardPage1;
                        return;
                    }
                    collection.Dispose();
                }

                // validation complete
                db.CardModel = _CardModel;
                db.CardRevision = _CardRevision;
                db.CardSerial = _CardSerialNumber;

                if (cbOffsetType.Text == "Bit")
                    db.Bit = Convert.ToInt32(tbBit.Text);
                else
                    db.Bit = -1;

                db.Length = Convert.ToInt32(tbLength.Text);
                db.Offset = tbOffset.Text;

                if (cbOffsetType.Text == "Bit")
                    db.OutputCode = _BitSample;
                else
                    db.OutputCode = _ByteSample;

                db.Save();

                labelControl6.Text = "Script for offset " + tbOffset.Text + " has been added to the database and a sample script has been generated for the offset type that you have selected.  Click on Finish to complete this wizard.";
            }
        }
예제 #5
0
        /// <summary>
#pragma warning disable 1574
        /// retrive a list of <see cref="DBObject.ClassInfo.KeyProperty"/> values (IDs)
#pragma warning restore 1574

        /// </summary>
        /// <param name="collection"></param>
        /// <returns></returns>
        public static SortedList GetIds(XPCollection collection)
        {
            var sortedList = new SortedList();
            foreach (IXPSimpleObject ixpSimpleObject in collection)
                sortedList.Add(ixpSimpleObject.ClassInfo.KeyProperty.GetValue(ixpSimpleObject), ixpSimpleObject);

            collection.Dispose();
            return sortedList;
        }
예제 #6
0
        private void wizardControl1_SelectedPageChanging(object sender, DevExpress.XtraWizard.WizardPageChangingEventArgs e)
        {
            if (e.PrevPage == welcomeWizardPage1 && e.Direction == DevExpress.XtraWizard.Direction.Forward)
            {
                meCardDetails.Text = String.Format("Please confirm that you wish to add a {0}{1} with a Serial Number of {2} to the system.  These details are not able to be edited once added to the system.  If anything is incorrect, please click the back button now to fix them.", cbModelNumber.Text, cbRevisionNumber.Text, tbSerialNumber.Text);
            }

            if (e.PrevPage == wizardPage1 && e.Direction == DevExpress.XtraWizard.Direction.Forward)
            {
                lblStep1Error.Text = "";    // Clear Error Box

                // Add Card Details to the Database
                cardDB.CardModel = cbModelNumber.Text;
                cardDB.CardRevision = cbRevisionNumber.Text;
                cardDB.CardSerialNumber = Convert.ToInt32(tbSerialNumber.Text);
                cardDB.CardConnected = false;

                XPCollection collection = new XPCollection(typeof(Database.Cards), CriteriaOperator.Parse(String.Format("CardModel == '{0}' AND CardRevision == '{1}' AND CardSerialNumber = {2}", cbModelNumber.Text, cbRevisionNumber.Text, Convert.ToInt32(tbSerialNumber.Text))));
                if (collection.Count == 0)
                {
                    tbCardName.Text = String.Format("{0}{1} [{2}]", cbModelNumber.Text, cbRevisionNumber.Text, tbSerialNumber.Text);
                }
                else
                {
                    lblStep1Error.Text = "The card you are trying to add already exists in the system, please check the card and try again.";
                    e.Page = welcomeWizardPage1;
                }
                collection.Dispose();
            }

            if (e.PrevPage == wizardPage2 && e.Direction == DevExpress.XtraWizard.Direction.Forward)
            {
                if (tbCardName.Text == "")
                    tbCardName.Text = String.Format("{0}{1} [{2}]", cbModelNumber.Text, cbRevisionNumber.Text, tbSerialNumber.Text);

                cardDB.CardName = tbCardName.Text;
                cardDB.CardDescription = tbCardDescription.Text;

                cardDB.Save();
            }

            if (e.PrevPage == completionWizardPage1)
            {
                MessageBox.Show("test");
            }
        }
예제 #7
0
        private void SetupScriptNewScript()
        {
            XPCollection collection = new XPCollection(typeof(Database.AnalogOutputScripts), CriteriaOperator.Parse(String.Format("CardModel == '{0}' AND CardRevision == '{1}' AND CardSerial == {2}", _CardModel, _CardRevision, _CardSerialNumber)));

            foreach (Database.AnalogOutputScripts dbitem in collection)
            {
                ImageComboBoxItem item;
                if (dbitem.Bit == -1)
                {
                    // Offset is a byte
                    item = new ImageComboBoxItem
                    {
                        Description = string.Format("Offset 0x{0}", dbitem.Offset),
                        Value = dbitem.Oid,
                        ImageIndex = 6
                    };
                }
                else
                {
                    // Offset is a bit
                    item = new ImageComboBoxItem
                    {
                        Description = string.Format("Offset 0x{0}, Bit {1}", dbitem.Offset, dbitem.Bit),
                        Value = dbitem.Oid,
                        ImageIndex = 6
                    };
                }

                bool itemadded = false;
                foreach (ImageComboBoxItem cbitem in repositoryItemImageComboBox1.Items)
                {
                    if (cbitem.Description == item.Description)
                        itemadded = true;
                }
                if (itemadded == false)
                    repositoryItemImageComboBox1.Items.Add(item);
            }
            collection.Dispose();
        }