Пример #1
0
        public DirectResult Save(iffsSurveyRequest SurveyRequest)
        {
            using (var transaction = new TransactionScope((TransactionScopeOption.Required), new TransactionOptions {
                IsolationLevel = IsolationLevel.ReadCommitted
            }))
            {
                _context.Database.Connection.Open();
                _context.Database.CommandTimeout = int.MaxValue;
                try
                {
                    int employeeId = 0;
                    var objUser    = (coreUser)Session[Constants.CurrentUser];
                    if (objUser != null && objUser.EmployeeId != null)
                    {
                        employeeId = (int)objUser.EmployeeId;
                    }
                    if (SurveyRequest.Id.Equals(0))
                    {
                        SurveyRequest.PreparedById = employeeId;
                        SurveyRequest.Date         = DateTime.Now;

                        /* ***************************************************
                        * Concurrency controlling scheme using global locking
                        * ***************************************************/

                        var objOperationType = _lookup.GetAll((Lookups.LupOperationType)).Where(o => o.Id == SurveyRequest.Id).FirstOrDefault();
                        CyberErp.Presentation.Iffs.Web.MvcApplication httpapplication = HttpContext.ApplicationInstance as CyberErp.Presentation.Iffs.Web.MvcApplication;
                        httpapplication.Application.Lock();
                        SurveyRequest.Number = _documentNoSetting.GetDocumentNumber("SurveyRequest");//objOperationType.Code + "/" +
                        _SurveyRequest.Add(SurveyRequest);
                        _documentNoSetting.SaveChanges();
                        httpapplication.Application.UnLock();

                        _notification.AddNew(new iffsNotification
                        {
                            Operation = Constants.SURVEYREQUEST,
                            ObjectId  = SurveyRequest.Id,
                            ActorId   = SurveyRequest.PreparedById,
                            Date      = DateTime.Now,
                            Message   = "Ordering Client Address: " + SurveyRequest.OrderingClientId + " Receiving Client Address: " + SurveyRequest.ReceivingClientId,
                            IsViewed  = false
                        });
                    }
                    else
                    {
                        _SurveyRequest.Edit(SurveyRequest);
                    }
                    _context.SaveChanges();
                    transaction.Complete();
                    return(this.Json(new { success = true, data = "Survey Request has been saved Successfully!" }));
                }
                catch (Exception exception)
                {
                    return(this.Json(new { success = false, data = exception.InnerException != null ? exception.InnerException.Message : exception.Message }));
                }
            }
        }
Пример #2
0
        public ActionResult Save(iffsInvoiceHeader invoiceHeader)
        {
            using (var transaction = new TransactionScope((TransactionScopeOption.Required), new TransactionOptions {
                IsolationLevel = IsolationLevel.ReadCommitted
            }))
            {
                _context.Database.Connection.Open();
                _context.Database.CommandTimeout = int.MaxValue;

                var    hashtable = JsonConvert.DeserializeObject <Hashtable>(Request.Params["record"]);
                string action    = hashtable["action"].ToString();
                try
                {
                    if (Request.Params["WithHoldingApplied"] != null && Request.Params["WithHoldingApplied"].ToString().Equals("on"))
                    {
                        invoiceHeader.WithHoldingApplied = true;
                    }
                    else
                    {
                        invoiceHeader.WithHoldingApplied = false;
                    }

                    if (invoiceHeader.Id == 0)
                    {
                        invoiceHeader.PreparedDate = DateTime.Now;
                        CyberErp.Presentation.Iffs.Web.MvcApplication httpapplication = HttpContext.ApplicationInstance as CyberErp.Presentation.Iffs.Web.MvcApplication;
                        httpapplication.Application.Lock();
                        if (action == "Add" && invoiceHeader.InvoiceNo == "Auto-Genereted")
                        {
                            invoiceHeader.InvoiceNo = GetDocumentNumber("Invoice");
                        }
                        _invoiceHeader.AddNew(invoiceHeader);
                        if (action == "Add" && invoiceHeader.InvoiceNo == "Auto-Genereted")
                        {
                            UpdateDocumentNumber("Invoice");
                        }
                        httpapplication.Application.UnLock();
                    }
                    else
                    {
                        _invoiceHeader.Edit(invoiceHeader);
                    }
                    var servicesString = hashtable["services"].ToString();
                    var operationIds   = hashtable["operationIds"].ToString();

                    SaveInvoiceOperations(operationIds, invoiceHeader.Id);
                    saveDetail(servicesString, invoiceHeader.Id);
                    _context.SaveChanges();
                    transaction.Complete();
                    return(this.Json(new { success = true, data = "Data has been saved successfully!", invoiceId = invoiceHeader.Id }));
                }
                catch (Exception exception)
                {
                    return(this.Json(new { success = false, data = exception.InnerException != null ? exception.InnerException.Message : exception.Message }));
                }
            }
        }
