Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (userAction != (int)Enums.UserAction.Add)
                {
                    model = issueDocumentRepo.GetIssueDocumentByID(issueDocumentID);

                    if (model != null)
                    {
                        GetIssueDocumentProvider().SetIssueDocumentModel(model);
                        FillForm();
                    }
                }

                FillDefaultValues();
                UserActionConfirmBtnUpdate(btnSaveChanges, userAction);
            }
            else
            {
                if (model == null && SessionHasValue(Enums.IssueDocumentSession.IssueDocumentModel))
                {
                    model = GetIssueDocumentProvider().GetIssueDocumentModel();
                }
            }
        }
Beispiel #2
0
        protected void gvDocuments_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            //Populate dto from session
            GetSessionValues();

            if (IssueBF.IssueDto.Documents[e.RowIndex].IsOld)
            {
                //Mark for deletion from database
                IssueBF.IssueDto.Documents[e.RowIndex].IsDeleted = true;
            }
            else
            {
                //Get the document
                IssueDocument issueDoc = IssueBF.IssueDto.Documents[e.RowIndex];

                try
                {
                    File.Delete(issueDoc.FullFileName);
                }
                catch (IOException ioEx)
                {
                    DisplayPopup("An error occured deleting the document.");
                }

                //Remove from documents list
                IssueBF.IssueDto.Documents.RemoveAt(e.RowIndex);
            }

            //Update session
            SetSessionValues();

            //Reload the grid
            LoadDocGrid();
        }
        public int SaveIssueDocument(IssueDocument model, int userID = 0)
        {
            try
            {
                model.tsUpdate       = DateTime.Now;
                model.tsUpdateUserID = userID;

                if (model.IssueDocumentID == 0)
                {
                    model.IssueNumber    = GetNextIssueDocumentNumber();
                    model.tsInsert       = DateTime.Now;
                    model.tsInsertUserID = userID;
                }

                model.Save();

                return(model.IssueDocumentID);
            }
            catch (Exception ex)
            {
                string error = "";
                CommonMethods.getError(ex, ref error);
                throw new Exception(CommonMethods.ConcatenateErrorIN_DB(DB_Exception.res_38, error, CommonMethods.GetCurrentMethodName()));
            }
        }
Beispiel #4
0
        public static Issue AdminGetIssue(Int32 VolumeIssueId)
        {
            Issue issue = new Issue();

            try
            {
                DataSet issueSet = IssueQueryHelper.AdminGetIssue(VolumeIssueId);

                if (issueSet.Tables.Count == 2)
                {
                    //Get the issue details
                    if (issueSet.Tables[0].Rows.Count > 0)
                    {
                        DataRow issRow = issueSet.Tables[0].Rows[0];

                        issue.IssueId = (Int32)issRow["IssueId"];

                        issue.IssueName = (string)issRow["IssueName"];

                        issue.IsActive = (bool)issRow["Active"];
                    }

                    //Get the documents
                    if (issueSet.Tables[1].Rows.Count > 0)
                    {
                        IssueDocument issDoc;

                        issue.Documents = new List <IssueDocument>();

                        foreach (DataRow docRow in issueSet.Tables[1].Rows)
                        {
                            issDoc = new IssueDocument();

                            issDoc.DocId = (Int32)docRow["DocId"];

                            issDoc.FullFileName = (string)docRow["FileName"];

                            issDoc.IssueDocTypeDescription = (string)docRow["IssueDocTypeDescription"];

                            issDoc.IssueDocTypeId = (Int32)docRow["IssueDocTypeId"];

                            issDoc.IsActive = (bool)docRow["Active"];

                            issDoc.IsNew = false;

                            issue.Documents.Add(issDoc);
                        }
                    }
                }

                return(issue);
            }
            catch (SqlException sqlEx)
            {
                Console.WriteLine(sqlEx.ToString());

                throw new DataException("An exception occured getting the issue details.", sqlEx);
            }
        }
Beispiel #5
0
        public void InitCommand(Database db, Int32 volumeIssueId, IssueDocument issueDoc)
        {
            dbCommand = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "VolumeIssueId", DbType.Int32, volumeIssueId);
            db.AddInParameter(dbCommand, "IssueDocTypeId", DbType.Int32, issueDoc.IssueDocTypeId);
            db.AddInParameter(dbCommand, "DocId", DbType.Int32, issueDoc.DocId);
        }
