示例#1
0
        private void btnDeleteIpt_Click(object sender, EventArgs e)
        {
            try
            {
                if (grvIPT.RowCount <= 0)
                {
                    return;
                }
                if (MessageBox.Show("Bạn có thật sự muốn xóa file này không?", TextUtils.Caption,
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }

                pbAnh.InitialImage = null;
                pbAnh.Image        = null;

                int linkID         = TextUtils.ToInt(grvIPT.GetFocusedRowCellValue(colIDipt));
                int materialFileID = TextUtils.ToInt(grvIPT.GetFocusedRowCellValue(colMaterialFileIDipt));

                MaterialFileLinkBO.Instance.Delete(linkID);
                MaterialFileBO.Instance.Delete(materialFileID);

                Material.File3D = 0;
                MaterialBO.Instance.Update(Material);

                loadIpt();

                string filePath = TextUtils.ToString(grvIPT.GetFocusedRowCellValue(colFilePathIPT));
                if (filePath == "")
                {
                    return;
                }
                DocUtils.InitFTPTK();
                DocUtils.DeleteFile(filePath);

                string path      = TextUtils.GetConfigValue("MaterialImagePath");
                string imagePath = path + "\\" + TextUtils.ToString(grvIPT.GetFocusedRowCellValue(colFileNameIPT));
                File.Delete(imagePath);
            }
            catch (Exception ex)
            {
                TextUtils.ShowError(ex.Message);
            }
        }
示例#2
0
        private void pictureBox1_DoubleClick(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter      = "File .iam|*iam|All File|*.*";
            ofd.Multiselect = false;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang load ảnh..."))
                {
                    IPTDetail.LoadData(ofd.FileName);
                    string imagePath = TextUtils.GetConfigValue("CoCauPath") + "\\" + CoCau.Code.Trim() + ".png";
                    Bitmap bit       = new Bitmap(IPTDetail.Image, IPTDetail.Image.Width / 3, IPTDetail.Image.Height / 3);
                    bit.Save(imagePath, ImageFormat.Png);
                    pictureBox1.ImageLocation = imagePath;
                }
            }
        }
示例#3
0
        private void btnCreateCoCau_Click(object sender, EventArgs e)
        {
            if (grvCoCau.Rows.Count == 0)
            {
                MessageBox.Show("Không tìm thấy cơ cấu để tạo!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            string saveImagePath = TextUtils.GetConfigValue("CoCauPath");
            int    count         = 0;

            foreach (DataGridViewRow row in grvCoCau.Rows)
            {
                string    code = TextUtils.ToString(row.Cells["colMaCoCau"].Value);
                DataTable dt   = TextUtils.Select("select top 1 Code from CoCauMau with(nolock) where Code = '" + code + "'");
                if (dt.Rows.Count > 0)
                {
                    continue;
                }

                string name      = TextUtils.ToString(row.Cells["colTenCoCau"].Value);
                string localPath = TextUtils.ToString(row.Cells["colImagePath"].Value);
                int    isSaved   = TextUtils.ToInt(row.Cells["colIsSaved"].Value);
                if (code == "")
                {
                    continue;
                }
                if (isSaved == 1)
                {
                    continue;
                }

                CoCauMauModel CoCau = new CoCauMauModel();
                CoCau.Name           = name.ToUpper();
                CoCau.Code           = code.ToUpper();
                CoCau.CoCauGroupID   = GroupID;
                CoCau.Note           = "";
                CoCau.Specifications = "";

                try
                {
                    File.Copy(localPath, saveImagePath + "//" + Path.GetFileName(localPath), true);
                    CoCau.ImagePath = saveImagePath + "//" + Path.GetFileName(localPath);
                    CoCau.ID        = (int)CoCauMauBO.Instance.Insert(CoCau);
                    count++;

                    frmCoCauMau frm = new frmCoCauMau();
                    frm.CoCau   = CoCau;
                    frm.GroupID = GroupID;
                    frm.ShowDialog();

                    _dtCoCau.Rows[row.Index]["IsSaved"] = 1;
                }
                catch
                {
                }
            }

            if (count > 0)
            {
                MessageBox.Show("Tạo cơ cấu thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);

                if (this.LoadDataChange != null)
                {
                    this.LoadDataChange(null, null);
                }
            }
            else
            {
                MessageBox.Show("Các cơ cấu này đã được tạo!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }