Exemplo n.º 1
0
        private void frmSaleItem_Load(object sender, EventArgs e)
        {
            try
            {
                bool isExist = ShopDAL.isItemTypeExists();
                if (isExist)
                {
                    ShopDAL db = new ShopDAL();
                    DataSet ds = db.GetItemsType();

                    //Creating dictionary to handle available quantity of all items. It's made of pair (Type_ID, Quantity)
                    quantitiesLeft = new Dictionary <string, string>();
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        quantitiesLeft.Add(dr["Type_ID"].ToString(), ShopDAL.getStockInHandQuantity(long.Parse(dr["Type_ID"].ToString())).ToString());
                    }

                    // Inserting Default Row for Selection
                    DataRow defaultRow = ds.Tables[0].NewRow();
                    defaultRow["Type_ID"] = "0";
                    defaultRow["Name"]    = "---------------- Select Item Type ----------------";
                    ds.Tables[0].Rows.InsertAt(defaultRow, 0);

                    cmb_itemType.DataSource    = ds.Tables[0];
                    cmb_itemType.DisplayMember = "Name";
                    cmb_itemType.ValueMember   = "Type_ID";
                    cmb_itemType.SelectedIndex = 0;

                    cmb_itemType.AutoCompleteMode   = AutoCompleteMode.Append;
                    cmb_itemType.AutoCompleteSource = AutoCompleteSource.ListItems;

                    lstView_sales.Columns[0].Width = 0;
                    lblItemCount.Text  = "0";
                    lblTotalPrice.Text = ConfigurationDAL.GetCurrentCurrency() + " 0.00";
                    txtSalePrice.Text  = "0";
                }
            }
            catch (IndexOutOfRangeException ex)
            {
                MessageBox.Show(this, "Add atleast one item type to Sale Item(s)", "Error:Sale Item(s)", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message.ToString(), "Error:Sale Item(s)", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }


            //string[] row1 = { "CD-Software", "2", "30" };
            //string[] row2 = { "CD-Software", "2", "30" };

            /*lstView_sales.Items.Add("1").SubItems.AddRange(row1);
             * lstView_sales.Items.Add("1").SubItems.AddRange(row2);
             *
             * foreach(ListViewItem lvi in lstView_sales.Items)
             * {
             *  MessageBox.Show(lvi.SubItems[3].Text);
             * }*/
        }
        private void onLoadBuy(object sender, EventArgs e)
        {
            try
            {
                bool isExist = ShopDAL.isItemTypeExists();
                if (isExist)
                {
                    ShopDAL dal = new ShopDAL();
                    DataSet ds  = dal.GetItemsType();
                    cmbItemType.DataSource    = ds.Tables[0];
                    cmbItemType.DisplayMember = "Name";
                    cmbItemType.ValueMember   = "Type_ID";
                }

                DataSet dsContractor = ContractorDAL.getContractorsDs();
                DataRow defaultRow   = dsContractor.Tables[0].NewRow();
                defaultRow["ID"]   = "0";
                defaultRow["Name"] = "------ Select Contractor  ------";
                dsContractor.Tables[0].Rows.InsertAt(defaultRow, 0);

                cmbContractor.DataSource    = dsContractor.Tables[0];
                cmbContractor.DisplayMember = "Name";
                cmbContractor.ValueMember   = "ID";
            }
            catch (IndexOutOfRangeException ex)
            {
                MessageBox.Show(this, "Add atleast one item type to add purchase", "Error:Add new stock", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message.ToString(), "Error:Add New Stock", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }
Exemplo n.º 3
0
        private void frmSearchItem_Load(object sender, EventArgs e)
        {
            lblTotalProfit.Text = ConfigurationDAL.GetCurrentCurrency() + " 0.00";
            try
            {
                bool isExist = ShopDAL.isItemTypeExists();
                if (isExist)
                {
                    ShopDAL db = new ShopDAL();
                    DataSet ds = db.GetItemsType();

                    DataRow defaultRow = ds.Tables[0].NewRow();
                    defaultRow["Type_ID"] = "0";
                    defaultRow["Name"]    = "---------------- Select Item Type ----------------";
                    ds.Tables[0].Rows.InsertAt(defaultRow, 0);

                    cmb_itemType.DataSource    = ds.Tables[0];
                    cmb_itemType.DisplayMember = "Name";
                    cmb_itemType.ValueMember   = "Type_ID";
                    cmb_itemType.SelectedIndex = 0;
                }
            }
            catch (IndexOutOfRangeException ex)
            {
                MessageBox.Show(this, "Add atleast one item type", "Error:Search Item(s)", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message.ToString(), "Error:Search Item(s)", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
            setupGridColumns();
            setupColumnsWidth();
        }