Пример #3
0
        //[FormHandler]
        public DirectResult Save(iffsSchedule schedule)
        {
            using (var transaction = new TransactionScope((TransactionScopeOption.Required), new TransactionOptions {
                IsolationLevel = IsolationLevel.ReadCommitted
            }))
            {
                _context.Database.Connection.Open();
                _context.Database.CommandTimeout = int.MaxValue;
                try
                {
                    // Request.Params[""]
                    int employeeId = 0;
                    schedule.StartTime = schedule.StartDate.TimeOfDay;
                    schedule.EndTime   = schedule.EndDate.TimeOfDay;
                    var objUser = (coreUser)Session[Constants.CurrentUser];
                    if (objUser != null && objUser.EmployeeId != null)
                    {
                        employeeId = (int)objUser.EmployeeId;
                    }
                    if (schedule.Id.Equals(0))
                    {
                        schedule.PreparedById = employeeId;

                        /* ***************************************************
                        * Concurrency controlling scheme using global locking
                        * ***************************************************/

                        //  var objOperationType = _lookup.GetAll((Lookups.LupOperationType)).Where(o => o.Id == Packing.Id).FirstOrDefault();
                        CyberErp.Presentation.Iffs.Web.MvcApplication httpapplication = HttpContext.ApplicationInstance as CyberErp.Presentation.Iffs.Web.MvcApplication;
                        httpapplication.Application.Lock();
                        //  Packing.Number = GetDocumentNumber("Packing");//objOperationType.Code + "/" +
                        _Schedule.AddNew(schedule);
                        // UpdateDocumentNumber("Packing");
                        httpapplication.Application.UnLock();
                    }
                    else
                    {
                        _Schedule.Edit(schedule);
                    }
                    _context.SaveChanges();
                    transaction.Complete();
                    return(this.Json(new { success = true, data = "Schedule has been saved Successfully!" }));
                }
                catch (Exception exception)
                {
                    return(this.Json(new { success = false, data = exception.InnerException != null ? exception.InnerException.Message : exception.Message }));
                }
            }
        }
