Example #1
0
        /// <summary>
        /// 刪除資料庫中的相關資料
        /// </summary>
        private void RunDeleteData(SIS.Configuration.ClsRMAConfig OldCRC)
        {
            try
            {
                My.MyDatabase MyDb = new My.MyDatabase();
                SIS.Configuration.ClsRMAConfig CRC = new Configuration.ClsRMAConfig();
                CRC.RMAID = txtRMAID.Text;

                SIS.DBClass.DBClassRMAMaster DBCRM = new DBClass.DBClassRMAMaster();

                if (MyDb.AuthPK(CRC.RMAID, "RMAID", "RMAMaster") == true)
                {
                    if (DBCRM.DeleteMasterDetailsData(CRC.RMAID, OldCRC))
                    {
                        MessageBox.Show("刪除[" + CRC.RMAID +
                                        "]退貨單資料成功", "刪除退貨單資料", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        LoadDefaultValue();
                    }
                    else
                    {
                        MessageBox.Show("刪除[" + CRC.RMAID +
                                        "]退貨單資料失敗", "刪除退貨單資料", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MessageBox.Show("對不起,資料庫不存在[ " + CRC.RMAID +
                                    " ]退貨單資料!!(資料不存在)", "資料刪除");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("錯誤訊息:" + ex.Message.ToString(), "發生例外");
            }
        }
Example #2
0
        /// <summary>
        /// 更新資料庫中的相關資料
        /// </summary>
        private void RunUpdateData(SIS.Configuration.Items[] OldItems)
        {
            try
            {
                My.MyDatabase MyDb = new My.MyDatabase();
                SIS.Configuration.ClsRMAConfig CRC = new Configuration.ClsRMAConfig();
                CRC.RMAID           = txtRMAID.Text;
                CRC.RMADate         = dtpRMADate.Value.ToString("yyyy年MM月dd日");
                CRC.RMAType         = RMAType;
                CRC.TotalPreTax     = int.Parse(txtTotalPreTax.Text);
                CRC.Tax             = int.Parse(txtTax.Text);
                CRC.TotalAfterTax   = int.Parse(txtTotalAfterTax.Text);
                CRC.StockIDOrShipID = txtStockIDOrShipID.Text;
                CRC.BusinessTax     = int.Parse(txtBusinessTax.Text);
                CRC.AmountPaid      = int.Parse(mtbAmountPaid.Text);
                CRC.UnpaidAmount    = int.Parse(txtUnpaidAmount.Text);
                CRC.RMAAmount       = int.Parse(mtbRMAAmount.Text);
                CRC.Staff           = cboStaff.Text;
                CRC.PaymentType     = cboPaymentType.Text.Split('-')[1];
                CRC.Notes           = rtbNotes.Text.Replace("'", "''");
                CRC.RMAItems        = getItemsValueFromDataGridView(dgvRMADetails);

                SIS.DBClass.DBClassRMAMaster DBCRM = new DBClass.DBClassRMAMaster();

                if (MyDb.AuthPK(CRC.RMAID, "RMAID", "RMAMaster") == true)
                {
                    if (DBCRM.Update(CRC, OldItems))
                    {
                        MessageBox.Show("更新[" + CRC.RMAID +
                                        "]退貨單資料成功", "更新退貨單資料", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        LoadDefaultValue();
                    }
                    else
                    {
                        MessageBox.Show("更新[" + CRC.RMAID +
                                        "]退貨單資料失敗", "更新退貨單資料", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MessageBox.Show("對不起,資料庫不存在[ " + CRC.RMAID +
                                    " ]退貨單資料!!(資料不存在)", "資料更新");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("錯誤訊息:" + ex.Message.ToString(), "發生例外");
            }
        }
Example #3
0
        //查詢
        private void tsbQuery_Click(object sender, EventArgs e)
        {
            string Msg = "是否要進行退貨單[" + txtRMAID.Text + "]查詢動作?\r\n";


            DialogResult DR;

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

            if (DR == DialogResult.Yes)
            {
                if (CheckField(SIS.Configuration.CheckFieldType.Query))
                {
                    SIS.DBClass.DBClassRMAMaster   DBCRM = new DBClass.DBClassRMAMaster();
                    SIS.Configuration.ClsRMAConfig CRC   = new Configuration.ClsRMAConfig();

                    bool result = DBCRM.QueryData(txtRMAID.Text, CRC);
                    if (result)
                    {
                        MessageBox.Show("有找到退貨單號:[" + txtRMAID.Text + "]資料!\r\n是否將退貨單資料載入?", "搜尋結果", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (DR == DialogResult.Yes)
                        {
                            txtRMAID.Text   = CRC.RMAID;
                            dtpRMADate.Text = CRC.RMADate;
                            if (CRC.RMAType == "Customer")
                            {
                                rdoRMAShip.Checked = true;
                            }
                            else
                            {
                                rdoRMAStock.Checked = true;
                            }
                            //rdoRMAShip.Checked = (CRC.RMAType == "Customer") ? true : false;
                            //rdoRMAStock.Checked = (CRC.RMAType == "Manufacturer") ? true : false;
                            txtTotalPreTax.Text     = CRC.TotalPreTax.ToString();
                            txtTax.Text             = CRC.Tax.ToString();
                            txtTotalAfterTax.Text   = CRC.TotalAfterTax.ToString();
                            txtStockIDOrShipID.Text = CRC.StockIDOrShipID;
                            txtBusinessTax.Text     = CRC.BusinessTax.ToString();
                            mtbAmountPaid.Text      = CRC.AmountPaid.ToString();
                            txtUnpaidAmount.Text    = CRC.UnpaidAmount.ToString();
                            mtbRMAAmount.Text       = CRC.RMAAmount.ToString();
                            cboStaff.Text           = CRC.Staff;
                            cboPaymentType.Text     = My.MyMethod.SearchComboBoxItems(cboPaymentType, CRC.PaymentType);
                            rtbNotes.Text           = CRC.Notes;

                            if (dgvRMADetails.Rows.Count >= 1)
                            {
                                btnRemoveItems_Click(sender, e);
                            }

                            DBClass.DBClassShipDetails  DBShip  = new DBClass.DBClassShipDetails();
                            DBClass.DBClassStockDetails DBStock = new DBClass.DBClassStockDetails();

                            for (int i = 0; i < CRC.RMAItems.Length; i++)
                            {
                                var index = dgvRMADetails.Rows.Add();
                                dgvRMADetails.Rows[index].Cells["ItemsID"].Value = CRC.RMAItems[i].ItemsID;
                                dgvRMADetails.Rows[index].Cells["NAME"].Value    = CRC.RMAItems[i].NAME;
                                if (CRC.RMAType == "Customer")
                                {
                                    dgvRMADetails.Rows[index].Cells["Quantity"].Value = DBShip.QueryItemQuantity(CRC.StockIDOrShipID, CRC.RMAItems[i].ItemsID);
                                }
                                else
                                {
                                    dgvRMADetails.Rows[index].Cells["Quantity"].Value = DBStock.QueryItemQuantity(CRC.StockIDOrShipID, CRC.RMAItems[i].ItemsID);
                                }
                                //dgvRMADetails.Rows[index].Cells["Quantity"].Value = CRC.RMAItems[i].Quantity.ToString();
                                dgvRMADetails.Rows[index].Cells["RMAQuantity"].Value = CRC.RMAItems[i].Quantity.ToString();
                                dgvRMADetails.Rows[index].Cells["ItemsUnit"].Value   = CRC.RMAItems[i].ItemsUnit;
                                dgvRMADetails.Rows[index].Cells["Price"].Value       = CRC.RMAItems[i].Price.ToString();
                                dgvRMADetails.Rows[index].Cells["Totals"].Value      = CRC.RMAItems[i].Totals.ToString();
                                dgvRMADetails.Rows[index].Cells["Notes"].Value       = CRC.RMAItems[i].Notes;
                            }
                            getTaxTotals();
                        }
                    }
                    else
                    {
                        MessageBox.Show("沒有找到退貨單號:[" + txtRMAID.Text + "]資料!", "搜尋結果");
                    }
                }
            }
            else
            {
                MessageBox.Show("取消退貨單查詢動作!!", "查詢進貨單");
            }
        }