Exemplo n.º 1
0
 private void btnThayDoiTuan_Click(object sender, EventArgs e)
 {
     Otif_DungChung._Tuan = Otif_DungChung.GetWeek((DateTime)dtpTuanNam.EditValue);
     Otif_DungChung._Nam  = ((DateTime)dtpTuanNam.EditValue).Year;
     lblTuanHienTai.Text  = string.Format("Tuần hiện tại: {0}/{1}", Otif_DungChung._Tuan, Otif_DungChung._Nam);
     MessageBox.Show("Thay đổi tuần làm việc thành công!", "Thông báo.");
 }
 private void uc_LaySanLuong_Load(object sender, EventArgs e)
 {
     _clsSL = new cls_SanLuong();
     Otif_DungChung.GetDonVi();
     dtpTuNgay.EditValue  = DateTime.Now;
     dtpDenNgay.EditValue = DateTime.Now;
 }
        private void uc_TienDoKeo_Load(object sender, EventArgs e)
        {
            Otif_DungChung.GetDonVi();
            dtpTuanNam.EditValue = DateTime.Now;

            _clsTDK = new cls_TienDoKeo();
            _clsDV  = new cls_DonVi();

            gvTienDoKeo.BestFitColumns();

            Load_KhauSanXuat();

            groupControl3.Text = string.Format("Tiến độ kéo tuần {0} năm {1}", Otif_DungChung.GetWeek(DateTime.Now), DateTime.Now.Year);
        }
 private void dtpTuanNam_EditValueChanged(object sender, EventArgs e)
 {
     groupControl3.Text = string.Format("Tiến độ kéo tuần {0} năm {1}", Otif_DungChung.GetWeek((DateTime)dtpTuanNam.EditValue), ((DateTime)dtpTuanNam.EditValue).Year);
 }
        private void btnImport_Click(object sender, EventArgs e)
        {
            DataTable data = GetDataTable(gvTienDoKeo);

            if (data.Rows.Count <= 0)
            {
                XtraMessageBox.Show("Vui lòng view file trước khi import.", "Có lỗi trong quá trình upload excel", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //Tạo bảng header
            //Đối với user admin được quyền chọn thời gian, đơn vị để up tiến độ kéo
            tbl_BangTienDoKeo_H header = new tbl_BangTienDoKeo_H();

            if (glueKhau.EditValue != null && (clsBienHeThong._MaNV == "admin" || Otif_DungChung._DonViID == 34))
            {
                header = _clsTDK.CreateHeader(new tbl_BangTienDoKeo_H()
                {
                    Tuan        = Otif_DungChung.GetWeek((DateTime)dtpTuanNam.EditValue),
                    Nam         = ((DateTime)dtpTuanNam.EditValue).Year,
                    DonViID     = clsXuLyChung.GetSafeInt(glueKhau.EditValue),
                    NgayCapNhat = DateTime.Now
                });
            }
            else
            {
                header = _clsTDK.CreateHeader(new tbl_BangTienDoKeo_H()
                {
                    Tuan        = Otif_DungChung.GetWeek(DateTime.Now),
                    Nam         = DateTime.Now.Year,
                    DonViID     = Otif_DungChung._DonViID,
                    NgayCapNhat = DateTime.Now
                });
            }
            //Xử lý data thành List<tbl_BangTienDoKeo_L>
            List <tbl_BangTienDoKeo_L> tienDoKeos = new List <tbl_BangTienDoKeo_L>();

            foreach (DataRow row in data.Rows)
            {
                tbl_BangTienDoKeo_L tienDoKeo_L = new tbl_BangTienDoKeo_L();
                tienDoKeo_L.ID_Header   = header.ID;
                tienDoKeo_L.NGH         = (DateTime)row[0];
                tienDoKeo_L.KHACHHANG   = row[1].ToString();
                tienDoKeo_L.SOLSX       = row[2].ToString();
                tienDoKeo_L.MASP        = row[3].ToString();
                tienDoKeo_L.MAMAU       = row[4].ToString();
                tienDoKeo_L.COSO        = Convert.ToInt32(row[5]);
                tienDoKeo_L.SLKH        = Convert.ToInt32(row[6]);
                tienDoKeo_L.NSU         = Convert.ToInt32(row[7]);
                tienDoKeo_L.DMHC        = Convert.ToDouble(row[8]);
                tienDoKeo_L.NANGSUAT    = Convert.ToDouble(row[9]);
                tienDoKeo_L.CONGCAN     = Convert.ToDouble(row[10]);
                tienDoKeo_L.LINE        = Convert.ToInt32(row[11]);
                tienDoKeo_L.NGAYBATDAU  = (DateTime)row[12];
                tienDoKeo_L.NGAYKETTHUC = (DateTime)row[13];

                tienDoKeos.Add(tienDoKeo_L);
            }

            //MessageBox.Show(tienDoKeos.Count.ToString());
            if (_clsTDK.CreateLine(tienDoKeos))
            {
                XtraMessageBox.Show("Import excel thành công.", "", MessageBoxButtons.OK, MessageBoxIcon.None);
            }
            else
            {
                XtraMessageBox.Show("Import không thành công.", "Có lỗi trong quá trình upload excel", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }