Ejemplo n.º 1
0
        public EditProvideGoodsTab(DataService Service, SetTab SetTab, DataEditTab PrevTab, List <TabListElement> content, Guid ObjectId)
            : base(Service, SetTab)
        {
            this.PrevTab  = PrevTab;
            this.ObjectId = ObjectId;

            TopButtons.Add(new Button("Back", ConsoleKey.F1, new Button.ButtonCallback(Close)));
            TopButtons.Add(new Button(ConsoleKey.Backspace, new Button.ButtonCallback(Close)));

            TopButtons.Add(new Button("Check", ConsoleKey.F2, new Button.ButtonCallback(CheckElement)));
            TopButtons.Add(new Button(ConsoleKey.Enter, new Button.ButtonCallback(CheckElement)));

            Elements = content;
        }
Ejemplo n.º 2
0
        public override void EditObjectField(string FieldName, Guid ObjectId, DataEditTab InvokerTab)
        {
            String       UserAnswer;
            GoodCategory obj;

            switch (FieldName)
            {
            case "Name":
                Console.Write("Enter new " + FieldName + ": ");
                try
                {
                    UserAnswer = Console.ReadLine();
                    obj        = Service.GetGoodsCategory(ObjectId);
                    obj.Name   = UserAnswer;
                    Service.UpdateItem(obj);
                }
                catch (Exception e)
                {
                    InvokerTab.Message = e.Message;
                }
                break;

            case "Description":
                try
                {
                    Console.Write("Enter new " + FieldName + ": ");
                    UserAnswer      = Console.ReadLine();
                    obj             = Service.GetGoodsCategory(ObjectId);
                    obj.Description = UserAnswer;
                    Service.UpdateItem(obj);
                }
                catch (Exception e)
                {
                    InvokerTab.Message = e.Message;
                }
                break;
            }
        }
Ejemplo n.º 3
0
 public abstract void EditObjectField(String Key, Guid ObjectId, DataEditTab InvokerTab);
Ejemplo n.º 4
0
        public void EditObjectField(String FieldName, Guid ObjectId, DataEditTab InvokerTab)
        {
            String UserAnswer;
            Good   obj;

            switch (FieldName)
            {
            case "Name":
                Console.Write("Enter new " + FieldName + ": ");

                try
                {
                    UserAnswer = Console.ReadLine();
                    obj        = Service.GetGood(ObjectId);
                    obj.Name   = UserAnswer;
                    Service.UpdateItem(obj);
                }
                catch (Exception e)
                {
                    InvokerTab.Message = e.Message;
                }
                break;

            case "BrandName":
                try
                {
                    Console.Write("Enter new " + FieldName + ": ");
                    UserAnswer    = Console.ReadLine();
                    obj           = Service.GetGood(ObjectId);
                    obj.BrandName = UserAnswer;
                    Service.UpdateItem(obj);
                }
                catch (Exception e)
                {
                    InvokerTab.Message = e.Message;
                }
                break;

            case "Count":
                try
                {
                    Console.Write("Enter new " + FieldName + ": ");
                    UserAnswer = Console.ReadLine();
                    obj        = Service.GetGood(ObjectId);
                    obj.SetCount(UserAnswer);
                    Service.UpdateItem(obj);
                }
                catch (Exception e)
                {
                    InvokerTab.Message = e.Message;
                }
                break;

            case "Price":
                try
                {
                    Console.Write("Enter new " + FieldName + ": ");
                    UserAnswer = Console.ReadLine();
                    obj        = Service.GetGood(ObjectId);
                    obj.SetPrice(UserAnswer);
                    Service.UpdateItem(obj);
                }
                catch (Exception e)
                {
                    InvokerTab.Message = e.Message;
                }
                break;

            case "Categories":
                obj = Service.GetGood(ObjectId);
                List <TabListElement> content = new List <TabListElement>();

                GoodCategory[] Categories = Service.GetGoodsCategoryes();
                foreach (GoodCategory Category in Categories)
                {
                    if (obj.CategoryesIds != null && obj.CategoryesIds.Any(item => item.Equals(Category.GUID)))
                    {
                        content.Add(new TabListElement(Category.Name, Id: Category.GUID, Checkable: true, Checked: true));
                    }
                    else
                    {
                        content.Add(new TabListElement(Category.Name, Id: Category.GUID, Checkable: true));
                    }
                }
                EditGoodCategoriesTab EditCatTab = new EditGoodCategoriesTab(Service, SetTabDelegate, InvokerTab, content, obj.GUID);
                SetTabDelegate.Invoke(EditCatTab, false);
                break;

            default:
                throw new UnexpectedFieldKey(FieldName);
            }
        }