public void AccessTableAdd()
        {
            String Criteria;

            Criteria = "PartnerID =" + textBox1.Text;
            Rs.MoveFirst();
            //go to the beginning to start serach
            Rs.Find(Criteria);
            //Either We find the record(s), which is the first record if there are more than one
            //If record is found the file pointer stays at it
            //if not found, the file pointer has passed eof meaning eof = true
            if (Rs.EOF == true)
            {
                //not found
                Rs.AddNew();
                SaveinTable();
                Rs.Update();
                MessageBox.Show("Record Added succesfully");
                ClearBoxes();
                return;
            }
            else
            {
                //found
                MessageBox.Show("Duplicate Record, try another PartnerID");
                return;
            }
        }
        public void loadItem(ref int id)
        {
            System.Windows.Forms.TextBox  oText  = null;
            System.Windows.Forms.CheckBox oCheck = null;
            if (id)
            {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from PrintGroup WHERE PrintGroupID = " + id);
            }
            else
            {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from PrintGroup");
                adoPrimaryRS.AddNew();
                this.Text    = this.Text + " [New record]";
                mbAddNewFlag = true;
            }
            setup();
            foreach (TextBox oText_loopVariable in this.txtFields)
            {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.MaxLength = adoPrimaryRS.Fields(oText.DataBindings).DefinedSize;
            }
            foreach (TextBox oText_loopVariable in this.txtInteger)
            {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.Leave += txtInteger_Leave;
            }
            buildDataControls();
            mbDataChanged = false;

            loadLanguage();
            ShowDialog();
        }
Beispiel #3
0
        /****** View with Source Object ******/


        private ADODB.Recordset ConvertToRecordset(DataTable inTable)
        {
            ADODB.Recordset result = new ADODB.Recordset();
            result.CursorLocation = ADODB.CursorLocationEnum.adUseClient;

            ADODB.Fields resultFields = result.Fields;
            System.Data.DataColumnCollection inColumns = inTable.Columns;

            foreach (DataColumn inColumn in inColumns)
            {
                resultFields.Append(inColumn.ColumnName
                                    , TranslateType(inColumn.DataType)
                                    , inColumn.MaxLength
                                    , inColumn.AllowDBNull ? ADODB.FieldAttributeEnum.adFldIsNullable : ADODB.FieldAttributeEnum.adFldUnspecified
                                    , null);
            }

            result.Open(System.Reflection.Missing.Value
                        , System.Reflection.Missing.Value
                        , ADODB.CursorTypeEnum.adOpenStatic
                        , ADODB.LockTypeEnum.adLockOptimistic, 0);

            foreach (DataRow dr in inTable.Rows)
            {
                result.AddNew(System.Reflection.Missing.Value, System.Reflection.Missing.Value);

                for (int columnIndex = 0; columnIndex < inColumns.Count; columnIndex++)
                {
                    resultFields[columnIndex].Value = dr[columnIndex];
                }
            }

            return(result);
        }
Beispiel #4
0
        private ADODB.Recordset CreateInMemoryADORS(IGTKeyObjects DDCKeyObjects)
        {
            ADODB.Recordset shapeADORecordset = new ADODB.Recordset();

            try
            {
                shapeADORecordset.Fields.Append("G3E_FNO", ADODB.DataTypeEnum.adInteger, 0, ADODB.FieldAttributeEnum.adFldFixed, null);
                shapeADORecordset.Fields.Append("G3E_FID", ADODB.DataTypeEnum.adInteger, 0, ADODB.FieldAttributeEnum.adFldFixed, null);
                shapeADORecordset.Open(System.Type.Missing, System.Type.Missing, ADODB.CursorTypeEnum.adOpenUnspecified, ADODB.LockTypeEnum.adLockUnspecified, 0);

                foreach (IGTKeyObject keyObject in DDCKeyObjects)
                {
                    shapeADORecordset.AddNew(System.Type.Missing, System.Type.Missing);
                    shapeADORecordset.Fields["G3E_FNO"].Value = keyObject.FNO;
                    shapeADORecordset.Fields["G3E_FID"].Value = keyObject.FID;
                    shapeADORecordset.Update(System.Type.Missing, System.Type.Missing);
                }
            }
            catch (Exception ex)
            {
                string exMsg = string.Format("Error occurred in {0} of {1}.{2}{3}", System.Reflection.MethodBase.GetCurrentMethod().Name, this.ToString(), Environment.NewLine, ex.Message);
                throw new Exception(exMsg);
            }

            return(shapeADORecordset);
        }
Beispiel #5
0
        public static void AddData <T>(this IDatabaseObject <T> source) where T : class
        {
            string name = typeof(T).Name;
            string sql  = "[" + name + "]";

            ADODB.Recordset rs = DataSeverConnection.Instance.Recordset(sql, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic);
            rs.AddNew();

            PropertyInfo[] properties = typeof(T).GetProperties();

            for (int i = 0; i < rs.Fields.Count; i++)
            {
                PropertyInfo property = null;

                properties.Each(f =>
                {
                    if (f.Name == rs.Fields[i].Name)
                    {
                        property = f;
                        return;
                    }
                });

                rs.Fields[i].Value = property.GetValue(source);
            }
            rs.Update();
            rs.Close();
        }
Beispiel #6
0
        public void loadItem(ref int id)
        {
            System.Windows.Forms.TextBox oText = null;
            System.Windows.Forms.CheckBox oCheck = null;
             // ERROR: Not supported in C#: OnErrorStatement

            if (id) {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from StockGroup WHERE StockGRoupID = " + id);
            } else {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from StockGroup");
                adoPrimaryRS.AddNew();
                this.Text = this.Text + " [New record]";
                mbAddNewFlag = true;
            }
            setup();
            BindingSource bind = new BindingSource();
            foreach (TextBox oText_loopVariable in this.txtFields) {
                oText = oText_loopVariable;
                bind.DataSource = adoPrimaryRS;
                oText.DataBindings.Add(bind.DataSource);
                oText.MaxLength = adoPrimaryRS.Fields(oText.DataBindings).DefinedSize;
            }

            foreach (CheckBox oCheck_loopVariable in this.chkFields) {
                oCheck = oCheck_loopVariable;
                oCheck.DataBindings.Add(bind.DataSource);
            }

            buildDataControls();
            mbDataChanged = false;

            loadLanguage();
            ShowDialog();
        }
Beispiel #7
0
        public void loadItem(ref int id)
        {
            System.Windows.Forms.TextBox oText = null;
            System.Windows.Forms.CheckBox oCheck = null;
             // ERROR: Not supported in C#: OnErrorStatement

            if (id) {
                gID = id;
                adoPrimaryRS = modRecordSet.getRS(ref "select * from Deposit WHERE DepositID = " + id);
            } else {
                gID = 0;
                adoPrimaryRS = modRecordSet.getRS(ref "select * from Deposit");
                adoPrimaryRS.AddNew();
                this.Text = this.Text + " [New record]";

                mbAddNewFlag = true;
            }
            setup();
            foreach (TextBox oText_loopVariable in txtFields) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.MaxLength = adoPrimaryRS.Fields(oText.DataBindings).DefinedSize;
            }
            foreach (TextBox oText_loopVariable in txtHide) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
            }
            foreach (TextBox oText_loopVariable in txtInteger) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.Leave += txtInteger_Leave;
                //txtInteger_Leave(txtInteger.Item((oText.Index)), New System.EventArgs())
            }
            foreach (TextBox oText_loopVariable in txtFloat) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);

                if (string.IsNullOrEmpty(oText.Text))
                    oText.Text = "0";
                oText.Text = Convert.ToString(Convert.ToDouble(oText.Text) * 100);
                oText.Leave += txtFloat_Leave;
                //txtFloat_Leave(txtFloat.Item((oText.Index)), New System.EventArgs())
            }
            //    For Each oText In Me.txtFloatNegative
            //        Set oText.DataBindings.Add(adoPrimaryRS)
            //        If oText.Text = "" Then oText.Text = "0"
            //        oText.Text = oText.Text * 100
            //        txtFloatNegative_LostFocus oText.Index
            //    Next
            //Bind the check boxes to the data provider
            foreach (CheckBox oCheck_loopVariable in chkFields) {
                oCheck = oCheck_loopVariable;
                oCheck.DataBindings.Add(adoPrimaryRS);
            }
            buildDataControls();
            mbDataChanged = false;

            loadLanguage();
            ShowDialog();
        }
Beispiel #8
0
        private void rent_Click(object sender, EventArgs e)
        {
            Rscar.MoveFirst();
            Rsuser.MoveFirst();
            while (!Rscar.EOF)
            {
                if (carID.Text.Equals(Rscar.Fields["CarID"].Value))
                {
                    Rscar.Fields["Availability"].Value = "No";

                    Rsuser.AddNew();
                    Rsuser.Fields["CarID"].Value       = Convert.ToInt32(carID.Text);
                    Rsuser.Fields["FirstName"].Value   = firstName.Text;
                    Rsuser.Fields["LastName"].Value    = lastName.Text;
                    Rsuser.Fields["PhoneNumber"].Value = phoneNumber.Text;
                    Rsuser.Fields["RentDate"].Value    = Convert.ToDateTime(rentDate.Text);
                    Rsuser.Fields["ReturnDate"].Value  = Convert.ToDateTime(returnDate.Text);
                    Rsuser.Fields["Rent"].Value        = "Yes";
                    Rscar.Update();
                    Rsuser.Update();
                    MessageBox.Show("You rent car successfully");
                    return;
                }
                Rscar.MoveNext();
            }
            MessageBox.Show("Something wrong....");
        }
Beispiel #9
0
        public void loadItem(ref int id)
        {
            System.Windows.Forms.TextBox oText = null;
            System.Windows.Forms.CheckBox oCheck = null;
            if (id) {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from PrintGroup WHERE PrintGroupID = " + id);
            } else {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from PrintGroup");
                adoPrimaryRS.AddNew();
                this.Text = this.Text + " [New record]";
                mbAddNewFlag = true;
            }
            setup();
            foreach (TextBox oText_loopVariable in this.txtFields) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.MaxLength = adoPrimaryRS.Fields(oText.DataBindings).DefinedSize;
            }
            foreach (TextBox oText_loopVariable in this.txtInteger) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.Leave += txtInteger_Leave;
            }
            buildDataControls();
            mbDataChanged = false;

            loadLanguage();
            ShowDialog();
        }
        public void loadItem(ref int id)
        {
            System.Windows.Forms.TextBox  oText  = null;
            System.Windows.Forms.CheckBox oCheck = null;
            // ERROR: Not supported in C#: OnErrorStatement

            if (id)
            {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from PayoutGroup WHERE PayoutGroupID = " + id);
            }
            else
            {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from PayoutGroup");
                adoPrimaryRS.AddNew();
                this.Text    = this.Text + " [New record]";
                mbAddNewFlag = true;
            }
            setup();
            foreach (TextBox oText_loopVariable in this.txtFields)
            {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.MaxLength = adoPrimaryRS.Fields(oText.DataBindings).DefinedSize;
            }

            foreach (CheckBox oCheck_loopVariable in this.chkFields)
            {
                oCheck = oCheck_loopVariable;
                oCheck.DataBindings.Add(adoPrimaryRS);
            }

            buildDataControls();
            mbDataChanged = false;
            ShowDialog();
        }
        public void CallingCLRMethodsThatHaveValueTypeParametersWorksWithReferenceTypes()
        {
            var recordset = new ADODB.Recordset();

            recordset.Fields.Append("name", ADODB.DataTypeEnum.adVarChar, 20, ADODB.FieldAttributeEnum.adFldUpdatable);
            recordset.Open(CursorType: ADODB.CursorTypeEnum.adOpenUnspecified, LockType: ADODB.LockTypeEnum.adLockUnspecified, Options: 0);
            recordset.AddNew();
            recordset.Fields["name"].Value = "TestName";
            recordset.Update();

            var _ = DefaultRuntimeSupportClassFactory.DefaultVBScriptValueRetriever;

            object objField = _.CALL(
                context: null,
                target: recordset,
                members: new string[0],
                argumentProviderBuilder: _.ARGS.Val("name")
                );

            Assert.Equal(
                "TestName",
                _.CALL(
                    context: null,
                    target: this,
                    member1: "MockMethodReturningInputString",
                    argumentProviderBuilder: _.ARGS.Ref(objField, v => { objField = v; })
                    )
                );
        }
Beispiel #12
0
        private void createButton_Click(object sender, EventArgs e)
        {
            if (clientIN.Text.Equals("") || accountIN.Text.Equals("") || typeIN.Text.Equals("") || balanceIN.Text.Equals("") || limitIN.Text.Equals("") || branchIN.Text.Equals(""))
            {
                MessageBox.Show("Please enter full of your infomation.");
            }
            else
            {
                RsAccount.AddNew();
                RsUser.AddNew();
                RsUser.Fields["ClientID"].Value = clientIN.Text;
                RsUser.Fields["Password"].Value = passIN.Text;


                RsAccount.Fields["ClientID"].Value      = Convert.ToInt32(clientIN.Text);
                RsAccount.Fields["AccountNumber"].Value = Convert.ToInt32(accountIN.Text);
                RsAccount.Fields["AccountType"].Value   = typeIN.Text;
                RsAccount.Fields["Balance"].Value       = Convert.ToInt32(balanceIN.Text);
                RsAccount.Fields["CreditLimit"].Value   = Convert.ToInt32(limitIN.Text);
                RsAccount.Fields["BranchNumber"].Value  = Convert.ToInt32(branchIN.Text);


                RsUser.Update();
                RsAccount.Update();
                Show();
                createAccount.Parent = null;
                login.Parent         = tabControl1;
            }
        }
Beispiel #13
0
        public void loadItem(ref int id)
        {
            System.Windows.Forms.TextBox  oText  = null;
            System.Windows.Forms.CheckBox oCheck = null;
            // ERROR: Not supported in C#: OnErrorStatement

            if (id)
            {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from PricelistFilter WHERE PricelistID = " + id);
            }
            else
            {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from PricelistFilter");
                adoPrimaryRS.AddNew();
                this.Text    = this.Text + " [New record]";
                mbAddNewFlag = true;
            }
            setup();
            foreach (TextBox oText_loopVariable in txtFields)
            {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.MaxLength = adoPrimaryRS.Fields(oText.DataBindings).DefinedSize;
            }
            //    For Each oText In Me.txtInteger
            //        Set oText.DataBindings.Add(adoPrimaryRS)
            //        txtInteger_LostFocus oText.Index
            //    Next
            //    For Each oText In Me.txtFloat
            //        Set oText.DataBindings.Add(adoPrimaryRS)
            //        If oText.Text = "" Then oText.Text = "0"
            //        oText.Text = oText.Text * 100
            //        txtFloat_LostFocus oText.Index
            //    Next
            //    For Each oText In Me.txtFloatNegative
            //        Set oText.DataBindings.Add(adoPrimaryRS)
            //        If oText.Text = "" Then oText.Text = "0"
            //        oText.Text = oText.Text * 100
            //        txtFloatNegative_LostFocus oText.Index
            //    Next
            //Bind the check boxes to the data provider
            foreach (CheckBox oCheck_loopVariable in this.chkFields)
            {
                oCheck = oCheck_loopVariable;
                oCheck.DataBindings.Add(adoPrimaryRS);
            }
            //buildDataControls
            mbDataChanged = false;
            //If Me.cmbDelivery.ListIndex = -1 Then
            //    chkChannel.value = 0
            //    cmbDelivery.Enabled = False
            //Else
            //    chkChannel.value = 1
            //    cmbDelivery.Enabled = True
            //End If

            loadLanguage();
            ShowDialog();
        }
