Exemplo n.º 1
0
        private void LadeAssignmentGridView_SelectionChanged(object sender, EventArgs e)
        {
            try
            {
                if (this.LadeAssignmentGridView.CurrentRow == null)
                {
                    return;
                }
                HPS.BLL.LadeAssignmentBLL.BLLLadeAssignment_TKeys LadeAssignmentKey = new HPS.BLL.LadeAssignmentBLL.BLLLadeAssignment_TKeys();
                LadeAssignmentKey.LadeAssignmentID_bint = (Int64?)this.LadeAssignmentGridView.CurrentRow.Cells["colLadeAssignmentID_bint"].Value;
                HPS.BLL.LadBillCreditBLL.BLLLadBillCredit_TFactory LadBillCreditFactory = new HPS.BLL.LadBillCreditBLL.BLLLadBillCredit_TFactory();
                string condition = "LadBillCredit_T.LadeAssignmentID_bint='" + Hepsa.Core.Common.PersentationController.GetEntityValue(this.LadeAssignmentGridView.CurrentRow.Cells[colLadeAssignmentID_bint.Name].Value, TypeCode.Int64) + "' or(LadBillCredit_T.LadBillCreditID_int is not null and LadBillCredit_T.Canceled_bit=0 AND LadBillCredit_T.Turn_bit is not NULL)";
                List <HPS.BLL.LadBillCreditBLL.BLLLadBillCredit_T> LadBillCreditList = LadBillCreditFactory.GetAllByCondition(condition);
                int LadBillCreditCount         = 0;
                int canceledLadBillCreditCount = 0;
                if (LadBillCreditList != null && LadBillCreditList.Count > 0)
                {
                    LadBillCreditCount         = LadBillCreditList.Count;
                    canceledLadBillCreditCount = LadBillCreditList.FindAll(itm => itm.Canceled_bit.Value == true).Count;
                }

                HPS.BLL.LadeAssignmentBLL.BLLLadeAssignment_TFactory LadeAssignmentFactory = new HPS.BLL.LadeAssignmentBLL.BLLLadeAssignment_TFactory();
                List <HPS.BLL.LadeAssignmentBLL.BLLLadeAssignment_T> LadeAssignmentList    = LadeAssignmentFactory.GetAllBy(HPS.BLL.LadeAssignmentBLL.BLLLadeAssignment_T.LadeAssignment_TField.LadeAssignmentID_bint, (Int64)LadeAssignmentGridView.CurrentRow.Cells[colLadeAssignmentID_bint.Name].Value);
                int CarCount = (int)Hepsa.Core.Common.PersentationController.GetEntityValue(this.LadeAssignmentGridView.CurrentRow.Cells[colCarCount_int.Name].Value, TypeCode.Int32);

                if (LadeAssignmentList != null && LadeAssignmentList.Count > 0)
                {
                    HPS.BLL.LadeCancelAssignmentBLL.BLLLadeCancelAssignment_TFactory LadeCancelAssignmentFactory = new HPS.BLL.LadeCancelAssignmentBLL.BLLLadeCancelAssignment_TFactory();
                    DataTable LadeCancelAssignmentTable = new DataTable();
                    LadeCancelAssignmentFactory.GetAllBy(HPS.BLL.LadeCancelAssignmentBLL.BLLLadeCancelAssignment_T.LadeCancelAssignment_TField.LadeAssignmentID_bint, LadeAssignmentKey.LadeAssignmentID_bint, ref LadeCancelAssignmentTable);
                    if (LadeCancelAssignmentTable != null && LadeCancelAssignmentTable.Rows.Count > 0)
                    {
                        Int32?Canceled = (from row in LadeCancelAssignmentTable.AsEnumerable() select(Int32) row["Count_int"]).Sum();
                        if (CarCount - LadBillCreditCount - Canceled >= 0)
                        {
                            LadeCancelStripButton.Enabled = true;
                        }
                        else
                        {
                            LadeCancelStripButton.Enabled = false;
                        }
                    }
                    else
                    {
                        if (CarCount - LadBillCreditCount - canceledLadBillCreditCount != 0)
                        {
                            LadeCancelStripButton.Enabled = true;
                        }
                        else
                        {
                            LadeCancelStripButton.Enabled = false;
                        }
                    }
                }

                if (int.Parse(LadeAssignmentGridView.CurrentRow.Cells["colRemainedCar"].Value.ToString()) > 0)
                {
                    LadeCancelStripButton.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message);
            }
        }