示例#1
0
        //private DataTable GetContractData(string condition, out int iBindQuantity)
        //{
        //    iBindQuantity = 0;
        //    string sql = string.Empty;

        //    //主体表
        //    sql = "select a.ContractID, a.SubscribeID, ContractNum as AgreementNum, CustomerName,CustomerPhone, '签约' as AgreementType, SubscribeDate, ContractDate,"
        //        + " ItemTypeName, Building, Unit, ItemNum, Area, Price, Amount, "
        //        + " TotalAmount, DownPayAmount, Loan, SalesID, SalesName,"
        //        + " ExtField0, ExtField1, ExtField2, ExtField3, ExtField4, ExtField5, ExtField6, ExtField7, ExtField8, ExtField9 "
        //        + " from ContractMain a"
        //        + " inner join  ContractDetail b on a.ContractID = b.ContractID "
        //        + " where ReturnDate is null and ProjectID = " + Login.User.ProjectID + " and  IsBind = 0 " + condition
        //        + " order by a.ContractID ";

        //    DataTable dtContract = SqlHelper.ExecuteDataTable(sql);
        //    dtContract.PrimaryKey = new DataColumn[] { dtContract.Columns["ContractID"] };


        //    //已收首付(除贷款) 、 未收首付
        //    sql = string.Format("select a.ContractID, isnull(sum(Amount),0) as DownPayTotal,DownPayAmount-IsNull(sum(b.Amount),0) as NoDownPay from ContractMain a  "
        //        + "inner join receipt b on a.ContractID = b.ContractID  "
        //        + "where a.ProjectID = {0}  and b.TypeCode != 0 group by a.ContractID, DownPayAmount", Login.User.ProjectID);
        //    DataTable dtRecTotal = SqlHelper.ExecuteDataTable(sql);

        //    for (int i = 0; i < dtRecTotal.Rows.Count; i++)
        //    {
        //        DataRow[] dr = dtContract.Select("ContractID = " + dtRecTotal.Rows[i]["ContractID"]);
        //        if (dr.Length == 0)
        //            dtRecTotal.Rows[i].Delete();
        //    }
        //    dtRecTotal.AcceptChanges();

        //    dtContract.Merge(dtRecTotal, false, MissingSchemaAction.Add);

        //    // 获取绑定(附属)物业信息
        //    for (int i = 0; i < dtContract.Rows.Count; i++)
        //    {
        //        string contractId = dtContract.Rows[i]["ContractID"].ToString();

        //        //绑定房源信息
        //        sql = "select ItemNum, Area, Price, Amount from ContractDetail where IsBind = 1 and ContractID = " + contractId;

        //        SqlDataReader dr = SqlHelper.ExecuteReader(sql);

        //        if (dr.HasRows)
        //        {
        //            DataTable dt = new DataTable();

        //            dt.Columns.Add("ContractID", typeof(int));
        //            dt.PrimaryKey = new DataColumn[] { dt.Columns["ContractID"] };

        //            string fieldValue = contractId;

        //            int itemIdx = 0;     //一个房源相同尾号
        //            while (dr.Read())
        //            {
        //                for (int j = 0; j < dr.FieldCount; j++)
        //                {
        //                    string fieldName = "BIND_" + dr.GetName(j) + itemIdx;
        //                    dt.Columns.Add(fieldName, typeof(string));
        //                    if (dr.GetName(j).Equals("Amount"))
        //                    {
        //                        fieldValue += "," + string.Format("{0:F0}",dr.GetValue(j));
        //                    }
        //                    else
        //                    {
        //                        fieldValue += "," + dr.GetValue(j).ToString();
        //                    }
        //                }

        //                itemIdx++;

        //                if (itemIdx > iBindQuantity)
        //                    iBindQuantity = itemIdx;
        //            }

        //            dr.Close();

        //            string[] strArray = fieldValue.Split(',');

        //            dt.Rows.Add(strArray);

        //            dtContract.Merge(dt, false, MissingSchemaAction.Add); //合并至主体表
        //        }
        //    }

        //    return dtContract;
        //}



        private void toolStripButton_Add_Click(object sender, EventArgs e)
        {
            if (dataGridView_Agreement.CurrentRow == null)
            {
                Prompt.Information("未选择相关签约信息");
                return;
            }

            FrmReceiptAdd receipt = new FrmReceiptAdd();

            string agreementId   = string.Empty;
            string agreementType = dataGridView_Agreement.CurrentRow.Cells["ColAgreementType"].Value.ToString();

            receipt.AgreementType = agreementType;

            if (agreementType.Equals("签约"))
            {
                agreementId = dataGridView_Agreement.CurrentRow.Cells["ColcontractID"].Value.ToString();
            }
            else
            {
                agreementId = dataGridView_Agreement.CurrentRow.Cells["ColSubscribeID"].Value.ToString();
            }

            receipt.SalesID     = dataGridView_Agreement.CurrentRow.Cells["ColSalesID"].Value.ToString();
            receipt.SalesName   = dataGridView_Agreement.CurrentRow.Cells["ColSalesName"].Value.ToString();
            receipt.AgreementID = agreementId;

            if (receipt.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                getReceiptRecord(dataGridView_Agreement.CurrentRow.Cells["ColcontractID"].Value.ToString(), true);

                if (agreementType.Equals("签约"))
                {
                    getReceiptRecord(agreementId, true);
                    UpdateReceiptGridDataView(dataGridView_Agreement.CurrentRow, true);
                    SetReceiptInfo(dataGridView_Agreement.CurrentRow, true);
                }
                else
                {
                    getReceiptRecord(agreementId, false);
                    UpdateReceiptGridDataView(dataGridView_Agreement.CurrentRow, false);
                    SetReceiptInfo(dataGridView_Agreement.CurrentRow, false);
                }

                Prompt.Information("操作成功,信息已添加!");
            }
        }