Beispiel #14
0
        private void submit_Click(object sender, EventArgs e)
        {
            Boolean flag = false;


            RsAccount.MoveFirst();
            if (amountbox.Text.Equals("") || numbox.Text.Equals("") || typebox.Text.Equals("") || branchnumbox.Text.Equals(""))
            {
                MessageBox.Show("Please enter full of your infomation.");
                Clear();
            }
            else
            {
                while (!RsAccount.EOF)
                {
                    if (Convert.ToInt32(numbox.Text) == RsAccount.Fields["AccountNumber"].Value && Convert.ToInt32(branchnumbox.Text) == RsAccount.Fields["BranchNumber"].Value)
                    {
                        flag = true;
                        break;
                    }
                    RsAccount.MoveNext();
                }
                if (flag == true)
                {
                    RsTranscript.AddNew();
                    RsTranscript.Fields["Date"].Value            = datebox.Text;
                    RsTranscript.Fields["Time"].Value            = timebox.Text;
                    RsTranscript.Fields["Amount"].Value          = Convert.ToInt32(amountbox.Text);
                    RsTranscript.Fields["AccountNumber"].Value   = Convert.ToInt32(numbox.Text);
                    RsTranscript.Fields["TransactionType"].Value = typebox.Text;
                    RsTranscript.Fields["BranchNumber"].Value    = Convert.ToInt32(branchnumbox.Text);

                    if (typebox.Text.Equals("Deposit"))
                    {
                        int total = Convert.ToInt32(amountbox.Text) + RsAccount.Fields["Balance"].Value;
                        RsAccount.Fields["Balance"].Value = total;
                    }
                    else if (typebox.Text.Equals("Withdraw"))
                    {
                        int total = RsAccount.Fields["Balance"].Value - Convert.ToInt32(amountbox.Text);
                        RsAccount.Fields["Balance"].Value = total;
                    }
                    RsAccount.Update();
                    RsTranscript.Update();
                    MessageBox.Show("Your transaction completed successfully!!!!");
                    Show();
                    info.Parent          = tabControl1;
                    transcript.Parent    = null;
                    createAccount.Parent = null;
                }
                else
                {
                    MessageBox.Show("Your transaction faild....");
                    Clear();
                }
            }
        }
Beispiel #15
0
        public void loadItem(ref int id)
        {
            System.Windows.Forms.TextBox oText = null;
            System.Windows.Forms.CheckBox oCheck = null;
             // ERROR: Not supported in C#: OnErrorStatement

            if (id) {
                pRid = id;
                adoPrimaryRS = modRecordSet.getRS(ref "select PricingGroupID,PricingGroup_Name,PricingGroup_RemoveCents,PricingGroup_RoundAfter,PricingGroup_RoundDown,PricingGroup_Unit1,PricingGroup_Case1,PricingGroup_Unit2,PricingGroup_Case2,PricingGroup_Unit3,PricingGroup_Case3,PricingGroup_Unit4,PricingGroup_Case4,PricingGroup_Unit5,PricingGroup_Case5,PricingGroup_Unit6,PricingGroup_Case6,PricingGroup_Unit7,PricingGroup_Case7,PricingGroup_Unit8,PricingGroup_Case8,PricingGroup_Disabled from PricingGroup WHERE PricingGroupID = " + id);
            } else {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from PricingGroup");
                adoPrimaryRS.AddNew();
                this.Text = this.Text + " [New record]";
                mbAddNewFlag = true;
            }
            setup();
            foreach (TextBox oText_loopVariable in this.txtFields) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.MaxLength = adoPrimaryRS.Fields(oText.DataBindings).DefinedSize;
            }
            foreach (TextBox oText_loopVariable in this.txtInteger) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.Leave += txtInteger_Leave;
            }
            foreach (TextBox oText_loopVariable in this.txtFloat) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                if (string.IsNullOrEmpty(oText.Text))
                    oText.Text = "0";
                oText.Text = Convert.ToString(Convert.ToDouble(oText.Text) * 100);
                oText.Leave += txtFloat_Leave;
            }
            foreach (TextBox oText_loopVariable in this.txtFloatNegative) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                if (string.IsNullOrEmpty(oText.Text))
                    oText.Text = "0";
                oText.Text = Convert.ToString(Convert.ToDouble(oText.Text) * 100);
                oText.Leave += txtFloatNegative_Leave;
            }

            if (Convert.ToInt16(adoPrimaryRS.Fields("PricingGroup_Disabled").Value)) {
                this.chkPricing.CheckState = System.Windows.Forms.CheckState.Checked;
                this.chkPricing.Tag = 1;
            } else {
                this.chkPricing.Tag = 0;
            }

            buildDataControls();
            mbDataChanged = false;

            loadLanguage();
            ShowDialog();
        }
Beispiel #16
0
        private void addcust_Click(object sender, EventArgs e)
        {
            if (addcust.Text == "&Add new Customer")
            {
                LockUnLockMe(false);
                textBox1.ReadOnly = false;
                int newid;
                if (cstmr_tb.RecordCount > 0)
                {
                    if (cpos != cstmr_tb.RecordCount)
                    {
                        cstmr_tb.MoveLast();
                        cpos = cstmr_tb.RecordCount;
                    }
                    newid = cstmr_tb.Fields["cID"].Value + 1;
                }
                else
                {
                    newid = 1;
                    //   textid.Text = (newid).ToString();
                    prev.Enabled = true;
                }
                emptyTxt();
                textid.Text  = newid.ToString();
                addcust.Text = "&SAVE DETAILS";
                fnd.Text     = "&Cancel";
                prev.Enabled = false;
                nxt.Enabled  = false;
                edt.Enabled  = false;
                return;
            }



            if (addcust.Text == "&SAVE DETAILS")
            {
                if (textname.Text == "")
                {
                    XtraMessageBox.Show("Invaild Name");
                    return;
                }

                cstmr_tb.AddNew();

                GetData();
                cstmr_tb.Update();
                SetButton();

                customers_list.Items.Add(textname.Text);
                customers_list.Update();
                cpos = cstmr_tb.RecordCount;
                LockUnLockMe(true);
                textBox1.ReadOnly = true;
            }
        }
        public void loadItem(ref int id)
        {
            System.Windows.Forms.TextBox  oText  = null;
            System.Windows.Forms.CheckBox oCheck = null;
            if (id)
            {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from PackSize WHERE PackSizeID = " + id);
            }
            else
            {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from PackSize");
                adoPrimaryRS.AddNew();
                this.Text    = this.Text + " [New record]";
                mbAddNewFlag = true;
            }
            setup();
            foreach (TextBox oText_loopVariable in txtFields)
            {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.MaxLength = adoPrimaryRS.Fields(oText.DataBindings).DefinedSize;
            }
            //    For Each oText In Me.txtInteger
            //        Set oText.DataBindings.Add(adoPrimaryRS)
            //        txtInteger_LostFocus oText.Index
            //    Next
            foreach (TextBox oText_loopVariable in txtFloat)
            {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                if (string.IsNullOrEmpty(oText.Text))
                {
                    oText.Text = "0";
                }
                oText.Text   = Convert.ToString(Convert.ToDouble(oText.Text) * 100);
                oText.Leave += txtFloat_Leave;
                //'txtFloat_Leave(txtFloat.Item((oText.Index)), New System.EventArgs())
            }
            //    For Each oText In Me.txtFloatNegative
            //        Set oText.DataBindings.Add(adoPrimaryRS)
            //        If oText.Text = "" Then oText.Text = "0"
            //        oText.Text = oText.Text * 100
            //        txtFloatNegative_LostFocus oText.Index
            //    Next
            //Bind the check boxes to the data provider
            //        For Each oCheck In Me.chkFields
            //            Set oCheck.DataBindings.Add(adoPrimaryRS)
            //        Next
            buildDataControls();
            mbDataChanged = false;

            loadLanguage();
            ShowDialog();
        }
Beispiel #18
0
        public void loadItem(ref int id)
        {
            System.Windows.Forms.TextBox oText = null;
            System.Windows.Forms.CheckBox oCheck = null;
             // ERROR: Not supported in C#: OnErrorStatement

            if (id) {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from Pricelist WHERE PricelistID = " + id);
            } else {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from Pricelist");
                adoPrimaryRS.AddNew();
                this.Text = this.Text + " [New record]";
                mbAddNewFlag = true;
            }
            setup();
            foreach (TextBox oText_loopVariable in txtFields) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.MaxLength = adoPrimaryRS.Fields(oText.DataBindings).DefinedSize;
            }
            //    For Each oText In Me.txtInteger
            //        Set oText.DataBindings.Add(adoPrimaryRS)
            //        txtInteger_LostFocus oText.Index
            //    Next
            //    For Each oText In Me.txtFloat
            //        Set oText.DataBindings.Add(adoPrimaryRS)
            //        If oText.Text = "" Then oText.Text = "0"
            //        oText.Text = oText.Text * 100
            //        txtFloat_LostFocus oText.Index
            //    Next
            //    For Each oText In Me.txtFloatNegative
            //        Set oText.DataBindings.Add(adoPrimaryRS)
            //        If oText.Text = "" Then oText.Text = "0"
            //        oText.Text = oText.Text * 100
            //        txtFloatNegative_LostFocus oText.Index
            //    Next
            //Bind the check boxes to the data provider
            foreach (CheckBox oCheck_loopVariable in chkFields) {
                oCheck = oCheck_loopVariable;
                oCheck.DataBindings.Add(adoPrimaryRS);
            }
            buildDataControls();
            mbDataChanged = false;
            if (this.cmbDelivery.SelectedIndex == -1) {
                chkChannel.CheckState = System.Windows.Forms.CheckState.Unchecked;
                cmbDelivery.Enabled = false;
            } else {
                chkChannel.CheckState = System.Windows.Forms.CheckState.Checked;
                cmbDelivery.Enabled = true;
            }

            loadLanguage();
            ShowDialog();
        }
Beispiel #19
0
        public void loadItem(ref int id)
        {
            System.Windows.Forms.TextBox oText = null;
            DateTimePicker oDate = null;

            System.Windows.Forms.CheckBox oCheck = null;

            mbAddNewFlagID = false;

            // ERROR: Not supported in C#: OnErrorStatement

            if (id)
            {
                p_Prom       = id;
                adoPrimaryRS = modRecordSet.getRS(ref "select GRVPromotion.* from GRVPromotion WHERE PromotionID = " + id);
            }
            else
            {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from GRVPromotion");
                adoPrimaryRS.AddNew();
                this.Text      = this.Text + " [New record]";
                mbAddNewFlag   = true;
                mbAddNewFlagID = true;
            }
            setup();
            foreach (TextBox oText_loopVariable in txtFields)
            {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.MaxLength = adoPrimaryRS.Fields(oText.DataBindings).DefinedSize;
            }

            foreach (DateTimePicker oDate_loopVariable in DTFields)
            {
                oDate = oDate_loopVariable;
                oDate.DataBindings.Add(adoPrimaryRS);
            }

            //adoPrimaryRS("Promotion_SpeTime")
            //Bind the check boxes to the data provider
            foreach (CheckBox oCheck_loopVariable in chkFields)
            {
                oCheck = oCheck_loopVariable;
                oCheck.DataBindings.Add(adoPrimaryRS);
            }
            buildDataControls();
            mbDataChanged = false;
            loadItems();

            loadLanguage();
            ShowDialog();
        }
Beispiel #20
0
        private void addcust_Click(object sender, EventArgs e)
        {
            if (addcust.Text == "&Add new Farmer")
            {
                LockUnLockMe(false);
                int newid;
                if (frmr_tb.RecordCount > 0)
                {
                    if (cpos != frmr_tb.RecordCount)
                    {
                        frmr_tb.MoveLast();
                        cpos = frmr_tb.RecordCount;
                    }
                    newid = frmr_tb.Fields["fID"].Value + 1;
                }
                else
                {
                    newid = 1;
                    //   textid.Text = (newid).ToString();
                    prev.Enabled = true;
                }
                emptyTxt();
                textid.Text  = newid.ToString();
                addcust.Text = "&Save Details";
                fnd.Text     = "&Cancel";
                prev.Enabled = false;
                nxt.Enabled  = false;
                edt.Enabled  = false;
                return;
            }



            if (addcust.Text == "&Save Details")
            {
                if (textname.Text == "")
                {
                    XtraMessageBox.Show("Invaild Name");
                    return;
                }

                frmr_tb.AddNew();

                GetData();
                frmr_tb.Update();
                SetButton();
                farmers_list.Items.Add(textname.Text);
                farmers_list.Update();
                cpos = frmr_tb.RecordCount;
            }
        }
Beispiel #21
0
        public void loadItem(ref int id)
        {
            System.Windows.Forms.TextBox  oText  = null;
            System.Windows.Forms.CheckBox oCheck = null;
            // ERROR: Not supported in C#: OnErrorStatement


            if (id)
            {
                k_posNew = false;
                k_posID  = id;
                //Get Warehouse ID...
                adoPrimaryRS = modRecordSet.getRS(ref "select * from Warehouse WHERE WarehouseID = " + id);
            }
            else
            {
                k_posNew     = true;
                adoPrimaryRS = modRecordSet.getRS(ref "select * from Warehouse");
                adoPrimaryRS.AddNew();
                this.Text             = this.Text + " [New record]";
                _txtInteger_0.Enabled = true;
                mbAddNewFlag          = true;
            }

            setup();
            foreach (TextBox oText_loopVariable in this.txtFields)
            {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.MaxLength = adoPrimaryRS.Fields(oText.DataBindings).DefinedSize;
            }
            foreach (TextBox oText_loopVariable in this.txtInteger)
            {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.Leave += txtInteger_Leave;
                //txtInteger_Leave(txtInteger.Item((oText.Index)), New System.EventArgs())
            }

            bolLoad = true;
            if (id)
            {
            }
            bolLoad = false;

            mbDataChanged = false;

            loadLanguage();
            ShowDialog();
        }
Beispiel #22
0
        //Adding new record into DB
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" ||
                textBox2.Text == "" ||
                textBox3.Text == "" ||
                textBox4.Text == "" ||
                textBox5.Text == "" ||
                textBox6.Text == "" ||
                textBox7.Text == "" ||
                textBox8.Text == "" ||
                textBox9.Text == "" ||
                textBox10.Text == "" ||
                textBox11.Text == "" ||
                textBox12.Text == "" ||
                textBox13.Text == "" ||
                textBox14.Text == "" ||
                textBox15.Text == "" ||
                textBox16.Text == "" ||
                textBox17.Text == "" ||
                textBox18.Text == "")
            {
                MessageBox.Show("Please Fill up all boxes");
                return;
            }
            String Criteria;

            Criteria = "ContactID =" + textBox1.Text;
            Rs.MoveFirst();
            //go to the beginning to start serach
            Rs.Find(Criteria);
            //Either We find the record(s), which is the first record if there are more than one
            //If record is found the file pointer stays at it
            //if not found, the file pointer has passed eof meaning eof = true
            if (Rs.EOF == true)
            {
                //not found
                Rs.AddNew();
                SaveinTable();
                Rs.Update();
                MessageBox.Show("Record Added succesfully");
                ClearBoxes();
                return;
            }
            else
            {
                //found
                MessageBox.Show("Duplicate Record, try another ISBN");
                return;
            }
        }
Beispiel #23
0
 private void addButton_Click(object sender, EventArgs e)
 {
     Rscar.MoveLast();
     Rscar.AddNew();
     Rscar.Fields["CarID"].Value        = Convert.ToInt32(carID.Text);
     Rscar.Fields["Name"].Value         = modifyName.Text;
     Rscar.Fields["Model"].Value        = modifyModel.Text;
     Rscar.Fields["Make"].Value         = modifyMake.Text;
     Rscar.Fields["Type"].Value         = modifyType.Text;
     Rscar.Fields["Color"].Value        = modifyColor.Text;
     Rscar.Fields["VIN"].Value          = Convert.ToInt32(modifyVIN.Text);
     Rscar.Fields["Price"].Value        = Convert.ToInt32(modifyPrice.Text);
     Rscar.Fields["Availability"].Value = true;
     Rscar.Update();
     modify.Parent = null;
     menu.Parent   = tab;
 }
