예제 #1
0
        public string ExportCSVTranscationsReport(ViewTransactionCBE transaction)
        {
            Int16    IsDataFound = 0;
            var      filename    = "TransactionDetails_" + DateTime.Now.ToString(Constants.dateTimeFormat24HForFileName) + ".csv";
            FileInfo file        = new FileInfo(Server.MapPath("~/Attachment/ExportFiles/" + filename));

            try
            {
                string strstarttime = Convert.ToDateTime(transaction.StartDate).ToString("dd/MM/yyyy HH:mm:ss");
                string strendtime   = Convert.ToDateTime(transaction.EndDate).ToString("dd/MM/yyyy HH:mm:ss");

                IsDataFound = CSVUtility.CreateCsv(file.FullName, TransactionBLL.TransDeatilsReport(strstarttime, strendtime));
                if (IsDataFound == 0)
                {
                    filename = "No Data to Export.";
                }
            }
            catch (Exception ex)
            {
                HelperClass.LogMessage("Failed Export Transaction Details_ CSV " + ex);
            }
            string Det = JsonConvert.SerializeObject(filename, Formatting.Indented);

            return(Det.Replace("\r", "").Replace("\n", ""));
        }
예제 #2
0
        public void DisplayDateRange(DateTime min, DateTime max)
        {
            UserBLL         bll  = new UserBLL();
            TransactionBLL  tll  = new TransactionBLL();
            List <ReportBO> lst  = tll.Read_Report();
            string          head = String.Format("{0,-15} {1,-10} {2,-10} {3,-10} {4,-10}", "Transaction Type", "User ID", "Holders Name", "Amount", "Date");

            WriteLine(head);
            for (int i = 0; i < lst.Count; i++)
            {
                DateTime    temp;
                CultureInfo provider = CultureInfo.InvariantCulture;
                try
                {
                    temp = DateTime.ParseExact(lst[i].Date, "d/MM/yyyy", provider);
                }
                catch (Exception ex)
                {
                    temp = temp = DateTime.ParseExact(lst[i].Date, "dd/MM/yyyy", provider);
                }
                if (temp >= min.Date && temp <= max.Date)
                {
                    WriteLine("{0,-15} {1,-10} {2,-10} {3,-10} {4,-10}", lst[i].Type, lst[i].User_Id, lst[i].Name, lst[i].Amount, lst[i].Date);
                }
            }
        }
예제 #3
0
        public void WithDrawCash(UserO usr, ref bool MaxAmount, ref DateTime tomorrow)
        {
            TransactionBLL tll   = new TransactionBLL();
            DateTime       today = DateTime.UtcNow.Date;

            if (today == tomorrow)
            {
                MaxAmount = false;
            }
            if (tll.Is24Hours(usr))
            {
                MaxAmount = false;
            }
            if (MaxAmount)
            {
                WriteLine("You cannot withdraw more than 20000 in one day.Please wait for 24 hours.");
                return;
            }
            Console.Clear();
            WriteLine("1---Fast Cash");
            WriteLine("2---Normal cash");
            int num = System.Convert.ToInt32(ReadLine());

            if (num == 1)
            {
                FastCash(usr, ref MaxAmount);
            }
            else if (num == 2)
            {
                NormalCash(usr, ref MaxAmount);
            }
        }
예제 #4
0
        public void DepositCash(UserO usr)
        {
            WriteLine("Enter the amount to deposit:");
            string amo = ReadLine();
            int    amount;

            if (int.TryParse(amo, out amount))
            {
                amount = System.Convert.ToInt32(amo);
                UserBLL bll     = new UserBLL();
                UserBO  obj     = new UserBO(bll.SearchByObject(usr));
                UserBO  Deposit = new UserBO(obj);
                Deposit.Starting_balance = Deposit.Starting_balance + amount;
                bll.Save_User(Deposit);
                WriteLine("Deposit successful.");
                DateTime dateTime = DateTime.UtcNow.Date;
                string   dat      = dateTime.ToString("dd/MM/yyyy");
                ReportBO repobj   = new ReportBO {
                    Type = "Cash Deposit", User_Id = obj.UsrAccNum, Name = obj.Name, Amount = amount.ToString(), Date = dat
                };
                TransactionBLL tll = new TransactionBLL();
                tll.Save_Transaction(repobj);
                WriteLine("Do you wish to print a reciept?(y/n)");
                char ans2 = ReadKey().KeyChar;
                if (ans2.Equals('y') || ans2.Equals('Y'))
                {
                    bll.Receipt_Deposit(obj, amount);
                }
            }
            else
            {
                WriteLine("Amount enetered was not in a correct format");
            }
        }
