From 2c648d6bf113baf2e1db5f05bfcd0543a10ac4f4 Mon Sep 17 00:00:00 2001 From: Dev18S <128153696+Dev18S@users.noreply.github.com> Date: Fri, 17 Mar 2023 18:51:59 +0530 Subject: [PATCH 1/4] Update NewContract.dart --- lib/NewContract.dart | 138 +++++++++++++++++++++++++++++-------------- 1 file changed, 95 insertions(+), 43 deletions(-) diff --git a/lib/NewContract.dart b/lib/NewContract.dart index 27ed67f..c69df1f 100644 --- a/lib/NewContract.dart +++ b/lib/NewContract.dart @@ -170,8 +170,11 @@ class NewWeb extends StatefulWidget { } class _NewWebState extends State { - TextEditingController _nameController=new TextEditingController(); - TextEditingController _ageController=new TextEditingController(); + TextEditingController title=new TextEditingController(); + TextEditingController description=new TextEditingController(); + TextEditingController requesterName=new TextEditingController(); + TextEditingController amnt=new TextEditingController(); + TextEditingController noticeperiod=new TextEditingController(); final _formKey = GlobalKey(); final _scaffoldKey = GlobalKey(); @@ -179,19 +182,33 @@ class _NewWebState extends State { @override void initState() { super.initState(); - _nameController = TextEditingController(); - _ageController = TextEditingController(); + title = TextEditingController(); + description = TextEditingController(); + requesterName=TextEditingController(); + amnt=TextEditingController(); + noticeperiod=TextEditingController(); + // dropdownvalue=contType; } @override void dispose() { super.dispose(); - _nameController.dispose(); - _ageController.dispose(); + title.dispose(); + description.dispose(); + requesterName.dispose(); + amnt.dispose(); + noticeperiod.dispose(); + // dropdownvalue.dispose(); } final firestore=FirebaseFirestore.instance.collection('newcontract'); - var value="-1"; + var contType="xyz"; + var reqstDept="CS"; + var countName="Soumya"; + var countCont="Tina Swift"; + var contEffDate="On Execution"; + var contEndDate="1 April"; + var tax="All Tax Included"; SingingCharacter? _character = SingingCharacter.Definite; @override @@ -305,7 +322,33 @@ class _NewWebState extends State { padding: const EdgeInsets.symmetric(vertical: 10,horizontal: 10), child: Text('Save and Continue'), )), - onPressed: (){}, + onPressed: (){ + FocusScope.of(context).unfocus(); + if(_formKey.currentState!.validate()){ + String id=DateTime.now().millisecondsSinceEpoch.toString(); + firestore.doc().set({ + 'contType':contType, + 'title' : title.text.toString(), + 'description' : description.text.toString(), + 'requesterName': requesterName.text.toString(), + 'reqstDept':reqstDept, + 'countName':countName, + 'countCont':countCont, + // 'contTerm': _character, + 'contEffDate':contEffDate, + 'contEndDate':contEndDate, + 'noticePeriod':noticeperiod.text.toString(), + 'Amount':amnt.text.toString(), + 'Tax':tax, + 'id':id, + + }).then((value) { + + }).onError((error, stackTrace) { + + + });} + }, ), ], @@ -340,6 +383,7 @@ class _NewWebState extends State { Padding( padding: const EdgeInsets.only(top: 150,left: 90), child: Form( + key: _formKey, child: Column( children: [ Stack( @@ -359,22 +403,26 @@ class _NewWebState extends State { child: SizedBox( height: 50, width: 400, - child: DropdownButtonFormField( - decoration: InputDecoration( - border: OutlineInputBorder( + child: + DropdownButtonFormField( + decoration: InputDecoration( + border: OutlineInputBorder( + + ), + hintText: 'Select ' ), - hintText: 'Select ' - ), - // hint: Text('Select'), - value: value, + // hint: Text('Select'), + value: contType, items: [ - DropdownMenuItem(child: Text('xyz'),value: "-1",), - DropdownMenuItem(child: Text('rwh'),value: "1",), - DropdownMenuItem(child: Text('dfgb'),value: "2",), + DropdownMenuItem(child: Text('xyz'),value: "xyz",), + DropdownMenuItem(child: Text('rwh'),value: "rwh",), + DropdownMenuItem(child: Text('dfgb'),value: "dfgb",), ], - onChanged: (v){}), + onChanged: ( v){ + contType=v!; + }), ), ), @@ -403,6 +451,7 @@ class _NewWebState extends State { ), ), child: TextField( + controller: title, decoration: InputDecoration( border: InputBorder.none, hintText: 'E-Commerce Vendor Agreement', @@ -438,6 +487,7 @@ class _NewWebState extends State { ), ), child: TextField( + controller: description, decoration: InputDecoration( border: InputBorder.none //hintText: 'Description(Optional)', @@ -476,6 +526,7 @@ class _NewWebState extends State { ), ), child: TextField( + controller: requesterName, decoration: InputDecoration( border: InputBorder.none //hintText: 'Description(Optional)', @@ -510,11 +561,11 @@ class _NewWebState extends State { hintText: 'Select ' ), // hint: Text('Select'), - value: value, + value: reqstDept, items: [ - DropdownMenuItem(child: Text('xyz'),value: "-1",), - DropdownMenuItem(child: Text('rwh'),value: "1",), - DropdownMenuItem(child: Text('dfgb'),value: "2",), + DropdownMenuItem(child: Text('CS'),value: "CS",), + DropdownMenuItem(child: Text('EC'),value: "EC",), + DropdownMenuItem(child: Text('Science'),value: "Science",), ], onChanged: (v){}), @@ -544,11 +595,11 @@ class _NewWebState extends State { hintText: 'Select ' ), // hint: Text('Select'), - value: value, + value: countName, items: [ - DropdownMenuItem(child: Text('FOM Tech'),value: "-1",), - DropdownMenuItem(child: Text('rwh'),value: "1",), - DropdownMenuItem(child: Text('dfgb'),value: "2",), + DropdownMenuItem(child: Text('Soumya'),value: "Soumya"), + DropdownMenuItem(child: Text('Ram'),value: "Ram",), + DropdownMenuItem(child: Text('Avni'),value: "Avni",), ], onChanged: (v){}), @@ -579,11 +630,11 @@ class _NewWebState extends State { hintText: 'Select ' ), // hint: Text('Select'), - value: value, + value: countCont, items: [ - DropdownMenuItem(child: Text('Tina Swift'),value: "-1",), - DropdownMenuItem(child: Text('rwh'),value: "1",), - DropdownMenuItem(child: Text('dfgb'),value: "2",), + DropdownMenuItem(child: Text('Tina Swift'),value: "Tina Swift",), + DropdownMenuItem(child: Text('Tina'),value: "Tina",), + DropdownMenuItem(child: Text('Swift'),value: "Swift",), ], onChanged: (v){}), @@ -649,10 +700,10 @@ class _NewWebState extends State { hintText: 'Select ' ), // hint: Text('Select'), - value: value, + value: contEffDate, items: [ - DropdownMenuItem(child: Text('On Execution'),value: "-1",), - DropdownMenuItem(child: Text('rwh'),value: "1",), + DropdownMenuItem(child: Text('On Execution'),value: "On Execution",), + DropdownMenuItem(child: Text('Executing'),value: "Executing",), DropdownMenuItem(child: Text('dfgb'),value: "2",), ], @@ -685,11 +736,11 @@ class _NewWebState extends State { hintText: 'Select ' ), // hint: Text('Select'), - value: value, + value: contEndDate, items: [ - DropdownMenuItem(child: Text('Select'),value: "-1",), - DropdownMenuItem(child: Text('rwh'),value: "1",), - DropdownMenuItem(child: Text('dfgb'),value: "2",), + DropdownMenuItem(child: Text('Select'),value: "1 April",), + DropdownMenuItem(child: Text('15 April'),value: "15 April",), + DropdownMenuItem(child: Text('5 May'),value: "5 May",), ], onChanged: (v){}), @@ -721,6 +772,7 @@ class _NewWebState extends State { ), ), child: TextField( + controller: noticeperiod, decoration: InputDecoration( border: InputBorder.none //hintText: 'Description(Optional)', @@ -778,6 +830,7 @@ class _NewWebState extends State { ), ), child: TextField( + controller: amnt, decoration: InputDecoration( border: InputBorder.none //hintText: 'Description(Optional)', @@ -813,11 +866,10 @@ class _NewWebState extends State { hintText: 'Select ' ), // hint: Text('Select'), - value: value, + value: tax, items: [ - DropdownMenuItem(child: Text('All Tax Included'),value: "-1",), - DropdownMenuItem(child: Text('rwh'),value: "1",), - DropdownMenuItem(child: Text('dfgb'),value: "2",), + DropdownMenuItem(child: Text('All Tax Included'),value: "All Tax Included",), + ], onChanged: (v){}), @@ -974,7 +1026,7 @@ class _NewWebState extends State { } addData() async { - String csvString = "${_nameController.text},${_ageController.text}"; + String csvString = "${title.text},${description.text}"; print(csvString); bool done = await addDataToCSV(csvString); SnackBar snackBar; From b969aa4294701c5a502938de767c5d57f6b46289 Mon Sep 17 00:00:00 2001 From: Dev18S <128153696+Dev18S@users.noreply.github.com> Date: Fri, 17 Mar 2023 18:52:35 +0530 Subject: [PATCH 2/4] Update NewContractTable.dart --- lib/NewContractTable.dart | 85 ++++++++++++++++++++++++++++++--------- 1 file changed, 67 insertions(+), 18 deletions(-) diff --git a/lib/NewContractTable.dart b/lib/NewContractTable.dart index a4f5365..b2261e1 100644 --- a/lib/NewContractTable.dart +++ b/lib/NewContractTable.dart @@ -9,23 +9,50 @@ class ContTable extends StatefulWidget { } class Record { - final String name; - final String age; - //final int votes; + // final String contType; + final String title; + final String description; + final String requesterName; + final String reqstDept; + final String countName; + final String countCont; + final String contEffDate; + final String contEndDate; + final String noticePeriod; + final String Amount; + final String Tax; final DocumentReference reference; Record.fromMap(Map map, {required this.reference}) - : assert(map['name'] != null), - //assert(map['r_name'] != null), - assert(map['age'] != null), - name = map['name'], - // rName = map['r_name'], - age = map['age']; + : //assert(map['contType'] != null), + assert(map['title'] != null), + assert(map['description'] != null), + assert(map['requesterName'] != null), + assert(map['reqstDept'] != null), + assert(map['countName'] != null), + assert(map['countCont'] != null), + assert(map['contEffDate'] != null), + assert(map['contEndDate'] != null), + assert(map['noticePeriod'] != null), + assert(map['Amount'] != null), + assert(map['Tax'] != null), + // contType = map['contType'], + title = map['title'], + description = map['description'], + requesterName = map['requesterName'], + reqstDept = map['reqstDept'], + countName = map['countName'], + countCont = map['countCont'], + contEffDate = map['contEffDate'], + contEndDate = map['contEndDate'], + noticePeriod = map['noticePeriod'], + Amount = map['Amount'], + Tax = map['Tax']; Record.fromSnapshot(DocumentSnapshot snapshot) : this.fromMap((snapshot.data()) as Map , reference: snapshot.reference); @override - String toString() => "Record<$name:$age>"; + String toString() => "Record<$title:$description:$requesterName:$reqstDept:$countName:$countCont:$contEffDate:$contEndDate:$noticePeriod:$Amount:$Tax>"; } class _ContTableState extends State { @@ -41,13 +68,24 @@ class _ContTableState extends State { return StreamBuilder( stream: FirebaseFirestore.instance.collection('newcontract').snapshots(), builder: (context, snapshot) { - if (!snapshot.hasData) return LinearProgressIndicator(); - + if (!snapshot.hasData) { + return LinearProgressIndicator(); + }else if(snapshot.hasError){ const Text('No data avaible right now'); } return DataTable( columns: [ - DataColumn(label: Text('Name')), - DataColumn(label: Text('Age')), - // DataColumn(label: Text('Rapper\nname')), + // DataColumn(label: Text('Contract Type')), + DataColumn(label: Text('Title')), + DataColumn(label: Text('Description')), + DataColumn(label: Text('Requester Name')), + DataColumn(label: Text('Requester Dept')), + DataColumn(label: Text('Counterparty Name')), + DataColumn(label: Text('Counterparty Contract')), + DataColumn(label: Text('Contract Effective Date')), + DataColumn(label: Text('Contract End Date')), + DataColumn(label: Text('Amount')), + DataColumn(label: Text('Tax')), + //DataColumn(label: Text('Contract End Date')), + ], rows: _buildList(context, snapshot.data!.docs) ); @@ -68,9 +106,20 @@ class _ContTableState extends State { final record = Record.fromSnapshot(data); return DataRow(cells: [ - DataCell(Text(record.name)), - DataCell(Text(record.age.toString())), + // DataCell(Text(record.contType.toString())), + DataCell(Text(record.title)), + DataCell(Text(record.description.toString())), + DataCell(Text(record.requesterName.toString())), + DataCell(Text(record.reqstDept)), + DataCell(Text(record.countName)), + DataCell(Text(record.countCont)), + DataCell(Text(record.contEffDate)), + DataCell(Text(record.contEndDate)), + DataCell(Text(record.noticePeriod)), + DataCell(Text(record.Amount)), + DataCell(Text(record.Tax)), + // DataCell(Text(record.rName)), ]); } -} \ No newline at end of file +} From 9b99a2ed55ef7c0ebba030d8da679515c0d1f71a Mon Sep 17 00:00:00 2001 From: Dev18S <128153696+Dev18S@users.noreply.github.com> Date: Sat, 18 Mar 2023 18:52:47 +0530 Subject: [PATCH 3/4] Update NewContractTable.dart --- lib/NewContractTable.dart | 49 ++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/lib/NewContractTable.dart b/lib/NewContractTable.dart index b2261e1..6394f28 100644 --- a/lib/NewContractTable.dart +++ b/lib/NewContractTable.dart @@ -9,10 +9,10 @@ class ContTable extends StatefulWidget { } class Record { - // final String contType; + final String contType; final String title; final String description; - final String requesterName; + final String requesterName; final String reqstDept; final String countName; final String countCont; @@ -24,10 +24,10 @@ class Record { final DocumentReference reference; Record.fromMap(Map map, {required this.reference}) - : //assert(map['contType'] != null), + : assert(map['contType'] != null), assert(map['title'] != null), assert(map['description'] != null), - assert(map['requesterName'] != null), + assert(map['requesterName'] != null), assert(map['reqstDept'] != null), assert(map['countName'] != null), assert(map['countCont'] != null), @@ -36,7 +36,7 @@ class Record { assert(map['noticePeriod'] != null), assert(map['Amount'] != null), assert(map['Tax'] != null), - // contType = map['contType'], + contType = map['contType'], title = map['title'], description = map['description'], requesterName = map['requesterName'], @@ -52,14 +52,15 @@ class Record { Record.fromSnapshot(DocumentSnapshot snapshot) : this.fromMap((snapshot.data()) as Map , reference: snapshot.reference); @override - String toString() => "Record<$title:$description:$requesterName:$reqstDept:$countName:$countCont:$contEffDate:$contEndDate:$noticePeriod:$Amount:$Tax>"; + String toString() => "Record<$contType:$title:$description:$reqstDept:$requesterName:$countName:$countCont:$contEffDate:$contEndDate:$noticePeriod:$Amount:$Tax>"; + // String toString() => "Record<$title:$description:$contType>"; } class _ContTableState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text(' Votes')), + appBar: AppBar(title: Text(' New Contracts')), body: _buildBody(context), ); } @@ -72,19 +73,33 @@ class _ContTableState extends State { return LinearProgressIndicator(); }else if(snapshot.hasError){ const Text('No data avaible right now'); } return DataTable( + columnSpacing: 5, columns: [ - // DataColumn(label: Text('Contract Type')), + DataColumn(label: Text('Contract Type')), + DataColumn(label: VerticalDivider()), DataColumn(label: Text('Title')), + DataColumn(label: VerticalDivider()), DataColumn(label: Text('Description')), + DataColumn(label: VerticalDivider()), DataColumn(label: Text('Requester Name')), + DataColumn(label: VerticalDivider()), DataColumn(label: Text('Requester Dept')), + DataColumn(label: VerticalDivider()), DataColumn(label: Text('Counterparty Name')), + DataColumn(label: VerticalDivider()), DataColumn(label: Text('Counterparty Contract')), + DataColumn(label: VerticalDivider()), DataColumn(label: Text('Contract Effective Date')), + DataColumn(label: VerticalDivider()), DataColumn(label: Text('Contract End Date')), + DataColumn(label: VerticalDivider()), + DataColumn(label: Text('Notice Period')), + DataColumn(label: VerticalDivider()), DataColumn(label: Text('Amount')), + DataColumn(label: VerticalDivider()), DataColumn(label: Text('Tax')), - //DataColumn(label: Text('Contract End Date')), + DataColumn(label: VerticalDivider()), + ], rows: _buildList(context, snapshot.data!.docs) @@ -106,18 +121,30 @@ class _ContTableState extends State { final record = Record.fromSnapshot(data); return DataRow(cells: [ - // DataCell(Text(record.contType.toString())), + DataCell(Container(child: Text(record.contType))), + DataCell( VerticalDivider()), DataCell(Text(record.title)), + DataCell( VerticalDivider()), DataCell(Text(record.description.toString())), - DataCell(Text(record.requesterName.toString())), + DataCell( VerticalDivider()), + DataCell(Text(record.requesterName.toString())), + DataCell( VerticalDivider()), DataCell(Text(record.reqstDept)), + DataCell( VerticalDivider()), DataCell(Text(record.countName)), + DataCell( VerticalDivider()), DataCell(Text(record.countCont)), + DataCell( VerticalDivider()), DataCell(Text(record.contEffDate)), + DataCell( VerticalDivider()), DataCell(Text(record.contEndDate)), + DataCell( VerticalDivider()), DataCell(Text(record.noticePeriod)), + DataCell( VerticalDivider()), DataCell(Text(record.Amount)), + DataCell( VerticalDivider()), DataCell(Text(record.Tax)), + DataCell( VerticalDivider()), // DataCell(Text(record.rName)), ]); From a6278c896c51a5c7ed650b642c1548f17119c759 Mon Sep 17 00:00:00 2001 From: Dev18S <128153696+Dev18S@users.noreply.github.com> Date: Sat, 18 Mar 2023 18:54:06 +0530 Subject: [PATCH 4/4] Update NewContract.dart --- lib/NewContract.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/NewContract.dart b/lib/NewContract.dart index c69df1f..bc28977 100644 --- a/lib/NewContract.dart +++ b/lib/NewContract.dart @@ -1087,3 +1087,5 @@ class _MediumChildState extends State { } } + +