Ejemplo n.º 1
0
        private void RunDeleteData()
        {
            try
            {
                My.MyDatabase MyDb = new My.MyDatabase();
                SIS.Configuration.ClsTakeStockConfig CTSC = new Configuration.ClsTakeStockConfig();
                CTSC.TakeStockID = txtTakeStockID.Text;

                SIS.DBClass.DBClassTakeStockMaster DBCTSM = new DBClass.DBClassTakeStockMaster();

                if (MyDb.AuthPK(CTSC.TakeStockID, "TakeStockID", "TakeStockMaster") == true)
                {
                    if (DBCTSM.DeleteMasterDetailsData(CTSC.TakeStockID))
                    {
                        MessageBox.Show("刪除[" + CTSC.TakeStockID +
                                        "]盤點單資料成功", "刪除盤點單資料", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        LoadDefaultValue();
                    }
                    else
                    {
                        MessageBox.Show("刪除[" + CTSC.TakeStockID +
                                        "]盤點單資料失敗", "刪除盤點單資料", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MessageBox.Show("對不起,資料庫不存在[ " + CTSC.TakeStockID +
                                    " ]刪除單資料!!(資料不存在)", "資料刪除");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("錯誤訊息:" + ex.Message.ToString(), "發生例外");
            }
        }
Ejemplo n.º 2
0
 //列印
 private void tsbPrint_Click(object sender, EventArgs e)
 {
     if (CheckField())
     {
         SIS.DBClass.DBClassTakeStockMaster DBCTSM = new DBClass.DBClassTakeStockMaster();
         bool result = DBCTSM.QueryData(txtTakeStockID.Text);
         if (result)
         {
             FrmReportPrint FRP = new FrmReportPrint("TakeStockID", txtTakeStockID.Text, "rptTakeStockMaster");
             FRP.ShowDialog();
         }
         else
         {
             MessageBox.Show("沒有找到盤點單號:[" + txtTakeStockID.Text + "]資料,無法列印!", "列印結果");
         }
     }
 }
Ejemplo n.º 3
0
        private void RunUpdateData()
        {
            try
            {
                My.MyDatabase MyDb = new My.MyDatabase();
                SIS.Configuration.ClsTakeStockConfig CTSC = new Configuration.ClsTakeStockConfig();
                CTSC.TakeStockID    = txtTakeStockID.Text;
                CTSC.TakeStockDate  = dtpTakeStockDate.Value.ToString("yyyy年MM月dd日");
                CTSC.TakeStockStaff = cboTakeStockStaff.Text;
                CTSC.Notes          = rtbNotes.Text.Replace("'", "''");
                CTSC.TakeStockItems = getItemsValueFromDataGridView(dgvTakeStockItemsInfo);

                SIS.DBClass.DBClassTakeStockMaster DBCTSM = new DBClass.DBClassTakeStockMaster();

                if (MyDb.AuthPK(CTSC.TakeStockID, "TakeStockID", "TakeStockMaster") == true)
                {
                    if (DBCTSM.Update(CTSC))
                    {
                        MessageBox.Show("更新[" + CTSC.TakeStockID +
                                        "]盤點單資料成功", "更新盤點單資料", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        LoadDefaultValue();
                    }
                    else
                    {
                        MessageBox.Show("更新[" + CTSC.TakeStockID +
                                        "]盤點單資料失敗", "更新盤點單資料", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MessageBox.Show("對不起,資料庫不存在[ " + CTSC.TakeStockID +
                                    " ]更新單資料!!(資料不存在)", "資料更新");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("錯誤訊息:" + ex.Message.ToString(), "發生例外");
            }
        }
Ejemplo n.º 4
0
        //查詢
        private void tsbQuery_Click(object sender, EventArgs e)
        {
            string Msg = "是否要進行盤點單[" + txtTakeStockID.Text + "]查詢動作?\r\n";


            DialogResult DR;

            DR = MessageBox.Show(Msg, "查詢盤點單", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (DR == DialogResult.Yes)
            {
                if (CheckField())
                {
                    SIS.DBClass.DBClassTakeStockMaster   DBCTSM = new DBClass.DBClassTakeStockMaster();
                    SIS.Configuration.ClsTakeStockConfig CTSC   = new Configuration.ClsTakeStockConfig();

                    bool result = DBCTSM.QueryData(txtTakeStockID.Text, CTSC);
                    if (result)
                    {
                        MessageBox.Show("有找到盤點單號:[" + txtTakeStockID.Text + "]資料!\r\n是否將盤點單資料載入?", "搜尋結果", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (DR == DialogResult.Yes)
                        {
                            //要從最後面資料列開始往上移除才能正確執行
                            for (int i = dgvTakeStockItemsInfo.Rows.Count - 1; i >= 0; i--)
                            {
                                dgvTakeStockItemsInfo.Rows.RemoveAt(i);
                                //System.Threading.Thread.Sleep(10);
                            }

                            txtTakeStockID.Text    = CTSC.TakeStockID;
                            dtpTakeStockDate.Text  = CTSC.TakeStockDate;
                            cboTakeStockStaff.Text = CTSC.TakeStockStaff;
                            rtbNotes.Text          = CTSC.Notes;

                            for (int i = 0; i < CTSC.TakeStockItems.Length; i++)
                            {
                                var index = dgvTakeStockItemsInfo.Rows.Add();
                                dgvTakeStockItemsInfo.Rows[index].Cells["ItemsID"].Value            = CTSC.TakeStockItems[i].ItemsID;
                                dgvTakeStockItemsInfo.Rows[index].Cells["NAME"].Value               = CTSC.TakeStockItems[i].NAME;
                                dgvTakeStockItemsInfo.Rows[index].Cells["Inventory"].Value          = CTSC.TakeStockItems[i].Inventory.ToString();
                                dgvTakeStockItemsInfo.Rows[index].Cells["TakeStockInventory"].Value = CTSC.TakeStockItems[i].TakeStockInventory.ToString();
                                dgvTakeStockItemsInfo.Rows[index].Cells["GainLossInventory"].Value  = CTSC.TakeStockItems[i].GainLossInventory.ToString();
                                dgvTakeStockItemsInfo.Rows[index].Cells["IsTakeStock"].Value        = CTSC.TakeStockItems[i].IsTakeStock; //Boolean
                                dgvTakeStockItemsInfo.Rows[index].Cells["ItemsUnit"].Value          = CTSC.TakeStockItems[i].ItemsUnit;
                                dgvTakeStockItemsInfo.Rows[index].Cells["Price"].Value              = CTSC.TakeStockItems[i].Price.ToString();
                                dgvTakeStockItemsInfo.Rows[index].Cells["Totals"].Value             = CTSC.TakeStockItems[i].Totals.ToString();
                                dgvTakeStockItemsInfo.Rows[index].Cells["Notes"].Value              = CTSC.TakeStockItems[i].Notes;
                            }

                            tsslDataCount.Text = dgvTakeStockItemsInfo.Rows.Count.ToString();
                        }
                    }
                    else
                    {
                        MessageBox.Show("沒有找到盤點單號:[" + txtTakeStockID.Text + "]資料!", "搜尋結果");
                    }
                }
            }
            else
            {
                MessageBox.Show("取消盤點單查詢動作!!", "查詢盤點單");
            }
        }