예제 #1
0
        private void addbutton_Click(object sender, EventArgs e)
        {
            try
            {
                if (categorynametextBox.Text.Length > 0 )
                {
                    Store aStore = new Store();
                    aStore.ItemName = categorynametextBox.Text;
                    StoreDAO aStoreDao = new StoreDAO();
                    string sr = aStoreDao.InsertOtherCategory(aStore);
                    MessageBox.Show(sr);
                    if (sr == "Insert Sucessfully")
                    {
                        this.Close();
                    }

                }
                else MessageBox.Show("Please Check Input");
            }
            catch (Exception)
            {

                MessageBox.Show("Please Check Input");
            }
        }
예제 #2
0
 private void LoadGridView()
 {
     StoreDAO aDao = new StoreDAO();
     List<Store> aStores = new List<Store>();
     aStores = aDao.GetAllStore();
     purchaseStoredataGridView.DataSource = aStores;
 }
예제 #3
0
        private void savebutton_Click(object sender, EventArgs e)
        {
            Store aStore = new Store();
            StoreDAO aStoreDao = new StoreDAO();
            aStore = aStoreDao.GetStoreByItemId(ItemId);
            Transaction1 aTransaction1 = new Transaction1();
            aTransaction1.ItemName = aStore.ItemName;
            aTransaction1.TransactionType = transactiontypelebel.Text;
            aTransaction1.Amount = Convert.ToDouble(quantitytextBox.Text)*aStore.UnitPrice;
            aTransaction1.Quantity = Convert.ToDouble(quantitytextBox.Text);
            aTransaction1.ItemUnit = aStore.Unit;
            aTransaction1.CauseOrPurpose = purposeTextBox.Text.Trim();

              aStore.Quantity -= Convert.ToDouble(quantitytextBox.Text);
              if (aStore.Quantity >= 0)
              {

                  aStoreDao.InsertTransaction(aTransaction1,CategoryId);

                  string sr = aStoreDao.UpdateStore(aStore);
                  MessageBox.Show(sr);
                  if (sr == "Insert Sucessfully")
                  {
                      this.Close();
                  }
              }
              else   MessageBox.Show("Not Enough quantity");
        }
예제 #4
0
        private void savebutton_Click(object sender, EventArgs e)
        {
            Store aStore=new Store();
            StoreDAO aStoreDao=new StoreDAO();
            aStore = aStoreDao.GetOtherStoreByItemId(ItemId);
            Transaction1 aTransaction1=new Transaction1();
            aTransaction1.ItemName = aStore.ItemName;
            aTransaction1.TransactionType = "Purchase";
            aTransaction1.SupplierName = supplierNamecomboBox.Text;
            aTransaction1.Amount = Convert.ToDouble(amounttextBox.Text);
            aTransaction1.Quantity = Convert.ToDouble(quantitytextBox.Text);
            aTransaction1.ItemUnit = aStore.Unit;

            aStoreDao.InsertOtherTransaction(aTransaction1,CategoryId);

            double newstore = aStore.Amount + Convert.ToDouble(amounttextBox.Text);
            double newquantity = aStore.Quantity + Convert.ToDouble(quantitytextBox.Text);
            double unitprice = 0;
            if (newquantity != 0)
            {
                unitprice = (newstore / newquantity);

            }
            else unitprice = 0;
            aStore.UnitPrice = unitprice;
            aStore.Quantity = newquantity;
            string sr = aStoreDao.UpdateOtherStore(aStore);
            MessageBox.Show(sr);
            if(sr=="Insert Sucessfully")
            {
                this.Close();
            }
        }
예제 #5
0
        private void addbutton_Click(object sender, EventArgs e)
        {
            try
            {
                if(itemnametextBox.Text.Length>0 && unitcomboBox.Text.Length>0)
                {
                    Store aStore=new Store();
                    aStore.ItemName = itemnametextBox.Text;
                    aStore.Unit = unitcomboBox.Text;
                    aStore.CategoryId = Convert.ToInt32(categorycomboBox.SelectedValue);
                    aStore.CategoryName = categorycomboBox.Text;
                    StoreDAO aStoreDao=new StoreDAO();
                    string sr = aStoreDao.InsertOtherItem(aStore);
                    MessageBox.Show(sr);
                    if(sr=="Insert Sucessfully")
                    {
                        this.Close();
                    }

                }
                else MessageBox.Show("Please Check Input");
            }
            catch (Exception)
            {

                MessageBox.Show("Please Check Input");
            }
        }
예제 #6
0
 private void AddOtherItem_Load(object sender, EventArgs e)
 {
     StoreDAO aStoreDao=new StoreDAO();
     List<Store> aList=new List<Store>();
     aList = aStoreDao.GetAllotherCategory();
     categorycomboBox.DataSource = aList;
     categorycomboBox.ValueMember = "StoreId";
     categorycomboBox.DisplayMember = "ItemName";
 }