예제 #5
0
 private void DashboardQueue()
 {
     try
     {
         string strstarttime = DateTime.Now.ToString("dd-MMM-yyyy");
         string Det          = JsonConvert.SerializeObject(TransactionBLL.StackChartData(strstarttime, strstarttime), Newtonsoft.Json.Formatting.Indented);
         if (!string.IsNullOrEmpty(Det))
         {
             #region Send data to MSMQ
             Message m = new Message();
             m.Formatter   = new BinaryMessageFormatter();
             m.Body        = Det;
             m.Recoverable = true;
             dashQueue     = VaaaN.MLFF.Libraries.CommonLibrary.MSMQ.Queue.Create(VaaaN.MLFF.Libraries.CommonLibrary.MSMQ.Queue.webChartDashboardMessageQueue);
             if (dashQueue != null)
             {
                 dashQueue.Purge();
             }
             dashQueue.Send(m);
             #endregion
         }
     }
     catch (Exception ex)
     {
         LogMessage("Failed to send into Dasboard Queue." + ex.Message);
     }
 }
예제 #6
0
        private void printTransactionReportbutton_Click(object sender, EventArgs e)
        {
            TransactionBLL          aTransactionBll = new TransactionBLL();
            List <TransationReport> aReports        = new List <TransationReport>();

            aReports = (List <TransationReport>)inventoryTransactionDataGridView.DataSource;

            if (aReports == null)
            {
                MessageBox.Show("No data Available Into GridView");
                return;
            }
            int           printlenght = aReports.Count;
            PrintDocument doc         = new TextDocument(aTransactionBll.PrintTransactionReport(aReports), printlenght);

            //ViewReport aReport = new ViewReport();
            printReportLogoType = 1;
            doc.PrintPage      += this.Doc_PrintPage;
            doc.DefaultPageSettings.Landscape = true;

            PrintDialog dlgSettings = new PrintDialog();

            dlgSettings.UseEXDialog = true;
            dlgSettings.Document    = doc;

            if (dlgSettings.ShowDialog() == DialogResult.OK)
            {
                doc.Print();
            }
        }
예제 #7
0
        private void LoadData()
        {
            dt = new DataTable();
            // get Data for dt
            TransactionBLL transactionBLL = new TransactionBLL();

            dt = transactionBLL.getAllTrans();
            dgvOrder.DataSource = dt;
        }
예제 #8
0
        public void NormalCash(UserO usr, ref bool MaxAmount)
        {
            WriteLine("Enter the amount of money You want to withdraw");
            string amo = ReadLine();
            int    amount;

            if (int.TryParse(amo, out amount))
            {
                amount = System.Convert.ToInt32(amo);
                UserBLL bll = new UserBLL();
                if (bll.CheckDate(amount))
                {
                    MaxAmount = true;
                    return;
                }
                WriteLine($"Are you sure you want to withdraw Rs.{amount}(Y/N)? ");
                char ans = ReadKey().KeyChar;
                if (ans.Equals('y') || ans.Equals('Y'))
                {
                    UserBO obj = new UserBO(bll.SearchByObject(usr));
                    UserBO cop = new UserBO(obj);
                    if (bll.CheckBalance(obj, amount))
                    {
                        obj.Starting_balance = obj.Starting_balance - amount;
                        bll.Test_Save(obj);
                        WriteLine("Ammount Withdrawn sucessfully");
                        DateTime dateTime = DateTime.UtcNow.Date;
                        string   dat      = dateTime.ToString("dd/MM/yyyy");
                        ReportBO repobj   = new ReportBO {
                            Type = "Cash Withdrawl", User_Id = obj.UsrAccNum, Name = obj.Name, Amount = amount.ToString(), Date = dat
                        };
                        TransactionBLL tll = new TransactionBLL();
                        tll.Save_Transaction(repobj);
                        WriteLine("Do You wish to print a receipt(y/n)");
                        char ans2 = ReadKey().KeyChar;
                        if (ans2.Equals('y') || ans2.Equals('Y'))
                        {
                            Display_Recipt(amount, obj);
                        }
                    }
                    else
                    {
                        bll.Test_Save(cop);
                        WriteLine("You dont have enough balance in your account");
                    }
                }
                else
                {
                    return;
                }
            }
            else
            {
                WriteLine("Please Enter a valid amount i.e, digits");
            }
        }
