Example #1
0
        private void UC_Dashboards_Load(object sender, EventArgs e)
        {
            int           a;
            SqlConnection con   = new SqlConnection(DataBaseCon.GetConnectionString());
            string        query = "SELECT MAX (IdFatura) FROM FaturaDetajet";
            SqlCommand    cmd   = new SqlCommand(query, con);

            con.Open();
            SqlDataReader dr;

            dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                string val = dr[0].ToString();
                if (val == "")
                {
                    txtInvNo.Text = "1";
                }
                else
                {
                    a             = Convert.ToInt32(dr[0].ToString());
                    a             = a + 1;
                    txtInvNo.Text = a.ToString();
                }
                con.Close();
            }
            dgListOfItems.Rows.Clear();
        }
Example #2
0
        public AutoCompleteStringCollection ItemsListDropDown()
        {
            SqlConnection con = new SqlConnection(DataBaseCon.GetConnectionString());
            AutoCompleteStringCollection asc = new AutoCompleteStringCollection();

            try
            {
                string query;
                query = "SELECT Barkodi FROM Artikulli";

                SqlCommand com = new SqlCommand(query, con);

                SqlDataReader dr;
                con.Open();

                dr = com.ExecuteReader();
                if ((dr != null) && (dr.HasRows))
                {
                    while (dr.Read())
                    {
                        asc.Add(dr.GetValue(0).ToString());
                    }
                    dr.Close();
                    com.Dispose();
                    con.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(asc);
        }
Example #3
0
        private void btnLogIn_Click(object sender, EventArgs e)
        {
            DashBoard dx = new DashBoard();

            SqlConnection x     = new SqlConnection(DataBaseCon.GetConnectionString());
            string        query = "spLoginKredenciale";
            SqlCommand    da    = new SqlCommand(query, x);

            da.CommandType = CommandType.StoredProcedure;
            da.Parameters.AddWithValue("@_Username", txbUsername.Text.ToString());
            da.Parameters.AddWithValue("@_Passwordi", txbPassword.Text.ToString());
            x.Open();
            SqlDataAdapter adapt = new SqlDataAdapter(da);
            DataSet        ds    = new DataSet();

            adapt.Fill(ds);
            x.Close();
            int count = ds.Tables[0].Rows.Count;

            if (count == 1)
            {
                this.Visible = false;
                dx.Show();
            }
            else
            {
                MetroFramework.MetroMessageBox.Show(this, "Incorrect UserName or Password ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnGetRaports_Click(object sender, EventArgs e)
        {
            SqlConnection  con = new SqlConnection(DataBaseCon.GetConnectionString());
            SqlDataAdapter da  = new SqlDataAdapter("Select * from FaturaDetajet where data between '" + dtPickerFrom.Value.ToString() + "'and'" + dtPickerTo.Value.ToString() + "'", con);
            DataTable      dt  = new DataTable();

            da.Fill(dt);
            dgRaports.DataSource = dt;

            double t2 = 0;

            for (int i = 0; i < dgRaports.Rows.Count; i++)
            {
                t2 += Convert.ToDouble(dgRaports.Rows[i].Cells[3].Value);
            }
            lblAllAmount.Text = t2.ToString();
        }
Example #5
0
        private void btnCash_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < dgListOfItems.Rows.Count; i++)
            {
                SqlConnection con = new SqlConnection(DataBaseCon.GetConnectionString());
                SqlCommand    cmd = new SqlCommand(@"INSERT INTO FaturaDetajet(IdFatura,IdArtikulli,Sasia,Cmimi,Data) VALUES ('" + dgListOfItems.Rows[i].Cells[8].Value + "','" + dgListOfItems.Rows[i].Cells[1].Value + "','" + dgListOfItems.Rows[i].Cells[6].Value + "','" + dgListOfItems.Rows[i].Cells[5].Value + "','" + dgListOfItems.Rows[i].Cells[9].Value + "')", con);
                con.Open();
                cmd.ExecuteNonQuery();
                MessageBox.Show("Test");
                con.Close();
            }

            int           a;
            SqlConnection conn  = new SqlConnection(DataBaseCon.GetConnectionString());
            string        query = "SELECT MAX (IdFatura) FROM FaturaDetajet";
            SqlCommand    cmdd  = new SqlCommand(query, conn);

            conn.Open();
            SqlDataReader dr;

            dr = cmdd.ExecuteReader();
            if (dr.Read())
            {
                string val = dr[0].ToString();
                if (val == "")
                {
                    txtInvNo.Text = "1";
                }
                else
                {
                    a             = Convert.ToInt32(dr[0].ToString());
                    a             = a + 1;
                    txtInvNo.Text = a.ToString();
                }
                conn.Close();
            }
            dgListOfItems.Rows.Clear();
            label4.Text   = "00.0";
            lblNoTax.Text = "00.0";
            lblTax.Text   = "00.0";
        }
Example #6
0
        private void dgListOfItems_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                SqlConnection con = new SqlConnection(DataBaseCon.GetConnectionString());
                if (e.ColumnIndex == 0)
                {
                    string newValue;

                    newValue = (dgListOfItems[e.ColumnIndex, e.RowIndex].Value).ToString();
                    con.Open();
                    SqlDataAdapter da = new SqlDataAdapter("SELECT IdArtikulli,EmriArtikullit, Njesia, Pershkrimi, Cmimi FROM Artikulli where Barkodi = '" + newValue + "' ", con);
                    DataTable      dt = new DataTable();
                    da.Fill(dt);

                    //bool duple = false;
                    //for (int i = 0; i < dgListOfItems.Rows.Count; i++)
                    //{
                    //    if (newValue == dgListOfItems.Rows[i].Cells[0].Value.ToString())
                    //    {
                    //        duple = true;
                    //        MessageBox.Show("duple");
                    //        break;
                    //    }


                    //}
                    //if (!duple)
                    //{
                    dgListOfItems.Rows[e.RowIndex].Cells[1].Value = dt.Rows[0][0].ToString();
                    dgListOfItems.Rows[e.RowIndex].Cells[2].Value = dt.Rows[0][1].ToString();
                    dgListOfItems.Rows[e.RowIndex].Cells[3].Value = dt.Rows[0][2].ToString();
                    dgListOfItems.Rows[e.RowIndex].Cells[4].Value = dt.Rows[0][3].ToString();
                    dgListOfItems.Rows[e.RowIndex].Cells[5].Value = dt.Rows[0][4].ToString();
                    dgListOfItems.Rows[e.RowIndex].Cells[6].Value = 1.ToString();

                    con.Close();

                    //}
                }
            }
            catch (Exception)
            {
                //MetroFramework.MetroMessageBox.Show(this, "This Barcode not Exist", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }



            foreach (DataGridViewRow row in dgListOfItems.Rows)
            {
                int qnt = Convert.ToInt32(row.Cells[6].Value);



                if (Convert.ToString(row.Cells[6].Value) == qnt.ToString())
                {
                    row.Cells[dgListOfItems.Columns[7].Index].Value = (Convert.ToDouble(row.Cells[dgListOfItems.Columns[5].Index].Value) * Convert.ToDouble(row.Cells[dgListOfItems.Columns[6].Index].Value));
                    dgListOfItems.Refresh();

                    double sum = 0;
                    double a   = 0.16;
                    for (int i = 0; i < dgListOfItems.Rows.Count; ++i)
                    {
                        sum += Convert.ToDouble(dgListOfItems.Rows[i].Cells[7].Value);
                    }

                    lblNoTax.Text = Convert.ToString(sum - (a * sum));
                    lblTax.Text   = Convert.ToString(a * sum);
                    label4.Text   = sum.ToString();
                }
            }
        }
 public DrinkDataAccess()
 {
     this.dataBase = new DataBaseCon();
 }
 public OrderDataAccess()
 {
     this.dataBase = new DataBaseCon();
 }
Example #9
0
 public CoinDataAccess()
 {
     this.dataBase = new DataBaseCon();
 }