Esempio n. 1
0
        private bool involvedDataDelete(DataGridViewRow dgvRow, int slipNo)
        {
            WorkReportData wrp;
            OsWkDetailData owd;
            OsPayOffData   ofd;
            OsPaymentData  omd;

            switch (Convert.ToString(dgvRow.Cells["Subject"].Value))
            {
            case "A":
            case "B":
            case "K":
                wrp = new WorkReportData();
                if (wrp.ExistenceSlipNo(slipNo))
                {
                    if (!wrp.ClearPartWorkReport(slipNo, Convert.ToInt32(dgvRow.Cells["CostReportID"].Value)))
                    {
                        deleteErrorMessage("作業内訳データ");
                        return(false);
                    }
                }
                else
                {
                    owd = new OsWkDetailData();
                    if (owd.ExistenceSlipNo(slipNo, Convert.ToInt32(dgvRow.Cells["CostReportID"].Value)))
                    {
                        if (!owd.DeleteOsWkDetail("@slip", slipNo))
                        {
                            deleteErrorMessage("外注作業内訳データ");
                            return(false);
                        }
                    }
                }
                break;

            case "F":
                ofd = new OsPayOffData();
                if (ofd.ExistenceSlipNo(slipNo))
                {
                    if (!ofd.DeletePayOff("@slip", slipNo))
                    {
                        deleteErrorMessage("外注精算データ");
                        return(false);
                    }
                }
                else
                {
                    omd = new OsPaymentData();
                    if (omd.ExistenceSlipNo(slipNo))
                    {
                        if (!omd.DeletePayment("@slip", slipNo))
                        {
                            deleteErrorMessage("外注出来高データ");
                            return(false);
                        }
                    }
                }
                break;

            default:
                owd = new OsWkDetailData();
                if (owd.ExistenceSlipNo(slipNo, Convert.ToInt32(dgvRow.Cells["CostReportID"].Value)))
                {
                    if (!owd.DeleteOsWkDetail("@slip", slipNo))
                    {
                        deleteErrorMessage("外注作業内訳データ");
                        return(false);
                    }
                }
                break;
            }
            return(true);
        }
Esempio n. 2
0
        private bool involvedDataUpdate(DataGridViewRow dgvRow, int slipNo)
        {
            WorkReportData wrp;
            OsWkDetailData owd;
            OsPayOffData   ofd;
            OsPaymentData  omd;

            decimal unitPrice = DHandling.ToRegDecimal(Convert.ToString(dgvRow.Cells["UnitPrice"].Value));
            decimal cost      = DHandling.ToRegDecimal(Convert.ToString(dgvRow.Cells["Cost"].Value));
            decimal qty       = DHandling.ToRegDecimal(Convert.ToString(dgvRow.Cells["Quantity"].Value));

            switch (Convert.ToString(dgvRow.Cells["Subject"].Value))
            {
            case "A":
            case "B":
            case "K":
                wrp = new WorkReportData();
                if (wrp.ExistenceSlipNo(slipNo))
                {
                    if (!wrp.UpdatePartWorkReport(slipNo, Convert.ToInt32(dgvRow.Cells["CostReportID"].Value), qty))
                    {
                        updateErrorMessage("作業内訳データ");
                        return(false);
                    }
                }
                else
                {
                    owd = new OsWkDetailData();
                    if (owd.ExistenceSlipNo(slipNo, Convert.ToInt32(dgvRow.Cells["CostReportID"].Value)))
                    {
                        if (!owd.UpdatePartOsWkDetail(slipNo, Convert.ToInt32(dgvRow.Cells["CostReportID"].Value), qty, cost))
                        {
                            updateErrorMessage("外注作業内訳データ");
                            return(false);
                        }
                    }
                }


                break;

            case "F":
                ofd = new OsPayOffData();
                if (ofd.ExistenceSlipNo(slipNo))
                {
                    ofd      = ofd.SelectOsPayOff(slipNo);
                    ofd.Cost = cost;
                    if (!ofd.UpdatePayOff())
                    {
                        updateErrorMessage("外注精算データ");
                        return(false);
                    }

                    //if (!ofd.UpdatePartPayOff(slipNo, cost))
                    //{
                    //    updateErrorMessage("外注精算データ");
                    //    return false;
                    //}
                }
                else
                {
                    omd = new OsPaymentData();
                    if (omd.ExistenceSlipNo(slipNo))
                    {
                        omd        = omd.SelectPayment(slipNo);
                        omd.Amount = cost;
                        if (!omd.UpdatePayment())
                        {
                            updateErrorMessage("外注出来高データ");
                            return(false);
                        }
                        //if (!omd.UpdatePartPayment(slipNo, cost))
                        //{
                        //    updateErrorMessage("外注出来高データ");
                        //    return false;
                        //}
                    }
                }

                break;

            default:
                owd = new OsWkDetailData();
                if (owd.ExistenceSlipNo(slipNo, Convert.ToInt32(dgvRow.Cells["CostReportID"].Value)))
                {
                    if (!owd.UpdatePartOsWkDetail(slipNo, Convert.ToInt32(dgvRow.Cells["CostReportID"].Value), qty, cost))
                    {
                        deleteErrorMessage("外注作業内訳データ");
                        return(false);
                    }
                }
                break;
            }
            return(true);
        }