Beispiel #1
0
        //刪除
        private void tsbDelete_Click(object sender, EventArgs e)
        {
            string Msg = "是否要進行進貨單[" + txtStockID.Text + "]刪除動作?\r\n";


            DialogResult DR;

            DR = MessageBox.Show(Msg, "刪除進貨單", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (DR == DialogResult.Yes)
            {
                if (CheckField())
                {
                    SIS.DBClass.DBClassStockDetails DBCSD    = new DBClass.DBClassStockDetails();
                    SIS.Configuration.Items[]       oldItems = null;

                    oldItems = DBCSD.QueryData(txtStockID.Text);
                    if (oldItems == null)
                    {
                        MessageBox.Show("對不起,資料庫不存在[ " + txtStockID.Text +
                                        " ]進貨單資料!!(資料不存在)", "資料刪除");
                        return;
                    }
                    RunDeleteData(oldItems);
                }
            }
            else
            {
                MessageBox.Show("取消進貨單刪除動作!!", "刪除進貨單");
            }
        }
Beispiel #2
0
        /// <summary>
        /// 查詢進貨單相關資料
        /// </summary>
        /// <param name="StockID">傳入進貨單編號</param>
        /// <param name="CSC">傳入存放查詢結果資料的SIS.Configuration.ClsStockConfig CSC</param>
        /// <returns></returns>
        public bool QueryData(string StockID, SIS.Configuration.ClsStockConfig CSC)
        {
            InitDB();
            string selectCmd;

            selectCmd = "Select * From " + TableName + " Where StockID='" + StockID + "'";

            try
            {
                cmd = new SqlCommand(selectCmd, conn);
                dr  = cmd.ExecuteReader();
                if (dr.Read())
                {
                    CSC.StockID                 = StockID;
                    CSC.StockDate               = dr["StockDate"].ToString();
                    CSC.TotalPreTax             = int.Parse(dr["TotalPreTax"].ToString());
                    CSC.Tax                     = int.Parse(dr["Tax"].ToString());
                    CSC.TotalAfterTax           = int.Parse(dr["TotalAfterTax"].ToString());
                    CSC.ManufacturerID          = dr["ManufacturerID"].ToString();
                    CSC.BusinessTaxStockTaxRate = int.Parse(dr["BusinessTaxStockTaxRate"].ToString());
                    CSC.AmountPaid              = int.Parse(dr["AmountPaid"].ToString());
                    CSC.UnpaidAmount            = int.Parse(dr["UnpaidAmount"].ToString());
                    CSC.StockStaff              = dr["StockStaff"].ToString();
                    CSC.PaymentType             = dr["PaymentType"].ToString();
                    CSC.Notes                   = dr["Notes"].ToString();
                    conn.Close();

                    SIS.DBClass.DBClassStockDetails DBSD = new DBClassStockDetails();

                    CSC.StockItems = DBSD.QueryData(StockID);
                    if (CSC.StockItems == null)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
                else
                {
                    conn.Close();
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errorMsg = ex.Message;
                conn.Close();
                return(false);
            }
        }
Beispiel #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("取消退貨單查詢動作!!", "查詢進貨單");
            }
        }