Exemple #1
0
        public string GetInsertSql(TransportSettlement model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.totalWeight != null)
            {
                strSql1.Append("totalWeight,");
                strSql2.Append("" + model.totalWeight + ",");
            }
            if (model.tcId != null)
            {
                strSql1.Append("tcId,");
                strSql2.Append("" + model.tcId + ",");
            }
            if (model.sum != null)
            {
                strSql1.Append("sum,");
                strSql2.Append("" + model.sum + ",");
            }
            if (model.inputDate != null)
            {
                strSql1.Append("inputDate,");
                strSql2.Append("getdate()',");
            }
            if (model.inputMan != null)
            {
                strSql1.Append("inputMan,");
                strSql2.Append("'" + model.inputMan + "',");
            }
            if (model.count != null)
            {
                strSql1.Append("count,");
                strSql2.Append("" + model.count + ",");
            }
            if (model.remark != null)
            {
                strSql1.Append("remark,");
                strSql2.Append("'" + model.remark + "',");
            }
            strSql.Append("insert into transportSettlement(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            strSql.Append(";declare  @tsdid int;");
            strSql.Append(";declare  @tsid int;");
            strSql.Append(";set @tsid=@@IDENTITY;");


            return(strSql.ToString());
        }
        private void save()
        {
            TransportSettlement transportSettlement = new TransportSettlement();

            transportSettlement.inputMan    = this.UserName;
            transportSettlement.sum         = decimal.Parse(txt_priceTotal.Text.Trim());
            transportSettlement.totalWeight = decimal.Parse(txt_suttleTotal.Text.Trim());
            transportSettlement.count       = int.Parse(txt_noteCount.Text.Trim());
            transportSettlement.tcId        = long.Parse(cmb_transportContract.SelectedValue.ToString());
            transportLogic.saveCompute(transportSettlement, dgv_transportGoodsInformationCorresponding, dgv_note, this.UserName);
        }
Exemple #3
0
        public void saveCompute(TransportSettlement transportSettlement, DataGridView dgv_detail, DataGridView dgv_note, string userName)
        {
            ArrayList sqlList = new ArrayList();

            TransportSettlementDetail transportSettlementDetail = null;

            TransportNoteCorresponding transportNoteCorresponding = null;

            List <TransportNoteCorresponding> tnList = null;

            string nodeCode = null;

            int count = 0;

            decimal sum = 0;

            sqlList.Add(new TransportSettlementAction().GetInsertSql(transportSettlement));

            foreach (DataGridViewRow dgvr in dgv_detail.Rows)
            {
                if (dgvr.Cells["id"].Value != null)
                {
                    tnList = new List <TransportNoteCorresponding>();
                    transportSettlementDetail          = new TransportSettlementDetail();
                    transportSettlementDetail.tgicId   = long.Parse(dgvr.Cells["id"].Value.ToString());
                    transportSettlementDetail.inputMan = userName;
                    count = 0;
                    sum   = 0;
                    foreach (DataGridViewRow dgvrn in dgv_note.Rows)
                    {
                        if (dgvr.Cells["id"].Value.ToString() == dgvrn.Cells["did"].Value.ToString())
                        {
                            count += 1;
                            sum   += decimal.Parse(Math.Round(compute(dgvr.Cells["price"].Value.ToString(), dgvrn.Cells["suttle"].Value.ToString(), dgvr.Cells["distance"].Value.ToString(), dgvr.Cells["formula"].Value.ToString()), 2).ToString());
                            string code = dgvrn.Cells["barcode"].Value.ToString();
                            nodeCode += ",'" + code + "'";
                            transportNoteCorresponding          = new TransportNoteCorresponding();
                            transportNoteCorresponding.cnId     = transportDB.queryConsignmentNoteID(code);
                            transportNoteCorresponding.snId     = transportDB.queryStockNoteID(code);
                            transportNoteCorresponding.inputMan = userName;
                            tnList.Add(transportNoteCorresponding);
                        }
                    }
                    transportSettlementDetail.count = count;
                    transportSettlementDetail.sum   = sum;
                    if (count > 0)
                    {
                        sqlList.Add(new TransportSettlementDetailAction().GetInsertSql(transportSettlementDetail));
                        foreach (TransportNoteCorresponding tnc in tnList)
                        {
                            sqlList.Add(new TransportNoteCorrespondingAction().GetInsertSql(tnc));
                        }
                    }
                }
            }//运输明细循环
            if (nodeCode != null)
            {
                sqlList.Add(transportDB.getNodeSql(nodeCode));
            }
            transportDB.ExecuteTransaction(sqlList);
        }