コード例 #1
0
 private void cbTenPhim_SelectedIndexChanged(object sender, EventArgs e)
 {
     dsPhim = dbPhim.TimPhim(cbTenPhim.Text.Trim());
     if (dsPhim.Tables[0].Rows.Count > 0)
     {
         txtMaPhim.Enabled = true;
         txtMaPhim.Text    = dsPhim.Tables[0].Rows[0].ItemArray[1].ToString();
         txtMaPhim.Enabled = false;
     }
 }
コード例 #2
0
        private void XuLyGioKetThuc()
        {
            DataSet ds        = dbPhim.TimPhim(Phimcb.Text.Trim());
            float   ThoiLuong = Convert.ToInt64(ds.Tables[0].Rows[0].ItemArray[4].ToString());
            float   Phut      = ThoiLuong % 60;
            float   Gio       = ThoiLuong / 60;

            Gio = Convert.ToInt64(Math.Round(Convert.ToDouble(Gio)));
            //tách suất chiếu
            string[] container;
            string   str = SuatChieucb.Text.ToString();

            container = str.ToLower().Split('h');
            foreach (var item in container)
            {
                if (item.Length < 2)
                {
                    item.Insert(0, "0");
                }
            }
            //xử lí phút:
            float phutKetThuc = Phut + Convert.ToInt64(container[1]);
            float carry       = 0;

            if (phutKetThuc > 60)
            {
                carry        = 1;
                phutKetThuc -= 60;
            }
            else if (phutKetThuc == 60)
            {
                carry       = 1;
                phutKetThuc = 0;
            }
            //xử lí giờ
            float gioKetThuc = Gio + Convert.ToInt64(container[0]);

            if (gioKetThuc + carry > 24)
            {
                gioKetThuc = gioKetThuc - 24 + carry;
            }
            else if (gioKetThuc + carry == 24)
            {
                gioKetThuc = 0;
            }
            else
            {
                gioKetThuc += carry;
            }
            //join 2 vế

            if (phutKetThuc.ToString().Length < 2)
            {
                //xử lí phút
                container[1] = phutKetThuc.ToString().Insert(0, "0");
            }
            else
            {
                container[1] = phutKetThuc.ToString();
            }
            if (gioKetThuc.ToString().Length < 2)
            {
                container[0] = gioKetThuc.ToString().Insert(0, "0");
            }
            else
            {
                container[0] = gioKetThuc.ToString();
            }
            string final = string.Join(":", container);

            txtGioKetThuc.Text = final;
        }