Beispiel #24
0
        private static bool InsertIntoAsketPorTimeEntries()
        {
            string Select = "select з.IdPorAsket, тз.IssueId, ТЗ.Spent_On,тз.Hours, Ф.UserName ,  тз.Comments + ' Импортировано из Redmine. ' as Comments, тз.id" +
                            " from      " + DB.TABLE_REDMINE_TIME_ENTRIES + " as ТЗ " +
                            " left join " + DB.TABLE_REDMINE_USERS + "  as П on тз.UserId = п.id " +
                            " left join " + DB.TABLE_ASKET_USERS + " as Ф On п.IdUserFromFam = Ф.код " +
                            " left join " + DB.TABLE_REDMINE_ISSUES + "  as З on ТЗ.IssueId = З.id " +
                            " where Deleted = 0 and InsertIntoAsketPor = 0 and з.idPorAsket is not null ";

            ADODB.Recordset rsSelect = DB.Select(Select);
            if (rsSelect == null)
            {
                return(false);
            }
            ADODB.Recordset RsAddPor = DB.Update("select top 1 Код, КодПоручения, Дата, Часов, Кто, Примечания from " + DB.TABLE_REPORT_DEVELOPER);
            if (RsAddPor == null)
            {
                return(false);
            }
            ADODB.Recordset RsUpdateTimeEntries = DB.Update("Select Id, InsertIntoAsketPor,IdRazrabAsket from  " + DB.TABLE_REDMINE_TIME_ENTRIES + " where Deleted = 0 and InsertIntoAsketPor = 0 and IdRazrabAsket =0");
            if (RsUpdateTimeEntries == null)
            {
                return(false);
            }
            while (!(rsSelect.EOF))
            {
                RsAddPor.AddNew();
                RsAddPor.Fields["КодПоручения"].Value = rsSelect.Fields["IdPorAsket"].Value;
                RsAddPor.Fields["Дата"].Value         = rsSelect.Fields["Spent_On"].Value;
                RsAddPor.Fields["Часов"].Value        = rsSelect.Fields["Hours"].Value;
                RsAddPor.Fields["Кто"].Value          = rsSelect.Fields["UserName"].Value;
                RsAddPor.Fields["Примечания"].Value   = rsSelect.Fields["Comments"].Value;
                RsAddPor.Update();
                RsUpdateTimeEntries.Filter = "id = " + rsSelect.Fields["id"].Value;
                if (RsUpdateTimeEntries.RecordCount == 1)
                {
                    RsUpdateTimeEntries.Fields["InsertIntoAsketPor"].Value = true;
                    RsUpdateTimeEntries.Fields["IdRazrabAsket"].Value      = RsAddPor.Fields["Код"].Value;
                    RsUpdateTimeEntries.Update();
                }
                rsSelect.MoveNext();
            }
            rsSelect.Close();
            RsAddPor.Close();
            return(true);
        }
Beispiel #25
0
        public bool salvar()
        {
            String SQL;

            if (alterado)
            {
                ADODB.Recordset RSDados = new ADODB.Recordset();
                RSDados.CursorLocation = ADODB.CursorLocationEnum.adUseClient;
                RSDados.LockType       = ADODB.LockTypeEnum.adLockOptimistic;
                RSDados.CursorType     = ADODB.CursorTypeEnum.adOpenKeyset;
                if (cod != 0)
                {
                    SQL = "SELECT Duplicatas.* FROM Duplicatas WHERE (((Duplicatas.Código)=" + cod + "));";
                }
                else
                {
                    SQL = "SELECT Duplicatas.* FROM Duplicatas;";
                }

                RSDados.Open(SQL, new Conexao().getContas());
                if (cod == 0)
                {
                    RSDados.AddNew();
                }

                RSDados.Fields["data"].Value          = Vencimento.ToShortDateString();
                RSDados.Fields["Origem"].Value        = Origem;
                RSDados.Fields["informação"].Value    = Informacao;
                RSDados.Fields["complemento"].Value   = Complemento;
                RSDados.Fields["Valor"].Value         = Valor;
                RSDados.Fields["Pago"].Value          = Pago;
                RSDados.Fields["Classificação"].Value = Classificacao;
                RSDados.Fields["DataNota"].Value      = DataNota.ToShortDateString();
                RSDados.Fields["Empresa"].Value       = Empresa;
                RSDados.Update();
                if (cod == 0)
                {
                    cod = Convert.ToInt32(RSDados.Fields["cod"].Value);
                }
                RSDados.Close();
                return(true);
            }

            return(false);
        }
        public void loadItem(ref int id)
        {
            System.Windows.Forms.TextBox oText = null;
            DateTimePicker oDate = null;
            System.Windows.Forms.CheckBox oCheck = null;

            mbAddNewFlagID = false;

             // ERROR: Not supported in C#: OnErrorStatement

            if (id) {
                p_Prom = id;
                adoPrimaryRS = modRecordSet.getRS(ref "select GRVPromotion.* from GRVPromotion WHERE PromotionID = " + id);
            } else {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from GRVPromotion");
                adoPrimaryRS.AddNew();
                this.Text = this.Text + " [New record]";
                mbAddNewFlag = true;
                mbAddNewFlagID = true;
            }
            setup();
            foreach (TextBox oText_loopVariable in txtFields) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.MaxLength = adoPrimaryRS.Fields(oText.DataBindings).DefinedSize;
            }

            foreach (DateTimePicker oDate_loopVariable in DTFields) {
                oDate = oDate_loopVariable;
                oDate.DataBindings.Add(adoPrimaryRS);
            }

            //adoPrimaryRS("Promotion_SpeTime")
            //Bind the check boxes to the data provider
            foreach (CheckBox oCheck_loopVariable in chkFields) {
                oCheck = oCheck_loopVariable;
                oCheck.DataBindings.Add(adoPrimaryRS);
            }
            buildDataControls();
            mbDataChanged = false;
            loadItems();

            loadLanguage();
            ShowDialog();
        }
Beispiel #27
0
        public void loadItem(ref int id)
        {
            System.Windows.Forms.TextBox oText = null;
            System.Windows.Forms.CheckBox oCheck = null;
            if (id) {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from VAT WHERE VATID = " + id);
            } else {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from VAT");
                adoPrimaryRS.AddNew();
                this.Text = this.Text + " [New record]";
                mbAddNewFlag = true;
            }
            setup();
            oText = _txtFields_0;
            oText.DataBindings.Add(adoPrimaryRS);
            oText.MaxLength = adoPrimaryRS.Fields(oText.DataBindings).DefinedSize;
            //Next oText
            //    For Each oText In Me.txtInteger
            //        Set oText.DataBindings.Add(adoPrimaryRS)
            //        txtInteger_LostFocus oText.Index
            //    Next
            oText = _txtFloat_0;
            oText.DataBindings.Add(adoPrimaryRS);
            if (string.IsNullOrEmpty(oText.Text))
                oText.Text = "0";
            oText.Text = Convert.ToString(Convert.ToDouble(oText.Text) * 100);
            oText.Leave += txtFloat_Leave;
            //txtFloat_Leave(_txtFloat_0.Item(0, New System.EventArgs()))
            //Next oText
            //    For Each oText In Me.txtFloatNegative
            //        Set oText.DataBindings.Add(adoPrimaryRS)
            //        If oText.Text = "" Then oText.Text = "0"
            //        oText.Text = oText.Text * 100
            //        txtFloatNegative_LostFocus oText.Index
            //    Next
            //Bind the check boxes to the data provider
            //        For Each oCheck In Me.chkFields
            //            Set oCheck.DataBindings.Add(adoPrimaryRS)
            //        Next
            buildDataControls();
            mbDataChanged = false;

            loadLanguage();
            ShowDialog();
        }
Beispiel #28
0
        public void loadItem(ref int id)
        {
            System.Windows.Forms.TextBox oText = null;
            System.Windows.Forms.CheckBox oCheck = null;
             // ERROR: Not supported in C#: OnErrorStatement

            if (id) {
                k_posNew = false;
                k_posID = id;
                //Get Warehouse ID...
                adoPrimaryRS = modRecordSet.getRS(ref "select * from Warehouse WHERE WarehouseID = " + id);
            } else {
                k_posNew = true;
                adoPrimaryRS = modRecordSet.getRS(ref "select * from Warehouse");
                adoPrimaryRS.AddNew();
                this.Text = this.Text + " [New record]";
                _txtInteger_0.Enabled = true;
                mbAddNewFlag = true;
            }

            setup();
            foreach (TextBox oText_loopVariable in this.txtFields) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.MaxLength = adoPrimaryRS.Fields(oText.DataBindings).DefinedSize;
            }
            foreach (TextBox oText_loopVariable in this.txtInteger) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.Leave += txtInteger_Leave;
                //txtInteger_Leave(txtInteger.Item((oText.Index)), New System.EventArgs())
            }

            bolLoad = true;
            if (id) {

            }
            bolLoad = false;

            mbDataChanged = false;

            loadLanguage();
            ShowDialog();
        }
        public void BugFix_AmbiguousIndexer_ADODB()
        {
            engine.Dispose();
            engine = new VBScriptEngine(WindowsScriptEngineFlags.EnableDebugging);

            var recordSet = new ADODB.Recordset();

            recordSet.Fields.Append("foo", ADODB.DataTypeEnum.adVarChar, 20);
            recordSet.Open(Missing.Value, Missing.Value, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic, 0);
            recordSet.AddNew(Missing.Value, Missing.Value);
            recordSet.Fields["foo"].Value = "bar";

            engine.AddHostObject("recordSet", recordSet);
            Assert.AreEqual("bar", engine.Evaluate("recordSet.Fields.Item(\"foo\").Value"));

            engine.Execute("recordSet.Fields.Item(\"foo\").Value = \"qux\"");
            Assert.AreEqual("qux", engine.Evaluate("recordSet.Fields.Item(\"foo\").Value"));

            TestUtil.AssertException <ScriptEngineException>(() => engine.Evaluate("recordSet.Fields.Item(\"baz\")"));
        }
        public void ADORecordsetSupportsDefaultFieldAccess()
        {
            var recordset = new ADODB.Recordset();

            recordset.Fields.Append("name", ADODB.DataTypeEnum.adVarChar, 20, ADODB.FieldAttributeEnum.adFldUpdatable);
            recordset.Open(CursorType: ADODB.CursorTypeEnum.adOpenUnspecified, LockType: ADODB.LockTypeEnum.adLockUnspecified, Options: 0);
            recordset.AddNew();
            recordset.Fields["name"].Value = "TestName";
            recordset.Update();

            var _ = DefaultRuntimeSupportClassFactory.DefaultVBScriptValueRetriever;

            Assert.Equal(
                recordset.Fields["name"],
                _.CALL(
                    context: null,
                    target: recordset,
                    members: new string[0],
                    argumentProviderBuilder: _.ARGS.Val("name")
                    ),
                new ADOFieldObjectComparer()
                );
        }
Beispiel #31
0
        public virtual void Add(bool addAll = false, ProgressReporter pg = null)
        {
            //lock (DataSeverConnection.Instance.Connection)
            //{
            try
            {
                string          sql  = "SELECT * FROM [" + typeof(T).Name.SanitizeTypeName() + "]";
                ADODB.Recordset rs   = DataSeverConnection.Instance.Recordset(sql, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic);
                string[]        keys = GetPrimaryKeyColumns();

                try
                {
                    rs.AddNew();
                    FillRecordset(addAll, rs, keys);
                    rs.Update();
                }
                catch (Exception) { return; }
                if (addAll == false)
                {
                    keys.Each(k =>
                    {
                        int pos           = rs.GetFieldPosition(k);
                        PropertyInfo temp = typeof(T).GetProperty(k);
                        object val        = rs.Fields[pos].Value;
                        temp.SetValue(this, Convert.ChangeType(val, temp.PropertyType));
                    });
                }
                rs.Close();
                NeedsToSave = false;
                if (pg != null)
                {
                    pg.ReportProgress(pg.ReportAction);
                }
            }
            catch (Exception err) { MessageBox.Show("Error adding to Database: " + err.Message); }
            //}
        }
Beispiel #32
0
        public static void Update_ADODB_from_ADO(DataTable inTable, ref ADODB.Recordset adoRs)
        {
            // ADODB.Recordset result = adoRs.Clone(ADODB.LockTypeEnum.adLockOptimistic);
            ADODB.Fields adoFields = adoRs.Fields;
            System.Data.DataColumnCollection inColumns = inTable.Columns;
            //Delete
            adoRs.MoveFirst();
            while (!adoRs.EOF)
            {
                adoRs.Delete();
                adoRs.MoveNext();
            }
            //Add
            foreach (DataRow dr in inTable.Rows)
            {
                adoRs.AddNew(System.Reflection.Missing.Value,
                             System.Reflection.Missing.Value);

                for (int columnIndex = 0; columnIndex < inColumns.Count; columnIndex++)
                {
                    adoFields[columnIndex].Value = dr[columnIndex];
                }
            }
        }
Beispiel #33
0
        public void loadItem(ref int id)
        {
            System.Windows.Forms.TextBox oText = null;
            System.Windows.Forms.CheckBox oCheck = null;
             // ERROR: Not supported in C#: OnErrorStatement

            gID = id;

            bool cBitA = false;
            bool cBitF = false;
            if (id) {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from Supplier WHERE SupplierID = " + id);

                if (32 & My.MyProject.Forms.frmMenu.gBit)
                    cBitA = true;
                if (64 & My.MyProject.Forms.frmMenu.gBit)
                    cBitF = true;
                if (cBitA == true & cBitF == true) {
                    _txtFloat_13.Enabled = true;
                    _txtFloat_14.Enabled = true;
                    _txtFloat_15.Enabled = true;
                    _txtFloat_16.Enabled = true;
                    _txtFloat_17.Enabled = true;
                }

            } else {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from Supplier");
                adoPrimaryRS.AddNew();
                this.Text = this.Text + " [New record]";
                mbAddNewFlag = true;
            }
            //    If adoPrimaryRS.BOF Or adoPrimaryRS.EOF Then
            //    Else
             // ERROR: Not supported in C#: OnErrorStatement

            foreach (TextBox oText_loopVariable in txtFields) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.MaxLength = adoPrimaryRS.Fields(oText.DataBindings).DefinedSize;
            }
            //        For Each oText In Me.txtInteger
            //            Set oText.DataBindings.Add(adoPrimaryRS)
            //            txtInteger_LostFocus oText.Index
            //        Next
            foreach (TextBox oText_loopVariable in txtFloat) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                if (string.IsNullOrEmpty(oText.Text))
                    oText.Text = "0";
                oText.Text = Convert.ToString(Convert.ToDouble(oText.Text) * 100);
                oText.Leave += txtFloat_Leave;
            }
            foreach (TextBox oText_loopVariable in txtFloatNegative) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                if (string.IsNullOrEmpty(oText.Text))
                    oText.Text = "0";
                oText.Text = Convert.ToString(Convert.ToDouble(oText.Text) * 100);
                oText.Leave += txtFloatNegative_Leave;
            }
            //Bind the check boxes to the data provider
            foreach (CheckBox oCheck_loopVariable in this.chkFields) {
                oCheck = oCheck_loopVariable;
                oCheck.DataBindings.Add(adoPrimaryRS);
            }
            buildDataControls();
            mbDataChanged = false;

            loadLanguage();
            ShowDialog();
            //    End If
        }
Beispiel #34
0
        public void BugFix_AmbiguousIndexer_ADODB()
        {
            engine.Dispose();
            engine = new VBScriptEngine(WindowsScriptEngineFlags.EnableDebugging);

            var recordSet = new ADODB.Recordset();
            recordSet.Fields.Append("foo", ADODB.DataTypeEnum.adVarChar, 20);
            recordSet.Open(Missing.Value, Missing.Value, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic, 0);
            recordSet.AddNew(Missing.Value, Missing.Value);
            recordSet.Fields["foo"].Value = "bar";

            engine.AddHostObject("recordSet", recordSet);
            Assert.AreEqual("bar", engine.Evaluate("recordSet.Fields.Item(\"foo\").Value"));

            engine.Execute("recordSet.Fields.Item(\"foo\").Value = \"qux\"");
            Assert.AreEqual("qux", engine.Evaluate("recordSet.Fields.Item(\"foo\").Value"));

            TestUtil.AssertException<ScriptEngineException>(() => engine.Evaluate("recordSet.Fields.Item(\"baz\")"));
        }