예제 #7
0
 private void itemNametextBox_TextChanged(object sender, EventArgs e)
 {
     if (itemNametextBox.Text == "" || string.IsNullOrEmpty(itemNametextBox.Text))
     {
         StoreDAO aDao = new StoreDAO();
         List<Store> aStores = new List<Store>();
         aStores = aDao.GetAllStore();
         purchaseStoredataGridView.DataSource = aStores;
     }
     else
     {
         StoreDAO aDao = new StoreDAO();
         List<Store> aStores = new List<Store>();
         aStores = aDao.GetAllStore();
         List<Store> aastore = (from myRow in aStores.AsEnumerable()
                                where myRow.ItemName.ToUpper().StartsWith(itemNametextBox.Text.ToUpper())
                                select myRow).ToList();
         // DataView view = results.AsDataView();
         purchaseStoredataGridView.DataSource = aastore;
     }
 }
예제 #8
0
 private void findItembutton_Click(object sender, EventArgs e)
 {
     // otherpurchaseStoredataGridView.DataSource = null;
     // otherpurchaseStoredataGridView.AutoGenerateColumns = false;
     if (itemNametextBox.Text == "" || string.IsNullOrEmpty(itemNametextBox.Text))
     {
         StoreDAO aDao = new StoreDAO();
         List<Store> aStores = new List<Store>();
         aStores = aDao.GetAllOtherStore();
         otherpurchaseStoredataGridView.DataSource = aStores;
     }
     else
     {
         StoreDAO aDao = new StoreDAO();
         List<Store> aStores = new List<Store>();
         aStores = aDao.GetAllOtherStore();
         List<Store> aastore = (from myRow in aStores.AsEnumerable()
                                where myRow.ItemName.ToUpper().StartsWith(itemNametextBox.Text.ToUpper())
                                select myRow).ToList();
         // DataView view = results.AsDataView();
         otherpurchaseStoredataGridView.DataSource = aastore;
     }
 }
예제 #9
0
        private void purchaseStoredataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }
            try
            {

                if(e.ColumnIndex==8) //when purchase
                {
                    PurchaseForm aForm=new PurchaseForm();
                    aForm.CategoryId = Convert.ToInt32("0" + purchaseStoredataGridView.Rows[e.RowIndex].Cells[1].Value);
                    aForm.ItemId = Convert.ToInt32("0" + purchaseStoredataGridView.Rows[e.RowIndex].Cells[0].Value);
                    aForm.itemnamelabel.Text = ( purchaseStoredataGridView.Rows[e.RowIndex].Cells[1+2].Value).ToString();
                    aForm.unitnameLebel.Text = (purchaseStoredataGridView.Rows[e.RowIndex].Cells[2+2].Value).ToString();
                    aForm.ShowDialog();
                    LoadGridView();
                }
                if (e.ColumnIndex == 9) //when stockout
                {
                    DamageOrStockOut aForm=new DamageOrStockOut();
                    aForm.CategoryId = Convert.ToInt32("0" + purchaseStoredataGridView.Rows[e.RowIndex].Cells[1].Value);
                    aForm.ItemId = Convert.ToInt32("0" + purchaseStoredataGridView.Rows[e.RowIndex].Cells[0].Value);
                    aForm.itemnamelabel.Text = (purchaseStoredataGridView.Rows[e.RowIndex].Cells[1 + 2].Value).ToString();
                    aForm.unitnameLebel.Text = (purchaseStoredataGridView.Rows[e.RowIndex].Cells[2 + 2].Value).ToString();
                    aForm.transactiontypelebel.Text = "Stock Out";
                    aForm.ShowDialog();
                    LoadGridView();
                }
                if (e.ColumnIndex == 10) //when damage
                {
                    DamageOrStockOut aForm = new DamageOrStockOut();
                    aForm.CategoryId = Convert.ToInt32("0" + purchaseStoredataGridView.Rows[e.RowIndex].Cells[1].Value);
                    aForm.ItemId = Convert.ToInt32("0" + purchaseStoredataGridView.Rows[e.RowIndex].Cells[0].Value);
                    aForm.itemnamelabel.Text = (purchaseStoredataGridView.Rows[e.RowIndex].Cells[1 + 2].Value).ToString();
                    aForm.unitnameLebel.Text = (purchaseStoredataGridView.Rows[e.RowIndex].Cells[2 + 2].Value).ToString();
                    aForm.transactiontypelebel.Text = "Damage";
                    aForm.ShowDialog();
                    LoadGridView();
                }

                if (e.ColumnIndex == 11) //when delete
                {
                    DialogResult dialogResult = MessageBox.Show("Are you sure want to delete it?", "Alert!", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        StoreDAO aStoreDao=new StoreDAO();
                        string sr = aStoreDao.DeleteItem(Convert.ToInt32("0" + purchaseStoredataGridView.Rows[e.RowIndex].Cells[0].Value));
                        MessageBox.Show(sr);
                        LoadGridView();
                    }
                    else if (dialogResult == DialogResult.No)
                    {
                        //do something else
                    }
                }

            }
            catch (Exception)
            {

            }
        }
