示例#1
0
        private void RunUpdateData(SIS.Configuration.Items[] OldItems)
        {
            try
            {
                My.MyDatabase MyDb = new My.MyDatabase();
                SIS.Configuration.ClsShipConfig CSC = new Configuration.ClsShipConfig();
                CSC.ShipID                 = txtShipID.Text;
                CSC.ShipDate               = dtpShipDate.Value.ToString("yyyy年MM月dd日");
                CSC.TotalPreTax            = int.Parse(txtTotalPreTax.Text);
                CSC.Tax                    = int.Parse(txtTax.Text);
                CSC.TotalAfterTax          = int.Parse(txtTotalAfterTax.Text);
                CSC.CustomerID             = cboCustomer.Text.Substring(0, cboCustomer.Text.IndexOf("-"));
                CSC.BusinessTaxShipTaxRate = int.Parse(txtBusinessTaxShipTaxRate.Text);
                CSC.AmountPaid             = int.Parse(mtbAmountPaid.Text);
                CSC.UnpaidAmount           = int.Parse(txtUnpaidAmount.Text);
                CSC.ShipStaff              = cboShipStaff.Text;
                CSC.PaymentType            = cboPaymentType.Text.Split('-')[1];
                CSC.Notes                  = rtbNotes.Text.Replace("'", "''");
                CSC.ShipItems              = getItemsValueFromDataGridView(dgvShipDetails);

                SIS.DBClass.DBClassShipMaster DBCSM = new DBClass.DBClassShipMaster();

                if (MyDb.AuthPK(CSC.ShipID, "ShipID", "ShipMaster") == true)
                {
                    if (DBCSM.Update(CSC, OldItems))
                    {
                        MessageBox.Show("更新[" + CSC.ShipID +
                                        "]出貨單資料成功", "更新出貨單資料", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        LoadDefaultValue();
                    }
                    else
                    {
                        MessageBox.Show("更新[" + CSC.ShipID +
                                        "]出貨單資料失敗", "更新出貨單資料", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MessageBox.Show("對不起,資料庫不存在[ " + CSC.ShipID +
                                    " ]出貨單資料!!(資料不存在)", "資料更新");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("錯誤訊息:" + ex.Message.ToString(), "發生例外");
            }
        }