示例#1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            //Get current customer
            Customer clkcustomer = GetCurrentRecord();

            if (clkcustomer != null)
            {
                if (MessageBox.Show("Do you want delete this record?", "Delete Record", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    List <Customer> lstDeleted = new List <Customer>();
                    lstDeleted.Add(clkcustomer);

                    string dataOrg = "";

                    //DeleteOptions deleteOptions = new DeleteOptions(false, new RecoverRecordIdTypeLinkar(false, "", ""), false);
                    DeleteOptions deleteOptions = new DeleteOptions(false, new RecoverIdType());

                    try
                    {
                        List <Customer> lstCustomers = this._LinkarClt.Delete <Customer>(filename, lstDeleted, dataOrg, deleteOptions);
                        cLkCustomersBindingSource.Remove(clkcustomer);
                    }
                    catch (Exception ex)
                    {
                        string msgErr = FormDemo.GetExceptionInfo(ex);
                        MessageBox.Show(this, msgErr, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
示例#2
0
        private void btnSelect_Click(object sender, EventArgs e)
        {
            string selectClause    = this.txtSelect.Text;
            string sortClause      = "";
            string dictClause      = "";
            string preSelectClause = "";

            bool calculated     = true;
            bool conversion     = false;
            bool formatSpec     = false;
            bool originalBuffer = true;
            bool onlyitemid     = false;
            bool pagination     = false;

            int regPage = 10;
            int numPag  = 1;

            SelectOptions selectOptions = new SelectOptions(onlyitemid, pagination, regPage, numPag, calculated, conversion, formatSpec, originalBuffer);

            string customVars = "";
            string error;

            //DateTime dtantes = DateTime.Now;
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            try
            {
                List <Customer> lstCustomers = this._LinkarClt.Select <Customer>(filename, selectClause, sortClause, dictClause, preSelectClause, selectOptions, customVars);
                if (lstCustomers != null)
                {
                    cLkCustomersBindingSource.DataSource = lstCustomers;
                }
            }
            catch (Exception ex)
            {
                string msgErr = FormDemo.GetExceptionInfo(ex);
                MessageBox.Show(this, msgErr, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //DateTime dtdespues = DateTime.Now;

            //TimeSpan ts = dtdespues - dtantes;
            //MessageBox.Show(ts.Minutes + " - " + ts.Seconds + " - " + ts.Milliseconds);
        }
示例#3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //Get current customer
            //Customer clkcustomer = GetCurrentRecord();
            //if (clkcustomer != null)
            //{
            //    GetRecord(ref clkcustomer);
            //    //Save or create new item
            //    if (clkcustomer.Status != LinkarMainClass.StatusTypes.NEW)
            //    {

            //        string ge = "";
            //        //Call the WriteItem method from CLkCustomer
            //        clkcustomer.WriteRecord(out ge, "");

            //        if (!string.IsNullOrEmpty(ge))
            //        {
            //            MessageBox.Show(ge.Replace(DBMV_Mark.VM_str, "\r\n"));
            //        }
            //        else
            //        {
            //            ChangeBarStatus(false, false);
            //        }
            //    }
            //    else
            //    {
            //        string ge = "";
            //        //Call the NewItem method from CLkCustomer
            //        clkcustomer.NewRecord(out ge, "");

            //        if (!string.IsNullOrEmpty(ge))
            //        {
            //            MessageBox.Show(ge.Replace(DBMV_Mark.VM_str, "\r\n"));
            //        }
            //        else
            //        {
            //            ChangeBarStatus(false, false);
            //        }
            //    }
            //}

            Customer clkcustomer = GetCurrentRecord();

            if (clkcustomer != null)
            {
                List <Customer> lstupd = new List <Customer>();
                GetRecord(ref clkcustomer);
                lstupd.Add(clkcustomer);

                string error;

                bool optimisticLock = false;
                bool readAfter      = false;
                bool calculated     = false;
                bool conversion     = false;
                bool formatSpec     = false;
                bool originalBuffer = false;

                string dataOrg = "";

                string customVars = "";

                Exception exErr = null;
                if (isNew)
                {
                    try
                    {
                        RecordIdType    recordIdType = new RecordIdType();
                        NewOptions      newOptions   = new NewOptions(recordIdType, readAfter, calculated, conversion, formatSpec, originalBuffer);
                        List <Customer> lstCustomers = this._LinkarClt.New(filename, lstupd, newOptions, customVars);
                    }
                    catch (Exception ex)
                    {
                        exErr = ex;
                    }
                }
                else
                {
                    try
                    {
                        UpdateOptions   updateOptions = new UpdateOptions(optimisticLock, readAfter, calculated, conversion, formatSpec, originalBuffer);
                        List <Customer> lstCustomers  = this._LinkarClt.Update(filename, lstupd, updateOptions, dataOrg, customVars);
                    }
                    catch (Exception ex)
                    {
                        exErr = ex;
                    }
                }

                if (exErr != null)
                {
                    string msgErr = FormDemo.GetExceptionInfo(exErr);
                    MessageBox.Show(this, msgErr, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                ChangeBarStatus(false, false);
                isNew = false;
            }
        }