Beispiel #6
0
        public void InitCommand(Database db, Int32 volumeIssueId, IssueDocument issueDoc)
        {
            dbCommand = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "VolumeIssueId", DbType.Int32, volumeIssueId);
            db.AddInParameter(dbCommand, "IssueDocTypeId", DbType.Int32, issueDoc.IssueDocTypeId);
            db.AddInParameter(dbCommand, "Data", DbType.Binary, issueDoc.Data);
            db.AddInParameter(dbCommand, "FileName", DbType.String, issueDoc.FileName);
            db.AddInParameter(dbCommand, "FileSizeKB", DbType.Int32, issueDoc.CalculateFileSizeInKB());
            db.AddInParameter(dbCommand, "Comments", DbType.String, issueDoc.Comments);
            db.AddInParameter(dbCommand, "Active", DbType.Int32, ConvBoolToInt32(issueDoc.IsActive));
            db.AddInParameter(dbCommand, "CreationUserId", DbType.Int32, issueDoc.CreationUserId);
        }
Beispiel #7
0
        private IssueDocument GetDocValues()
        {
            IssueDocument issueDoc = new IssueDocument();

            issueDoc.IssueDocTypeId = Convert.ToInt32(ddlIssueDocTypes.SelectedValue);

            issueDoc.Comments = tbComments.Text.Trim();

            issueDoc.CreationUserId = UserInfo.UserDto.UserId;

            issueDoc.IsActive = Convert.ToBoolean(Convert.ToInt32(ddlDocStatus.SelectedValue));

            return(issueDoc);
        }
 public bool DeleteIssueDocument(IssueDocument model)
 {
     try
     {
         model.Delete();
         return(true);
     }
     catch (Exception ex)
     {
         string error = "";
         CommonMethods.getError(ex, ref error);
         throw new Exception(CommonMethods.ConcatenateErrorIN_DB(DB_Exception.res_39, error, CommonMethods.GetCurrentMethodName()));
     }
 }
 public static IssueDto AsDto(this IssueDocument document)
 => new IssueDto
 {
     Id           = document.Id,
     Type         = document.Type,
     Status       = document.Status,
     Title        = document.Title,
     Description  = document.Description,
     StoryPoints  = document.StoryPoints,
     ProjectId    = document.ProjectId,
     EpicId       = document.EpicId,
     SprintId     = document.SprintId,
     Assignees    = document.Assignees ?? Enumerable.Empty <Guid>(),
     LinkedIssues = document.LinkedIssues ?? Enumerable.Empty <Guid>(),
     CreatedAt    = document.CreatedAt
 };
Beispiel #10
0
        private bool AddOrEditEntityObject(bool add = false, bool completeIssueDocument = false)
        {
            if (add)
            {
                model = new IssueDocument(session);
                model.IssueDocumentID = 0;
                model.IssueStatus     = issueDocumentRepo.GetIssueDocumentStatusByCode(Enums.IssueDocumentStatus.DELOVNA, model.Session);
            }
            else if (!add && model == null)
            {
                model = GetIssueDocumentProvider().GetIssueDocumentModel();
            }

            model.IssueNumber = txtIssueDocumentNumber.Text;
            model.Name        = txtName.Text;
            model.IssueDate   = DateEditIssueDocumentDate.Date;

            int buyerID = CommonMethods.ParseInt(GetGridLookupValue(GridLookupBuyer));

            if (model.BuyerID != null)
            {
                model.BuyerID = clientRepo.GetClientByID(buyerID, model.BuyerID.Session);
            }
            else
            {
                model.BuyerID = clientRepo.GetClientByID(buyerID);
            }

            model.InternalDocument = txtInternalDocument.Text;
            model.InvoiceNumber    = txtInvoiceNumber.Text;
            model.Notes            = MemoNotes.Text;
            model.PermissionDoc    = txtPermissonDoc.Text;


            if (completeIssueDocument)
            {
                model.IssueStatus = issueDocumentRepo.GetIssueDocumentStatusByCode(Enums.IssueDocumentStatus.ZAKLJUCENO, model.Session);
                utilityRepo.ClearStockByIssueDocumentID(model.IssueDocumentPositions.ToList());
            }

            issueDocumentID = issueDocumentRepo.SaveIssueDocument(model, PrincipalHelper.GetUserID());

            return(true);
        }
Beispiel #11
0
        protected void gvDocuments_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType.Equals(DataControlRowType.DataRow))
            {
                if (IssueBF.IssueDto.Documents[e.Row.RowIndex].IsDeleted)
                {
                    e.Row.Visible = false;
                }

                Label lblDocType = (Label)e.Row.FindControl("lblDocType");

                IssueDocument issueDoc = (IssueDocument)e.Row.DataItem;

                if (!(lblDocType == null || issueDoc == null))
                {
                    ListItem liItem = ddlIssueDocTypes.Items.FindByValue(issueDoc.IssueDocTypeId.ToString());

                    if (liItem != null)
                    {
                        lblDocType.Text = liItem.Text;
                    }
                }
            }
        }
