Esempio n. 1
0
        private void bunifuThinButton21_Click(object sender, EventArgs e)
        {
            try
            {
                conn.Open();
                string     sql  = "SELECT DATEDIFF (day, NGAYDEN, NGAYDI) AS ngayo From PHONGTHUE, KHACHHANG WHERE  SOPHONG = '" + sophong + "' AND khachhang.MAKH = '" + makh.Trim() + "'";
                SqlCommand cmd1 = new SqlCommand(sql, conn);
                cmd1.CommandType = CommandType.Text;
                SqlDataAdapter da = new SqlDataAdapter(cmd1);
                DataTable      dt = new DataTable();
                da.Fill(dt);

                object SUM;
                SUM = dt.Compute("Max(ngayo)", "");
                thanhtientext.Text = SUM.ToString();
                int ngayo = Int32.Parse(thanhtientext.Text); // so ngay o

                string     sql2 = "SELECT gia AS GIA From PHONGTHUE, KHACHHANG, LOAIPHONG, PHONG WHERE KHACHHANG.MAKH = PHONGTHUE.MAKH AND PHONGTHUE.SOPHONG = PHONG.SOPHONG AND PHONG.LOAIPHONG = LOAIPHONG.LOAIPHONG AND PHONGTHUE.SOPHONG  = '" + sophong + "' AND khachhang.MAKH = '" + makh.Trim() + "'";
                SqlCommand cmd2 = new SqlCommand(sql2, conn);
                cmd2.CommandType = CommandType.Text;
                SqlDataAdapter da2 = new SqlDataAdapter(cmd2);
                DataTable      dt2 = new DataTable();
                da2.Fill(dt2);

                object GIA;
                GIA = dt2.Compute("Max(GIA)", "");
                thanhtientext.Text = GIA.ToString();
                double gia = Convert.ToDouble(thanhtientext.Text); //so tien trong 1 ngay

                thanhtientext.Text = (gia * ngayo).ToString();     // tong tien

                string     doanhthu    = "UPDATE DOANHTHU SET TONGTIEN = TONGTIEN + " + thanhtientext.Text + " WHERE THANG = " + DateTime.Today.Month.ToString();
                SqlCommand cmddoanhthu = new SqlCommand(doanhthu, conn);  //cong tien vao doanh thu trong thang
                cmddoanhthu.ExecuteNonQuery();

                string     sql3 = "UPDATE PHONGTHUE SET NGAYDI = GETDATE() WHERE MAKH ='" + makhtxt.Text + "' ";
                SqlCommand cmd3 = new SqlCommand(sql3, conn);
                cmd3.ExecuteNonQuery();                         // UPDATE NGAYDI = HOM NAY

                sql2 = "SELECT distinct SOPHONG FROM PHONGTHUE WHERE NGAYDEN <= '" + DateTime.Now.ToString("yyyy/MM/dd") + "' AND NGAYDI > '" + DateTime.Now.ToString("yyyy/MM/dd") + "'";
                showdata(sql2);
            }
            catch
            {
                MessageBox.Show("Loi!!! vui long kiem tra lai");
            }
            finally
            {
                conn.Close();
            }
            FormChinh.LoadTrangThai();
        }
Esempio n. 2
0
        int demgiatri(string sql,string dem, Bunifu.UI.WinForms.BunifuTextbox.BunifuTextBox text)
        {
            conn.Open();
            SqlCommand cmd2 = new SqlCommand(sql, conn);
            cmd2.CommandType = CommandType.Text;
            SqlDataAdapter da2 = new SqlDataAdapter(cmd2);
            DataTable dt2 = new DataTable();
            da2.Fill(dt2);

            object GIA;
            GIA = dt2.Compute(dem, "");
            text.Text = text.Text +": "+ GIA.ToString();
            conn.Close();
            return 0;
        }
Esempio n. 3
0
        /// <summary>
        /// Returns the hash code of the CEP object.
        /// </summary>
        /// <returns>The CEP's hash code.</returns>
        public override int GetHashCode()
        {
            unchecked
            {
                int hashcode;

                const int baseHash       = 63689;
                const int baseMultiplier = 378551;

                hashcode = (baseHash * baseMultiplier) ^ ZipCode.GetHashCode();
                hashcode = (hashcode * baseMultiplier) ^ Address.GetHashCode();
                hashcode = (hashcode * baseMultiplier) ^ Complement.GetHashCode();
                hashcode = (hashcode * baseMultiplier) ^ Neighborhood.GetHashCode();
                hashcode = (hashcode * baseMultiplier) ^ City.GetHashCode();
                hashcode = (hashcode * baseMultiplier) ^ State.GetHashCode();
                hashcode = (hashcode * baseMultiplier) ^ Unity.GetHashCode();
                hashcode = (hashcode * baseMultiplier) ^ IBGE.GetHashCode();
                hashcode = (hashcode * baseMultiplier) ^ GIA.GetHashCode();

                return(hashcode);
            }
        }