예제 #9
0
        public void FastCash(UserO usr, ref bool MaxAmount)
        {
            Console.Clear();
            WriteLine("1----500");
            WriteLine("2----1000");
            WriteLine("3----2000");
            WriteLine("4----5000");
            WriteLine("5----10000");
            WriteLine("6----15000");
            WriteLine("7----20000");
            int     opt    = System.Convert.ToInt32(ReadLine());
            UserBLL bll    = new UserBLL();
            int     amount = Place_Balance(opt);

            if (bll.CheckDate(amount))
            {
                MaxAmount = true;
                return;
            }
            WriteLine($"Are you sure you want to withdraw Rs.{amount}(Y/N)? ");
            char ans = ReadKey().KeyChar;

            if (ans.Equals('y') || ans.Equals('Y'))
            {
                UserBO obj = new UserBO(bll.SearchByObject(usr));
                UserBO cop = new UserBO(obj);
                if (bll.CheckBalance(obj, amount))
                {
                    obj.Starting_balance = obj.Starting_balance - amount;
                    bll.Test_Save(obj);
                    WriteLine("Ammount Withdrawn sucessfully");
                    DateTime dateTime = DateTime.UtcNow.Date;
                    string   dat      = dateTime.ToString("dd/MM/yyyy");
                    ReportBO repobj   = new ReportBO {
                        Type = "Cash Withdrawl", User_Id = obj.UsrAccNum, Name = obj.Name, Amount = amount.ToString(), Date = dat
                    };
                    TransactionBLL tll = new TransactionBLL();
                    tll.Save_Transaction(repobj);
                    WriteLine("Do You wish to print a receipt(y/n)");
                    char ans2 = ReadKey().KeyChar;
                    if (ans2.Equals('y') || ans2.Equals('Y'))
                    {
                        Display_Recipt(amount, obj);
                    }
                }
                else
                {
                    bll.Test_Save(cop);
                    WriteLine("You dont have enough balance in your account");
                }
            }
            else
            {
                WriteLine("GoodLuck");
            }
        }
예제 #10
0
        private void btnDeliver_Click(object sender, EventArgs e)
        {
            TransactionBLL transactionBLL = new TransactionBLL();

            if (transactionBLL.SetStatus("Delivering", IDTrans))
            {
                MessageBox.Show("Delevering");
            }
            this.Close();
        }
예제 #11
0
파일: Receipt.cs 프로젝트: tanjirantu/Tulsi
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            MedicineBLL    med  = new MedicineBLL();
            TransactionBLL tran = new TransactionBLL();

            foreach (Medicine m in medicines)
            {
                tran.Insert(m);
                med.Update(m);
            }
        }
예제 #12
0
        public string DashBoardTransactionData(ViewTransactionCBE transaction)
        {
            string result = "";

            string strstarttime = Convert.ToDateTime(transaction.StartDate).ToString("dd/MM/yyyy HH:mm:ss");
            string strendtime   = Convert.ToDateTime(transaction.EndDate).ToString("dd/MM/yyyy HH:mm:ss");
            string Det          = JsonConvert.SerializeObject(TransactionBLL.TransDeatilsReport(strstarttime, strendtime), Formatting.Indented);

            result = Det.Replace("\r", "").Replace("\n", "");
            return(result);
        }
예제 #13
0
        private void LoadData()
        {
            dt = new DataTable();
            // load dt from database
            TransactionBLL transactionBLL = new TransactionBLL();

            dt = transactionBLL.getAllTrans(email);
            //Khai bao cot IDTrans la khoa chinh
            dt.PrimaryKey = new DataColumn[] { dt.Columns[0] };
            DataView view = dt.DefaultView;

            view.Sort = "CreateDate DESC";

            dgvHistory.DataSource = view;
        }
        public async Task <IHttpActionResult> GetAccountTransactionByAccount(int accountId, int?size = 50)
        {
            List <OutTransaction> tlist = null;

            try
            {
                TransactionBLL bll = new TransactionBLL(_unit);

                tlist = bll.GetTransactionList(accountId, size);
            }
            catch (Exception ex)
            {
                LogHelper.Error(_log, ex.ToString());
                return(InternalServerError(ex));
            }

            return(Ok(tlist));
        }
        public async Task <IHttpActionResult> GetTransactionById(int id)
        {
            Transaction tr = null;

            try
            {
                TransactionBLL bll = new TransactionBLL(_unit);

                tr = bll.GetByID(id);
            }
            catch (Exception ex)
            {
                LogHelper.Error(_log, ex.ToString());
                return(InternalServerError(ex));
            }

            return(Ok(tr));
        }
예제 #16
0
        private void showButton_Click(object sender, EventArgs e)
        {
            DateTime fromdate = fromdateTimePicker.Value;
            DateTime todate   = todateTimePicker.Value;

            todate = todate.AddDays(1);
            // todate = todate.AddSeconds(-1);
            fromdate = fromdate.Date;
            todate   = todate.Date;
            todate   = todate.AddSeconds(-1);
            List <Transaction> aTransactions   = new List <Transaction>();
            TransactionBLL     aTransactionBll = new TransactionBLL();

            aTransactions = aTransactionBll.GetTransactionBetweenDate(fromdate, todate);

            // inventoryTransactionDataGridView.DataSource = aTransactions;
            ShowReport(aTransactions);
        }
예제 #17
0
        private void btnCancel_Click(object sender, EventArgs e)
        {
            // Cong lai so luong trong bang tree
            TreeBLL treeBLL = new TreeBLL();

            foreach (DataRow row in dt.Rows)
            {
                string name     = row.Field <string>(2).ToString();
                int    quantity = int.Parse(row.Field <int>(3).ToString());
                treeBLL.IncreaseQuantity(name, quantity);
            }
            TransactionBLL transactionBLL = new TransactionBLL();

            if (transactionBLL.SetStatus("Cancel", IDTrans))
            {
                MessageBox.Show("Cancel");
            }
            this.Close();
        }
