public async Task <int> SetTaskSeenToComplete(MyTaskDBModel _dbModel, string UserCode) { UserCode = Cipher.Encrypt(UserCode); string url = RepositorySettings.BaseURl + "TNA?OrderRefTaskTemplateChildId=" + _dbModel.OrderRefTaskTemplateChildId + "&UserCode=" + UserCode; HttpClient client = new HttpClient(); HttpResponseMessage result = await client.PostAsync(url, null); return(JsonConvert.DeserializeObject <int>(result.Content.ReadAsStringAsync().Result)); }
public int SetTaskSeenToComplete(MyTaskDBModel _dbModel, string UserCode) { //DateTime dtS = DateTime.ParseExact(_dbModel.CommittedDate.ToString(), "mm/dd/yyyy", CultureInfo.InvariantCulture); SqlParameter[] param = new SqlParameter[] { new SqlParameter("@OrderRefTaskTemplateChildId", _dbModel.OrderRefTaskTemplateChildId), new SqlParameter("@SeenBy", UserCode), new SqlParameter("@QryOption", 5), }; int result = ExecuteNoResult("PlanningTNA.dbo.Sp_Get_MyTask_Details", param); return(result); }
public override View GetGroupView(int groupPosition, bool isExpanded, View convertView, ViewGroup parent) { MyTaskDBModel model = MatchItems[groupPosition]; View view = convertView; Holder holder = null; //if (convertView == null) // { if (bitopiApplication.MyTaskType == MyTaskType.UNSEEN) { view = LayoutInflater.From(_context).Inflate(Resource.Layout.MyTaskUnSeenRow, parent, false); } if (bitopiApplication.MyTaskType == MyTaskType.SEEN) { view = LayoutInflater.From(_context).Inflate(Resource.Layout.MyTaskSeenRow, parent, false); } if (bitopiApplication.MyTaskType == MyTaskType.COMPLETED) { view = LayoutInflater.From(_context).Inflate(Resource.Layout.MyTaskCompletedRow, parent, false); } // visiblePosArray[position%visiblePosArray.length]=position; if (bitopiApplication.MyTaskType == MyTaskType.UNSEEN) { holder = new Holder(); } else { holder = new Holder2(); } if (holder is Holder2) { ((Holder2)holder).remarks = view.FindViewById <TextView>(Resource.Id.etRemarks); ((Holder2)holder).commitedDate = view.FindViewById <TextView>(Resource.Id.etCommitedDate); } else { holder.remarks = view.FindViewById <EditText>(Resource.Id.etRemarks); holder.commitedDate = view.FindViewById <EditText>(Resource.Id.etCommitedDate); } if (bitopiApplication.MyTaskType == MyTaskType.UNSEEN || bitopiApplication.MyTaskType == MyTaskType.SEEN) { holder.ckbox = view.FindViewById <CheckBox>(Resource.Id.chckApprove); } //} //else //{ // holder = convertView.Tag as Holder; // if (!(holder is Holder2)) // { // holder.ckbox.SetOnClickListener(null); // holder.ckbox.Checked = false; // holder.commitedDate.Click += null; // holder.remarks.KeyPress += null; // } //} if (model.IsDisabled) { holder.ckbox.Enabled = false; if (bitopiApplication.MyTaskType == MyTaskType.UNSEEN) { holder.commitedDate.Enabled = holder.remarks.Enabled = false; } } if (bitopiApplication.MyTaskType == MyTaskType.UNSEEN || bitopiApplication.MyTaskType == MyTaskType.SEEN) { holder.ckbox.Click += (sender, e) => { var builder = new Android.App.AlertDialog.Builder(_context); builder.SetMessage("Are you sure to seen this task?"); if (bitopiApplication.MyTaskType == MyTaskType.UNSEEN) { model.Remarks = holder.remarks.Text;//etUserName.SetBackgroundResource(Resource.Drawable.rounded_textview_error); if (holder.commitedDate.Text == "") { holder.commitedDate.SetBackgroundResource(Resource.Drawable.rounded_textview_error); ((CheckBox)sender).Checked = false; return; } else { holder.commitedDate.SetBackgroundResource(Resource.Drawable.rounded_textview); } } builder.SetPositiveButton("OK", (s, ev) => { CheckBox senderCheckBox = ((CheckBox)sender); View parentView = (View)senderCheckBox.Parent; Holder holder1 = parentView.Tag as Holder; ; var progressDialog = ProgressDialog.Show(_context, null, "Please wait...", true); new Thread(new ThreadStart(() => { TNARepository repo = new TNARepository(); int result = 0; if (bitopiApplication.MyTaskType == MyTaskType.UNSEEN) { result = repo.SetTaskUnSeentoSeen(_MyTaskList[holder.GroupPostiion], bitopiApplication.User.UserCode).Result; } if (bitopiApplication.MyTaskType == MyTaskType.SEEN) { result = repo.SetTaskSeenToComplete(_MyTaskList[holder.GroupPostiion], bitopiApplication.User.UserCode).Result; } if (result == 1) { _MyTaskList[holder1.GroupPostiion].IsDisabled = true; } _context.RunOnUiThread(() => { if (result == 1) { //ListViewAnimationHelper helper = new ListViewAnimationHelper(adapter, lvMyTask, MatchItems); //helper.animateRemoval(lvMyTask, parentView); int position = lvMyTask.GetPositionForView(parentView); MatchItems.RemoveAt(position); NotifyDataSetChanged(); if (MatchItems.Count == 0 && calback != null) { calback(); } progressDialog.Dismiss(); Toast.MakeText(_context, "Has been seen", ToastLength.Short).Show(); } else { ((CheckBox)sender).Checked = false; Toast.MakeText(_context, "Data Save Failed. Please Try Later", ToastLength.Short).Show(); } }); })).Start(); }); builder.SetNegativeButton("CANCEL", (s, ev) => { ((CheckBox)sender).Checked = false; }); builder.Create().Show(); }; } if (holder is Holder2) { ((Holder2)holder).remarks.Text = model.Remarks; ((Holder2)holder).commitedDate.Text = model.CommittedDate; } else { (holder).remarks.Text = model.Remarks; holder.commitedDate.Text = model.PlannedDate; } (view.FindViewById <TextView>(Resource.Id.tvTask)).Text = model.Task; (view.FindViewById <TextView>(Resource.Id.tvShimpentDate)).Text = model.ShipmentDate; if (bitopiApplication.MyTaskType == MyTaskType.UNSEEN) { holder.commitedDate.Click += (s, e) => { DateTime SetDate; if (holder.commitedDate.Text == "") { SetDate = DateTime.Today; //model.ActualDate= holder.commitedDate.Text = SetDate.Date.ToString("dd/MM/yyyy"); } else { //DateTime.TryParseExact(holder.commitedDate.Text, "dd/MM/yyyy", new CultureInfo("en-US"), //DateTimeStyles.None, //out SetDate); SetDate = Convert.ToDateTime(holder.commitedDate.Text); } DatePickerDialog dialog = new DatePickerDialog(_context, (sender, evnt) => { model.PlannedDate = model.CommittedDate = holder.commitedDate.Text = evnt.Date.ToString("dd/MM/yyyy"); holder.commitedDate.SetBackgroundResource(Resource.Drawable.rounded_textview); }, SetDate.Year, SetDate.Month - 1, SetDate.Day); dialog.DatePicker.MinDate = SetDate.Millisecond; dialog.Show(); }; holder.remarks.TextChanged += (s, e) => { model.Remarks = holder.remarks.Text; }; if (currentlyFocusedRow == groupPosition) { holder.remarks.RequestFocus(); } (view.FindViewById <EditText>(Resource.Id.etCommitedDate)).FocusableInTouchMode = false; //(view.FindViewById<EditText>(Resource.Id.etRemarks)).FocusableInTouchMode = true; holder.remarks.OnFocusChangeListener = new CustomOnFocusChangeListener(this, groupPosition, lvMyTask); } //(view.FindViewById<EditText>(Resource.Id.etCommitedDate)).Click += (s, e) => //{ // sender = s; // _context.ShowDialog(); //}; //view.Tag = groupPosition; holder.GroupPostiion = groupPosition; view.Tag = holder; return(view); }
public List <MyTaskDBModel> GetUnSeenTask(string UserCode, string TaskType) { SqlParameter[] param = null; if (TaskType == "UNSEEN") { param = new SqlParameter[] { new SqlParameter("@QryOption", 1), new SqlParameter("@DefaultAsignee", UserCode) } } ; else if (TaskType == "SEEN") { param = new SqlParameter[] { new SqlParameter("@QryOption", 2), new SqlParameter("@DefaultAsignee", UserCode) } } ; else if (TaskType == "COMPLETE") { param = new SqlParameter[] { new SqlParameter("@QryOption", 3), new SqlParameter("@DefaultAsignee", UserCode) } } ; List <MyTaskDBModel> _DBModelList = new List <MyTaskDBModel>(); try { DataTable dt = ExecuteDataTable("PlanningTNA.dbo.Sp_Get_MyTask_Details", param); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { MyTaskDBModel _DBModel = new MyTaskDBModel(); _DBModel.OrderRefNo = dr["OrderRefNo"].ToString(); _DBModel.Buyer = dr["Buyer"].ToString(); _DBModel.FileRefNo = dr["FileRefNo"].ToString(); _DBModel.BuyerStyleRef = dr["BuyerStyle"].ToString(); _DBModel.PoNo = dr["PoNo"].ToString(); _DBModel.ShipmentDate = dr["ShipmentDate"].ToString(); _DBModel.LotNo = dr["LotNo"].ToString(); _DBModel.Task = dr["TaskDescription"].ToString(); _DBModel.PlannedDate = dr["PlannedStartDate"].ToString(); if (TaskType == "UNSEEN") { _DBModel.CommittedDate = dr["PlannedStartDate"].ToString(); } else { _DBModel.CommittedDate = dr["CommittedStartDate"].ToString(); } _DBModel.Asignee = dr["Asignee"].ToString(); _DBModel.Seen = dr["IsSeen"].ToString(); _DBModel.Remarks = dr["Remarks"].ToString(); _DBModel.ChekList = dr["ChekList"].ToString(); _DBModel.OrderRefTaskTemplateChildId = Convert.ToInt32(dr["OrderRefTaskTemplateChildId"].ToString()); _DBModelList.Add(_DBModel); } } return(_DBModelList); } catch (Exception ex) { //ErrorSignal.FromCurrentContext().Raise(ex); throw ex; } finally { _DBModelList = null; } }