示例#2
0
        private void toolStripButton_Edit_Click(object sender, EventArgs e)
        {
            if (dataGridView_Receipt.CurrentRow == null)
            {
                Prompt.Warning("没有选择信息!");
                return;
            }

            if (dataGridView_Receipt.CurrentRow.Cells["ColSource"].Value.ToString() == "0")
            {
                Prompt.Warning("业务单据生成的收款,不能修改!");
                return;
            }


            if (dataGridView_Receipt.CurrentRow.Cells["ColSettleState"].Value.ToString() == "是")
            {
                Prompt.Warning("已结算记录,不能修改!");
                return;
            }



            FrmReceiptAdd receipt = new FrmReceiptAdd();

            string agreementId   = string.Empty;
            string agreementType = dataGridView_Agreement.CurrentRow.Cells["ColAgreementType"].Value.ToString();

            if (agreementType.Equals("签约"))
            {
                agreementId = dataGridView_Agreement.CurrentRow.Cells["ColcontractID"].Value.ToString();
            }
            else
            {
                agreementId = dataGridView_Agreement.CurrentRow.Cells["ColSubscribeID"].Value.ToString();
            }

            receipt.Owner         = this;
            receipt.FrmMode       = FormMode.modify;
            receipt.ReceiptID     = dataGridView_Receipt.CurrentRow.Cells["ColRecID"].Value.ToString();
            receipt.AgreementID   = agreementId;
            receipt.AgreementType = agreementType;
            receipt.SalesID       = dataGridView_Receipt.CurrentRow.Cells["ColRecSalesID"].Value.ToString();

            if (receipt.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (dataGridView_Agreement.CurrentRow.Cells["ColAgreementType"].Value.ToString().Equals("签约"))
                {
                    getReceiptRecord(agreementId, true);
                    UpdateReceiptGridDataView(dataGridView_Agreement.CurrentRow, true);
                    SetReceiptInfo(dataGridView_Agreement.CurrentRow, true);
                }
                else
                {
                    getReceiptRecord(agreementId, false);
                    UpdateReceiptGridDataView(dataGridView_Agreement.CurrentRow, false);
                    SetReceiptInfo(dataGridView_Agreement.CurrentRow, false);
                }

                Prompt.Information("操作成功,数据已更新!");
            }
        }