예제 #18
0
        public void Test_UpdateSpanDays()
        {
            TradePositionBLL     bll   = new TradePositionBLL(_unit);
            TransactionBLL       tbll  = new TransactionBLL(_unit);
            List <TradePosition> aList = bll.GetListByAccount(1060);

            foreach (var p in aList)
            {
                if (p.ExitTransactionId.HasValue)
                {
                    var entryTrans = tbll.GetByID(p.EntryTransactionId);
                    var exitTrans  = tbll.GetByID(p.ExitTransactionId.Value);

                    p.days = new TickerBLL(_unit).GetTradesDaySpan(p.ShareId, entryTrans.TradingDate, exitTrans.TradingDate);

                    bll.Update(p);
                }
            }
        }
예제 #19
0
        private void btnCancel_Click(object sender, EventArgs e)
        {
            int     IDTrans = int.Parse(dgvHistory.Rows[RowIndex].Cells[0].Value.ToString());
            DataRow row     = dt.Rows.Find(IDTrans);
            string  status  = row.Field <string>(4).ToString();

            if (status.Equals("Active")) // neu status eq 'Active' means Admin has not approve yet. - > allow cancel
            {
                if (MessageBox.Show("Are you really want to cancel :( ", "Notice", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    // Cong lai so luong trong bang tree
                    TreeBLL   treeBLL  = new TreeBLL();
                    OrderBLL  orderBLL = new OrderBLL();
                    DataTable dtOrders = new DataTable();
                    dtOrders = orderBLL.getOrders(IDTrans);

                    foreach (DataRow r in dtOrders.Rows)
                    {
                        string name     = r.Field <string>(2).ToString();
                        int    quantity = int.Parse(r.Field <int>(3).ToString());
                        treeBLL.IncreaseQuantity(name, quantity);
                    }


                    // update database and update table
                    TransactionBLL transactionBLL = new TransactionBLL();
                    if (transactionBLL.CancelOrdering(IDTrans))
                    {
                        MessageBox.Show("Canceled!");
                        row["Status"] = "Cancel";
                        dgvHistory.Refresh();
                    }
                }
            }
            else if (status.Equals("Delivering"))
            {
                MessageBox.Show("Cannot cancel your order cuz it's delivering");
            }
            else
            {
                MessageBox.Show("It's alreadly canceled");
            }
        }
        public bool Insert_Transaction(TransactionBLL t, out int transactionID)
        {
            bool isSuccess = true;

            transactionID = -1;
            SqlConnection conn = new SqlConnection(myconnstrng);

            try
            {
                string     sql = "INSERT INTO tbl_transactions(type,delr_cust_id,grandTotal,transaction_date,tax,discount,added_by) VALUES (@type,@delr_cust_id,@grandTotal,@transaction_date,@tax,@discount,@added_by);SELECT @@IDENTITY;";
                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.AddWithValue("@type", t.type);
                cmd.Parameters.AddWithValue("@delr_cust_id", t.delr_cust_id);
                cmd.Parameters.AddWithValue("@grandTotal", t.grandTotal);
                cmd.Parameters.AddWithValue("@transaction_date", t.transaction_date);
                cmd.Parameters.AddWithValue("@tax", t.tax);
                cmd.Parameters.AddWithValue("@discount", t.discount);
                cmd.Parameters.AddWithValue("@added_by", t.added_by);

                conn.Open();

                object o = cmd.ExecuteScalar();

                if (o != null)
                {
                    transactionID = int.Parse(o.ToString());
                    isSuccess     = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return(isSuccess);
        }
        public bool InsertTransaction(TransactionBLL u, out int transactionId)
        {
            bool isSuccess = false;

            transactionId = -1;
            //Static Method to Connect Database
            SqlConnection con = new SqlConnection(myConnection);

            try
            {
                String     sql = "INSERT INTO tbl_transactions (type,customer_id,grandTotal,transaction_date,tax,discount,added_by) VALUES(@type,@customer_id,@grandTotal,@transaction_date,@tax,@discount,@added_by); SELECT @@IDENTITY;";
                SqlCommand cmd = new SqlCommand(sql, con);
                cmd.Parameters.AddWithValue("@type", u.type);
                cmd.Parameters.AddWithValue("@customer_id", u.CustomerID);
                cmd.Parameters.AddWithValue("@grandTotal", u.grandTotal);
                cmd.Parameters.AddWithValue("@transaction_date", u.transaction_date);
                cmd.Parameters.AddWithValue("@tax", u.tax);
                cmd.Parameters.AddWithValue("@discount", u.discount);
                cmd.Parameters.AddWithValue("@added_by", u.added_by);
                con.Open();
                object o = cmd.ExecuteScalar();
                // if the Query is Excuted then the value of the rows will be greater thean zero
                if (o != null)
                {
                    isSuccess     = true;
                    transactionId = int.Parse(o.ToString());
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
            }

            return(isSuccess);
        }
예제 #22
0
        private void btnSaveAll_Click(object sender, EventArgs e)
        {
            TransactionBLL transaction = new TransactionBLL();

            transaction.type = lblTopPurcSale.Text;
            string    deaCusName = txtPSDeaCusName.Text;
            DeaCusBLL dc         = dcdal.GetDeaCusIDFromName(deaCusName);

            transaction.delr_cust_id     = dc.id;
            transaction.grandTotal       = Math.Round(decimal.Parse(txtPSCDGrandTotal.Text), 2);
            transaction.transaction_date = DateTime.Now;
            transaction.tax      = decimal.Parse(txtPSCDVat.Text);
            transaction.discount = decimal.Parse(txtPSCDDiscount.Text);
            string  loggeduser = frmLogin.loggedIn;
            UserBLL user       = udal.GetIdFromUsername(loggeduser);

            transaction.added_by = user.id;


            transaction.transactionDetails = transactionDT;

            bool Success = false;

            using (TransactionScope scope = new TransactionScope())
            {
                int transactionID = -1;

                bool X = tdal.Insert_Transaction(transaction, out transactionID);

                for (int i = 0; i < transactionDT.Rows.Count; i++)
                {
                    TransactionDetailsBLL td = new TransactionDetailsBLL();
                    String      ProductName  = transactionDT.Rows[i][0].ToString();
                    ProductsBLL p            = pdal.GetProductIDFromName(ProductName);
                    td.product_id   = p.id;
                    td.rate         = decimal.Parse(transactionDT.Rows[i][1].ToString());
                    td.qty          = decimal.Parse(transactionDT.Rows[i][2].ToString());
                    td.total        = Math.Round(decimal.Parse(transactionDT.Rows[i][3].ToString()), 2);
                    td.delr_cust_id = dc.id;
                    td.added_date   = DateTime.Now;
                    td.added_by     = user.id;

                    string transactionType = lblTopPurcSale.Text;
                    bool   Y = false;
                    if (transactionType == "PURCHASE")
                    {
                        Y = pdal.IncreaseProduct(td.product_id, td.qty);
                    }
                    else if (transactionType == "SALES")
                    {
                        Y = pdal.DecreaseProduct(td.product_id, td.qty);
                    }

                    bool Z = tdDal.Insert_TransactionDetails(td);
                    Success = X && Y && Z;
                }

                if (Success == true)
                {
                    scope.Complete();

                    // CODE TO PRINT BILL
                    DGVPrinter printer = new DGVPrinter();
                    printer.Title               = "\r\n\r\nEVERYTHING PVT. LTD.\r\n";
                    printer.SubTitle            = "\r\n MAIN ROAD NEAR RAILWAY STATION ,P.O:GHATSILA,\r\nDIST:EAST SINGHBHUM ,JHARKHAND\r\n Mob: 9583340426 \r\n\r\n ";
                    printer.SubTitleFormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoClip;
                    printer.PageNumbers         = true;
                    printer.PageNumberInHeader  = false;
                    printer.PorportionalColumns = true;
                    printer.HeaderCellAlignment = StringAlignment.Near;
                    printer.Footer              = "Discount:" + txtPSCDDiscount.Text + "%\r\n" + "TAX:" + txtPSCDVat.Text + "%\r\n" + "Grand-Total:RS" + txtPSCDGrandTotal.Text + "\r\n\r\n" + "THANK YOU FOR BUSINESS WITH US";
                    printer.FooterSpacing       = 15;
                    printer.PrintDataGridView(dgvPSAddedProduct);
                    //----------------------------------------------------------------------------------------------------------------------------

                    MessageBox.Show("Transaction Successfully Done.");
                    dgvPSAddedProduct.DataSource = null;
                    dgvPSAddedProduct.Rows.Clear();
                    txtPSDeaCusSearch.Text  = "";
                    txtPSDeaCusName.Text    = "";
                    txtPSDeaCusEmail.Text   = "";
                    txtPSDeaCusContact.Text = "";
                    txtPSDeaCusAddress.Text = "";
                    txtPSPDSearch.Text      = "";
                    txtPSPDName.Text        = "";
                    txtPSPDInventory.Text   = "0";
                    txtPSPDRate.Text        = "0";
                    txtPSPDQty.Text         = "";
                    txtPSCDSubtotal.Text    = "0";
                    txtPSCDDiscount.Text    = "0";
                    txtPSCDVat.Text         = "0";
                    txtPSCDGrandTotal.Text  = "0";
                    txtPSCDpaidamount.Text  = "0";
                    txtPSCDRetAmut.Text     = "0";
                }
                else
                {
                    MessageBox.Show("Failed Transaction,Retry");
                }
            }
        }
        public void Test_GetTransactionList()
        {
            TransactionBLL tBLL = new TransactionBLL(_unit);

            var tList = tBLL.GetTransactionList(1039, 50);
        }
예제 #24
0
        private void TransactionWhenBusinessPackageIsActive()
        {
            InventoryItem aItem = new InventoryItem();

            aItem = (InventoryItem)itemNamecomboBox.SelectedItem;
            InventoryCategory aInventoryCategory = new InventoryCategory();

            aInventoryCategory = (InventoryCategory)categoryNamecomboBox.SelectedItem;


            Stock       aStock          = new Stock();
            StockBLL    aStockBll       = new StockBLL();
            string      transactiontype = transactionTypecomboBox.SelectedItem.ToString();
            Transaction aTransaction    = new Transaction();

            aTransaction.TransactionDate = DateTime.Now;
            aTransaction.Item            = aItem;
            aTransaction.Category        = aInventoryCategory;
            aTransaction.TransactionType = transactiontype;
            CUserInfo aUserInfo = new CUserInfo();

            aUserInfo.UserName    = RMSGlobal.LogInUserName;
            aTransaction.UserInfo = aUserInfo;
            string sr = string.Empty;


            if (transactiontype == "Stock In")
            {
                // aStock = aStockBll.GetStockByItemid(aItem.ItemId);

                if ((Convert.ToDouble(quantitytextBox.Text) != 0))
                {
                    aStock.Stocks      = Convert.ToDouble(quantitytextBox.Text);
                    aStock.Item        = aItem;
                    aStock.Category    = aInventoryCategory;
                    aTransaction.Stock = aStock;
                    TransactionBLL aBll = new TransactionBLL();
                    sr = aBll.SendToKitchen(aTransaction);
                    ShowAndClear(sr);
                }
                else
                {
                    MessageBox.Show("Your Quantity Must be Greater than 0 and  less than or equal to " + aStock.Stocks + " " + unittypelabel.Text);
                }
            }

            //aStock = aStockBll.GetStockByItemidFrominventory_kitchen_stock(aItem);


            if (transactiontype == "Damage_in_kitchen")
            {
                if (danmagetextBox.Text.Length > 0)
                {
                    aStock = aStockBll.GetStockByItemidFrominventory_kitchen_stock(aItem);

                    if ((aStock.Stocks >= Convert.ToDouble(quantitytextBox.Text)) &&
                        (Convert.ToDouble(quantitytextBox.Text) != 0))
                    {
                        aStock.Stocks             = Convert.ToDouble(quantitytextBox.Text);
                        aStock.Item               = aItem;
                        aStock.Category           = aInventoryCategory;
                        aTransaction.Stock        = aStock;
                        aTransaction.DamageReport = danmagetextBox.Text.Replace("'", "''");

                        TransactionBLL aBll = new TransactionBLL();
                        sr = aBll.DamageInKitchen(aTransaction);
                        ShowAndClear(sr);
                    }
                    else
                    {
                        MessageBox.Show("Your Quantity Must be Greater than 0 and  less than or equal to  " + aStock.Stocks + " " +
                                        unittypelabel.Text);
                    }
                }
                else
                {
                    MessageBox.Show("Please Check Your Damage Report Field It's Never Empty");
                }
            }
        }
예제 #25
0
        private void button1_Click(object sender, EventArgs e)
        {
            //get the values from PurchaseSales from
            TransactionBLL transaction = new TransactionBLL();

            transaction.type = lblTop.Text;

            //Get the Id of the Customer here

            //lets get name of the customer first
            string      CustomerOrSellerName = txtName.Text;
            CustomerBLL customerbll          = customerdal.GetCustomerOrSellerIDFromName(CustomerOrSellerName);

            //getting the transactionID
            transaction.CustomerID       = customerbll.id;
            transaction.grandTotal       = Math.Round(decimal.Parse(txtTotalPPrice.Text), 2);
            transaction.transaction_date = DateTime.Now;
            transaction.tax      = decimal.Parse(txtVAT.Text);
            transaction.discount = decimal.Parse(txtDiscount.Text);

            //Get the userName of loggedin User
            string  username = frmLogin.LoggedInUserName;
            UserBll userbll  = userdal.GetIDFromUsername(username);

            transaction.added_by           = userbll.id;
            transaction.transactionDetails = transactionDT;

            //lets Create a boolean variable to check if successful
            bool success = false;

            using (TransactionScope scope = new TransactionScope())
            {
                int transactionID = -1;
                //create bool value and inset transaction
                bool w = transDal.InsertTransaction(transaction, out transactionID);
                for (int i = 0; i < transactionDT.Rows.Count; i++)
                {
                    //Get all the Details of the Product
                    TransactionDetailBLL transactionddetilbll = new TransactionDetailBLL();
                    //Get the productName and Conert it Id
                    string     productname = transactionDT.Rows[i][0].ToString();
                    ProductBLL producbll   = productdal.GetProduuctIDFromName(productname);

                    transactionddetilbll.product_id = producbll.Id;
                    transactionddetilbll.rate       = decimal.Parse(transactionDT.Rows[i][1].ToString());
                    transactionddetilbll.qty        = decimal.Parse(transactionDT.Rows[i][2].ToString());
                    transactionddetilbll.total      = Math.Round(decimal.Parse(transactionDT.Rows[i][3].ToString()), 2);

                    //lets get id of the customer firt
                    transactionddetilbll.Id         = customerbll.id;
                    transactionddetilbll.added_date = DateTime.Now;
                    transactionddetilbll.added_by   = userbll.id;

                    //now before inserting we need to increasing or decrease Product Quantity Based on Purchase or Sales
                    string TransactionType = lblTop.Text;

                    //lets check whether we are on puchase o sales
                    bool xpursal = false;
                    if (TransactionType == "Purchase")
                    {
                        xpursal = productdal.IncreaseProduct(transactionddetilbll.product_id, transactionddetilbll.qty);
                        if (xpursal == true)
                        {
                            MessageBox.Show("Product Increase is Successful");
                        }
                        else
                        {
                            MessageBox.Show("Product Increase Falied !!!!!");
                        }
                    }
                    else if (TransactionType == "Sales")
                    {
                        xpursal = productdal.DecreaseProduct(transactionddetilbll.product_id, transactionddetilbll.qty);
                        if (xpursal == true)
                        {
                            MessageBox.Show("Product Decrease is Successful");
                        }
                        else
                        {
                            MessageBox.Show("Product Decrease Falied !!!!!");
                        }
                    }

                    //Finally insert TransactionDetails inside the DataBase
                    bool y = transDetailDal.InsertTransaction(transactionddetilbll);
                    success = w && y && xpursal;
                }
                if (success == true)
                {
                    scope.Complete();
                    //Code To print Bill
                    DGVPrinter print = new DGVPrinter();
                    print.Title               = "\r\n\r\n SHADY'S Store Bill";
                    print.SubTitle            = "Yemen,Taiz \r\n Phone:772816006";
                    print.SubTitleFormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoClip;
                    print.PageNumbers         = true;
                    print.PageNumberInHeader  = false;
                    print.PorportionalColumns = true;
                    print.HeaderCellAlignment = StringAlignment.Near;
                    print.Footer              = "Discount: " + txtDiscount.Text + "% \r\n ValueAddedTax: " + txtVAT.Text + "%\r\n" + "Total Price: " + txtTotalPPrice.Text + "\r\n Thanks For Your Visit.";
                    print.FooterSpacing       = 7;
                    print.PrintDataGridView(dgvAddedproducts);

                    //Transaction Compelte
                    MessageBox.Show(" Transaction Compeleted Successfully");
                    //Clear of the DataGrid view
                    dgvAddedproducts.DataSource = null;
                    dgvAddedproducts.Rows.Clear();

                    txtCustomerSearch.Text   = "";
                    txtName.Text             = "";
                    txtEmail.Text            = "";
                    txtContact.Text          = "";
                    txtAddress.Text          = "";
                    txtProductSearch.Text    = "";
                    txtProductName.Text      = "";
                    txtProdcutInventory.Text = "0";
                    txtProdcutQTY.Text       = "0";
                    txtRowTotal.Text         = "0";
                    txtDiscount.Text         = "0";
                    txtVAT.Text          = "0";
                    txtTotalPPrice.Text  = "0";
                    txtPaidAmount.Text   = "";
                    txtReturnAmount.Text = "";
                }
                else
                {
                    //Transaction Failed
                    MessageBox.Show("Transaction Failed");
                }
            }
        }
예제 #26
0
        public string ExportCSVTranscations(ViewTransactionCBE transaction)
        {
            Int16    IsDataFound = 0;
            var      filename    = "Transaction_Details_Registered_" + DateTime.Now.ToString(Constants.dateTimeFormat24HForFileName) + ".csv";
            var      filename1   = "Transaction_Details_UnRegistered_" + DateTime.Now.ToString(Constants.dateTimeFormat24HForFileName) + ".csv";
            FileInfo file        = new FileInfo(Server.MapPath("~/Attachment/ExportFiles/" + filename));
            FileInfo file1       = new FileInfo(Server.MapPath("~/Attachment/ExportFiles/" + filename1));

            try
            {
                string strstarttime = Convert.ToDateTime(transaction.StartDate).ToString("dd/MM/yyyy HH:mm:ss");
                string strendtime   = Convert.ToDateTime(transaction.EndDate).ToString("dd/MM/yyyy HH:mm:ss");
                string strQuery     = " WHERE 1=1 ";
                if (strstarttime != null && strendtime != null)
                {
                    strQuery += " AND  TRANSACTION_DATETIME BETWEEN TO_DATE('" + strstarttime + "','DD/MM/YYYY HH24:MI:SS') AND  TO_DATE('" + strendtime + "','DD/MM/YYYY HH24:MI:SS')";
                }
                else if (strstarttime != null)
                {
                    strQuery += " AND  TRANSACTION_DATETIME >= TO_DATE('" + strstarttime + "','DD/MM/YYYY HH24:MI:SS')";
                }
                else if (strendtime != null)
                {
                    strQuery += " AND  TRANSACTION_DATETIME <= TO_DATE('" + strendtime + "','DD/MM/YYYY HH24:MI:SS')";
                }
                DataTable dt      = TransactionBLL.TransDeatils(strQuery);
                DataView  dv      = new DataView(dt);
                DataTable Charged = dt.AsEnumerable()
                                    .Where(r => r.Field <decimal>("IS_REGISTERED") == 1)
                                    .CopyToDataTable();
                //DataTable Charged = (DataTable)(dv.RowFilter = "IS_BALANCE_UPDATED=1").;
                if (Charged.Rows.Count > 0)
                {
                    IsDataFound = CSVUtility.CreateCsv(file.FullName, Charged);
                    if (IsDataFound == 0)
                    {
                        filename = string.Empty;
                    }
                }
                DataTable UnCharged = dt.AsEnumerable()
                                      .Where(r => r.Field <decimal>("IS_REGISTERED") != 1)
                                      .CopyToDataTable();
                if (UnCharged.Rows.Count > 0)
                {
                    IsDataFound = CSVUtility.CreateCsv(file1.FullName, UnCharged);
                    if (IsDataFound == 0)
                    {
                        if (string.IsNullOrEmpty(filename))
                        {
                            filename = "No Data to Export.";
                        }
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(filename))
                        {
                            filename = "No Data to Export.";
                        }
                        else
                        {
                            filename = filename + ";" + filename1;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                filename = "No Data to Export. :" + ex.Message;
                HelperClass.LogMessage("Failed Export Transaction Details_ CSV " + ex);
            }
            string Det = JsonConvert.SerializeObject(filename, Formatting.Indented);

            return(Det.Replace("\r", "").Replace("\n", ""));
        }
예제 #27
0
 public TransactionReport()
 {
     InitializeComponent();
     this.transactions = new TransactionBLL();
     this.medicine     = new MedicineBLL();
 }
예제 #28
0
        public HttpResponseMessage Post()
        {
            try
            {
                System.Threading.Tasks.Task <string> content = Request.Content.ReadAsStringAsync();
                Object jobj = new object();

                var orderId = new TransactionLibrary().GetOrderId();

                //dados da operação
                jobj = JObject.Parse(content.Result);
                JToken client_id    = JObject.Parse(jobj.ToString()).SelectToken("client_id");
                JToken cart_id      = JObject.Parse(jobj.ToString()).SelectToken("cart_id");
                JToken client_name  = JObject.Parse(jobj.ToString()).SelectToken("client_name");
                JToken value_to_pay = JObject.Parse(jobj.ToString()).SelectToken("value_to_pay");
                JToken credit_card  = JObject.Parse(jobj.ToString()).SelectToken("credit_card");

                #region Cartão de Crédito
                //dados do cartão de crédito
                jobj = JObject.Parse(credit_card.ToString());
                JToken number           = JObject.Parse(jobj.ToString()).SelectToken("number");
                JToken cvv              = JObject.Parse(jobj.ToString()).SelectToken("cvv");
                JToken exp_date         = JObject.Parse(jobj.ToString()).SelectToken("exp_date");
                JToken card_holder_name = JObject.Parse(jobj.ToString()).SelectToken("card_holder_name");

                CreditCard creditCard = new CreditCard();
                creditCard.card_number      = number.ToString();
                creditCard.cvv              = Convert.ToInt32(cvv);
                creditCard.exp_date         = exp_date.ToString();
                creditCard.card_holder_name = card_holder_name.ToString();

                //registra o cartão de crédito
                CreditCardBLL creditCardBll = new CreditCardBLL();
                creditCardBll.Inserir(creditCard);
                #endregion

                #region Transação
                //registra a transação de venda
                Transaction transaction = new Transaction();
                transaction.client_id    = client_id.ToString();
                transaction.cart_id      = cart_id.ToString();
                transaction.client_name  = client_name.ToString();
                transaction.total_to_pay = Convert.ToInt32(value_to_pay);
                transaction.credit_card  = creditCard.card_number;
                transaction.order_id     = orderId;
                transaction.date         = DateTime.Today.ToString("dd/MM/yyyy");

                TransactionBLL transactionBll = new TransactionBLL();
                transactionBll.Inserir(transaction);
                #endregion

                #region Histórico
                History history = new History();
                history.card_number = creditCard.card_number;
                history.client_id   = transaction.client_id;
                history.value       = transaction.total_to_pay;
                history.order_id    = orderId;

                HistoryBLL historyBll = new HistoryBLL();
                historyBll.Inserir(history);
                #endregion

                return(Request.CreateResponse(HttpStatusCode.OK, new { message = "Compra realizada com sucesso!" }));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, new { message = ex.Message.ToString() }));
            }
        }
예제 #29
0
 public Dashboard()
 {
     InitializeComponent();
     this.transaction = new TransactionBLL();
     this.medicine    = new MedicineBLL();
 }