Exemple #1
0
        public ActionResult Edit(ItemSubGroup model)
        {
            model.OrganizationId = OrganizationId;
            model.CreatedDate    = System.DateTime.Now;
            model.CreatedBy      = UserID.ToString();

            var repo = new ItemSubGroupRepository();


            bool isexists = repo.IsFieldExists(repo.ConnectionString(), "ItemSubGroup", "ItemSubGroupName", model.ItemSubGroupName, "ItemSubGroupId", model.ItemSubGroupId);

            if (!isexists)
            {
                var result = new ItemSubGroupRepository().UpdateItemSubGroup(model);

                if (result.ItemSubGroupId > 0)
                {
                    TempData["Success"] = "Updated Successfully! (" + result.ItemSubGroupRefNo + ")";
                    return(RedirectToAction("Create"));
                }
                else
                {
                    FillItemGroup();
                    TempData["error"] = "Oops!!..Something Went Wrong!!";
                    return(View("Edit", model));
                }
            }
            else
            {
                FillItemGroup();
                TempData["error"] = "This Item Name Already Exists!!";
                return(View("Create", model));
            }
        }
Exemple #2
0
        private async void SaveCustomer()
        {
            IRestDataMapper mapper = containerExtension.Resolve <IRestDataMapper>();

            if (!string.IsNullOrEmpty(SelectedItemGroup.subGroupName))
            {
                ItemSubGroup g = await ItemRestService.CreateItemSubGroupAsync(mapper, SelectedItemGroup);

                if (g.id > 0)
                {
                    dialogService.ShowMsgDialog("New Item Group Creation", "Item Group Created Successfully", MsgDialogType.infor, (r) =>
                    {
                        LoadAllItemSubGroups();
                        NewCustomer();
                    });
                }
                else
                {
                    dialogService.ShowMsgDialog("New Item Group Creation", "Can't Save Item Group", MsgDialogType.error, (r) =>
                    {
                        return;
                    });
                }
            }
            else
            {
                dialogService.ShowMsgDialog("New Item Group Creation", "Invalid Item Group Details or Already Exist Customer", MsgDialogType.warrning, (r) =>
                {
                    return;
                });
            }
        }
        public ItemSubGroup InsertItemSubGroup(ItemSubGroup model)
        {
            using (IDbConnection connection = OpenConnection(dataConnection))
            {
                IDbTransaction trn = connection.BeginTransaction();
                string         sql = @"INSERT INTO ItemSubGroup (ItemSubGroupRefNo,ItemSubGroupName,ItemGroupId,
            CreatedBy,CreatedDate,OrganizationId) VALUES(@ItemSubGroupRefNo,@ItemSubGroupName,@ItemGroupId,@CreatedBy,getDate(),@OrganizationId);
            SELECT CAST(SCOPE_IDENTITY() as int)";

                int id = 0;

                try
                {
                    int internalid = DatabaseCommonRepository.GetInternalIDFromDatabase(connection, trn, typeof(ItemSubGroup).Name, "0", 1);
                    model.ItemSubGroupRefNo = "ISG/" + internalid;
                    id = connection.Query <int>(sql, model, trn).Single();
                    model.ItemSubGroupId = id;
                    InsertLoginHistory(dataConnection, model.CreatedBy, "Create", "Item Sub Group", id.ToString(), "0");
                    trn.Commit();
                }
                catch (Exception e)
                {
                    trn.Rollback();
                    model.ItemSubGroupId    = 0;
                    model.ItemSubGroupRefNo = null;
                }
                return(model);
            }
        }
        private void ItemSubGroupSelection(ItemSubGroup obj)
        {
            IEnumerable <ItemSubGroup> enumerable = iSubGroup.Items.Cast <ItemSubGroup>();
            ItemSubGroup isg = enumerable.Where(r => r.subGroupName.Equals(obj.subGroupName)).FirstOrDefault();
            int          i   = iSubGroup.Items.IndexOf(isg);

            iSubGroup.SelectedIndex = i;
        }