Пример #4
0
        public ActionResult Save(iffsQuotationHeaderExt quotationExt)
        {
            using (var transaction = new TransactionScope((TransactionScopeOption.Required), new TransactionOptions {
                IsolationLevel = IsolationLevel.ReadCommitted
            }))
            {
                _context.Database.Connection.Open();
                _context.Database.CommandTimeout = int.MaxValue;

                var    hashtable = JsonConvert.DeserializeObject <Hashtable>(quotationExt.record);
                string action    = hashtable["action"].ToString();
                iffsQuotationHeader quotation = new iffsQuotationHeader();
                Utility.CopyObject(quotationExt, quotation);
                var quotationNo = quotation.QuotationNo;
                try
                {
                    if (quotation.Id == 0)
                    {
                        quotation.PreparedDate = DateTime.Now;
                        CyberErp.Presentation.Iffs.Web.MvcApplication httpapplication = HttpContext.ApplicationInstance as CyberErp.Presentation.Iffs.Web.MvcApplication;
                        httpapplication.Application.Lock();
                        if (action == "Add" && quotationNo == "Auto-Genereted")
                        {
                            quotation.QuotationNo = GetDocumentNumber("Quotation");
                        }
                        _quotationHeader.AddNew(quotation);
                        if (action == "Add" && quotationNo == "Auto-Genereted")
                        {
                            UpdateDocumentNumber("Quotation");
                        }
                        httpapplication.Application.UnLock();
                    }
                    else
                    {
                        _quotationHeader.Edit(quotation);
                    }
                    var servicesString = hashtable["services"].ToString();
                    saveDetail(servicesString, quotation.Id);
                    _context.SaveChanges();
                    transaction.Complete();
                    return(this.Json(new { success = true, data = "Data has been saved successfully!", quotationId = quotation.Id }));
                }
                catch (Exception exception)
                {
                    return(this.Json(new { success = false, data = exception.InnerException != null ? exception.InnerException.Message : exception.Message }));
                }
            }
        }
Пример #5
0
        public ActionResult Save(iffsOperation operation)
        {
            using (var transaction = new TransactionScope((TransactionScopeOption.Required), new TransactionOptions {
                IsolationLevel = IsolationLevel.ReadCommitted
            }))
            {
                _context.Database.Connection.Open();
                _context.Database.CommandTimeout = int.MaxValue;
                try
                {
                    int employeeId = 0;
                    var objUser    = (coreUser)Session[Constants.CurrentUser];
                    if (objUser != null && objUser.EmployeeId != null)
                    {
                        employeeId = (int)objUser.EmployeeId;
                    }


                    if (operation.Id.Equals(0))
                    {
                        operation.PreparedById = employeeId;
                        operation.PreparedDate = DateTime.Now;

                        CyberErp.Presentation.Iffs.Web.MvcApplication httpapplication = HttpContext.ApplicationInstance as CyberErp.Presentation.Iffs.Web.MvcApplication;
                        httpapplication.Application.Lock();
                        //operation.OperationNo = GetDocumentNumber("Operation");
                        _operation.AddNew(operation);
                        //UpdateDocumentNumber("Operation");
                        httpapplication.Application.UnLock();
                    }
                    else
                    {
                        _operation.Edit(operation);
                    }

                    _context.SaveChanges();
                    transaction.Complete();
                    return(this.Json(new { success = true, data = "Data has been saved successfully!" }));
                }
                catch (Exception exception)
                {
                    return(this.Json(new { success = false, data = exception.InnerException != null ? exception.InnerException.Message : exception.Message }));
                }
            }
        }
