Exemplo n.º 1
0
    protected void btnExcel_Click(object sender, EventArgs e)
    {
        if (Session["ViewAdjustments-Where"] != null)
        {
            string where = Session["ViewAdjustments-Where"].ToString();
            if (!string.IsNullOrEmpty(where))
            {
                int maximumRows   = int.MaxValue;
                int startRowIndex = 0;

                List <TransactionLines> transactionList = TransactionLines.GetPagedAdjustmentsByDateInterval(ref maximumRows, ref startRowIndex, where);
                gvExport.DataSource = transactionList;
                gvExport.DataBind();
                gvExport.Visible = true;
            }

            Response.Clear();
            Response.AddHeader("content-disposition", "attachment;filename=ViewAdjustments.xls");
            Response.Charset = "";

            // If you want the option to open the Excel file without saving then
            // comment out the line below
            // Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.ContentType = "application/ms-excel";
            System.IO.StringWriter       stringWrite = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter htmlWrite   = new HtmlTextWriter(stringWrite);
            gvExport.RenderControl(htmlWrite);
            Response.Write(stringWrite.ToString());
            Response.End();

            gvExport.Visible = false;
        }
    }
    protected void btnRemove_Click(object sender, EventArgs e)
    {
        try
        {
            int    id  = -1;
            string _id = Request.QueryString["id"].ToString();
            int.TryParse(_id, out id);
            int userId = CurrentEnvironment.LoggedUser.Id;

            int i = TransactionLines.Delete(id);

            if (i > 0)
            {
                lblSuccess.Visible = true;
                lblWarning.Visible = false;
                lblError.Visible   = false;
                gvTransactionLines.DataBind();
                ClearControls(this);
            }
            else
            {
                lblSuccess.Visible = false;
                lblWarning.Visible = true;
                lblError.Visible   = false;
            }
        }
        catch (Exception ex)
        {
            lblSuccess.Visible = false;
            lblWarning.Visible = false;
            lblError.Visible   = true;
        }
    }
 protected bool tlExists(int transactionId, int lotid)
 {
     if (TransactionLines.GetTransactionLinesByTransactionIdLotId(transactionId, lotid) != null)
     {
         lblSuccess.Visible = false;
         lblWarning.Visible = true;
         lblError.Visible   = false;
         return(true);
     }
     return(false);
 }