Beispiel #12
0
        protected void btnAddDoc_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                //Get session values
                GetSessionValues();

                try
                {
                    if (tbUploadDocument.HasFile && tbUploadDocument.PostedFile != null)
                    {
                        string fileName = SaveDocToTemp(tbUploadDocument);

                        IssueDocument issueDoc = GetDocValues();

                        issueDoc.FullFileName = fileName;

                        IssueBF.IssueDto.Documents.Add(issueDoc);

                        SetSessionValues();

                        LoadDocGrid();

                        ResetDocumentFormValues();
                    }
                    else
                    {
                        DisplayPopup("The document cannot be empty.  Please choose a document with content.");
                    }
                }
                catch (IOException ioEx)
                {
                    throw;
                }
            }
        }
Beispiel #13
0
 public void SetIssueDocumentModel(IssueDocument model)
 {
     AddValueToSession(Enums.IssueDocumentSession.IssueDocumentModel, model);
 }
Beispiel #14
0
 public static Issue AsEntity(this IssueDocument document)
 => new Issue(document.Id, document.ProjectId, document.SprintId);
 public static Issue AsEntity(this IssueDocument document)
 => new Issue(document.Id, document.Type, document.Status, document.Title, document.Description, document.StoryPoints, document.ProjectId, document.EpicId, document.SprintId, document.Assignees, document.LinkedIssues, document.CreatedAt);
        public int CreateIssueDocumentFromMobileTransactions(List <int> mobileTransactionsID, int userID, int buyerID)
        {
            UnitOfWork uow = XpoHelper.GetNewUnitOfWork();
            XPQuery <MobileTransaction>   mobileTrans   = uow.Query <MobileTransaction>();
            XPQuery <InventoryDeliveries> invDeliveries = uow.Query <InventoryDeliveries>();

            var mobileTransactions = mobileTrans.Where(mt => mobileTransactionsID.Any(mti => mti == mt.MobileTransactionID)).ToList();

            if (mobileTransactions != null && mobileTransactions.Count > 0)
            {
                var buyer = clientRepo.GetClientByID(buyerID, session);
                //from locationID we get buyer
                IssueDocument document = new IssueDocument(session);

                document.IssueDocumentID  = 0;
                document.IssueNumber      = GetNextIssueDocumentNumber();
                document.BuyerID          = buyer;
                document.IssueStatus      = GetIssueDocumentStatusByCode(Enums.IssueDocumentStatus.DELOVNA);
                document.IssueDate        = DateTime.Now;
                document.Name             = $"Izdaja materiala za kupca: {buyer.Name}";
                document.Notes            = "Prenos iz mobilnih transkacij";
                document.InternalDocument = "000000";
                document.InvoiceNumber    = DateTime.Now.Year.ToString() + "/000000";
                document.tsInsert         = DateTime.Now;
                document.tsInsertUserID   = userID;
                document.tsUpdate         = DateTime.Now;
                document.tsUpdateUserID   = userID;

                document.Save();

                var issueDocument         = GetIssueDocumentByID(document.IssueDocumentID, uow);
                IssueDocumentPosition pos = null;
                foreach (var item in mobileTransactions)
                {
                    pos = new IssueDocumentPosition(uow);

                    pos.IssueDocumentID = issueDocument;
                    pos.SupplierID      = clientRepo.GetClientByID(item.SupplierID.ClientID, uow);

                    //Kosovna količina
                    pos.Quantity = item.Quantity <= 0 ? invDeliveries.Count(inv => inv.PackagesUIDs.Contains(item.UIDCode)) : item.Quantity;// če se še ni shranila količina na mobilnih transkacijah jo poiščemo v invnetoryDeliveries

                    pos.UID250              = item.UIDCode;
                    pos.Name                = item.ProductID.Name;
                    pos.Notes               = "Prenos iz mobilnih transakcij";
                    pos.tsInsert            = DateTime.Now;
                    pos.tsInsertUserID      = userID;
                    pos.tsUpdate            = DateTime.Now;
                    pos.tsUpdateUserID      = userID;
                    pos.ProductID           = productRepo.GetProductByID(item.ProductID.ProductID, uow);
                    pos.MobileTransactionID = item;
                }

                uow.CommitChanges();


                return(document.IssueDocumentID);
            }

            return(-1);
        }