Пример #6
0
        public DirectResult Save(iffsJobOrderHeader jobOrderHeader)
        {
            using (var transaction = new TransactionScope((TransactionScopeOption.Required), new TransactionOptions {
                IsolationLevel = IsolationLevel.ReadCommitted
            }))
            {
                _context.Database.Connection.Open();
                _context.Database.CommandTimeout = int.MaxValue;
                try
                {
                    int employeeId = 0;
                    var objUser    = (coreUser)Session[Constants.CurrentUser];
                    if (objUser != null && objUser.EmployeeId != null)
                    {
                        employeeId = (int)objUser.EmployeeId;
                    }

                    var hashtable            = JsonConvert.DeserializeObject <Hashtable>(Request.Params["record"]);
                    var voucherDetailsString = hashtable["templateDetails"].ToString();
                    voucherDetailsString = voucherDetailsString.Remove(voucherDetailsString.Length - 1);
                    var    voucherDetails = voucherDetailsString.Split(new[] { ';' });
                    string action         = hashtable["action"].ToString();
                    var    jobOrderNo     = jobOrderHeader.JobOrderNo;
                    if (Request.Params["IsViewed"] != null)
                    {
                        jobOrderHeader.IsViewed = true;
                    }


                    if (jobOrderHeader.Id.Equals(0))
                    {
                        jobOrderHeader.PreparedById = employeeId;
                        jobOrderHeader.PreparedDate = DateTime.Now;


                        /* ***************************************************
                        * Concurrency controlling scheme using global locking
                        * ***************************************************/
                        if (jobOrderNo == "Auto-Generated")
                        {
                            var objOperationType = _lookup.GetAll((Lookups.LupOperationType)).Where(o => o.Id == jobOrderHeader.OperationTypeId).FirstOrDefault();
                            CyberErp.Presentation.Iffs.Web.MvcApplication httpapplication = HttpContext.ApplicationInstance as CyberErp.Presentation.Iffs.Web.MvcApplication;
                            httpapplication.Application.Lock();
                            jobOrderHeader.JobOrderNo = objOperationType.Code + "/" + GetDocumentNumber("JobOrder");
                            jobOrderHeader.Version    = "000";
                            _jobOrderHeader.AddNew(jobOrderHeader);
                            UpdateDocumentNumber("JobOrder");
                            httpapplication.Application.UnLock();
                        }
                        else
                        {
                            _jobOrderHeader.AddNew(jobOrderHeader);
                        }
                    }
                    else
                    {
                        if (action == "Revised")
                        {
                            var    objJobOrder     = _jobOrderHeader.Get(j => j.Id == jobOrderHeader.ParentJobOrderId);
                            var    objJobHistories = _historyHeader.GetAll().Where(h => h.ParentJobOrderId == jobOrderHeader.ParentJobOrderId);
                            var    objJobDetail    = _jobOrderDetail.GetAll().Where(o => o.JobOrderHeaderId == jobOrderHeader.ParentJobOrderId);
                            int    versionint      = 0;
                            string version         = "";
                            if (objJobHistories.Any())
                            {
                                var lastVersion = objJobHistories.LastOrDefault().Version;
                                versionint = Convert.ToInt32(lastVersion);
                                versionint = versionint + 1;
                                version    = "00" + versionint.ToString();
                            }
                            else
                            {
                                version = "001";
                            }

                            //Make the copy of the previous joborder in history table

                            iffsJobOrderHistoryHeader history = new iffsJobOrderHistoryHeader();
                            history.Quotations           = objJobOrder.Quotations;
                            history.JobOrderNo           = objJobOrder.JobOrderNo;
                            history.OperationTypeId      = objJobOrder.OperationTypeId;
                            history.ParentJobOrderId     = objJobOrder.Id;
                            history.Version              = version;
                            history.ValidityDate         = objJobOrder.ValidityDate;
                            history.UltimateClient       = objJobOrder.UltimateClient;
                            history.ReceivingClient      = objJobOrder.ReceivingClient;
                            history.ContactPersonForeign = objJobOrder.ContactPersonForeign;
                            history.ContactPersonLocal   = objJobOrder.ContactPersonLocal;
                            history.PreparedById         = objJobOrder.PreparedById;
                            history.PreparedDate         = objJobOrder.PreparedDate;
                            history.CheckedById          = objJobOrder.CheckedById;
                            history.CheckedDate          = objJobOrder.CheckedDate;
                            history.ApprovedById         = objJobOrder.ApprovedById;
                            history.ApprovedDate         = objJobOrder.ApprovalDate;
                            history.Status   = objJobOrder.Status;
                            history.IsViewed = objJobOrder.IsViewed;
                            history.Remark   = objJobOrder.Remark;
                            history.IsRequiredDocumentsSubmited = objJobOrder.IsRequiredDocumentsSubmited;
                            _historyHeader.AddNew(history);

                            foreach (var d in objJobDetail)
                            {
                                iffsJobOrderHistoryDetail historyDetail = new iffsJobOrderHistoryDetail();
                                historyDetail.JobOrderHeaderId = history.Id;
                                historyDetail.FieldCategory    = d.FieldCategory;
                                historyDetail.Field            = d.Field;
                                historyDetail.Value            = d.Value;
                                _historyDetail.AddNew(historyDetail);
                            }
                            _context.Entry(objJobOrder).State = EntityState.Detached;

                            jobOrderHeader.CheckedById  = null;
                            jobOrderHeader.CheckedDate  = null;
                            jobOrderHeader.ApprovedById = null;
                            jobOrderHeader.ApprovalDate = null;
                        }
                        _jobOrderHeader.Edit(jobOrderHeader);
                    }

                    var quotations = Request.Form["QuotationRecs"];
                    quotations = quotations.Remove(quotations.Length - 1);
                    var quotationDetails = quotations.Split(new[] { ';' });

                    SaveJobOrderDetails(jobOrderHeader, voucherDetails.ToList(), action, quotationDetails.ToList());

                    //if (action != "Revised")
                    //{
                    //    var quotations = Request.Form["QuotationRecs"];
                    //    quotations = quotations.Remove(quotations.Length - 1);
                    //    var quotationDetails = quotations.Split(new[] { ';' });

                    //    SaveJobOrderDetails(jobOrderHeader, voucherDetails.ToList(), action, quotationDetails.ToList());
                    //}
                    //else
                    //{
                    //    SaveJobOrderDetails(jobOrderHeader, voucherDetails.ToList(), action, null);

                    //}

                    _context.SaveChanges();
                    transaction.Complete();
                    return(this.Json(new { success = true, data = "Job Order has been saved Successfully!" }));
                }
                catch (Exception exception)
                {
                    return(this.Json(new { success = false, data = exception.InnerException != null ? exception.InnerException.Message : exception.Message }));
                }
            }
        }
