Esempio n. 1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            int         id  = TextUtils.ToInt(treeData.FocusedNode.GetValue(colIDTree));
            frmCoCauMau frm = new frmCoCauMau();

            frm.GroupID         = id;
            frm.LoadDataChange += main_LoadDataChange;
            frm.Show();
        }
Esempio n. 2
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            int id = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID));

            if (id == 0)
            {
                return;
            }
            CoCauMauModel model = (CoCauMauModel)CoCauMauBO.Instance.FindByPK(id);
            int           catId = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colGroup));

            _rownIndex = grvData.FocusedRowHandle;

            frmCoCauMau frm = new frmCoCauMau();

            frm.GroupID         = catId;
            frm.CoCau           = model;
            frm.LoadDataChange += main_LoadDataChange;
            frm.Show();
        }
Esempio n. 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);
            }
        }