예제 #1
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));
            }
        }
예제 #2
0
        public RepositeryResponce saveGrn(pos_grnheader grnheader)
        {
            int sucses = 0;

            try
            {
                dbentities.pos_grnheader.Add(grnheader);
                sucses = dbentities.SaveChanges();
            }
            catch (Exception exception)
            {
                dbentities.pos_grnheader.Remove(grnheader);
                return(new RepositeryResponce(false, GrnConstances.SAVEERROR, null));
            }
            if (sucses == 1)
            {
                int id = dbentities.pos_grnheader.OrderBy(header => header.time).ToList().Last().id;


                return(new RepositeryResponce(true, GrnConstances.SAVESUCESS, new { id }));
            }
            else
            {
                return(new RepositeryResponce(false, GrnConstances.SAVEERROR, null));
            }
        }
예제 #3
0
        public RepositeryResponce Save(pos_item item)
        {
            int sucses = 0;
            RepositeryResponce responce = new RepositeryResponce();

            try
            {
                if (item.id > 0)
                {
                    var current = dbentities.pos_item.Find(item.id);
                    dbentities.Entry(current).CurrentValues.SetValues(item);
                }
                else
                {
                    dbentities.pos_item.Add(item);
                }

                sucses = dbentities.SaveChanges();
            }
            catch (Exception exception)
            {
                responce.sucsess = false;
                responce.message = exception.Message;
                dbentities.pos_item.Remove(item);
                return(responce);
            }
            if (sucses == 1)
            {
                responce.sucsess = true;
                responce.message = CatgoryConstant.Savesucses;
                return(responce);
            }
            else
            {
                responce.sucsess = false;
                responce.message = CatgoryConstant.SaveError;
                return(responce);
            }
        }
예제 #4
0
        public RepositeryResponce SaveGrnItems(List <pos_grnitem> grnitemlist)
        {
            int sucsee = 0;

            try
            {
                dbentities.pos_grnitem.AddRange(grnitemlist);
                sucsee = dbentities.SaveChanges();
            }catch (Exception exception)
            {
                return(new RepositeryResponce(false, "Error on item save", null));
            }
            if (sucsee == 1)
            {
                return(new RepositeryResponce(true, "Sucsesfully saves", null));
            }
            else
            {
                return(new RepositeryResponce(false, "Error on item save", null));
            }
        }
예제 #5
0
        public RepositeryResponce saveGrn(pos_grnitem grnitem)
        {
            int sucses = 0;

            try
            {
                dbentities.pos_grnitem.Add(grnitem);
                sucses = dbentities.SaveChanges();
            }
            catch (Exception exception)
            {
                return(new RepositeryResponce(false, GrnConstances.SAVEERROR, null));
            }
            if (sucses == 1)
            {
                return(new RepositeryResponce(true, GrnConstances.SAVESUCESS, null));
            }
            else
            {
                return(new RepositeryResponce(false, GrnConstances.SAVEERROR, null));
            }
        }
예제 #6
0
        internal string SaveUnit(UnitDto posunit)
        {
            int sucses = 0;

            try
            {
                dbentities.pos_unit.Add(posunit.Map());
                sucses = dbentities.SaveChanges();
            }
            catch (Exception exception)
            {
                return(exception.Message);
            }
            if (sucses == 1)
            {
                return("save correctly");
            }
            else
            {
                return("some thing went wrong");
            }
        }