Exemplo n.º 4
0
 private void btnDelete_ItemClick(object sender, ItemClickEventArgs e)
 {
     try
     {
         if (LinesView.FocusedRowHandle >= 0)
         {
             TransactionLines l = lines.Get(long.Parse(LinesView.GetRowCellValue(LinesView.FocusedRowHandle, LinesView.Columns[0]).ToString()));
             lines.Delete(l);
             LinesView.DeleteRow(LinesView.FocusedRowHandle);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 5
0
        private void ExecuteSaveItemViewCommand(object obj)
        {
            try
            {
                CurrentItem.CategoryId      = SelectedCategory.Id;
                CurrentItem.UnitOfMeasureId = SelectedUnitOfMeasure.Id;

                var stat = _itemService.InsertOrUpdate(CurrentItem);
                if (stat == string.Empty)
                {
                    if (SelectedTransaction != null)
                    {
                        //if (TransactionQuantity == null || (TransactionQuantity!=null && TransactionQuantity<=0))
                        //{
                        //    MessageBox.Show("Quantity Can't Be Empty and Less than or equalzero");
                        //    return;
                        //}

                        var selectedTransactionLine = new TransactionLineDTO()
                        {
                            TransactionId = SelectedTransaction.Id
                        };

                        if (SelectedTransaction.Id == 0)
                        {
                            selectedTransactionLine.Transaction = SelectedTransaction;
                        }

                        selectedTransactionLine.ItemId    = CurrentItem.Id;
                        selectedTransactionLine.Unit      = (decimal)TransactionLine.UnitQuantity;// TransactionQuantity;
                        selectedTransactionLine.EachPrice = 0;
                        stat = new TransactionService(true).InsertOrUpdateChild(selectedTransactionLine);
                        if (string.IsNullOrEmpty(stat))
                        {
                            selectedTransactionLine.Item = new ItemDTO()
                            {
                                ItemCode = CurrentItem.ItemCode,
                                Id       = CurrentItem.Id
                            };
                            TransactionLines.Add(selectedTransactionLine);
                        }
                    }

                    #region Change Item Qty after adding a new PI

                    //if (QuantityEditVisibility != null && QuantityEditVisibility == "Visible" &&
                    //    _itemPreviousQty != CurrentQuantity && SelectedWarehouse != null && SelectedWarehouse.Id != -1)
                    //{
                    //    var itemQty = new ItemQuantityDTO
                    //    {
                    //        WarehouseId = SelectedWarehouse.Id,
                    //        ItemId = CurrentItem.Id,
                    //        QuantityOnHand = CurrentQuantity
                    //    };
                    //    var stat2 = _itemQuantityService.InsertOrUpdate(itemQty, true);

                    //    if (stat2 == string.Empty)
                    //        CloseWindow(obj);
                    //    else
                    //        MessageBox.Show(
                    //            "item detail saved successfully but updating quantity failed, try again..." +
                    //            Environment.NewLine + stat2, "save error", MessageBoxButton.OK, MessageBoxImage.Error);
                    //}
                    //else
                    //{
                    //    CloseWindow(obj);
                    //}
                    #endregion

                    CurrentItem         = GetNewCurrentItem();
                    TransactionLine     = new TransactionLineModel();
                    ItemsListVisibility = "Collapsed";
                    _itemPreviousQty    = 0;
                }
                else
                {
                    MessageBox.Show("Got Problem while saving item, try again..." + Environment.NewLine + stat, "save error", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("Problem saving Item..." +
                                Environment.NewLine + exception.Message +
                                Environment.NewLine + exception.InnerException);
            }
        }
        public LocalReport GetDelivaryReport(
            String Receipt)
        {
            string receipt = Receipt;

            int                 type                = 2;
            int                 entryStatus         = 0;
            int                 transactionStatus   = 0;
            int                 defaultAddressType  = 0;
            Transaction         TransactionHeader   = new Transaction();
            TransactionCustomer TransactionCustomer = new TransactionCustomer();
            TransactionLines    TransactionLines    = new TransactionLines(null);

            using (var db = new DeliveryDbContext(builder.ConnectionString))
            {
                var transaction = from tra_h in db.RBOTRANSACTIONTABLE
                                  join sto in db.RBOSTORETABLE on tra_h.STORE equals sto.STOREID
                                  where tra_h.RECEIPTID == receipt &&
                                  tra_h.TYPE == type &&
                                  tra_h.ENTRYSTATUS == entryStatus
                                  select new Transaction()
                {
                    ReceiptID = tra_h.RECEIPTID,
                    StoreID   = sto.STOREID,
                    Name      = sto.NAME,
                    TransDate = tra_h.TRANSDATE ?? DateTime.MinValue,
                    NetAmount = tra_h.NETAMOUNT ?? 0
                };
                //  LINENUM   changed to LINENUM = (decimal)tra_i.LINEID  in line 195 colu 156 by rafeeq
                var transactionLine = from tra_h in db.RBOTRANSACTIONTABLE
                                      join tra_l in db.RBOTRANSACTIONSALESTRANS
                                      on tra_h.TRANSACTIONID equals tra_l.TRANSACTIONID
                                      join tra_i in db.RBOTRANSACTIONINFOCODETRANS
                                      on
                                      new { tra_l.TRANSACTIONID, tra_l.LINENUM, INFOCODEID = Program.isDelevary } equals new { tra_i.TRANSACTIONID, LINENUM = (decimal)tra_i.LINEID, tra_i.INFOCODEID } into info_d
                from info in info_d.DefaultIfEmpty()
                join info_sub in db.RBOINFORMATIONSUBCODETABLE on
                    info.INFORMATION equals info_sub.SUBCODEID into info_sub_d
                from info_s in info_sub_d.DefaultIfEmpty()
                where tra_h.RECEIPTID == receipt &&
                tra_h.TYPE == type &&
                tra_h.ENTRYSTATUS == entryStatus &&
                tra_l.TRANSACTIONSTATUS == transactionStatus
                    select new TransactionLine()
                {
                    ItemId         = tra_l.ITEMID,
                    Description    = tra_l.DESCRIPTION,
                    Qty            = (tra_l.QTY ?? 0) * -1,
                    TaxInckInPrice = tra_l.TAXINCLINPRICE ?? 0,
                    Comment        = tra_l.COMMENT,
                    ExtraInfo      = string.IsNullOrEmpty(info_s.DESCRIPTION) ? "NON DELIVERABLE" : info_s.DESCRIPTION
                };

                var transactionCustomer = from tra_h in db.RBOTRANSACTIONTABLE
                                          join tra_i in db.RBOTRANSACTIONINFOCODETRANS
                                          on
                                          new { tra_h.TRANSACTIONID, INFOCODEID = Program.customerInfoCode } equals new { tra_i.TRANSACTIONID, tra_i.INFOCODEID } into info_d
                from info in info_d.DefaultIfEmpty()
                join cust in db.CUSTTABLE on new { CUSTACCOUNT = string.IsNullOrEmpty(info.INFORMATION) ? tra_h.CUSTACCOUNT : info.INFORMATION } equals
                new { CUSTACCOUNT = cust.ACCOUNTNUM }
                join address in db.CUSTOMERADDRESS on
                new { cust.ACCOUNTNUM, ADDRESSTYPE = defaultAddressType } equals new { address.ACCOUNTNUM, address.ADDRESSTYPE }
                where tra_h.RECEIPTID == receipt &&
                tra_h.TYPE == type &&
                tra_h.ENTRYSTATUS == entryStatus
                select new TransactionCustomer()
                {
                    ReceiptID   = tra_h.RECEIPTID,
                    CustAccount = string.IsNullOrEmpty(info.INFORMATION) ? tra_h.CUSTACCOUNT : info.INFORMATION,
                    Name        = cust.NAME,
                    Address     = cust.ADDRESS,
                    Phone       = cust.PHONE,
                    Address1    = address.ADDRESS,
                    Street      = address.STREET
                };

                TransactionHeader = transaction.Count() > 0 ? transaction.ToList()[0] : null;

                TransactionLines = transactionLine.Count() > 0 ? new TransactionLines(transactionLine.ToList()) : null;

                TransactionCustomer = transactionCustomer.Count() > 0 ? transactionCustomer.ToList()[0] : null;

                //this.dataGridViewReceipt.DataSource = transaction.ToList();
                //this.dataGridViewTransaction.DataSource = transactionLine.ToList();
                //this.dataGridViewCustomer.DataSource = transactionCustomer.ToList();

                this.TransactionBindingSource.DataSource = TransactionHeader;

                this.TransactionCustomerBindingSource.DataSource = TransactionCustomer;

                this.TransactionLinesBindingSource.DataSource = TransactionLines;

                //ReportDataSource dataSourceTran = new ReportDataSource("Transaction", transaction.Count() > 0 ? transaction.ToList()[0] : null);
                //ReportDataSource dataSourceCust = new ReportDataSource("TrransactionCustomer", transactionCustomer.Count() > 0 ? transactionCustomer.ToList()[0] : null);
                //ReportDataSource dataSourceLine = new ReportDataSource("TransactionLines", transactionLine.Count() > 0 ? new TransactionLines(transactionLine.ToList()) : null);

                //this.reportViewerDelivary.LocalReport.DataSources.Add(dataSourceTran);
                //Sthis.reportViewerDelivary.LocalReport.DataSources.Add(dataSourceCust);
                //this.reportViewerDelivary.LocalReport.DataSources.Add(dataSourceLine);
                LocalReport.Refresh();
                return(LocalReport);
            }
        }