Beispiel #35
0
        public void CopyTable(ADOX.Table tblAccess)
        {
            ADODB.Recordset recMaster = new ADODB.Recordset();
            ADODB.Recordset recLoop = new ADODB.Recordset();
            int intLoop = 0;

            string strInfile = "";
            string strSQL = "SELECT ";
            string strRecord;
            string strLoadFilePath = strSourceDbPath.Replace("\\", "\\\\");
            string strFileName = strTempPath + tblAccess.Name + ".txt";

            StreamWriter sw = new StreamWriter(strFileName, false);
            //create the infile
                strInfile += "LOAD DATA LOCAL INFILE '" + strFileName + "' INTO TABLE " + strMySQLDBName + "." + tblAccess.Name + " ";
                strInfile += "FIELDS TERMINATED BY ',' ";
                strInfile += "ESCAPED BY '\\\\' ";
                strInfile += "LINES TERMINATED BY 0x0d0a ";
                strInfile += "(";

                //loop through fields to enumerate them for the infile and build a select statement
                for (intLoop = 0; intLoop < tblAccess.Columns.Count; intLoop++)
                {
                    strInfile += MySQLName((tblAccess.Columns[intLoop].Name));
                    switch (tblAccess.Columns[intLoop].Type)
                    {
                        case ADOX.DataTypeEnum.adDate: //convert to MySQL datetime format
                            strSQL += "FORMAT([" + tblAccess.Columns[intLoop].Name + "],  'YYYY-MM-DD HH:MM:SS') as " + tblAccess.Columns[intLoop].Name;
                            break;
                        default:
                            strSQL += "[" + tblAccess.Columns[intLoop].Name + "]";
                            break;
                    }
                    if (intLoop < tblAccess.Columns.Count - 1)
                    {
                        strSQL += ",";
                        strInfile += ", ";
                    }
                }
                strInfile += ");";
                strSQL += " FROM [" + tblAccess.Name + "]";

                //open the "Master" recordset
                recMaster.CursorLocation = ADODB.CursorLocationEnum.adUseClient;
                recMaster.Open(strSQL, conJCMS_db, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic, 0);

                //create the "Loop" recordset, this is a clone of the master, with the exception
                //that the definedsize for text fields is lengthened.  This is because the added
                //escape characters could potentially exceed the field length in the master recordset
                recLoop.CursorLocation = ADODB.CursorLocationEnum.adUseClient;
                ADODB.Fields fdsLoop = recLoop.Fields;
                ADODB.Fields fdsMaster = recMaster.Fields;
                foreach (ADODB.Field fldIn in fdsMaster)
                {
                    if (fldIn.Type.ToString().IndexOf("Char") > 0)
                    {
                        fdsLoop.Append(fldIn.Name,
                            fldIn.Type,
                            fldIn.DefinedSize + 30,
                            ADODB.FieldAttributeEnum.adFldIsNullable,
                            null);
                    }
                    else
                    {
                        fdsLoop.Append(fldIn.Name,
                        fldIn.Type,
                        fldIn.DefinedSize,
                        ADODB.FieldAttributeEnum.adFldIsNullable,
                        null);
                    }
                }
                recLoop.Open(System.Reflection.Missing.Value, System.Reflection.Missing.Value, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic, 0);

                recLoop.AddNew(System.Reflection.Missing.Value, System.Reflection.Missing.Value);

                while (!recMaster.EOF)
                {
                    for (int columnIndex = 0; columnIndex < recMaster.Fields.Count; columnIndex++)
                    {
                        recLoop.Fields[columnIndex].Value = recMaster.Fields[columnIndex].Value;
                        if (recLoop.Fields[columnIndex].Value.ToString().Length > 0)
                        {
                            if ((recLoop.Fields[columnIndex].Value.ToString().IndexOf("\\", 0) + 1) > 0)
                            {
                                recLoop.Fields[columnIndex].Value = recLoop.Fields[columnIndex].Value.ToString().Replace("\\", "\\\\");
                            }
                            if ((recLoop.Fields[columnIndex].Value.ToString().IndexOf(",", 0) + 1) > 0)
                            {
                                recLoop.Fields[columnIndex].Value = recLoop.Fields[columnIndex].Value.ToString().Replace(",", "\\,");
                            }
                            if ((recLoop.Fields[columnIndex].Value.ToString().IndexOf(System.Environment.NewLine, 0) + 1) > 0)
                            {
                                recLoop.Fields[columnIndex].Value = recLoop.Fields[columnIndex].Value.ToString().Replace(System.Environment.NewLine, " ");
                            }
                        }
                    }
                    strRecord = recLoop.GetString(ADODB.StringFormatEnum.adClipString, 1, ",", System.Environment.NewLine, "\\N");
                    recLoop.MovePrevious();
                    sw.Write(strRecord);
                    recMaster.MoveNext();
                }
                recMaster.Close();
                recMaster.ActiveConnection = null;
                try
                {
                    recLoop.Close();
                }
                catch
                {

                }
                sw.Close();
                ExecuteSQL(strInfile);
                File.Delete(strFileName);
                recLoop = null;
        }
Beispiel #36
0
        public void loadItem(ref int id)
        {
            int x = 0;
            string lCode = null;
            string leCode = null;
            string lPassword = null;

            System.Windows.Forms.TextBox oText = null;
            System.Windows.Forms.CheckBox oCheck = null;
             // ERROR: Not supported in C#: OnErrorStatement

            if (id) {
                k_posNew = false;
                k_posID = id;
                //Get POS ID...
                adoPrimaryRS = modRecordSet.getRS(ref "select * from POS WHERE POSID = " + id);

                //new serialization check
                lPassword = Strings.LTrim(Strings.Replace(My.MyProject.Forms.frmMenu.lblCompany.Text, "'", ""));
                lPassword = Strings.RTrim(Strings.Replace(lPassword, " ", ""));
                lPassword = Strings.Trim(Strings.Replace(lPassword, ".", ""));
                lPassword = Strings.LCase(lPassword);
                leCode = "";
                lCode = "";
                for (x = 0; x <= Strings.Len(lPassword); x++) {
                    lCode = Strings.Mid(lPassword, x, 1);
                    lCode = Convert.ToString(Strings.Asc(lCode));
                    if (Convert.ToDouble(lCode) > 96 & Convert.ToDouble(lCode) < 123) {
                        leCode = leCode + Strings.Mid(lPassword, x, 1);
                    }
                }
                lPassword = leCode;
                lCode = Convert.ToString(adoPrimaryRS.Fields("POS_CID").Value * 135792468);
                leCode = Encrypt(lCode, lPassword);
                for (x = 1; x <= Strings.Len(leCode); x++) {
                    if (Strings.Asc(Strings.Mid(leCode, x, 1)) < 33) {
                        leCode = Strings.Left(leCode, x - 1) + Strings.Chr(33) + Strings.Mid(leCode, x + 1);
                    }
                }
                if (Strings.Split(adoPrimaryRS.Fields("POS_Code").Value, Strings.Chr(255))[0] != leCode) {
                    lblLic[1].Visible = true;
                    lblLic[0].Visible = true;
                }
                //new serialization check
            } else {
                k_posNew = true;
                adoPrimaryRS = modRecordSet.getRS(ref "select * from POS");
                adoPrimaryRS.AddNew();
                this.Text = this.Text + " [New record]";
                mbAddNewFlag = true;
            }

            setup();

            foreach (TextBox oText_loopVariable in txtFields) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.MaxLength = adoPrimaryRS.Fields(oText.DataBindings).DefinedSize;
            }
            if (k_posNew == true)
                _txtFields_10.Text = basCryptoProcs.strCDKey;
            foreach (TextBox oText_loopVariable in txtInteger) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.Leave += txtInteger_Leave;
                //txtInteger_Leave(txtInteger.Item((oText.Index)), New System.EventArgs())
            }
            foreach (TextBox oText_loopVariable in txtFloat) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                if (string.IsNullOrEmpty(oText.Text))
                    oText.Text = "0";
                oText.Text = Convert.ToString(Convert.ToDouble(oText.Text) * 100);
                oText.Leave += txtFloat_Leave;
                //txtFloat_Leave(txtFloat.Item((oText.Index)), New System.EventArgs())
            }

            bolLoad = true;
            if (id) {
                if (adoPrimaryRS.Fields("POS_KitchenMonitor").Value == true) {
                    this.chkKitchenMonitors.CheckState = System.Windows.Forms.CheckState.Checked;
                    this.chkKitchenMonitors.Tag = 1;
                } else {
                    this.chkKitchenMonitors.CheckState = System.Windows.Forms.CheckState.Unchecked;
                    this.chkKitchenMonitors.Tag = 0;
                }
            }
            bolLoad = false;

            //Bind the check boxes to the data provider
            foreach (CheckBox oCheck_loopVariable in chkFields) {
                oCheck = oCheck_loopVariable;
                oCheck.DataBindings.Add(adoPrimaryRS);
            }
            buildDataControls();

             // ERROR: Not supported in C#: OnErrorStatement

            if (id) {
            } else {
                cmbKeyboard.BoundText = Convert.ToString(2);
                cmbWH.BoundText = Convert.ToString(2);
            }
            mbDataChanged = false;

            loadLanguage();
            ShowDialog();
        }
Beispiel #37
0
        public void loadItem(ref int id)
        {
            ADODB.Recordset rsP = default(ADODB.Recordset);
            System.Windows.Forms.TextBox oText = null;
            System.Windows.Forms.CheckBox oCheck = null;
             // ERROR: Not supported in C#: OnErrorStatement

            InOper = id;
            inController = false;

            if (id) {
                adoPrimaryRS = modRecordSet.getRS(ref "select PersonID,Person_Title,Person_FirstName,Person_LastName,Person_Position,Person_Cell,Person_Telephone,Person_UserID,Person_Password,Person_QuickAccess,Person_IDNo,Person_Disabled,Person_Drawer from Person WHERE PersonID = " + id);
                rsP = modRecordSet.getRS(ref "SELECT * FROM Person WHERE PersonID = " + id);
                txtComm.Text = Strings.FormatNumber(rsP.Fields("Person_Comm").Value, 2);
                //for duplication access id
                _txtFields_12.Text = rsP.Fields("Person_QuickAccess").Value;

                rsP = modRecordSet.getRS(ref "SELECT Controller_Permission FROM ControllerPermission WHERE Controller_PersonID = " + id);
                if (rsP.RecordCount == 0) {
                    inController = true;
                    modRecordSet.cnnDB.Execute("INSERT INTO ControllerPermission (Controller_PersonID,Controller_Permission) VALUES (" + id + ",0)");
                    this.chkController.CheckState = System.Windows.Forms.CheckState.Unchecked;
                    this.chkController.Tag = 0;
                } else {
                    if (rsP.Fields("Controller_Permission").Value == true) {
                        this.chkController.CheckState = System.Windows.Forms.CheckState.Checked;
                        this.chkController.Tag = 1;
                    } else {
                        this.chkController.CheckState = System.Windows.Forms.CheckState.Unchecked;
                        this.chkController.Tag = 0;
                    }
                }
                _lbl_1.Text = "Employee No. " + id;
            } else {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from Person");
                adoPrimaryRS.AddNew();
                this.Text = this.Text + " [New record]";
                mbAddNewFlag = true;
                _lbl_1.Text = "Employee No. " + " [New record]";
            }

            setup();

            foreach (TextBox oText_loopVariable in this.txtFields) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.MaxLength = adoPrimaryRS.Fields(oText.DataBindings).DefinedSize;
            }

            perIden = id;

             // ERROR: Not supported in C#: OnErrorStatement

            if (id) {
                cmbDraw.SelectedIndex = adoPrimaryRS.Fields("Person_Drawer").Value;
            } else {
                cmbDraw.SelectedIndex = 0;
            }

            foreach (CheckBox oCheck_loopVariable in this.chkFields) {
                oCheck = oCheck_loopVariable;
                oCheck.DataBindings.Add(adoPrimaryRS);
            }

            buildDataControls();
            mbDataChanged = false;

            loadLanguage();
            ShowDialog();
        }
        public void loadItem(ref int id)
        {
            System.Windows.Forms.TextBox oText = null;
            DateTimePicker oDate = new DateTimePicker();

            System.Windows.Forms.CheckBox oCheck = null;
            // ERROR: Not supported in C#: OnErrorStatement


            ADODB.Recordset rs = default(ADODB.Recordset);
            rs = modRecordSet.getRS(ref "SELECT * FROM Channel");
            while (!(rs.EOF))
            {
                chkFields[rs.Fields("ChannelID").Value].Text = rs.Fields("ChannelID").Value + ". " + rs.Fields("Channel_Code").Value;
                rs.moveNext();
            }
            rs.Close();


            if (id)
            {
                adoPrimaryRS = modRecordSet.getRS(ref "select Increment.* from Increment WHERE IncrementID = " + id);
            }
            else
            {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from Increment");
                adoPrimaryRS.AddNew();
                this.Text    = this.Text + " [New record]";
                mbAddNewFlag = true;
            }
            setup();
            foreach (TextBox oText_loopVariable in this.txtFields)
            {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.MaxLength = adoPrimaryRS.Fields(oText.DataBindings).DefinedSize;
            }

            foreach (TextBox oText_loopVariable in this.txtInteger)
            {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.Leave += txtInteger_Leave;
                //txtInteger_Leave(txtInteger.Item((oText.TabIndex)), New System.EventArgs())
            }
            //    For Each oText In Me.txtInteger
            //        Set oText.DataBindings.Add(adoPrimaryRS)
            //        txtInteger_LostFocus oText.Index
            //    Next
            //    For Each oText In Me.txtFloat
            //        Set oText.DataBindings.Add(adoPrimaryRS)
            //        If oText.Text = "" Then oText.Text = "0"
            //        oText.Text = oText.Text * 100
            //        txtFloat_LostFocus oText.Index
            //    Next
            //    For Each oText In Me.txtFloatNegative
            //        Set oText.DataBindings.Add(adoPrimaryRS)
            //        If oText.Text = "" Then oText.Text = "0"
            //        oText.Text = oText.Text * 100
            //        txtFloatNegative_LostFocus oText.Index
            //    Next
            //Bind the check boxes to the data provider
            foreach (CheckBox oCheck_loopVariable in chkFields)
            {
                oCheck = oCheck_loopVariable;
                oCheck.DataBindings.Add(adoPrimaryRS);
            }
            buildDataControls();
            mbDataChanged = false;
            gID           = id;
            if (gID)
            {
                loadItems();
            }

            loadLanguage();
            ShowDialog();
        }
        public void loadItem(ref int id, ref short section)
        {
            System.Windows.Forms.TextBox oText = null;
            System.Windows.Forms.CheckBox oCheck = null;
             // ERROR: Not supported in C#: OnErrorStatement

            this.lblSettl.Visible = true;
            this.txtSettlement.Visible = true;

            if (id) {
                adoPrimaryRS = modRecordSet.getRS(ref "select SupplierID,Supplier_Name,Supplier_PostalAddress,Supplier_PhysicalAddress,Supplier_Telephone,Supplier_Facimile,Supplier_RepresentativeName,Supplier_RepresentativeNumber,Supplier_ShippingCode,Supplier_OrderAttentionLine,Supplier_Ullage,Supplier_discountCOD,Supplier_discount15days,Supplier_discount30days,Supplier_discount60days,Supplier_discount90days,Supplier_discount120days,Supplier_discountSmartCard,Supplier_discountDefault,Supplier_Current,Supplier_30Days,Supplier_60Days,Supplier_90Days,Supplier_120Days from Supplier WHERE SupplierID = " + id);
            } else {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from Supplier");
                adoPrimaryRS.AddNew();
                this.Text = this.Text + " [New record]";
                mbAddNewFlag = true;
            }
            gSection = section;
            switch (gSection) {
                case sec_Payment:
                    this.Text = "Account Payment";
                    break;
                case sec_Debit:
                    this.lblSettl.Visible = false;
                    this.txtSettlement.Visible = false;
                    this._lblLabels_11.Text = "Debit Journal";
                    this.Text = "Debit Journal-Increase amount owing";
                    break;
                case sec_Credit:
                    this.lblSettl.Visible = false;
                    this.txtSettlement.Visible = false;
                    this._lblLabels_11.Text = "Credit Journal";
                    this.Text = "Credit Journal-Decrease amount owing";
                    break;
                default:
                    this.Close();
                    return;

                    break;
            }
            _lbl_2.Text = "&2. Transaction (" + this.Text + ")";
            this.cmbPeriod.SelectedIndex = 0;
            //    If adoPrimaryRS.BOF Or adoPrimaryRS.EOF Then
            //    Else
            foreach (TextBox oText_loopVariable in this.txtFields) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.MaxLength = adoPrimaryRS.Fields(oText.DataBindings).DefinedSize;
            }
            //        For Each oText In Me.txtInteger
            //            Set oText.DataBindings.Add(adoPrimaryRS)
            //            txtInteger_LostFocus oText.Index
            //        Next
            foreach (TextBox oText_loopVariable in this.txtFloat) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                if (string.IsNullOrEmpty(oText.Text))
                    oText.Text = "0";
                oText.Text = Convert.ToString(Convert.ToDouble(oText.Text) * 100);
                oText.Leave += txtFloat_Leave;
            }
            //        For Each oText In Me.txtFloatNegative
            //            Set oText.DataBindings.Add(adoPrimaryRS)
            //            If oText.Text = "" Then oText.Text = "0"
            //            oText.Text = oText.Text * 100
            //            txtFloatNegative_LostFocus oText.Index
            //        Next
            //Bind the check boxes to the data provider
            //        For Each oCheck In Me.chkFields
            //            Set oCheck.DataBindings.Add(adoPrimaryRS)
            //        Next
            buildDataControls();
            mbDataChanged = false;

            loadLanguage();
            ShowDialog();
            //    End If
        }