예제 #10
0
        private void showreportButton_Click(object sender, EventArgs e)
        {
            DateTime fromDate = fromdateTimePicker.Value;
            fromDate = fromDate.Date;
            DateTime toDate = todateTimePicker.Value;
            toDate = toDate.Date;
            toDate = toDate.AddDays(1);
            toDate = toDate.AddSeconds(-1);

            List<Transaction1> aTransactions = new List<Transaction1>();
            StoreDAO aStoreDao = new StoreDAO();

            if(categoryRadioButton.Checked)
            {
                aTransactions = aStoreDao.GetOtherTransactionBydate(fromDate, toDate, Convert.ToInt32(categorycomboBox.SelectedValue));
            }
            else  if (transactionRadioButton.Checked)
            {
                aTransactions = aStoreDao.GetOtherTransactionBydateAndTransactionType(fromDate, toDate, transactionTypeComboBox.Text);
            }

            otherdataGridView.DataSource = aTransactions;
        }
예제 #11
0
        private void showreportButton_Click(object sender, EventArgs e)
        {
            DateTime fromDate = fromdateTimePicker.Value;
            fromDate = fromDate.Date;
            DateTime toDate = todateTimePicker.Value;
            toDate = toDate.Date;
            toDate = toDate.AddDays(1);
            toDate = toDate.AddSeconds(-1);

            List<Transaction1> otherTransactions = new List<Transaction1>();
            List<Transaction1> aTransactions = new List<Transaction1>();
            List<Transaction1> employeeTransactions = new List<Transaction1>();
            StoreDAO aStoreDao = new StoreDAO();
            EmployeeDAO aEmployeeDao=new EmployeeDAO();
            otherTransactions = aStoreDao.GetOtherTransactionBydateForProfit(fromDate, toDate);
            aTransactions = aStoreDao.GetTransactionBydateForProfit(fromDate, toDate);
            employeeTransactions = aEmployeeDao.EmployeeTransactionReportBydate(fromDate, toDate);

            Int64 startDate = new DateTime(fromdateTimePicker.Value.Year, fromdateTimePicker.Value.Month, fromdateTimePicker.Value.Day, 0, 0, 0).Ticks;
            DateTime dtTemp = todateTimePicker.Value.AddDays(1);
            Int64 endDate = new DateTime(dtTemp.Year, dtTemp.Month, dtTemp.Day, 0, 0, 0).Ticks;
            List<Transaction1> saleTransactions = new List<Transaction1>();
            saleTransactions = aStoreDao.showAllData(startDate, endDate);
            toDate = todateTimePicker.Value;
            toDate = toDate.Date;
            List<ProfitLoss> aProfitLosses=new List<ProfitLoss>();
            while(fromDate<=toDate)
            {
                ProfitLoss aProfitLoss=new ProfitLoss();
                aProfitLoss.Date = fromDate;
                aProfitLoss.AccsCost = AmountCalculate(otherTransactions, fromDate);
                aProfitLoss.RMCost = AmountCalculate(aTransactions, fromDate);
                aProfitLoss.SalaryCost = AmountCalculate(employeeTransactions, fromDate);
                aProfitLoss.SaleAmount = AmountCalculate(saleTransactions, fromDate);
                double amount1 = (aProfitLoss.AccsCost + aProfitLoss.RMCost + aProfitLoss.SalaryCost);
                if (aProfitLoss.SaleAmount - amount1 < 0)
                {
                    aProfitLoss.Loss = aProfitLoss.SaleAmount - amount1;
                }
                else aProfitLoss.Profit = aProfitLoss.SaleAmount - amount1;
                aProfitLosses.Add(aProfitLoss);
                fromDate = fromDate.AddDays(1);
            }

            profitlossdataGridView.DataSource = aProfitLosses;
        }
예제 #12
0
 private void LoadRawmaterialCategory()
 {
     StoreDAO aStoreDao = new StoreDAO();
     List<Store> aList = new List<Store>();
     aList = aStoreDao.GetAllRawmaterialCategory();
     categorycomboBox.DataSource = aList;
     categorycomboBox.ValueMember = "StoreId";
     categorycomboBox.DisplayMember = "ItemName";
 }