private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     Lblcapacidad.Text          = dataGridView1.CurrentRow.Cells[2].Value.ToString();
     lblUnidad.Text             = dataGridView1.CurrentRow.Cells[3].Value.ToString();
     lblunidadseleccionada.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString();
     DateTimePicker1.Focus();
 }
 private void DateTimePicker1_Validating(System.Object sender, System.ComponentModel.CancelEventArgs e)
 {
     if ((DateTimePicker2.Value.Date) > (DateTimePicker1.Value.Date))
     {
         MessageBox.Show("Invalid Selection", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         DateTimePicker1.Focus();
     }
 }
Ejemplo n.º 3
0
 private void ResetRecord()
 {
     DateTimePicker1.Value = DateTime.Now;
     TextBox1.Clear();
     TextBox2.Clear();
     TextBox3.Clear();
     btnadd.Text = "Add";
     DateTimePicker1.Focus();
 }
Ejemplo n.º 4
0
 protected void bttHuyBo_Click(object sender, EventArgs e)
 {
     txtMaCP.Text           = "";
     txtGiaGoc.Text         = "";
     txtGiaSauKhiGiam.Text  = "";
     txtRreaDKSU.InnerText  = "";
     txtSLCPMinGiamGia.Text = "";
     txtSLSPmin.Text        = "";
     DateTimePicker1.setDate("");
     DateTimePicker2.setDate("");
 }
Ejemplo n.º 5
0
        protected void bttDangSP_Click(object sender, EventArgs e)
        {
            if (DateTimePicker1.getDate() == "" && DateTimePicker2.getDate() == "")
            {
                lbResultInfo.Text = "Chưa điền ngày";
                return;
            }
            DateTime batdau;
            DateTime ketthuc;

            if (!DateTime.TryParse(DateTimePicker1.getDate(), out batdau))
            {
                lbResultInfo.Text = "Trường ngày bắt đầu không đúng dịnh dạng ngày";
                return;
            }
            if (!DateTime.TryParse(DateTimePicker2.getDate(), out ketthuc))
            {
                lbResultInfo.Text = "Trường ngày kết thúc không đúng dịnh dạng ngày";
                return;
            }
            COUPON_DTO couDTO = new COUPON_DTO();

            couDTO.MaCoupon          = txtMaCP.Text;
            couDTO.MaSanPham         = ddlTenSP.SelectedValue.ToString();
            couDTO.GiaSauGiam        = float.Parse(txtGiaSauKhiGiam.Text);
            couDTO.ThoiGianBD        = batdau;
            couDTO.ThoiGianKT        = ketthuc;
            couDTO.SoLuongSanPhamMin = int.Parse(txtSLSPmin.Text);
            couDTO.TinhTrangCoupon   = "1";
            couDTO.DieuKienSuDung    = txtRreaDKSU.Value.ToString();
            couDTO.GiaGoc            = float.Parse(txtGiaGoc.Text);
            couDTO.DonViTienTe       = ddlDVTienTe.Text;
            couDTO.SoLuongCouponMin  = int.Parse(txtSLCPMinGiamGia.Text);
            try
            {
                CouponBUS.CreateCoupon(couDTO);
                lbResultInfo.Text = "Đã tạo thành công";
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int isLogIn;

            int.TryParse(Session["IsLogin"].ToString(), out isLogIn);
            if (isLogIn == 1)
            {
                string typeUser = Session["LoaiUser"].ToString();
                if (typeUser == "Manager" && Request.QueryString["macp"] != "")
                {
                    if (!IsPostBack)
                    {
                        string     macp = Request.QueryString["macp"];
                        COUPON_DTO cp   = CouponBUS.GetCouponInfor1(macp);
                        txtGiaGoc.Text         = cp.GiaGoc.ToString();
                        txtGiaSauKhiGiam.Text  = cp.GiaSauGiam.ToString();
                        txtMaCP.Text           = cp.MaCoupon;
                        txtRreaDKSU.Value      = cp.DieuKienSuDung;
                        txtSLCPMinGiamGia.Text = cp.SoLuongCouponMin.ToString();
                        txtSLSPmin.Text        = cp.SoLuongSanPhamMin.ToString();
                        DateTimePicker1.setDate(cp.ThoiGianBD.ToShortDateString());
                        DateTimePicker2.setDate(cp.ThoiGianKT.ToShortDateString());
                        TextBox1.Text = cp.TenSanPham;

                        /*
                         * List<Coupon> list = CouponBUS.GetCouponInfor(macp);
                         * txtGiaGoc.Text = list[0].GiaHangKhiChuaGiam.ToString();
                         * txtGiaSauKhiGiam.Text = list[0].GiaHangSauKhiGiam.ToString();
                         * txtMaCP.Text = list[0].MaCoupon;
                         * txtRreaDKSU.Value = list[0].DieuKienSuDung;
                         * txtSLCPMinGiamGia.Text=list[0].s*/
                    }
                }
                else
                {
                    Response.Redirect("../Shared/Default.aspx");
                }
            }
            else
            {
                Response.Redirect("../Shared/Default.aspx");
            }
        }
Ejemplo n.º 7
0
        private void DateTimePicker1_CalendarClosed(object sender, RoutedEventArgs e)
        {
            bool b2 = false;

            using (StreamReader file = new StreamReader("WriteLines.txt"))
            {
                string ln;

                while ((ln = file.ReadLine()) != null)
                {
                    if (ln == DateTimePicker1.ToString())
                    {
                        Textbox1.Text = file.ReadLine();
                        b2            = true;
                    }
                }
                file.Close();
            }
            if (b2 == false)
            {
                if (this.isDataDirty)
                {
                    string           msg    = "Data is dirty. Close without saving?";
                    MessageBoxResult result =
                        MessageBox.Show(
                            msg,
                            "Data App",
                            MessageBoxButton.YesNo,
                            MessageBoxImage.Warning);
                    if (result == MessageBoxResult.No)
                    {
                        // If user doesn't want to close, cancel closure
                    }
                    else
                    {
                        Textbox1.Text    = "";
                        this.isDataDirty = false;
                    }
                }
            }
        }
Ejemplo n.º 8
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string           messageBoxText = "There is entry on this date, do you want to override?";
            string           caption        = "Word Processor";
            MessageBoxButton button         = MessageBoxButton.YesNoCancel;
            MessageBoxImage  icon           = MessageBoxImage.Warning;
            int b1 = 0;

            using (StreamReader file = new StreamReader("WriteLines.txt"))
            {
                string ln;

                while ((ln = file.ReadLine()) != null)
                {
                    if (ln == DateTimePicker1.ToString())
                    {
                        b1 = 1;
                    }
                }
                file.Close();
            }

            if (b1 == 1)
            {
                using (StreamReader file = new StreamReader("WriteLines.txt"))
                {
                    string ln;

                    while ((ln = file.ReadLine()) != null)
                    {
                        if (ln == DateTimePicker1.ToString())
                        {
                            MessageBoxResult result = MessageBox.Show(messageBoxText, caption, button, icon);
                            switch (result)
                            {
                            case MessageBoxResult.Yes:
                                b1 = 2;
                                break;

                            case MessageBoxResult.No:
                                // User pressed No button
                                // ...
                                break;

                            case MessageBoxResult.Cancel:
                                // User pressed Cancel button
                                // ...
                                break;
                            }
                        }
                    }
                    file.Close();
                }
            }

            if (b1 == 2)
            {
                List <string> quotelist = File.ReadAllLines("WriteLines.txt").ToList();
                for (int i = 0; i < quotelist.Count; i++)
                {
                    if (quotelist[i] == DateTimePicker1.ToString())
                    {
                        quotelist.RemoveRange(i, 2);
                        break;
                    }
                }
                File.WriteAllLines("WriteLines.txt", quotelist.ToArray());
                using (StreamWriter writetext = File.AppendText("WriteLines.txt"))
                {
                    writetext.WriteLine(DateTimePicker1.ToString());
                    writetext.WriteLine(Textbox1.Text);
                }
                this.isDataDirty = false;
            }
            else
            {
                using (StreamWriter writetext = File.AppendText("WriteLines.txt"))
                {
                    writetext.WriteLine(DateTimePicker1.ToString());
                    writetext.WriteLine(Textbox1.Text);
                }
                this.isDataDirty = false;
            }
        }
Ejemplo n.º 9
0
 private void Open_Click(object sender, RoutedEventArgs e)
 {
     DateTimePicker1.OpenPopup();
 }