Beispiel #40
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox2.Text == "")
            {
                MessageBox.Show("PAY Type can't be empty");
                comboBox2.Select();
                comboBox2.Focus();
                return;
            }
            if (comboBox2.Text == "CHEQUE")
            {
                if (textBox5.Text == "")
                {
                    MessageBox.Show("Enter Cheque Details");
                    textBox5.Select();
                    textBox5.Focus();
                    return;
                }
            }
            for (int i = 0; i < dataGridView1.RowCount - 1; i++)
            {
                for (int j = 0; j <= 2; j++)
                {
                    if (dataGridView1.Rows[i].Cells[j] == null || dataGridView1.Rows[i].Cells[j].Value == "")
                    {
                        MessageBox.Show("Field can't be empty");
                        dataGridView1.CurrentCell = dataGridView1.Rows[i].Cells[j];
                        return;
                    }
                }
            }

            Temp1.Open(@"select * from farmerpayment", Program.DB, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic);
            for (int i = 0; i < dataGridView1.RowCount - 1; i++)
            {
                Temp1.AddNew();
                Temp1.Fields["fpayId"].Value = Int64.Parse(textBox1.Text);
                if (comboBox2.Text == "CASH")
                {
                    Temp1.Fields["fpaytype"].Value = "CASH";
                }
                else if (comboBox2.Text == "CHEQUE")
                {
                    Temp1.Fields["fpaytype"].Value = "CHEQUE : " + textBox5.Text;
                }

                Temp2.Open(@"select * from farmerdetails WHERE fNames='" + dataGridView1.Rows[i].Cells[0].EditedFormattedValue + "'", Program.DB, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic);
                Temp1.Fields["fID"].Value = Temp2.Fields["fID"].Value;
                Temp2.Close();

                Temp1.Fields["pattiId"].Value = Int64.Parse(dataGridView1.Rows[i].Cells[1].EditedFormattedValue.ToString());
                Temp1.Fields["Amount"].Value  = decimal.Parse(dataGridView1.Rows[i].Cells[2].EditedFormattedValue.ToString());

                Temp2.Open(@"select * from pattirefer WHERE pattiID = " + Int64.Parse(dataGridView1.Rows[i].Cells[1].EditedFormattedValue.ToString()) + "", Program.DB, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic);
                Temp2.Fields["payable"].Value = Temp2.Fields["payable"].Value - decimal.Parse(dataGridView1.Rows[i].Cells[2].EditedFormattedValue.ToString());
                Temp2.Update();
                Temp2.Close();

                Temp1.Fields["PayDay"].Value = dateTimePicker1.Value.ToShortDateString();

                Temp1.Fields["TotalAmount"].Value = decimal.Parse(textBox2.Text);

                Temp1.Update();
            }
            Temp1.Close();
            MessageBox.Show("SAVED");
            textBox1.Text           = (Int64.Parse(textBox1.Text) + 1).ToString();
            comboBox2.SelectedIndex = -1;
            label7.Visible          = false;
            textBox5.Visible        = false;
            textBox2.Text           = "";
            dataGridView1.Rows.Clear();
        }
Beispiel #41
0
        public void loadItem(ref int id)
        {
            ADODB.Recordset rs = default(ADODB.Recordset);
            int lID = 0;
            System.Windows.Forms.TextBox oText = null;
            System.Windows.Forms.CheckBox oCheck = null;
             // ERROR: Not supported in C#: OnErrorStatement

            if (id) {
                adoPrimaryRS = modRecordSet.getRS(ref "SELECT PriceSet.PriceSetID, PriceSet.PriceSet_Name, PriceSet.PriceSet_StockItemID, PriceSet.PriceSet_Disabled From PriceSet WHERE (((PriceSet.PriceSetID)=" + id + "));");
            } else {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from [PriceSet]");
                adoPrimaryRS.AddNew();
                this.Text = this.Text + "[New Record]";
                mbAddNewFlag = true;
            }
            setup();

            foreach (TextBox oText_loopVariable in txtFields) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.MaxLength = adoPrimaryRS.Fields(oText.DataBindings).DefinedSize;
            }

            //Bind the check boxes to the data provider
            foreach (CheckBox oCheck_loopVariable in chkFields) {
                oCheck = oCheck_loopVariable;
                lID = adoPrimaryRS.Fields("PriceSet_StockItemID").Value;
                if (lID != 0) {
                    rs = modRecordSet.getRS(ref "SELECT StockItem.StockItem_Name FROM StockItem WHERE (StockItemID = " + lID + ")");
                    if (rs.BOF | rs.EOF) {
                        this.lblStockItem.Text = "No Stock Item Selected ...";
                        this.lblStockItem.Tag = 0;
                    } else {
                        this.lblStockItem.Text = rs("StockItem_Name");
                        this.lblStockItem.Tag = lID;
                    }

                }
                oCheck.DataBindings.Add(adoPrimaryRS);
            }
            if (_chkFields_0.CheckState == 2)
                _chkFields_0.CheckState = System.Windows.Forms.CheckState.Unchecked;
            buildDataControls();
            mbDataChanged = false;
            setup();

            loadLanguage();
            ShowDialog();
        }
        private void printTransactionA4(ref transaction lTransaction)
        {
            string typeQuote = null;
            string typeAccountPayment = null;
            string typeConsignment = null;
            string typeConsignmentReturn = null;
            string typeAccountSaleCOD = null;
            string typeAccountSale = null;
            int lRetVal = 0;
            int hkey = 0;
            string vValue = null;
            decimal lnVat = default(decimal);
            string gPath = null;
            ADODB.Recordset rs = default(ADODB.Recordset);
            customer customer_Renamed = null;
            string sql = null;
            ADODB.Recordset rsNew = new ADODB.Recordset();
            //Dim rsNew2                  As New Recordset

            lineItem lineitem_Renamed = null;
            string lString = null;
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            short lPaymentType = 0;
            string[] lArray = null;
            decimal TCurrency = default(decimal);

            decimal QuoteTotal = default(decimal);

             // ERROR: Not supported in C#: OnErrorStatement

            //Set which invoice is required
            string sPrintGST = null;
            sPrintGST = "";
            QuoteTotal = 0;
            //lRetVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\4POS\pos", 0, KEY_QUERY_VALUE, hkey)
            //lRetVal = QueryValueEx(hkey, "printGST", sPrintGST)
            //RegCloseKey (hkey)
            //If sPrintGST = "" Then sPrintGST = "0"

            // If gParameters.A4Exclusive = True Then
            //     Set Report = New cryReceipt1
            // ElseIf sPrintGST = "1" Then
            //     Set Report = New cryReceipt1
            // Else
            Report.Load("cryReceipt.rpt");
            // End If

            //lPaymentType = getPaymentType(lTransaction)

            //If lPaymentType And typeAccountPayment Then
            //    printTransactionPaymentA4 lTransaction
            //    Exit Sub
            //End If
            //Dim lnVat               As Currency
            gPath = "C:\\4POS\\pos\\";
            int lVatAmount = 0;
            int lAmount = 0;

            rsNew.Open(gPath + "data\\item.rs", , ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic);
            //, adOpenStatic, adLockOptimistic
            lnVat = 0;
            //a = rsNew.RecordCount
            //rsNew.Close

            //rsNew2.source = rsNew.source

            //rsNew("transactionItem_quantity").Type = rsNew("transactionItem_price").Type
            //rsNew("transactionItem_quantity").DefinedSize = rsNew("transactionItem_price").DefinedSize
            //rsNew2("transactionItem_quantity").Attributes = rsNew("transactionItem_price").Attributes
            //rsNew2("transactionItem_quantity").NumericScale = rsNew("transactionItem_price").NumericScale
            //rsNew2("transactionItem_quantity").Precision = rsNew("transactionItem_price").Precision

            foreach (lineItem lineitem_Renamed_loopVariable in lTransaction.lineItems) {
                lineitem_Renamed = lineitem_Renamed_loopVariable;
                rsNew.AddNew();
                if (lineitem_Renamed.revoke) {
                } else {
                    rsNew.Fields("transactionItem_build").Value = lineitem_Renamed.build;
                    rsNew.Fields("transactionItem_code").Value = lineitem_Renamed.code;
                    rsNew.Fields("transactionItem_depositType").Value = lineitem_Renamed.depositType;
                    rsNew.Fields("transactionItem_id").Value = lineitem_Renamed.id;
                    rsNew.Fields("transactionItem_lineNo").Value = lineitem_Renamed.lineNo;
                    rsNew.Fields("transactionItem_name").Value = lineitem_Renamed.name;
                    rsNew.Fields("transactionItem_originalPrice").Value = lineitem_Renamed.originalPrice;
                    rsNew.Fields("transactionItem_price").Value = lineitem_Renamed.price;
                    rsNew.Fields("transactionItem_quantity").Value = lineitem_Renamed.quantity;
                    rsNew.Fields("transactionItem_receiptName").Value = Strings.LTrim(Strings.Mid(lineitem_Renamed.receiptName, Strings.InStr(1, lineitem_Renamed.receiptName, "x") + 1, Strings.Len(lineitem_Renamed.receiptName)));
                    //lineitem.receiptName
                    rsNew.Fields("transactionItem_reversal").Value = lineitem_Renamed.reversal;
                    rsNew.Fields("transactionItem_revoke").Value = lineitem_Renamed.revoke;
                    rsNew.Fields("transactionItem_set").Value = lineitem_Renamed.setBuild;
                    rsNew.Fields("transactionItem_shrink").Value = lineitem_Renamed.shrink;
                    rsNew.Fields("transactionItem_type").Value = lineitem_Renamed.transactionType;
                    rsNew.Fields("transactionItem_vat").Value = lineitem_Renamed.vat;

                    if (lineitem_Renamed.vat > 0)
                        lnVat = lnVat + ((lineitem_Renamed.quantity * lineitem_Renamed.price) - ((lineitem_Renamed.quantity * lineitem_Renamed.price) / (1 + (lineitem_Renamed.vat / 100))));
                    QuoteTotal = QuoteTotal + (lineitem_Renamed.quantity * lineitem_Renamed.price);
                    //If gParameters.A4Exclusive = True Then TCurrency = TCurrency + ((lineitem.quantity * lineitem.price) / (1 + (lineitem.vat) / 100))
                    //TCurrency = 0 'TCurrency + ((lineitem.quantity * lineitem.price) / (1 + (lineitem.vat) / 100))
                    rsNew.update();
                }
            }

            //rsNew.MoveFirst
            //vValue = rsNew("transactionItem_quantity")
            vValue = "";
            lRetVal = modUtilities.RegOpenKeyEx(modUtilities.HKEY_LOCAL_MACHINE, "Software\\4POS\\pos", 0, modUtilities.KEY_QUERY_VALUE, ref hkey);
            lRetVal = modUtilities.QueryValueEx(hkey, "A4Items", ref vValue);
            modUtilities.RegCloseKey(hkey);
            if (string.IsNullOrEmpty(vValue))
                vValue = "0";
            if (vValue == "1") {
                rsNew.Sort = "transactionItem_receiptName";
            } else if (vValue == "0") {
            }

            Report.Database.Tables(1).SetDataSource(rsNew);
            //Report.Database.Tables(2).SetDataSource rsNew, 3
            Report.SetParameterValue("txtCompanyName", lTransaction.companyName);
            Report.SetParameterValue("txtCompanyDetails1", lTransaction.heading1);

            if (!string.IsNullOrEmpty(lTransaction.heading2)) {
                Report.SetParameterValue("txtCompanyDetails2", lTransaction.heading2);
                if (!string.IsNullOrEmpty(lTransaction.heading3)) {
                    Report.SetParameterValue("txtCompanyDetails3", lTransaction.heading3);

                    //If gParameters.tr_PrintInvoice = False Then
                    if (!string.IsNullOrEmpty(lTransaction.taxNumber)) {
                        Report.SetParameterValue("txtCompanyDetails4", "TAX NO :" + lTransaction.taxNumber);
                    }
                    //End If
                } else {
                    //If gParameters.tr_PrintInvoice = False Then
                    if (!string.IsNullOrEmpty(lTransaction.taxNumber)) {
                        Report.SetParameterValue("txtCompanyDetails3", "TAX NO :" + lTransaction.taxNumber);
                    }
                    //End If
                }
            } else {
                if (!string.IsNullOrEmpty(lTransaction.heading3)) {
                    Report.SetParameterValue("txtCompanyDetails2", lTransaction.heading3);
                    //If gParameters.tr_PrintInvoice = False Then
                    if (!string.IsNullOrEmpty(lTransaction.taxNumber)) {
                        Report.SetParameterValue("txtCompanyDetails3", "TAX NO :" + lTransaction.taxNumber);
                    }
                    //End If

                } else {
                    //If gParameters.tr_PrintInvoice = False Then
                    if (!string.IsNullOrEmpty(lTransaction.taxNumber)) {
                        Report.SetParameterValue("txtCompanyDetails2", "TAX NO :" + lTransaction.taxNumber);
                    }
                    //End If
                }
            }

            lString = lString + lTransaction.heading1 + Strings.Chr(13);
            lString = lString + lTransaction.heading2 + Strings.Chr(13);
            lString = lString + lTransaction.heading3 + Strings.Chr(13);
            if (!string.IsNullOrEmpty(lTransaction.taxNumber))
                lString = lString + "TAX NO :" + lTransaction.taxNumber;
            lString = Strings.Replace(lString, Strings.Chr(13) + Strings.Chr(13), Strings.Chr(13));
            lString = Strings.Replace(lString, Strings.Chr(13) + Strings.Chr(13), Strings.Chr(13));

            Report.SetParameterValue("txtInvoiceNumber", lTransaction.transactionID);
            Report.SetParameterValue("txtInvoiceDate", Strings.Format(lTransaction.transactionDate, "dd mmm yyyy hh:mm"));
            Report.SetParameterValue("txtPOS", lTransaction.posName);
            Report.SetParameterValue("txtCashier", lTransaction.cashierName);
            if (Strings.LCase(lTransaction.transactionType) == "deposit credit") {
                Report.SetParameterValue("txtType", "DEPOSIT CREDIT");
                Report.SetParameterValue("txtTypeSpecial", "");
                Report.SetParameterValue("txtInvoiceNumber", "[" + lTransaction.transactionID + "]");
            } else {
                if (lTransaction.transactionSpecial_Renamed == null) {
                    if (lTransaction.customer_Renamed == null) {
                        Report.SetParameterValue("txtCustomer", "Cash Sale");
                        switch (lTransaction.paymentType) {
                            case Convert.ToString(1):
                                Report.SetParameterValue("txtCustomer", "Cash Sale");
                                break;
                            case Convert.ToString(2):
                                Report.SetParameterValue("txtCustomer", "Credit Card Sale");
                                break;
                            case Convert.ToString(3):
                                Report.SetParameterValue("txtCustomer", "Debit Card Sale");
                                break;
                            case Convert.ToString(4):
                                Report.SetParameterValue("txtCustomer", "Cheque Sale");
                                break;
                            case Convert.ToString(7):
                                Report.SetParameterValue("txtCustomer", "Split Tender");
                                break;
                            default:
                                Report.SetParameterValue("txtCustomer", "Cash Sale");
                                break;
                        }
                        Report.SetParameterValue("txtType", "TAX INVOICE");
                        Report.SetParameterValue("txtTypeSpecial", "");
                    } else {
                        Report.SetParameterValue("txtSigned", lTransaction.customer_Renamed.signed_Renamed);
                        Report.SetParameterValue("txtCustomer", lTransaction.customer_Renamed.name);
                        if (!string.IsNullOrEmpty(lTransaction.customer_Renamed.physical)) {
                            lArray = Strings.Split(lTransaction.customer_Renamed.physical, Constants.vbCrLf);
                            Report.SetParameterValue("txtCustAddress1", lArray[0]);
                            if (Information.UBound(lArray) >= 1)
                                Report.SetParameterValue("txtCustAddress2", lArray[1]);
                            if (Information.UBound(lArray) >= 2)
                                Report.SetParameterValue("txtCustAddress3", lArray[2]);
                            if (Information.UBound(lArray) >= 3)
                                Report.SetParameterValue("txtCustAddress4", lArray[3]);

                        }
                        if (!string.IsNullOrEmpty(lTransaction.customer_Renamed.tax))
                            Report.SetParameterValue("txtCustAddress5", "TAX NO: " + lTransaction.customer_Renamed.tax);
                        //Report.txtCustomerAddress.SetText lTransaction.customer.name & Chr(13) & Chr(13) & Replace(lTransaction.customer.physical, Chr(10), "") & Chr(13) & Chr(13) & "TAX NO: " & lTransaction.customer.tax
                        Report.SetParameterValue("txtType", "TAX INVOICE");
                        if (lTransaction.customer_Renamed.terms) {
                            Report.SetParameterValue("txtTypeSpecial", "Account Sale");
                        } else {
                            Report.SetParameterValue("txtTypeSpecial", "Cash Sale");
                        }
                    }
                } else {
                    Report.SetParameterValue("txtType", "");
                    Report.SetParameterValue("txtTypeSpecial", "");
                    if (lPaymentType & typeQuote) {
                        Report.SetParameterValue("txtType", "QUOTE");
                        if (lPaymentType & typeConsignment) {
                            if (lPaymentType & typeAccountSale | lPaymentType & typeAccountSaleCOD) {
                                Report.SetParameterValue("txtTypeSpecial", "Account Consignment");
                            } else {
                                Report.SetParameterValue("txtTypeSpecial", "Consignment");
                            }
                        } else if (lPaymentType & typeConsignmentReturn) {
                            if (lPaymentType & typeAccountSale | lPaymentType & typeAccountSaleCOD) {
                                Report.SetParameterValue("txtTypeSpecial", "Account Consignment Return Quote");
                            } else {
                                Report.SetParameterValue("txtTypeSpecial", "Consignment Return");
                            }
                        } else {
                            if (lPaymentType & typeAccountSale | lPaymentType & typeAccountSaleCOD) {
                                Report.SetParameterValue("txtTypeSpecial", "Account");
                            } else {
                                Report.SetParameterValue("txtTypeSpecial", "");
                            }
                        }
                    } else if (lPaymentType & typeConsignment) {
                        if (lPaymentType & typeAccountSale | lPaymentType & typeAccountSaleCOD) {
                            Report.SetParameterValue("txtType", "Account Consignment Sale");
                        } else {
                            Report.SetParameterValue("txtType", "Consignment Sale");
                        }
                    } else if (lPaymentType & typeConsignmentReturn) {
                        if (lPaymentType & typeAccountSale | lPaymentType & typeAccountSaleCOD) {
                            Report.SetParameterValue("txtType", "Account Consignment Return");
                        } else {
                            Report.SetParameterValue("txtType", "Consignment Return");
                        }
                    } else if (lPaymentType & typeAccountSale) {
                        Report.SetParameterValue("txtType", "Account Sale");
                    } else if (lPaymentType & typeAccountPayment) {
                        Report.SetParameterValue("txtType", "Account Payment");
                    }

                    if (lTransaction.customer_Renamed == null) {
                        if (!string.IsNullOrEmpty(lTransaction.transactionSpecial_Renamed.address)) {
                            lArray = Strings.Split(lTransaction.transactionSpecial_Renamed.address, Constants.vbCrLf);
                            Report.SetParameterValue("txtCustAddress1", lArray[0]);
                            if (Information.UBound(lArray) >= 1)
                                Report.SetParameterValue("txtCustAddress2", lArray[1]);
                            if (Information.UBound(lArray) >= 2)
                                Report.SetParameterValue("txtCustAddress3", lArray[2]);
                            if (Information.UBound(lArray) >= 3)
                                Report.SetParameterValue("txtCustAddress4", lArray[3]);

                        }
                        Report.SetParameterValue("txtSigned", lTransaction.transactionSpecial_Renamed.name);
                        Report.SetParameterValue("txtCustomer", lTransaction.transactionSpecial_Renamed.name);
                    } else {
                        if (!string.IsNullOrEmpty(lTransaction.customer_Renamed.tax))
                            lTransaction.customer_Renamed.physical = lTransaction.customer_Renamed.physical;
                        if (!string.IsNullOrEmpty(lTransaction.customer_Renamed.physical)) {
                            lArray = Strings.Split(lTransaction.customer_Renamed.physical, Constants.vbCrLf);
                            Report.SetParameterValue("txtCustAddress1", lArray[0]);
                            if (Information.UBound(lArray) >= 1)
                                Report.SetParameterValue("txtCustAddress2", lArray[1]);
                            if (Information.UBound(lArray) >= 2)
                                Report.SetParameterValue("txtCustAddress3", lArray[2]);
                            if (Information.UBound(lArray) >= 3)
                                Report.SetParameterValue("txtCustAddress4", lArray[3]);
                        }
                        Report.SetParameterValue("txtSigned.", lTransaction.customer_Renamed.signed_Renamed);
                        Report.SetParameterValue("txtCustomer", lTransaction.customer_Renamed.name);
                    }
                }
            }
            //do report reference.....
            if (!string.IsNullOrEmpty(lTransaction.CardRefer)) {
                Report.SetParameterValue("txtCard", "Card Reference : " + lTransaction.CardRefer);
                //ElseIf gParameters.CardRefer = True Then
                //    Report.txtCard.SetText "Card Reference : " & stCard
            }

            if (!string.IsNullOrEmpty(lTransaction.OrderRefer)) {
                Report.SetParameterValue("txtOrder", "Order Reference : " + lTransaction.OrderRefer);
                //ElseIf gParameters.OrderRefer = True Then
                //    Report.txtOrder.SetText "Order Reference : " & stOrder
            }

            if (!string.IsNullOrEmpty(lTransaction.SerialRefer)) {
                Report.SetParameterValue("txtSerial", "Serial Reference : " + lTransaction.SerialRefer);
                //ElseIf gParameters.SerialRefer = True Then
                //    Report.txtSerial.SetText "Serial Reference : " & stSerial
            }

            Report.SetParameterValue("txtDiscount", Strings.FormatNumber(lTransaction.paymentDiscount, 2));
            //If gParameters.A4Exclusive = True Then
            //   Report.txtAText.SetText FormatNumber(TCurrency - lTransaction.paymentDiscount, 2)
            //End If

            //If frmMain.lblChange.Caption = "" Then frmMain.lblChange.Caption = "0.00"

            if (lPaymentType & typeQuote) {
                Report.SetParameterValue("txtTender", Strings.FormatNumber("0.00", 2));
            } else {
                Report.SetParameterValue("txtTender", Strings.FormatNumber(lTransaction.paymentTender, 2));
                //  lTransaction.paymentTender, 2)
            }
            Report.SetParameterValue("txtVAT", Strings.FormatNumber(lnVat, 2));
            Report.SetParameterValue("txtChange", Strings.FormatNumber("0.00", 2));

            //Report.txtTotal.SetText FormatNumber(lTransaction.paymentTotal, 2)
            if (lPaymentType & typeQuote) {
                //FIXED: it was calculating twice    Report.txtTotal.SetText FormatNumber((QuoteTotal - lTransaction.paymentDiscount), 2)
                Report.SetParameterValue("txtTotal", Strings.FormatNumber(QuoteTotal, 2));
                //a = QuoteTotal
            } else {
                Report.SetParameterValue("txtTotal", Strings.FormatNumber(lTransaction.paymentTotal, 2));
            }

            if (lPaymentType & typeQuote | lPaymentType & typeConsignment | lPaymentType & typeConsignmentReturn | lPaymentType & typeAccountSale) {
                Report.ReportDefinition.Sections("Section7").SectionFormat.EnableSuppress = true;
            }

            //New banking details
            ADODB.Recordset rsCompBank = default(ADODB.Recordset);
            rsCompBank = modRecordSet.getRS(ref "select * from Company;");
            if (rsCompBank.RecordCount) {
                if (Information.IsDBNull(rsCompBank.Fields("Company_BankName").Value)) {
                } else {
                    Report.SetParameterValue("txtBankName", rsCompBank.Fields("Company_BankName"));
                }
                if (Information.IsDBNull(rsCompBank.Fields("Company_BranchName").Value)) {
                } else {
                    Report.SetParameterValue("txtBranchName", rsCompBank.Fields("Company_BranchName"));
                }
                if (Information.IsDBNull(rsCompBank.Fields("Company_BranchCode").Value)) {
                } else {
                    Report.SetParameterValue("txtBranchCode", rsCompBank.Fields("Company_BranchCode"));
                }
                if (Information.IsDBNull(rsCompBank.Fields("Company_AccountNumber").Value)) {
                } else {
                    Report.SetParameterValue("txtAccountNumber", rsCompBank.Fields("Company_AccountNumber"));
                }
            }
            //...................

            //Report.selectPrinter "", Printer.DeviceName, ""
            //'Report.VerifyOnEveryPrint = True
            //Report.PrintOut False
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
            My.MyProject.Forms.frmReportShow.CRViewer1.ReportSource = Report;
            My.MyProject.Forms.frmReportShow.mReport = Report;
            My.MyProject.Forms.frmReportShow.sMode = "0";
            My.MyProject.Forms.frmReportShow.CRViewer1.Refresh();
            My.MyProject.Forms.frmReportShow.ShowDialog();

            return;
            ptA4:
            Interaction.MsgBox(Err().Number + Err().Description);
             // ERROR: Not supported in C#: ResumeStatement
        }
