コード例 #1
0
        public UnpaidPurchaseInvoiceModel GetDataIntoModel()
        {
            UnpaidPurchaseInvoiceModel JForm = new UnpaidPurchaseInvoiceModel();

            JForm.UnpaidPurchaseInvoiceDetailsData = new List <UnpaidPurchaseInvoiceEntity>();
            //UnpaidSalesInvoiceEntity model = new UnpaidSalesInvoiceEntity();

            //JForm.UnpaidSalesInvoiceData = model;

            foreach (var item in UnpaidPurchaseInvoicedetailsEntity)
            {
                if (item.ID != null)
                {
                    UnpaidPurchaseInvoiceEntity jEntity = new UnpaidPurchaseInvoiceEntity();
                    jEntity.ID              = item.ID;
                    jEntity.SupplierName    = item.SupplierName;
                    jEntity.InvoiceNo       = "OPI-" + item.InvoiceNo;
                    jEntity.UnpaidAmount    = item.UnpaidAmount;
                    jEntity.InvoiceDate     = item.InvoiceDate;
                    jEntity.InvoiceDateTime = DateTime.ParseExact(item.InvoiceDate, DateFormat, null);
                    if (item.ID != 0 && Convert.ToInt32(item.ID) > 0)
                    {
                        JForm.UnpaidPurchaseInvoiceDetailsData.Add(jEntity);
                    }
                }
            }

            return(JForm);
        }
コード例 #2
0
        public int SaveUnpaidPurchaseInvoiceData(UnpaidPurchaseInvoiceModel JForm)
        {
            //int autoId = 0;
            // UnpaidSalesInvoice obj = new UnpaidSalesInvoice();
            try
            {
                using (SASEntitiesEDM entities = new SASEntitiesEDM())
                {
                    UnpaidPurchaseInvoice obj1;
                    if (JForm.UnpaidPurchaseInvoiceDetailsData != null)
                    {
                        foreach (UnpaidPurchaseInvoiceEntity JEntity in JForm.UnpaidPurchaseInvoiceDetailsData)
                        {
                            //save entity value
                            obj1                 = new UnpaidPurchaseInvoice();
                            obj1.S_ID            = JEntity.ID;
                            obj1.UnpaidPI_No     = JEntity.InvoiceNo;
                            obj1.UnpaidPI_Date   = JEntity.InvoiceDateTime;
                            obj1.UnpaidPI_Amount = JEntity.UnpaidAmount;
                            obj1.CreatedDate     = DateTime.Now;
                            obj1.IsDeleted       = false;
                            if (obj1 != null)
                            {
                                entities.UnpaidPurchaseInvoices.Add(obj1);
                                entities.SaveChanges();
                            }
                            //if (entities.UnpaidPurchaseInvoices.AsNoTracking().FirstOrDefault(x => x.ID == JEntity.ID) == null)
                            //{
                            //    entities.UnpaidPurchaseInvoices.Add(obj1);
                            //    entities.SaveChanges();

                            //}
                            //else
                            //{
                            //    entities.Entry(obj1).State = EntityState.Modified;
                            //    entities.SaveChanges();
                            //}
                        }
                    }

                    else
                    {
                    }
                }
                return(1);
            }
            catch (Exception e)
            {
                //    return 0;
                throw e;
            }
        }
コード例 #3
0
        public string ValidateJournal()
        {
            string msg = string.Empty;
            UnpaidPurchaseInvoiceModel JForm = GetDataIntoModel();
            //var tempInvoiceNumber = unpaidInvoiceRepository.IsChequeNoPresent();
            //string result = JForm.UnpaidPurchaseInvoiceDetailsData.Where(x => x.InvoiceNo == tempInvoiceNumber).Select(x => x.InvoiceNo).FirstOrDefault();
            //if (result != null)
            //{
            //    msg = "Entry against Cheque No is already done";
            //}
            //if (result == null)
            //{
            //    msg = "No Entry is done till Now";
            //}
            List <string> ListInvoiceNumber = unpaidInvoiceRepository.IsChequeNoPresent();
            List <string> InsideList        = JForm.UnpaidPurchaseInvoiceDetailsData.Select(x => x.InvoiceNo).ToList();
            List <string> PINumberList      = InsideList.Distinct().ToList();

            foreach (var item in JForm.UnpaidPurchaseInvoiceDetailsData)
            {
                if (InsideList.Count != PINumberList.Count)
                {
                    msg = "Two Invoice Number Should Not Be Same";
                    //this.CASErrors =msg;
                    break;
                }
                if (ListInvoiceNumber == null)
                {
                    msg = "No Entry is done till Now";
                    //this.CASErrors=msg;
                    break;
                }
                if (ListInvoiceNumber.Contains(item.InvoiceNo))
                {
                    msg = "Entry against Cheque No is already done ";
                    // this.CASErrors = msg;
                    break;
                }
            }

            return(msg);
        }
コード例 #4
0
        public void SaveUnpaidPurchaseInvoice(object param)
        {
            MessageBoxResult result = System.Windows.MessageBox.Show("Do you want to save changes?", "Save Confirmation", MessageBoxButton.YesNo);

            if (result == MessageBoxResult.Yes)
            {
                Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
                string msg = ValidateJournal();
                if (msg != string.Empty && msg != "No Entry is done till Now")
                {
                    CASErrors            = msg;
                    Mouse.OverrideCursor = null;
                    return;
                }
                else
                {
                    CASErrors = string.Empty;
                    UnpaidPurchaseInvoiceModel JForm = GetDataIntoModel();
                    unpaidInvoiceRepository.SaveUnpaidPurchaseInvoiceData(JForm);
                    Mouse.OverrideCursor = null;
                }
            }
        }
コード例 #5
0
        public int SaveUnpaidPurchaseInvoiceData(UnpaidPurchaseInvoiceModel JForm)
        {
            IUnpaidPurchaseInvoiceDAL obj = new UnpaidPurchaseInvoiceDAL();

            return(obj.SaveUnpaidPurchaseInvoiceData(JForm));
        }