Ejemplo n.º 1
0
        private void SetInfoTransactionPrivateCopy()
        {
            transPrivateCopy = new InfoTransaction();

            // transPrivateCopy.Timing = transaction.Timing;

            foreach (Transaction trans in transaction.Transactions)
            {
                Transaction t = new Transaction();
                t.AutoNumber = trans.AutoNumber;
                t.Name = trans.Name;

                foreach (TransField field in trans.TransFields)
                {
                    TransField tf = new TransField();
                    tf.DesField = field.DesField;
                    tf.DesValue = field.DesValue;
                    tf.FieldType = field.FieldType;
                    tf.SrcField = field.SrcField;
                    tf.SrcGetValue = field.SrcGetValue;
                    tf.SrcValue = field.SrcValue;
                    tf.UpdateMode = field.UpdateMode;

                    t.TransFields.Add(tf);
                }

                foreach (TransKeyField keyField in trans.TransKeyFields)
                {
                    TransKeyField tkf = new TransKeyField();
                    tkf.DesField = keyField.DesField;
                    tkf.FieldType = keyField.FieldType;
                    tkf.SrcField = keyField.SrcField;
                    tkf.SrcGetValue = keyField.SrcGetValue;
                    tkf.SrcValue = keyField.SrcValue;
                    tkf.WhereMode = keyField.WhereMode;

                    t.TransKeyFields.Add(tkf);
                }
                t.TransMode = trans.TransMode;
                t.TransStep = trans.TransStep;
                t.TransTableName = trans.TransTableName;
                t.WhenDelete = trans.WhenDelete;
                t.WhenInsert = trans.WhenInsert;
                t.WhenUpdate = trans.WhenUpdate;

                transPrivateCopy.Transactions.Add(t);
            }

            transPrivateCopy.UpdateComp = transaction.UpdateComp;
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            List<string> lstSrcColumn = new List<string>();
            List<string> lstDesColumn = new List<string>();

            InfoTransactionTransFieldsAddDialog ittfad = new InfoTransactionTransFieldsAddDialog();

            if (strSrcTable != string.Empty && _conn != null)
            {

                if (uctran != null && uctran.SelectCmd != null)
                {
                    ittfad.cmbSrcField.Items.AddRange(uctran.SelectCmd.GetFields());
                }
            }

            if (strDesTable != string.Empty && _conn != null)
            {
                try
                {
                    lstDesColumn = AddColumn(strDesTable);
                }
                catch(Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error",  MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                foreach (string strColumn in lstDesColumn)
                {
                    ittfad.cmbDesField.Items.Add(strColumn);
                }
            }

            ittfad.cbxUpdateMode.Items.Add("Dec");
            ittfad.cbxUpdateMode.Items.Add("Disable");
            ittfad.cbxUpdateMode.Items.Add("Inc");
            ittfad.cbxUpdateMode.Items.Add("Replace");
            ittfad.cbxUpdateMode.Items.Add("WriteBack");
            ittfad.cbxUpdateMode.SelectedIndex = 3;

            if (ittfad.ShowDialog() == DialogResult.OK)
            {
                TransField tf = new TransField();
                tf.DesField = ittfad.cmbDesField.Text;
                tf.SrcField = ittfad.cmbSrcField.Text;
                tf.SrcGetValue = ittfad.txtSrcGetValue.Text;

                switch (ittfad.cbxUpdateMode.SelectedIndex)
                {
                    case 0:
                        tf.UpdateMode = UpdateMode.Dec;
                        break;
                    case 1:
                        tf.UpdateMode = UpdateMode.Disable;
                        break;
                    case 2:
                        tf.UpdateMode = UpdateMode.Inc;
                        break;
                    case 3:
                        tf.UpdateMode = UpdateMode.Replace;
                        break;
                    case 4:
                        tf.UpdateMode = UpdateMode.WriteBack;
                        break;
                }
                this.transPrivateCopy.TransFields.Add(tf);

                this.lbDesField.Items.Add(tf.DesField);
                this.lbScrField.Items.Add(tf.SrcField);

                switch (tf.UpdateMode)
                {
                    case UpdateMode.Dec:
                        this.lbRelation.Items.Add(tf.DesField + " - " + tf.SrcField);
                        break;
                    case UpdateMode.Disable:
                        this.lbRelation.Items.Add(tf.DesField + " X " + tf.SrcField);
                        break;
                    case UpdateMode.Inc:
                        this.lbRelation.Items.Add(tf.DesField + " + " + tf.SrcField);
                        break;
                    case UpdateMode.Replace:
                        this.lbRelation.Items.Add(tf.DesField + " = " + tf.SrcField);
                        break;
                    case UpdateMode.WriteBack:
                        this.lbRelation.Items.Add(tf.DesField + " <- " + tf.SrcField);
                        break;
                }
            }
        }
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            int selindex = this.lbRelation.SelectedIndex;

            List<string> lstSrcColumn = new List<string>();
            List<string> lstDesColumn = new List<string>();

            if (selindex != -1)
            {
                InfoTransactionTransFieldsAddDialog ittfad = new InfoTransactionTransFieldsAddDialog();

                if (strSrcTable != string.Empty && _conn != null)
                {
                    if (uctran != null && uctran.SelectCmd != null)
                    {
                        ittfad.cmbSrcField.Items.AddRange(uctran.SelectCmd.GetFields());
                    }
                }

                if (strDesTable != string.Empty && _conn != null)
                {
                    try
                    {
                        lstDesColumn = AddColumn(strDesTable);
                    }
                    catch
                    {
                        MessageBox.Show(string.Format("Transtable :{0} \ndoesn't exist", strDesTable));
                        return;
                    }
                    foreach (string strColumn in lstDesColumn)
                    {
                        ittfad.cmbDesField.Items.Add(strColumn);
                    }
                }

                ittfad.cbxUpdateMode.Items.Add("Dec");
                ittfad.cbxUpdateMode.Items.Add("Disable");
                ittfad.cbxUpdateMode.Items.Add("Inc");
                ittfad.cbxUpdateMode.Items.Add("Replace");
                ittfad.cbxUpdateMode.Items.Add("WriteBack");

                ittfad.cmbDesField.Text = this.lbDesField.Items[selindex].ToString();
                ittfad.cmbSrcField.Text = this.lbScrField.Items[selindex].ToString();
                ittfad.txtSrcGetValue.Text = this.txtSrcGetValue.Text;

                switch (((TransField)this.transPrivateCopy.TransFields[selindex]).UpdateMode)
                {
                    case UpdateMode.Dec:
                        ittfad.cbxUpdateMode.SelectedIndex = 0;
                        break;
                    case UpdateMode.Disable:
                        ittfad.cbxUpdateMode.SelectedIndex = 1;
                        break;
                    case UpdateMode.Inc:
                        ittfad.cbxUpdateMode.SelectedIndex = 2;
                        break;
                    case UpdateMode.Replace:
                        ittfad.cbxUpdateMode.SelectedIndex = 3;
                        break;
                    case UpdateMode.WriteBack:
                        ittfad.cbxUpdateMode.SelectedIndex = 4;
                        break;
                }

                if (ittfad.ShowDialog() == DialogResult.OK)
                {
                    TransField tf = new TransField();
                    tf.DesField = ittfad.cmbDesField.Text;
                    tf.SrcField = ittfad.cmbSrcField.Text;
                    tf.SrcGetValue = ittfad.txtSrcGetValue.Text;

                    switch (ittfad.cbxUpdateMode.SelectedIndex)
                    {
                        case 0:
                            tf.UpdateMode = UpdateMode.Dec;
                            break;
                        case 1:
                            tf.UpdateMode = UpdateMode.Disable;
                            break;
                        case 2:
                            tf.UpdateMode = UpdateMode.Inc;
                            break;
                        case 3:
                            tf.UpdateMode = UpdateMode.Replace;
                            break;
                        case 4:
                            tf.UpdateMode = UpdateMode.WriteBack;
                            break;
                    }

                    this.transPrivateCopy.TransFields[selindex] = tf;
                    this.lbDesField.Items[selindex] = tf.DesField;
                    this.lbScrField.Items[selindex] = tf.SrcField;

                    switch (tf.UpdateMode)
                    {
                        case UpdateMode.Dec:
                            this.lbRelation.Items[selindex] = tf.DesField + " - " + tf.SrcField;
                            break;
                        case UpdateMode.Disable:
                            this.lbRelation.Items[selindex] = tf.DesField + " X " + tf.SrcField;
                            break;
                        case UpdateMode.Inc:
                            this.lbRelation.Items[selindex] = tf.DesField + " + " + tf.SrcField;
                            break;
                        case UpdateMode.Replace:
                            this.lbRelation.Items[selindex] = tf.DesField + " = " + tf.SrcField;
                            break;
                        case UpdateMode.WriteBack:
                            this.lbRelation.Items[selindex] = tf.DesField + " <- " + tf.SrcField;
                            break;
                    }

                }

            }
        }
        private void SetTransactionPrivateCopy()
        {
            transPrivateCopy = new Transaction();

            foreach (TransField field in transaction.TransFields)
            {
                TransField tf = new TransField();
                tf.DesField = field.DesField;
                tf.DesValue = field.DesValue;
                tf.FieldType = field.FieldType;
                tf.SrcField = field.SrcField;
                tf.SrcGetValue = field.SrcGetValue;
                tf.SrcValue = field.SrcValue;
                tf.UpdateMode = field.UpdateMode;

                transPrivateCopy.TransFields.Add(tf);
            }
        }
        private void SetTransactionPrivateCopy()
        {
            transPrivateCopy = new Transaction();

            transPrivateCopy.AutoNumber = transaction.AutoNumber;
            transPrivateCopy.Name = transaction.Name;

            foreach (TransField field in transaction.TransFields)
            {
                TransField tf = new TransField();
                tf.DesField = field.DesField;
                tf.DesValue = field.DesValue;
                tf.FieldType = field.FieldType;
                tf.SrcField = field.SrcField;
                tf.SrcGetValue = field.SrcGetValue;
                tf.SrcValue = field.SrcValue;
                tf.UpdateMode = field.UpdateMode;

                transPrivateCopy.TransFields.Add(tf);
            }

            foreach (TransKeyField keyField in transaction.TransKeyFields)
            {
                TransKeyField tkf = new TransKeyField();
                tkf.DesField = keyField.DesField;
                tkf.FieldType = keyField.FieldType;
                tkf.SrcField = keyField.SrcField;
                tkf.SrcGetValue = keyField.SrcGetValue;
                tkf.SrcValue = keyField.SrcValue;
                tkf.WhereMode = keyField.WhereMode;

                transPrivateCopy.TransKeyFields.Add(tkf);
            }
            transPrivateCopy.TransMode = transaction.TransMode;
            transPrivateCopy.TransStep = transaction.TransStep;
            transPrivateCopy.TransTableName = transaction.TransTableName;
            //new add by ccm
            transPrivateCopy.WhenInsert = transaction.WhenInsert;
            transPrivateCopy.WhenUpdate = transaction.WhenUpdate;
            transPrivateCopy.WhenDelete = transaction.WhenDelete;
        }