Exemple #5
0
        private async void NewCustomer()
        {
            aggregator.GetEvent <DataGridSelectionClearEvent>().Publish();
            aggregator.GetEvent <UIElementFocusEvent>().Publish("");
            await Task.Delay(1000);

            SelectedItemGroup = new ItemSubGroup()
            {
                id           = 0,
                subGroupName = string.Empty
            };
        }
        public static async Task <ItemSubGroup> GetItemSubGroupByNameAsync(IRestDataMapper mapper, string subGroupName)
        {
            ItemSubGroup reds = new ItemSubGroup();

            if (mapper == null)
            {
                return(reds);
            }
            string url = $"item/api/v1/itemsubgroup/{subGroupName}";

            reds = await mapper.GetDataAsync <ItemSubGroup>(url);

            return(reds);
        }
        public static async Task <ItemSubGroup> UpdateItemSubGroupAsync(IRestDataMapper mapper, ItemSubGroup data)
        {
            ItemSubGroup reds = new ItemSubGroup();

            if (mapper == null)
            {
                return(reds);
            }
            string url = $"item/api/v1/itemsubgroup/{data.id}";

            reds = await mapper.PutDataAsync(url, data);

            return(reds);
        }
Exemple #8
0
        public ActionResult Delete(ItemSubGroup model)
        {
            var result = new ItemSubGroupRepository().DeleteItemSubGroup(model);


            if (result.ItemSubGroupId > 0)
            {
                TempData["Success"] = "Deleted Successfully! (" + model.ItemSubGroupRefNo + ")";
                return(RedirectToAction("Create"));
            }
            else
            {
                TempData["error"] = "Oops!!..Something Went Wrong!!";
                return(View("Create", model));
            }
        }
        public ItemSubGroup UpdateItemSubGroup(ItemSubGroup model)
        {
            using (IDbConnection connection = OpenConnection(dataConnection))
            {
                string sql = @"UPDATE ItemSubGroup SET ItemSubGroupName = @ItemSubGroupName,ItemGroupId = @ItemGroupId, CreatedBy = @CreatedBy,CreatedDate= GETDATE(),OrganizationId = @OrganizationId OUTPUT INSERTED.ItemSubGroupId  WHERE ItemSubGroupId = @ItemSubGroupId";

                try
                {
                    var id = connection.Execute(sql, model);
                    model.ItemSubGroupId = id;
                    InsertLoginHistory(dataConnection, model.CreatedBy, "Update", "Item Sub Group", id.ToString(), "0");
                }
                catch (Exception ex)
                {
                    model.ItemSubGroupId = 0;
                }
                return(model);
            }
        }
        public ItemSubGroup DeleteItemSubGroup(ItemSubGroup model)
        {
            using (IDbConnection connection = OpenConnection(dataConnection))
            {
                string sql = @"UPDATE ItemSubGroup SET isActive = 0 OUTPUT INSERTED.ItemSubGroupId  WHERE ItemSubGroupId = @ItemSubGroupId";

                try
                {
                    var id = connection.Execute(sql, model);
                    model.ItemSubGroupId = id;
                    InsertLoginHistory(dataConnection, model.CreatedBy, "Delete", "Item Sub Group", id.ToString(), "0");
                }
                catch (Exception ex)
                {
                    model.ItemSubGroupId = 0;
                }
                return(model);
            }
        }
Exemple #11
0
        private async void UpdateCustomer()
        {
            IRestDataMapper mapper = containerExtension.Resolve <IRestDataMapper>();

            if (SelectedItemGroup != null)
            {
                if (SelectedItemGroup.id > 0)
                {
                    ItemSubGroup g = await ItemRestService.UpdateItemSubGroupAsync(mapper, SelectedItemGroup);

                    if (g.id > 0)
                    {
                        dialogService.ShowMsgDialog("Item Group Update", "Item Group Update Successfully", MsgDialogType.infor, (r) =>
                        {
                            LoadAllItemSubGroups();
                            NewCustomer();
                        });
                    }
                    else
                    {
                        dialogService.ShowMsgDialog("Item Group Update", "Can't Update Item Group", MsgDialogType.error, (r) =>
                        {
                            return;
                        });
                    }
                }
                else
                {
                    dialogService.ShowMsgDialog("Item Group Update", "Please Select Item Group Before Update", MsgDialogType.warrning, (r) =>
                    {
                        return;
                    });
                }
            }
            else
            {
                dialogService.ShowMsgDialog("Item Group Update", "Please Select Item Group Before Update", MsgDialogType.warrning, (r) =>
                {
                    return;
                });
            }
        }
Exemple #12
0
 public CustomList <ItemSubGroup> GetAllItemSubGroup(String itemGroupID)
 {
     return(ItemSubGroup.GetAllItemSubGroup(itemGroupID));
 }
Exemple #13
0
 public CustomList <ItemSubGroup> GetAllItemSubGroup()
 {
     return(ItemSubGroup.GetAllItemSubGroup());
 }