Пример #7
0
        public DirectResult SaveSetting(int parentId, IList<iffsPackingListSetting> PackingListSettings)
        {
            using (var transaction = new TransactionScope((TransactionScopeOption.Required), new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted }))
            {
                _context.Database.Connection.Open();
                _context.Database.CommandTimeout = int.MaxValue;
                try
                {
                    foreach (var item in PackingListSettings)
                    {
                        // Request.Params[""]
                        int employeeId = 0;
                        var objUser = (coreUser)Session[Constants.CurrentUser];
                        if (objUser != null && objUser.EmployeeId != null)
                        {
                            employeeId = (int)objUser.EmployeeId;
                        }
                        if (parentId != 0)
                            item.ParentId = parentId;
                        if (item.Id.Equals(0))
                        {

                            /* ***************************************************
                            * Concurrency controlling scheme using global locking                                              
                            * ***************************************************/

                            //  var objOperationType = _lookup.GetAll((Lookups.LupOperationType)).Where(o => o.Id == PackingList.Id).FirstOrDefault();
                            CyberErp.Presentation.Iffs.Web.MvcApplication httpapplication = HttpContext.ApplicationInstance as CyberErp.Presentation.Iffs.Web.MvcApplication;
                            httpapplication.Application.Lock();
                            //  PackingList.Number = GetDocumentNumber("PackingList");//objOperationType.Code + "/" + 
                            _PackingListSetting.AddNew(item);
                            // UpdateDocumentNumber("PackingList");
                            httpapplication.Application.UnLock();
                        }
                        else
                        {
                            _PackingListSetting.Edit(item);
                        }
                    }
                    _context.SaveChanges();
                    transaction.Complete();
                    return this.Json(new { success = true, data = "PackingList has been saved Successfully!" });
                }
                //catch (SQLException Ex)
                //{

                //}
                catch (Exception ex)
                {
                    if (ex.InnerException.InnerException is SqlException)
                    {
                        SqlException sqlException = ex.InnerException.InnerException as SqlException;
                        if (sqlException.Number == 2601)
                            return this.Json(new { success = false, data = "The items that are entered are already exist!! " });
                        return this.Json(new { success = false, data = ex.InnerException != null ? ex.InnerException.Message : ex.Message });

                    }
                    return this.Json(new { success = false, data = ex.InnerException != null ? ex.InnerException.Message : ex.Message });
                }
            }
        }