Beispiel #43
0
        public void loadItem(ref int id)
        {
            System.Windows.Forms.TextBox oText = null;
            System.Windows.Forms.CheckBox oCheck = null;
             // ERROR: Not supported in C#: OnErrorStatement

            gID = 0;

            bool cBitA = false;
            bool cBitF = false;
            if (id) {
                //checkcustid = id
                adoPrimaryRS = modRecordSet.getRS(ref "select * from Customer WHERE CustomerID = " + id);
                cmbTerms.SelectedIndex = adoPrimaryRS.Fields("Customer_Terms").Value;
                mbAddNewFlag = false;
                gID = id;

                if (8 & My.MyProject.Forms.frmMenu.gBit)
                    cBitA = true;
                if (16 & My.MyProject.Forms.frmMenu.gBit)
                    cBitF = true;
                if (cBitA == true & cBitF == true) {
                    _txtFloat_13.Enabled = true;
                    _txtFloat_14.Enabled = true;
                    _txtFloat_15.Enabled = true;
                    _txtFloat_16.Enabled = true;
                    _txtFloat_17.Enabled = true;
                    _txtFloat_18.Enabled = true;
                }

            } else {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from Customer");
                adoPrimaryRS.AddNew();
                this.Text = this.Text + " [New record]";
                mbAddNewFlag = true;
                cmbTerms.SelectedIndex = 0;
                this.cmbChannel.BoundText = Convert.ToString(0);
            }
            //    If adoPrimaryRS.BOF Or adoPrimaryRS.EOF Then
            //    Else
            foreach (TextBox oText_loopVariable in txtFields) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.MaxLength = adoPrimaryRS.Fields(oText.DataBindings).DefinedSize;
            }
            //        For Each oText In Me.txtInteger
            //            Set oText.DataBindings.Add(adoPrimaryRS)
            //            txtInteger_LostFocus oText.Index
            //        Next
            foreach (TextBox oText_loopVariable in txtFloat) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                if (string.IsNullOrEmpty(oText.Text))
                    oText.Text = "0";
                oText.Text = Convert.ToString(Convert.ToDouble(oText.Text) * 100);
                oText.Leave += txtFloat_Leave;
                //txtFloat_Leave(txtFloat.Item((oText.Index)), New System.EventArgs())
            }
            //Bind the check boxes to the data provider
            foreach (CheckBox oCheck_loopVariable in chkFields) {
                oCheck = oCheck_loopVariable;
                oCheck.DataBindings.Add(adoPrimaryRS);
            }
            cmbTerms.DataSource = adoPrimaryRS;
            buildDataControls();
            mbDataChanged = false;
            if (mbAddNewFlag == true) {
                foreach (CheckBox oCheck_loopVariable in this.chkFields) {
                    oCheck = oCheck_loopVariable;
                    oCheck.CheckState = System.Windows.Forms.CheckState.Unchecked;
                }
                cmbChannel.BoundText = "1";
            }

            loadLanguage();
            ShowDialog();
            //    End If
        }
Beispiel #44
0
        public void loadItem(ref int id)
        {
            System.Windows.Forms.TextBox oText = null;
            System.Windows.Forms.CheckBox oCheck = null;
             // ERROR: Not supported in C#: OnErrorStatement

            if (id) {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from Channel WHERE ChannelID = " + id);
                //        If IsNull(adoPrimaryRS("Channel_PriceToChannel1")) Then
                //            cmbChannelPrice.ListIndex = 0
                //        Else
                switch (adoPrimaryRS.Fields("Channel_PriceToChannel1").Value) {
                    case -1:
                        cmbChannelPrice.SelectedIndex = 1;
                        break;
                    case 1:
                        cmbChannelPrice.SelectedIndex = 2;
                        break;
                    default:
                        cmbChannelPrice.SelectedIndex = 0;
                        break;
                }
                //        End If
            } else {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from POS");
                adoPrimaryRS.AddNew();
                this.Text = this.Text + " [New record]";
                mbAddNewFlag = true;
            }

            setup();
            foreach (TextBox oText_loopVariable in txtFields) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.MaxLength = adoPrimaryRS.Fields(oText.DataBindings).DefinedSize;
            }
            this.optType[Convert.ToInt16(_txtFields_0.Text)].Checked = true;
            if (id == 1) {
                _optType_0.Enabled = false;
                _optType_1.Enabled = false;
            }
            //    For Each oText In Me.txtInteger
            //        Set oText.DataBindings.Add(adoPrimaryRS)
            //        txtInteger_LostFocus oText.Index
            //    Next
            //    For Each oText In Me.txtFloat
            //        Set oText.DataBindings.Add(adoPrimaryRS)
            //        If oText.Text = "" Then oText.Text = "0"
            //        oText.Text = oText.Text * 100
            //        txtFloat_LostFocus oText.Index
            //    Next
            //    For Each oText In Me.txtFloatNegative
            //        Set oText.DataBindings.Add(adoPrimaryRS)
            //        If oText.Text = "" Then oText.Text = "0"
            //        oText.Text = oText.Text * 100
            //        txtFloatNegative_LostFocus oText.Index
            //    Next
            //Bind the check boxes to the data provider
            foreach (CheckBox oCheck_loopVariable in chkFields) {
                oCheck = oCheck_loopVariable;
                oCheck.DataBindings.Add(adoPrimaryRS);
            }
            buildDataControls();
            mbDataChanged = false;

            loadLanguage();
            ShowDialog();
        }
Beispiel #45
0
        private void btnsave_Click(object sender, EventArgs e)
        {
            ADODB.Recordset tmp = new ADODB.Recordset();
            try
            {
                if (ADOconn.State == 0)
                {
                    ADOconn.Open("Provider=SQLOLEDB;Initial Catalog= " + decoder.InitialCatalog + ";Data Source=" + decoder.DataSource + ";", decoder.UserID, decoder.Password, 0);
                }

                ADODB.Recordset rec = new ADODB.Recordset();

                Conn.Close();
                // Conn.Open();

                bool isempty;
                isempty = false;

                if (isedit)
                {
                    if (txtpriv.Text.Substring(1, 1) == "0")
                    {
                        MessageBox.Show("Insufficient Priveleges ", "Insufficient Priveleges ");
                        return;
                    }
                }
                else
                {
                    if (txtpriv.Text.Substring(0, 1) == "0")
                    {
                        MessageBox.Show("Insufficient Priveleges ", "Insufficient Priveleges ");
                        return;
                    }
                }



                if (isempty)
                {
                    MessageBox.Show("Entry Not Completed, Please fill all Yellow Marked fileds!!", "Invalid Entry");
                    return;
                }



                try
                {
                    //    ADOconn.BeginTrans();



                    //if (cmbmonth.SelectedIndex<0)
                    //{
                    //    MessageBox.Show("Invalid Salary Month, Please Select a Valid Month", "Invalid Entry");
                    //    return;


                    //}



                    ADOconn.BeginTrans();


                    int i = 0;

                    string entry_no = dtentry.Value.Date.ToString("yyyyMMdd");

                    if (isedit)
                    {
                        sql = "delete from reconcil_det  where Reconcil_No =  '" + entry_no + "'";
                        object a;

                        ADOconn.Execute(sql, out a);
                    }
                    sql = "select * from reconcil_det  where Reconcil_No =  '" + entry_no + "'";
                    rec = new ADODB.Recordset();
                    rec.Open(sql, ADOconn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic, -1);

                    if (rec.RecordCount == 0)
                    {
                        // rec.AddNew();
                    }
                    else
                    {
                        MessageBox.Show("Entry Already Exist , Cannot enter as a New entry", "Invalid Entry");
                        return;
                    }
                    for (i = 0; i < dgv1.Rows.Count; i++)
                    {
                        if (dgv1[0, i].Value != null)
                        {
                            rec.AddNew();
                            if (dgv1[3, i].Value == null)
                            {
                                dgv1[3, i].Value = 0;
                            }
                            if (dgv1[4, i].Value == null)
                            {
                                dgv1[4, i].Value = 0;
                            }
                            double amt = Convert.ToDouble(dgv1[3, i].Value) + Convert.ToDouble(dgv1[4, i].Value);

                            rec.Fields["Reconcil_No"].Value   = entry_no;
                            rec.Fields["Reconcil_Date"].Value = dtentry.Value.Date;

                            rec.Fields["Reconcil_user"].Value = Gvar.username;
                            rec.Fields["Amount"].Value        = Math.Abs(amt);
                            rec.Fields["Bank_No"].Value       = cmbbank.SelectedValue;

                            rec.Fields["DR_CR"].Value = dgv1[2, i].Value;

                            rec.Fields["plus_minus"].Value = "";
                            rec.Fields["pay_date"].Value   = dgv1[0, i].Value;
                            rec.Fields["SNO"].Value        = i + 1;
                            rec.Fields["trn_type"].Value   = "A";
                            rec.Fields["NARRATION"].Value  = dgv1[5, i].Value;


                            rec.Update();
                        }
                    }

                    for (i = 0; i < dgvbank.Rows.Count; i++)
                    {
                        if (dgvbank[2, i].Value != null)
                        {
                            rec.AddNew();
                            if (dgvbank[0, i].Value == null)
                            {
                                dgvbank[0, i].Value = "";
                            }
                            if (dgvbank[1, i].Value == null)
                            {
                                dgvbank[1, i].Value = 0;
                            }
                            double amt = Convert.ToDouble(dgvbank[2, i].Value);

                            rec.Fields["Reconcil_No"].Value   = entry_no;
                            rec.Fields["Reconcil_Date"].Value = dtentry.Value.Date;

                            rec.Fields["Reconcil_user"].Value = Gvar.username;
                            rec.Fields["Amount"].Value        = Math.Abs(amt);
                            rec.Fields["Bank_No"].Value       = cmbbank.SelectedValue;

                            if (dgvbank[1, i].Value == "+")
                            {
                                rec.Fields["DR_CR"].Value = "D";
                            }
                            else
                            {
                                rec.Fields["DR_CR"].Value = "C";
                            }


                            rec.Fields["plus_minus"].Value = dgvbank[1, i].Value;
                            rec.Fields["pay_date"].Value   = "";
                            rec.Fields["SNO"].Value        = i + 1;
                            rec.Fields["trn_type"].Value   = "B";
                            rec.Fields["NARRATION"].Value  = dgvbank[0, i].Value;


                            rec.Update();
                        }
                    }
                    for (i = 0; i < dgvbook.Rows.Count; i++)
                    {
                        if (dgvbook[2, i].Value != null)
                        {
                            rec.AddNew();
                            if (dgvbook[0, i].Value == null)
                            {
                                dgvbook[0, i].Value = "";
                            }
                            if (dgvbook[1, i].Value == null)
                            {
                                dgvbook[1, i].Value = 0;
                            }
                            double amt = Convert.ToDouble(dgvbook[2, i].Value);

                            rec.Fields["Reconcil_No"].Value   = entry_no;
                            rec.Fields["Reconcil_Date"].Value = dtentry.Value.Date;

                            rec.Fields["Reconcil_user"].Value = Gvar.username;
                            rec.Fields["Amount"].Value        = Math.Abs(amt);
                            rec.Fields["Bank_No"].Value       = cmbbank.SelectedValue;

                            if (dgvbook[1, i].Value == "+")
                            {
                                rec.Fields["DR_CR"].Value = "D";
                            }
                            else
                            {
                                rec.Fields["DR_CR"].Value = "C";
                            }


                            rec.Fields["plus_minus"].Value = dgvbook[1, i].Value;
                            rec.Fields["pay_date"].Value   = "";
                            rec.Fields["SNO"].Value        = i + 1;
                            rec.Fields["trn_type"].Value   = "C";
                            rec.Fields["NARRATION"].Value  = dgvbook[0, i].Value;


                            rec.Update();
                        }
                    }



                    ADOconn.CommitTrans();


                    isedit = true;
                    MessageBox.Show("Successfully Saved");
                }
                catch (Exception ex)
                {
                    ADOconn.RollbackTrans();
                    MessageBox.Show(ex.Message);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #46
0
        private void addcust_Click_1(object sender, EventArgs e)
        {
            if (addcust.Text == "&Add new Commodity")
            {
                LockUnLockMe(false);
                int newid;


                /*    if (comm_tb.RecordCount > 0)
                 *  {
                 *
                 *      if (cpos != comm_tb.RecordCount)
                 *      {
                 *          comm_tb.MoveLast();
                 *          cpos = comm_tb.RecordCount;
                 *      }
                 *      newid = comm_tb.Fields["ID"].Value + 1;
                 *
                 *
                 *  }
                 *  else
                 *  {
                 *      newid = 1;
                 *   //  textid.Text = (newid).ToString();
                 *      prev.Enabled = true;
                 *  }*/
                emptyTxt();
                // textid.Text = newid.ToString();
                addcust.Text = "&Save Details";
                fnd.Text     = "&Cancel";
                prev.Enabled = false;
                nxt.Enabled  = false;
                edt.Enabled  = false;
                return;
            }



            if (addcust.Text == "&Save Details")
            {
                if (textname.Text == "")
                {
                    XtraMessageBox.Show("Invaild Name");
                    return;
                }

                /*  if (textaddress.Text == "")
                 * {
                 *    XtraMessageBox.Show("Invaild price");
                 *    return;
                 * }*/
                if (textmobile.Text == "")
                {
                    XtraMessageBox.Show("Invaild Weight");
                    return;
                }

                if (textid.Text == "")
                {
                    XtraMessageBox.Show("Invaild ID");
                    return;
                }
                else
                {
                    temp_tb.Open(@"select * from commidities where coID=" + Int32.Parse(textid.Text) + "", Program.DB, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic);
                    if (temp_tb.RecordCount != 0)
                    {
                        XtraMessageBox.Show("Same ID already exists");
                        temp_tb.Close();
                        return;
                    }
                    temp_tb.Close();
                }

                comm_tb.AddNew();

                GetData();
                comm_tb.Update();
                SetButton();
                commidities_list.Items.Add(textname.Text);
                commidities_list.Update();
                cpos = comm_tb.RecordCount;
                LockUnLockMe(true);
            }
        }
Beispiel #47
0
        public void loadItem(ref int id)
        {
            System.Windows.Forms.TextBox oText = null;
            DateTimePicker oDate = new DateTimePicker();
            System.Windows.Forms.CheckBox oCheck = null;
             // ERROR: Not supported in C#: OnErrorStatement

            ADODB.Recordset rs = default(ADODB.Recordset);
            rs = modRecordSet.getRS(ref "SELECT * FROM Channel");
            while (!(rs.EOF)) {
                chkFields[rs.Fields("ChannelID").Value].Text = rs.Fields("ChannelID").Value + ". " + rs.Fields("Channel_Code").Value;
                rs.moveNext();
            }
            rs.Close();

            if (id) {
                adoPrimaryRS = modRecordSet.getRS(ref "select Increment.* from Increment WHERE IncrementID = " + id);
            } else {
                adoPrimaryRS = modRecordSet.getRS(ref "select * from Increment");
                adoPrimaryRS.AddNew();
                this.Text = this.Text + " [New record]";
                mbAddNewFlag = true;
            }
            setup();
            foreach (TextBox oText_loopVariable in this.txtFields) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.MaxLength = adoPrimaryRS.Fields(oText.DataBindings).DefinedSize;
            }

            foreach (TextBox oText_loopVariable in this.txtInteger) {
                oText = oText_loopVariable;
                oText.DataBindings.Add(adoPrimaryRS);
                oText.Leave += txtInteger_Leave;
                //txtInteger_Leave(txtInteger.Item((oText.TabIndex)), New System.EventArgs())
            }
            //    For Each oText In Me.txtInteger
            //        Set oText.DataBindings.Add(adoPrimaryRS)
            //        txtInteger_LostFocus oText.Index
            //    Next
            //    For Each oText In Me.txtFloat
            //        Set oText.DataBindings.Add(adoPrimaryRS)
            //        If oText.Text = "" Then oText.Text = "0"
            //        oText.Text = oText.Text * 100
            //        txtFloat_LostFocus oText.Index
            //    Next
            //    For Each oText In Me.txtFloatNegative
            //        Set oText.DataBindings.Add(adoPrimaryRS)
            //        If oText.Text = "" Then oText.Text = "0"
            //        oText.Text = oText.Text * 100
            //        txtFloatNegative_LostFocus oText.Index
            //    Next
            //Bind the check boxes to the data provider
            foreach (CheckBox oCheck_loopVariable in chkFields) {
                oCheck = oCheck_loopVariable;
                oCheck.DataBindings.Add(adoPrimaryRS);
            }
            buildDataControls();
            mbDataChanged = false;
            gID = id;
            if (gID) {
                loadItems();
            }

            loadLanguage();
            ShowDialog();
        }
        /// <param name="file"></param>
        public static void WriteData(string file)
        {
            //Objekt aus XML-File erstellenaa
            XmlSerializer serializer       = new XmlSerializer(typeof(results));
            results       resultingMessage = (results)serializer.Deserialize(new XmlTextReader(file));

            //Recordset
            ADODB.Connection cn       = new ADODB.Connection();
            ADODB.Recordset  rs       = new ADODB.Recordset();
            ADODB.Recordset  rsDelete = new ADODB.Recordset();
            string           cnStr;

            //Connection string.
            cnStr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=PPS-Datenbank.mdb";
            //Provider=Microsoft.Jet.OLEDB.4.0;Data Source=

            try
            {
                cn.Open(cnStr);
            }
            catch (Exception test)
            {
                string dbFehler = Thread.CurrentThread.CurrentUICulture.Name == "de" ? "Datenbank konnte nicht geöffnet werden!" : "Database could not be loaded";
                MessageBox.Show(dbFehler + " " + test);
            }

            //Überprüfung ob Periode drin
            try
            {
                rs.Open("Select * From warehousestock_article WHERE period = '" + resultingMessage.period + "'", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                if (!rs.EOF)
                {
                    string periodeFehler = Thread.CurrentThread.CurrentUICulture.Name == "de" ? "Diese Periode wurde bereits importiert!" : "You can not import a period twice.";
                    MessageBox.Show(periodeFehler);
                    return;
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                rs.Close();
            }

            //Tabelle warehousestock_article
            try
            {
                rs.Open("Select * From warehousestock_article", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                foreach (resultsWarehousestockArticle myElement in resultingMessage.warehousestock.article)
                {
                    rs.AddNew();
                    rs.Fields["period"].Value      = resultingMessage.period;
                    rs.Fields["id"].Value          = myElement.id;
                    rs.Fields["amount"].Value      = myElement.amount;
                    rs.Fields["startamount"].Value = myElement.startamount;
                    rs.Fields["pct"].Value         = myElement.pct;
                    rs.Fields["price"].Value       = myElement.price;
                    rs.Fields["stockvalue"].Value  = myElement.stockvalue;
                }
                rs.Update();
            }
            catch (Exception)
            {
            }
            finally
            {
                rs.Close();
            }

            //Tabelle warehousestock_totalvalue
            try
            {
                rs.Open("Select * From warehousestock_totalvalue", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                rs.AddNew();
                rs.Fields["period"].Value     = resultingMessage.period;
                rs.Fields["stockvalue"].Value = resultingMessage.warehousestock.totalstockvalue;
                rs.Update();
            }
            catch (Exception)
            {
            }
            finally
            {
                rs.Close();
            }



            //Tabelle inwardstockmovement
            try
            {
                rs.Open("Select * From inwardstockmovement", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                foreach (resultsOrder myElement in resultingMessage.inwardstockmovement)
                {
                    rs.AddNew();
                    rs.Fields["period"].Value        = resultingMessage.period;
                    rs.Fields["id"].Value            = myElement.id;
                    rs.Fields["orderperiod"].Value   = myElement.orderperiod;
                    rs.Fields["mode"].Value          = myElement.mode;
                    rs.Fields["article"].Value       = myElement.article;
                    rs.Fields["amount"].Value        = myElement.amount;
                    rs.Fields["time"].Value          = myElement.time;
                    rs.Fields["materialcosts"].Value = myElement.materialcosts;
                    rs.Fields["ordercosts"].Value    = myElement.ordercosts;
                    rs.Fields["entirecosts"].Value   = myElement.entirecosts;
                    rs.Fields["piececosts"].Value    = myElement.piececosts;
                }
                rs.Update();
            }
            catch (Exception)
            {
            }
            finally
            {
                rs.Close();
            }

            //Tabelle futureinwardstockmovement
            try
            {
                rs.Open("Select * From futureinwardstockmovement", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                foreach (resultsOrder1 myElement in resultingMessage.futureinwardstockmovement)
                {
                    rs.AddNew();
                    rs.Fields["period"].Value      = resultingMessage.period;
                    rs.Fields["id"].Value          = myElement.id;
                    rs.Fields["orderperiod"].Value = myElement.orderperiod;
                    rs.Fields["mode"].Value        = myElement.mode;
                    rs.Fields["article"].Value     = myElement.article;
                    rs.Fields["amount"].Value      = myElement.amount;
                }
                rs.Update();
            }
            catch (Exception)
            {
            }
            finally
            {
                rs.Close();
            }



            //Tabelle idletimecosts_workplace
            try
            {
                rs.Open("Select * From idletimecosts_workplace", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                foreach (resultsIdletimecostsWorkplace myElement in resultingMessage.idletimecosts.workplace)
                {
                    rs.AddNew();
                    rs.Fields["period"].Value               = resultingMessage.period;
                    rs.Fields["id"].Value                   = myElement.id;
                    rs.Fields["setupevents"].Value          = myElement.setupevents;
                    rs.Fields["idletime"].Value             = myElement.idletime;
                    rs.Fields["wageidletimecosts"].Value    = myElement.wageidletimecosts;
                    rs.Fields["wagecosts"].Value            = myElement.wagecosts;
                    rs.Fields["machineidletimecosts"].Value = myElement.machineidletimecosts;
                }
                rs.Update();
            }
            catch (Exception)
            {
            }
            finally
            {
                rs.Close();
            }


            //Tabelle idletimecosts_sum
            try
            {
                rs.Open("Select * From idletimecosts_sum", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                rs.AddNew();
                rs.Fields["period"].Value               = resultingMessage.period;
                rs.Fields["setupevents"].Value          = resultingMessage.idletimecosts.sum.setupevents;
                rs.Fields["idletime"].Value             = resultingMessage.idletimecosts.sum.idletime;
                rs.Fields["wageidletimecosts"].Value    = resultingMessage.idletimecosts.sum.wageidletimecosts;
                rs.Fields["wagecosts"].Value            = resultingMessage.idletimecosts.sum.wagecosts;
                rs.Fields["machineidletimecosts"].Value = resultingMessage.idletimecosts.sum.machineidletimecosts;
                rs.Update();
            }
            catch (Exception)
            {
            }
            finally
            {
                rs.Close();
            }


            //Tabelle waitinglistworkstations
            try
            {
                rs.Open("Select * From waitinglistworkstations", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                foreach (resultsWorkplace myElement in resultingMessage.waitinglistworkstations)
                {
                    if (myElement.waitinglist == null)
                    {
                        rs.AddNew();
                        rs.Fields["period"].Value       = resultingMessage.period;
                        rs.Fields["id"].Value           = myElement.id;
                        rs.Fields["timeneed_sum"].Value = myElement.timeneed;
                    }
                    else
                    {
                        foreach (resultsWorkplaceWaitinglist myUnterelement in myElement.waitinglist)
                        {
                            rs.AddNew();
                            rs.Fields["period"].Value       = resultingMessage.period;
                            rs.Fields["id"].Value           = myElement.id;
                            rs.Fields["timeneed_sum"].Value = myElement.timeneed;

                            rs.Fields["period_wp"].Value  = myUnterelement.period;
                            rs.Fields["order"].Value      = myUnterelement.order;
                            rs.Fields["firstbatch"].Value = myUnterelement.firstbatch;
                            rs.Fields["lastbatch"].Value  = myUnterelement.lastbatch;
                            rs.Fields["item"].Value       = myUnterelement.item;
                            rs.Fields["amount"].Value     = myUnterelement.amount;
                            rs.Fields["timeneed"].Value   = myUnterelement.timeneed;
                        }
                    }
                }
                rs.Update();
            }
            catch (Exception)
            {
            }
            finally
            {
                rs.Close();
            }


            //TODO WaitinglistStock
            try
            {
                rs.Open("Select * From waitingliststock", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                foreach (resultsMissingpart missingpart in resultingMessage.waitingliststock)
                {
                    foreach (resultsMissingpartWaitinglist myWaitingListElement in missingpart.waitinglist)
                    {
                        rs.AddNew();
                        rs.Fields["missingpart"].Value = missingpart.id;
                        rs.Fields["period"].Value      = resultingMessage.period;
                        rs.Fields["item"].Value        = myWaitingListElement.item;
                        rs.Fields["amount"].Value      = myWaitingListElement.amount;
                        rs.Fields["order"].Value       = myWaitingListElement.order;
                        rs.Fields["firstbatch"].Value  = myWaitingListElement.firstbatch;
                        rs.Fields["lastbatch"].Value   = myWaitingListElement.lastbatch;
                    }
                }
                rs.Update();
            }
            catch (Exception)
            {
            }
            finally
            {
                rs.Close();
            }

            //TODO orders inwrok mit liste?
            //Tabelle ordersinwork
            try
            {
                rs.Open("Select * From ordersinwork", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                foreach (resultsWorkplace1 myElement in resultingMessage.ordersinwork)
                {
                    rs.AddNew();
                    rs.Fields["period"].Value     = resultingMessage.period;
                    rs.Fields["id"].Value         = myElement.id;
                    rs.Fields["period_oiw"].Value = myElement.period;
                    rs.Fields["order"].Value      = myElement.order;
                    rs.Fields["batch"].Value      = myElement.batch;
                    rs.Fields["item"].Value       = myElement.item;
                    rs.Fields["amount"].Value     = myElement.amount;
                    rs.Fields["timeneed"].Value   = myElement.timeneed;
                }
                rs.Update();
            }
            catch (Exception)
            {
            }
            finally
            {
                rs.Close();
            }



            //Tabelle completedorders
            try
            {
                rs.Open("Select * From completedorders", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                foreach (resultsOrder2 myElement in resultingMessage.completedorders)
                {
                    foreach (resultsOrderBatch myUnterelement in myElement.batch)
                    {
                        rs.AddNew();
                        rs.Fields["period"].Value             = resultingMessage.period;
                        rs.Fields["o_period"].Value           = myElement.period;
                        rs.Fields["o_id"].Value               = myElement.id;
                        rs.Fields["o_item"].Value             = myElement.item;
                        rs.Fields["o_quantity"].Value         = myElement.quantity;
                        rs.Fields["o_cost"].Value             = myElement.cost;
                        rs.Fields["o_averageunitcosts"].Value = myElement.averageunitcosts;

                        rs.Fields["b_id"].Value        = myUnterelement.id;
                        rs.Fields["b_amount"].Value    = myUnterelement.amount;
                        rs.Fields["b_cycletime"].Value = myUnterelement.cycletime;
                        rs.Fields["b_cost"].Value      = myUnterelement.cost;
                    }
                }
                rs.Update();
            }
            catch (Exception)
            {
            }
            finally
            {
                rs.Close();
            }


            //Tabelle cycletimes
            try
            {
                rs.Open("Select * From cycletimes", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                rs.AddNew();
                rs.Fields["period"].Value        = resultingMessage.period;
                rs.Fields["startedorders"].Value = resultingMessage.cycletimes.startedorders;
                rs.Fields["waitingorders"].Value = resultingMessage.cycletimes.waitingorders;
                rs.Update();
            }
            catch (Exception)
            {
            }
            finally
            {
                rs.Close();
            }


            //Tabelle cycletimes_order
            try
            {
                rs.Open("Select * From cycletimes_order", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                foreach (resultsCycletimesOrder myElement in resultingMessage.cycletimes.order)
                {
                    rs.AddNew();
                    rs.Fields["period"].Value          = resultingMessage.period;
                    rs.Fields["id"].Value              = myElement.id;
                    rs.Fields["period_order"].Value    = myElement.period;
                    rs.Fields["starttime"].Value       = myElement.starttime;
                    rs.Fields["finishtime"].Value      = myElement.finishtime;
                    rs.Fields["cycletimemin"].Value    = myElement.cycletimemin;
                    rs.Fields["cycletimefactor"].Value = myElement.cycletimefactor;
                }
                rs.Update();
            }
            catch (Exception)
            {
            }
            finally
            {
                rs.Close();
            }

            //Tabelle general
            try
            {
                rs.Open("Select * From tbl_general", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                rs.AddNew();
                rs.Fields["period"].Value = resultingMessage.period;

                rs.Fields["capacity_current"].Value = resultingMessage.result.general.capacity.current;
                rs.Fields["capacity_average"].Value = resultingMessage.result.general.capacity.average;
                rs.Fields["capacity_all"].Value     = resultingMessage.result.general.capacity.all;

                rs.Fields["possiblecapacity_current"].Value = resultingMessage.result.general.possiblecapacity.current;
                rs.Fields["possiblecapacity_average"].Value = resultingMessage.result.general.possiblecapacity.average;
                rs.Fields["possiblecapacity_all"].Value     = resultingMessage.result.general.possiblecapacity.all;

                rs.Fields["relpossiblenormalcapacity_current"].Value = resultingMessage.result.general.relpossiblenormalcapacity.current;
                rs.Fields["relpossiblenormalcapacity_average"].Value = resultingMessage.result.general.relpossiblenormalcapacity.average;
                rs.Fields["relpossiblenormalcapacity_all"].Value     = resultingMessage.result.general.relpossiblenormalcapacity.all;

                rs.Fields["productivetime_current"].Value = resultingMessage.result.general.productivetime.current;
                rs.Fields["productivetime_average"].Value = resultingMessage.result.general.productivetime.average;
                rs.Fields["productivetime_all"].Value     = resultingMessage.result.general.productivetime.all;

                rs.Fields["effiency_current"].Value = resultingMessage.result.general.effiency.current;
                rs.Fields["effiency_average"].Value = resultingMessage.result.general.effiency.average;
                rs.Fields["effiency_all"].Value     = resultingMessage.result.general.effiency.all;

                rs.Fields["sellwish_current"].Value = resultingMessage.result.general.sellwish.current;
                rs.Fields["sellwish_average"].Value = resultingMessage.result.general.sellwish.average;
                rs.Fields["sellwish_all"].Value     = resultingMessage.result.general.sellwish.all;

                rs.Fields["salesquantity_current"].Value = resultingMessage.result.general.salesquantity.current;
                rs.Fields["salesquantity_average"].Value = resultingMessage.result.general.salesquantity.average;
                rs.Fields["salesquantity_all"].Value     = resultingMessage.result.general.salesquantity.all;

                rs.Fields["deliveryreliability_current"].Value = resultingMessage.result.general.deliveryreliability.current;
                rs.Fields["deliveryreliability_average"].Value = resultingMessage.result.general.deliveryreliability.average;
                rs.Fields["deliveryreliability_all"].Value     = resultingMessage.result.general.deliveryreliability.all;

                rs.Fields["idletime_current"].Value = resultingMessage.result.general.idletime.current;
                rs.Fields["idletime_average"].Value = resultingMessage.result.general.idletime.average;
                rs.Fields["idletime_all"].Value     = resultingMessage.result.general.idletime.all;

                rs.Fields["idletimecosts_current"].Value = resultingMessage.result.general.idletimecosts.current;
                rs.Fields["idletimecosts_average"].Value = resultingMessage.result.general.idletimecosts.average;
                rs.Fields["idletimecosts_all"].Value     = resultingMessage.result.general.idletimecosts.all;

                rs.Fields["storevalue_current"].Value = resultingMessage.result.general.storevalue.current;
                rs.Fields["storevalue_average"].Value = resultingMessage.result.general.storevalue.average;
                rs.Fields["storevalue_all"].Value     = resultingMessage.result.general.storevalue.all;

                rs.Fields["storagecosts_current"].Value = resultingMessage.result.general.storagecosts.current;
                rs.Fields["storagecosts_average"].Value = resultingMessage.result.general.storagecosts.average;
                rs.Fields["storagecosts_all"].Value     = resultingMessage.result.general.storagecosts.all;

                rs.Update();
            }
            catch (Exception)
            {
            }
            finally
            {
                rs.Close();
            }



            //Tabelle normalsale
            try
            {
                rs.Open("Select * From normalsale", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                rs.AddNew();
                rs.Fields["period"].Value = resultingMessage.period;

                rs.Fields["salesprice_current"].Value = resultingMessage.result.normalsale.salesprice.current;
                rs.Fields["salesprice_average"].Value = resultingMessage.result.normalsale.salesprice.average;
                rs.Fields["salesprice_all"].Value     = resultingMessage.result.normalsale.salesprice.all;

                rs.Fields["profit_current"].Value = resultingMessage.result.normalsale.profit.current;
                rs.Fields["profit_average"].Value = resultingMessage.result.normalsale.profit.average;
                rs.Fields["profit_all"].Value     = resultingMessage.result.normalsale.profit.all;

                rs.Fields["profitperunit_current"].Value = resultingMessage.result.normalsale.profitperunit.current;
                rs.Fields["profitperunit_average"].Value = resultingMessage.result.normalsale.profitperunit.average;
                rs.Fields["profitperunit_all"].Value     = resultingMessage.result.normalsale.profitperunit.all;

                rs.Update();
            }
            catch (Exception)
            {
            }
            finally
            {
                rs.Close();
            }



            //Tabelle directsale
            try
            {
                rs.Open("Select * From directsale", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                rs.AddNew();
                rs.Fields["period"].Value = resultingMessage.period;

                rs.Fields["profit_current"].Value = resultingMessage.result.directsale.profit.current;
                rs.Fields["profit_average"].Value = resultingMessage.result.directsale.profit.average;
                rs.Fields["profit_all"].Value     = resultingMessage.result.directsale.profit.all;

                rs.Fields["contractpenalty_current"].Value = resultingMessage.result.directsale.contractpenalty.current;
                rs.Fields["contractpenalty_average"].Value = resultingMessage.result.directsale.contractpenalty.average;
                rs.Fields["contractpenalty_all"].Value     = resultingMessage.result.directsale.contractpenalty.all;

                rs.Update();
            }
            catch (Exception)
            {
            }
            finally
            {
                rs.Close();
            }



            //Tabelle marketplacesale
            try
            {
                rs.Open("Select * From marketplacesale", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                rs.AddNew();
                rs.Fields["period"].Value = resultingMessage.period;

                rs.Fields["profit_current"].Value = resultingMessage.result.marketplacesale.profit.current;
                rs.Fields["profit_average"].Value = resultingMessage.result.marketplacesale.profit.average;
                rs.Fields["profit_all"].Value     = resultingMessage.result.marketplacesale.profit.all;

                rs.Update();
            }
            catch (Exception)
            {
            }
            finally
            {
                rs.Close();
            }



            //Tabelle summary
            try
            {
                rs.Open("Select * From summary", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                rs.AddNew();
                rs.Fields["period"].Value = resultingMessage.period;

                rs.Fields["profit_current"].Value = resultingMessage.result.summary.profit.current;
                rs.Fields["profit_average"].Value = resultingMessage.result.summary.profit.average;
                rs.Fields["profit_all"].Value     = resultingMessage.result.summary.profit.all;

                rs.Update();
            }
            catch (Exception)
            {
            }
            finally
            {
                rs.Close();
            }
            /// <summary>
            /// Überflüssige Werte aus der DB löschen, wenn Initialer Stand hochgeladen wird
            /// </summary>

            try
            {
                rs.Open("Select distinct period from warehousestock_article ORDER BY period Desc", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                int periode = Convert.ToInt32(rs.Fields["period"].Value);
                if (periode == 0)
                {
                    rsDelete.Open("Delete From inwardstockmovement", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                    rsDelete.Open("Delete From futureinwardstockmovement Where period = '0'", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                    //rsDelete.Open("Delete From idletimecosts", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                    rsDelete.Open("Delete From idletimecosts_workplace where period ='0'", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                    rsDelete.Open("Delete From idletimecosts_sum where period = '0'", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                    rsDelete.Open("Delete From waitinglistworkstations where period = '0'", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                    rsDelete.Open("Delete From waitingliststock where period = 0", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                    rsDelete.Open("Delete From ordersinwork where period = '0'", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                    rsDelete.Open("Delete From completedorders where period = '0'", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                    rsDelete.Open("Delete From cycletimes where period = '0'", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                    rsDelete.Open("Delete From cycletimes_order where period = '0'", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                    rsDelete.Open("Delete From tbl_general where period = '0'", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                    rsDelete.Open("Delete From normalsale where period = '0'", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                    rsDelete.Open("Delete From directsale where period = '0'", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                    rsDelete.Open("Delete From marketplacesale where period = '0'", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                    rsDelete.Open("Delete From summary where period = '0'", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                }
            }
            catch (Exception test)
            {
                MessageBox.Show(test.Message);
            }
            finally
            {
                rs.Close();
            }

            MessageBox.Show("XML-File importiert");

            cn.Close();
        }
        /// <summary>
        /// Creates an ADODB.Recordset from an System.Collections.Generic.IEnumerable(T).
        /// </summary>
        /// <typeparam name="T">The type of the elements of input.</typeparam>
        /// <param name="input">The System.Collections.Generic.IEnumerable(T) to create an ADODB.Recordset from.</param>
        /// <returns>An ADODB.Recordset that contains elements from the input sequence.</returns>
        public static ADODB.Recordset ToRecordset <T>(this IEnumerable <T> input)
        {
            var adoType = new ADODB.DataTypeEnum();

            if (DataTypes.TryGetAdoTypeForClrType(typeof(T), out adoType))
            {
                throw new ArgumentException("The T of IEnumerable<T> must be a custom POCO, not an ADO compatible type.", "input");
            }

            var rs   = new ADODB.Recordset();
            var type = typeof(T);

            BindingFlags flags = BindingFlags.Public | BindingFlags.Instance;

            PropertyInfo[] properties = type.GetProperties(flags);

            // create properties
            foreach (var property in properties)
            {
                if (DataTypes.TryGetAdoTypeForClrType(property.PropertyType, out adoType))
                {
                    int definedSize = 0;

                    if (property.PropertyType == typeof(string))
                    {
                        // TODO: set string size to length of longest string in POCO?
                        definedSize = 1000;
                    }

                    if (property.PropertyType == typeof(Guid))
                    {
                        definedSize = 38;
                    }

                    rs.Fields.Append(property.Name, adoType, definedSize, ADODB.FieldAttributeEnum.adFldIsNullable);
                }
            }

            // insert data
            rs.Open();

            if (input.Any())
            {
                foreach (var item in input)
                {
                    rs.AddNew();

                    foreach (var property in properties)
                    {
                        var value = property.GetValue(item, null);

                        if (property.PropertyType == typeof(Guid))
                        {
                            value = value.ToString();
                        }

                        if (value != null)
                        {
                            rs.Fields[property.Name].Value = value;
                        }
                    }

                    rs.Update();
                }
            }

            return(rs);
        }