Exemplo n.º 1
0
        private void xemDanhMụcVậtTưCủaCụmToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string code       = TextUtils.ToString(grvData.GetFocusedRowCellValue(colCode));
            string name       = TextUtils.ToString(grvData.GetFocusedRowCellValue(colName));
            string moduleCode = code.Substring(0, 10);

            DataTable dtDMVT = TextUtils.Select("select * from MaterialModuleLink with(nolock) where ModuleCode = '" + moduleCode + "'");

            DataRow[] drs = dtDMVT.Select("Code = '" + code + "'");
            if (drs.Length < 0)
            {
                return;
            }

            string stt = TextUtils.ToString(drs[0]["STT"]);

            DataRow[] drs1 = dtDMVT.Select("STT like '" + stt + ".%'");
            if (drs1.Length > 0)
            {
                DataTable dt = drs1.CopyToDataTable();
                dt.ImportRow(drs[0]);

                frmViewDMVT frm = new frmViewDMVT();
                frm.DtDMVT = dt;
                frm.Code   = code;
                frm.Name   = name;
                frm.Show();
            }
        }
Exemplo n.º 2
0
        private void btnShowDMVT_Click(object sender, EventArgs e)
        {
            string    code   = TextUtils.ToString(grvData.GetFocusedRowCellValue(colCodeTK));
            string    name   = TextUtils.ToString(grvData.GetFocusedRowCellValue(colNameTK));
            DataTable dtDMVT = new DataTable();

            dtDMVT = LibQLSX.Select("select * from vMaterialModuleLink with(nolock) where ModuleCode = '" + code + "' order by ID");
            frmViewDMVT frm = new frmViewDMVT();

            frm.Name   = name;
            frm.Code   = code;
            frm.DtDMVT = dtDMVT.Copy();
            frm.Show();
        }
Exemplo n.º 3
0
        private void xemDanhMụcVậtTưToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát", "Đang load danh mục vật tư"))
                {
                    DocUtils.InitFTPQLSX();
                    string code = gridView1.GetFocusedRowCellValue(colModuleCode).ToString();
                    string name = gridView1.GetFocusedRowCellValue(colModuleName).ToString();

                    //string strFilePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                    //string strFTPFileName = @"//Thietke.Ck/" + code.Substring(0, 6) + "/" + code + ".Ck" + "/VT." + code + ".xlsm ";
                    //string strSaveName = code + ".xlsm";
                    //if (!DocUtils.CheckExits(strFTPFileName))
                    //{
                    //    MessageBox.Show("Module không có trên nguồn thiết kế!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    //    return;
                    //}
                    //DocUtils.DownloadFile(strFilePath, strSaveName, strFTPFileName);
                    //DataTable dtDMVT = TextUtils.ExcelToDatatableNoHeader(strFilePath + "/" + strSaveName, "DMVT");
                    //if (File.Exists(strFilePath + "/" + strSaveName))
                    //{
                    //    File.Delete(strFilePath + "/" + strSaveName);
                    //}
                    //dtDMVT = dtDMVT.AsEnumerable()
                    //           .Where(row => TextUtils.ToInt(row.Field<string>("F1") == "" ||
                    //               row.Field<string>("F1") == null ? "0" : row.Field<string>("F1").Substring(0, 1)) > 0)
                    //           .CopyToDataTable();

                    DataTable dtDMVT = TextUtils.Select("select * from vMaterialModuleLink with(nolock) where ModuleCode = '" + code + "'");

                    // Hiển thị trên form
                    frmViewDMVT frm = new frmViewDMVT();
                    frm.Name   = name;
                    frm.Code   = code;
                    frm.DtDMVT = dtDMVT.Copy();
                    frm.Show();
                }
            }
            catch (Exception ex)
            {
                TextUtils.ShowError(ex);
            }
        }
Exemplo n.º 4
0
        private void btnShowDMVT_Click(object sender, EventArgs e)
        {
            try
            {
                using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát", "Đang load danh mục vật tư"))
                {
                    //DocUtils.InitFTPQLSX();
                    string code           = grvData.GetFocusedRowCellValue(colCode).ToString();
                    string name           = grvData.GetFocusedRowCellValue(colName).ToString();
                    string strFilePath    = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                    string strFTPFileName = "";
                    string strSaveName    = "";
                    DocUtils.InitFTPQLSX();
                    DataTable dtDMVT = new DataTable();

                    if (code.StartsWith("TPAD."))
                    {
                        //dtDMVT = LibQLSX.Select("select * from MaterialModuleLink with(nolock) where ModuleCode = '" + code + "' order by ID");
                        strFTPFileName = string.Format("Thietke.Ck/{0}/{1}.Ck/VT.{1}.xlsm", code.Substring(0, 6), code);
                        strSaveName    = code + ".xlsm";
                    }
                    else
                    {
                        strFTPFileName = @"//Thietke.Dt/PCB/" + code + "/PRD." + code + "/VT." + code + ".xls";
                        strSaveName    = code + ".xls";
                    }

                    if (!DocUtils.CheckExits(strFTPFileName))
                    {
                        MessageBox.Show("Module không có trên nguồn thiết kế!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        return;
                    }
                    DocUtils.DownloadFile(strFilePath, strSaveName, strFTPFileName);
                    dtDMVT = TextUtils.ExcelToDatatableNoHeader(strFilePath + "/" + strSaveName, "DMVT");
                    if (File.Exists(strFilePath + "/" + strSaveName))
                    {
                        File.Delete(strFilePath + "/" + strSaveName);
                    }
                    dtDMVT.Columns["F1"].ColumnName  = "STT";
                    dtDMVT.Columns["F2"].ColumnName  = "Name";
                    dtDMVT.Columns["F3"].ColumnName  = "ThongSo";
                    dtDMVT.Columns["F4"].ColumnName  = "Code";
                    dtDMVT.Columns["F5"].ColumnName  = "MaVatLieu";
                    dtDMVT.Columns["F6"].ColumnName  = "Unit";
                    dtDMVT.Columns["F7"].ColumnName  = "Qty";
                    dtDMVT.Columns["F8"].ColumnName  = "VatLieu";
                    dtDMVT.Columns["F9"].ColumnName  = "Weight";
                    dtDMVT.Columns["F10"].ColumnName = "Hang";
                    dtDMVT.Columns["F11"].ColumnName = "Description";

                    dtDMVT = dtDMVT.AsEnumerable()
                             .Where(row => TextUtils.ToInt(row.Field <string>("STT") == "" ||
                                                           row.Field <string>("STT") == null ? "0" : row.Field <string>("STT").Substring(0, 1)) > 0)
                             .CopyToDataTable();

                    // Hiển thị trên form
                    frmViewDMVT frm = new frmViewDMVT();
                    frm.Name   = name;
                    frm.Code   = code;
                    frm.DtDMVT = dtDMVT.Copy();
                    frm.Show();
                }
            }
            catch (Exception ex)
            {
                TextUtils.ShowError(ex);
            }
        }