Exemple #1
0
        /// <summary>
        /// 現在保存している外注出来高データをDBから読取り表示する
        /// </summary>
        /// <param name="reportDate"></param>
        /// <param name="costCode"></param>
        /// <param name="officeCode"></param>
        /// <param name="department"></param>
        private void selectPaymentData(DataGridView dgv, DateTime reportDate, string officeCode, string department)
        {
            readyPro    = true;
            dgv.Enabled = true;
            dgv.Rows.Clear();
            dgv.Rows.Add(iniRCnt);

            opd = new OsPaymentData();

            DataTable dt = opd.SelectPayment(reportDate.EndOfMonth(), officeCode, department);

            if (dt == null || dt.Rows.Count < 1)
            {
                labelMsg.Text = "表示できるデータはありません。";
                seqNoReNumbering(dgv);
                this.dataGridView1.CurrentCell = null;
                readyPro = false;
                return;
            }
            labelMsg.Text = "";
            if (dt.Rows.Count > iniRCnt)
            {
                dgv.Rows.Add(dt.Rows.Count - iniRCnt + 5);
            }

            TaskData       tdp = new TaskData();
            ListFormDataOp lo  = new ListFormDataOp();
            DataRow        dr;
            string         taskCode;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dr = dt.Rows[i];
                if (i == 0)
                {
                    string[] ckItems = new string[] { "AdminCheck", "DirectorCheck", "PresidentCheck" };
                    string[] dtItems = new string[] { "ACheckDate", "DCheckDate", "PCheckDate" };
                    for (int j = 0; j < ckItems.Length; j++)
                    {
                        int checkStat = Convert.ToInt32(dr[ckItems[j]]);
                        ckArray[j].Checked = (checkStat == 1) ? true : false;
                        dtArray[j]         = (checkStat == 1) ? Convert.ToDateTime(dr[dtItems[j]]) : DateTime.MinValue;
                        lbArray[j].Text    = (checkStat == 1) ? dtArray[j].ToLongDateString() : "";
                    }

                    if (ckArray[2].Checked)
                    {
                        buttonDisEnabled();
                    }
                    else if (ckArray[1].Checked)
                    {
                        buttonDisEnabled();
                        buttonCost.Enabled = true;
                    }
                    else if (ckArray[0].Checked)
                    {
                        buttonEnabled();
                        buttonCost.Enabled = false;
                    }
                }

                dgv.Rows[i].Cells["ItemCode"].Value = Convert.ToString(dr["ItemCode"]);
                dgv.Rows[i].Cells["Item"].Value     = Convert.ToString(dr["Item"]);
                dgv.Rows[i].Cells["OrderNo"].Value  = Convert.ToString(dr["OrderNo"]);
                taskCode = Convert.ToString(dr["TaskCode"]);
                dgv.Rows[i].Cells["TaskCode"].Value = taskCode;
                if (Convert.ToString(dr["OrderAmount"]) == "" || Convert.ToString(dr["OrderAmount"]) == "0.00")
                {
                    dgv.Rows[i].Cells["OAmount"].Value =
                        opd.SelectOAmountPayment(Convert.ToString(dr["ItemCode"]), taskCode, Conv.OfficeCode, Conv.DepartCode, dateTimePickerEx1.Value);
                }
                else
                {
                    dgv.Rows[i].Cells["OAmount"].Value = Convert.ToDecimal(dr["OrderAmount"]);
                }
                dgv.Rows[i].Cells["SAmount"].Value =
                    opd.SelectSumAmountPayment(Convert.ToString(dr["ItemCode"]), taskCode, Conv.OfficeCode, Conv.DepartCode, dateTimePickerEx1.Value);
                dgv.Rows[i].Cells["Amount"].Value = Convert.ToDecimal(dr["Amount"]);
                calculateInvolvedItems(dgv.Rows[i]);

                dgv.Rows[i].Cells["LeaderMCode"].Value  = Convert.ToString(dr["LeaderMCode"]);
                dgv.Rows[i].Cells["SlipNo"].Value       = Convert.ToInt32(dr["SlipNo"]) == 0 ? "" : Convert.ToString(dr["SlipNo"]);
                dgv.Rows[i].Cells["CostReportID"].Value = Convert.ToInt32(dr["CostReportID"]) == 0 ? "" : Convert.ToString(dr["CostReportID"]);

                dgv.Rows[i].Cells["PaymentID"].Value = Convert.ToString(dr["OsPaymentID"]);
                dgv.Rows[i].Cells["Check"].Value     = false;


                TaskCodeNameData tcnd = lo.SelectTaskCodeNameData(taskCode, Conv.OfficeCode);
                if (tcnd != null)
                {
                    dgv.Rows[i].Cells["TaskName"].Value = tcnd.TaskName;

                    tdp = tdp.SelectTaskData(taskCode);
                    dgv.Rows[i].Cells["SalesMCode"].Value  = "0" + tdp.SalesMCode;
                    dgv.Rows[i].Cells["PartnerCode"].Value = tdp.PartnerCode;
                }
            }
            seqNoReNumbering(dgv);
            this.dataGridView1.CurrentCell = null;

            readyPro = false;
        }
Exemple #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);
        }