Example #1
0
 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (EditList.Count > 0)
     {
         e.Cancel = true;
         ToastMessage.Show(this, "有未保存的项目,请保存完之后再退出。");
     }
 }
Example #2
0
        private void ArchiveForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            List <GridRow> list = GetUnSavedList();

            if (list.Count > 0)
            {
                ToastMessage.Show(this, "尚有未保存的内容,请保存后再退出。");
                e.Cancel = true;
            }
        }
Example #3
0
        private void btnSaveRegister_Click(object sender, EventArgs e)
        {
            btnRegistration.Focus();
            List <GridRow> list = GetUnSavedList();

            if (list.Count == 0)
            {
                ToastMessage.Show(this, "没有可保存的内容。");
                return;
            }
            SaveArchiveInfo(list);
            ToastMessage.Show(this, "已保存。");
        }
Example #4
0
 private void btnSaveProject_Click(object sender, EventArgs e)
 {
     btnSaveProject.Focus();
     ProjectGrid.EndUpdate();
     if (EditList.Count == 0)
     {
         ToastMessage.Show(this, "没有可保存的内容。");
         return;
     }
     SaveProjectInfo(EditList);
     EditList.Clear();
     ToastMessage.Show(this, "已保存。");
 }
Example #5
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            bool      IsWarninged = false;
            GridPanel panel       = ArchiveGrid.PrimaryGrid;
            int       DeleteCount = 0;

            foreach (GridRow row in panel.Rows)
            {
                if (row.Checked && !row.Cells["gcId"].IsValueNull)
                {
                    int id = int.Parse(row.Cells["gcId"].Value.ToString());
                    if (!CheckDelete(id))
                    {
                        string name = row.Cells["gcArchName"].Value.ToString();
                        MessageBox.Show(string.Format("“{0}”有借出或归还记录,无法删除。若要删除,请先删除该资料的借出或归还信息。 ", name), "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        continue;
                    }
                    if (!IsWarninged)
                    {
                        bool IsCancel = MessageBox.Show("确定要删除吗? ", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2).Equals(DialogResult.No);
                        if (IsCancel)
                        {
                            return;
                        }
                        IsWarninged = true;
                    }
                    try
                    {
                        DeleteArchiveInfo(id);
                        row.IsDeleted = true;
                        DeleteCount++;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            if (DeleteCount > 0)
            {
                ToastMessage.Show(this, "已删除 " + DeleteCount.ToString() + " 条记录");
            }
        }
Example #6
0
        private int SaveLendArchiveInfo(List <GridRow> list)
        {
            int changeCount = 0;

            using (SQLiteConnection conn = new SQLiteConnection(DataSourceManager.DataSource))
            {
                conn.Open();
                SQLiteCommand cmd = new SQLiteCommand();
                cmd.Connection = conn;
                try
                {
                    foreach (GridRow gr in list)
                    {
                        LendArchive ai = GridCellMapToLendArchive(gr);
                        if (!CheckLendable(ai))
                        {
                            gr["gcCount"].CellStyles.Default.TextColor = Color.Red;
                            ToastMessage.Show(this, ai.ArchiveName + " 剩余数量不足,请重新修改借出数量");
                            continue;
                        }
                        cmd.CommandText = GenLendArchiveSQL(ai);
                        cmd.ExecuteNonQuery();
                        gr["gcCount"].CellStyles.Default.TextColor = Color.Black;
                        cmd.CommandText = NotifyLendArchiveRemaining(ai);
                        cmd.ExecuteNonQuery();
                        LendArchiveRetreeIdFixRowCellReadonly(gr, ai);
                        changeCount++;
                    }
                }
                catch (System.Data.SQLite.SQLiteException E)
                {
                    MessageBox.Show(cmd.CommandText + Environment.NewLine + E.Message);
                }
                finally
                {
                    conn.Close();
                }
            }
            return(changeCount);
        }
Example #7
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            bool      IsWarninged = false;
            GridPanel panel       = LendGrid.PrimaryGrid;
            int       DeleteCount = 0;

            foreach (GridRow row in panel.Rows)
            {
                if (row.Checked && !row.Cells["gcId"].IsValueNull)
                {
                    if (!IsWarninged)
                    {
                        bool IsCancel = MessageBox.Show("若删除记录,借出的资料份数会返还到该资料的剩余份数。确定要删除借出记录吗? ", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2).Equals(DialogResult.No);
                        if (IsCancel)
                        {
                            return;
                        }
                        IsWarninged = true;
                    }
                    try
                    {
                        int id     = int.Parse(row.Cells["gcId"].Value.ToString());
                        int copies = int.Parse(row.Cells["gcCount"].Value.ToString());
                        int archId = int.Parse(row.Cells["gcArchId"].Value.ToString());
                        DeleteLeadArchive(id, copies, archId);
                        row.IsDeleted = true;
                        DeleteCount++;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            if (DeleteCount > 0)
            {
                ToastMessage.Show(this, "已删除 " + DeleteCount.ToString() + " 条记录");
            }
        }
Example #8
0
        private void btnSaveSend_Click(object sender, EventArgs e)
        {
            btnSaveSend.Focus();
            LendGrid.PrimaryGrid.EndDataUpdate();
            List <GridRow> list = new List <GridRow>();

            foreach (GridRow gr in LendGrid.PrimaryGrid.Rows)
            {
                if (gr.RowDirty && !gr.IsDeleted)
                {
                    list.Add(gr);
                }
            }
            if (list.Count == 0)
            {
                ToastMessage.Show(this, "没有可保存的内容。");
                return;
            }
            if (SaveLendArchiveInfo(list) > 0)
            {
                ToastMessage.Show(this, "已保存。");
            }
        }