Пример #1
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            string  name           = textBoxName.Text;
            string  address        = textBoxAddres.Text;
            int     contact        = int.Parse(textBoxContact.Text);
            decimal cusloyltypoint = decimal.Parse(textBoxLoyalty.Text);

            pos_customer customer = new pos_customer
            {
                id = customerid,
                customeraddrees = address,
                customername    = name,
                customercontact = contact,
                loyaltypoint    = cusloyltypoint,
            };

            RepositeryResponce repositeryResponce = customerRepo.Save(customer);

            if (repositeryResponce.sucsess)
            {
                loadDatagrid();
                Reset();
                ShowMessageSucsess(repositeryResponce.message);
            }
            else
            {
                ShowMessageError(repositeryResponce.message);
            }
        }
Пример #2
0
        public RepositeryResponce Remove(int id)
        {
            int sucsess = 0;


            try
            {
                pos_customer customer = findbyId(id);
                dbentities.Entry(customer).State = EntityState.Deleted;

                sucsess = dbentities.SaveChanges();
            }
            catch (Exception exeption)
            {
                return(new RepositeryResponce(false, CustomerConstance.SAVEERROR, null));
            }


            if (sucsess == 1)
            {
                return(new RepositeryResponce(true, CustomerConstance.SAVESUCESS, null));
            }
            else
            {
                return(new RepositeryResponce(false, CustomerConstance.SAVEERROR, null));
            }
        }
Пример #3
0
        private static int Partition(ref pos_customer[] arr, int left, int right)
        {
            decimal pivot = arr[left].loyaltypoint;

            while (true)
            {
                while (arr[left].loyaltypoint < pivot)
                {
                    left++;
                }

                while (arr[right].loyaltypoint > pivot)
                {
                    right--;
                }

                if (left < right)
                {
                    if (arr[left] == arr[right])
                    {
                        return(right);
                    }

                    pos_customer temp = arr[left];
                    arr[left]  = arr[right];
                    arr[right] = temp;
                }
                else
                {
                    return(right);
                }
            }
        }
Пример #4
0
        public RepositeryResponce Save(pos_customer customer)
        {
            int sucsess = 0;


            try
            {
                if (customer.id > 0)
                {
                    //pos_customer curentcustomer = findbyId(customer.id);
                    //dbentities.Entry(curentcustomer).CurrentValues.SetValues(customer);
                    dbentities.Entry(customer).State = EntityState.Modified;
                }
                else
                {
                    dbentities.pos_customer.Add(customer);
                }

                sucsess = dbentities.SaveChanges();
            }catch (Exception exeption)
            {
                return(new RepositeryResponce(false, CustomerConstance.SAVEERROR, null));
            }


            if (sucsess == 1)
            {
                return(new RepositeryResponce(true, CustomerConstance.SAVESUCESS, null));
            }
            else
            {
                return(new RepositeryResponce(false, CustomerConstance.SAVEERROR, null));
            }
        }
Пример #5
0
        private void fillData(int value)
        {
            pos_customer customer = customerRepo.findbyId(value);

            textBoxName.Text    = customer.customername;
            textBoxAddres.Text  = customer.customeraddrees;
            textBoxContact.Text = customer.customercontact.ToString();
            textBoxLoyalty.Text = customer.loyaltypoint.ToString();
            customerid          = customer.id;
        }