Example #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);
            }
        }
Example #2
0
        private void LadeCancelStripButton_Click(object sender, EventArgs e)
        {
            try
            {
                BLL.LadeAssignmentBLL.BLLLadeAssignment_TFactory LadeAssignmentFactory = new HPS.BLL.LadeAssignmentBLL.BLLLadeAssignment_TFactory();
                HPS.BLL.LadeCancelAssignmentBLL.BLLLadeCancelAssignment_TFactory LadeCancelAssignmentFactory = new HPS.BLL.LadeCancelAssignmentBLL.BLLLadeCancelAssignment_TFactory();

                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.LadeAssignmentBLL.BLLLadeAssignment_T LadeAssignmentEntity = new HPS.BLL.LadeAssignmentBLL.BLLLadeAssignment_T();
                LadeAssignmentEntity = LadeAssignmentFactory.GetBy(LadeAssignmentKey);
                if (LadeAssignmentEntity.Accepted_bit == true)
                {
                    HPS.BLL.LadeAssignmentCacelRequestBLL.BLLLadeAssignmentCacelRequest_TFactory LadeAssignmentCacelRequestFactory = new HPS.BLL.LadeAssignmentCacelRequestBLL.BLLLadeAssignmentCacelRequest_TFactory();
                    DataTable LadeAssignmentCacelRequestDataTable = new DataTable();
                    LadeAssignmentCacelRequestFactory.GetAllBy(HPS.BLL.LadeAssignmentCacelRequestBLL.BLLLadeAssignmentCacelRequest_T.LadeAssignmentCacelRequest_TField.LadeAssignmentID_bint, LadeAssignmentKey.LadeAssignmentID_bint, ref LadeAssignmentCacelRequestDataTable);
                    if (!(LadeAssignmentCacelRequestDataTable != null && LadeAssignmentCacelRequestDataTable.Rows.Count > 0 && HPS.Common.CurrentUser.user.CompanyID_int.HasValue == false))
                    {
                        throw new ApplicationException("این اطلاع سرانی بار تأیید شده است و قابل تغییر نمی باشد");
                    }
                    if (string.IsNullOrEmpty(LadeAssignmentCacelRequestDataTable.Rows[0]["AcceptedDate_nvc"].ToString()))
                    {
                        throw new ApplicationException("درخواست انصراف یا اعمال تغییرات قبول نشده است");
                    }
                }

                DataTable remainedLadeAssignmentTable = new DataTable();
                string    remainedCarCondition        = string.Format("LadeAssignmentID_bint={0}", Hepsa.Core.Common.PersentationController.GetEntityValue(this.LadeAssignmentGridView.CurrentRow.Cells[colLadeAssignmentID_bint.Name].Value, TypeCode.Int64));
                LadeAssignmentFactory.SelectRemainedDetailSelectByCondition(remainedCarCondition, remainedLadeAssignmentTable);
                int remaindCount_int = 0;
                if (remainedLadeAssignmentTable != null && remainedLadeAssignmentTable.Rows.Count > 0)
                {
                    remaindCount_int = (Int32)remainedLadeAssignmentTable.Rows[remainedLadeAssignmentTable.Rows.Count - 1]["RemainderCount_int"];
                }

                if (remaindCount_int == 0)
                {
                    string LadeCancelCondition = string.Format("LadeCancelAssignment_T.LadeAssignmentID_bint={0}", Hepsa.Core.Common.PersentationController.GetEntityValue(this.LadeAssignmentGridView.CurrentRow.Cells[colLadeAssignmentID_bint.Name].Value, TypeCode.Int64));
                    List <HPS.BLL.LadeCancelAssignmentBLL.BLLLadeCancelAssignment_T> LadeCancelList = LadeCancelAssignmentFactory.GetAllByCondition(LadeCancelCondition);
                    if (LadeCancelList != null && LadeCancelList.Count > 0)
                    {
                        throw new ApplicationException("بار مورد نظر باطل شده است");
                    }
                    else
                    {
                        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) + "' and LadBillCredit_T.LadBillCreditID_int is not null and LadBillCredit_T.Canceled_bit=0 ";
                        List <HPS.BLL.LadBillCreditBLL.BLLLadBillCredit_T> LadBillCreditList = new List <HPS.BLL.LadBillCreditBLL.BLLLadBillCredit_T>();
                        LadBillCreditList = LadBillCreditFactory.GetAllByCondition(condition);

                        if (LadBillCreditList != null && LadBillCreditList.Count > 0)
                        {
                            throw new ApplicationException("بار مورد نظر مجوز گرفته است");
                        }
                    }
                }
                HPS.Present.LadeCancelAssignment.LadeCancelAssignmentEntityForm LadeCancelAssignment = new HPS.Present.LadeCancelAssignment.LadeCancelAssignmentEntityForm(LadeAssignmentKey);
                LadeCancelAssignment.ShowDialog();
                LadeAssignmentGridView_SelectionChanged(this.LadeAssignmentCommentGridView, null);
            }
            catch (Exception ex)
            {
                Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message);
            }
        }
Example #3
0
        private void TurnPrintStripButton_Click(object sender, EventArgs e)
        {
            try
            {
                HPS.BLL.LadBillCreditBLL.BLLLadBillCredit_TFactory LadBillCreditFactory = new HPS.BLL.LadBillCreditBLL.BLLLadBillCredit_TFactory();
                string condition = "LadBillCredit_T.TrafficID_bint='" + Hepsa.Core.Common.PersentationController.GetEntityValue(this.TrafficGridView.CurrentRow.Cells[colTrafficID_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);

                if (LadBillCreditList != null && LadBillCreditList.Count > 0)
                {
                    bool?ladturn = LadBillCreditList[LadBillCreditList.Count - 1].Turn_bit;
                    if (LadBillCreditList[LadBillCreditList.Count - 1].Canceled_bit == false || (LadBillCreditList[LadBillCreditList.Count - 1].Canceled_bit == true && ladturn == false))
                    {
                        throw new ApplicationException("نوبت مورد نظر مجوز گرفته است");
                    }
                }
                HPS.BLL.TurnManagementBLL.BLLTurnManagement_TFactory TurnManagementFactory = new HPS.BLL.TurnManagementBLL.BLLTurnManagement_TFactory();
                string    conditionTurnManagement = string.Format("TurnManagement_T.TrafficID_bint='{0}' ", Hepsa.Core.Common.PersentationController.GetEntityValue(this.TrafficGridView.CurrentRow.Cells[colTrafficID_bint.Name].Value, TypeCode.Int64));
                DataTable TurnManagementTable     = new DataTable();
                TurnManagementFactory.GetAllByCondition(conditionTurnManagement, ref TurnManagementTable);
                if (TurnManagementTable != null && TurnManagementTable.Rows.Count > 0)
                {
                    if (TurnManagementTable.Rows[TurnManagementTable.Rows.Count - 1]["Return_bit"].ToString() == "False")
                    {
                        throw new ApplicationException("نوبت مورد نظر باطل شده است");
                    }
                }

                //HPS.Reports.ReportDoc.AcceptedTurnReport rpt = new HPS.Reports.ReportDoc.AcceptedTurnReport((Int64)Hepsa.Core.Common.PersentationController.GetEntityValue(this.TrafficGridView.CurrentRow.Cells[colTrafficID_bint.Name].Value, TypeCode.Int64));
                //rpt.Document.Printer.PrinterName = string.Empty;
                //rpt.Run();

                //Properties.Settings s = new HPS.Properties.Settings();
                //if (string.IsNullOrEmpty(s.PrinterName))
                //{
                //    rpt.Document.Print(true, true, true);
                //}
                //else
                //{
                //    rpt.Document.Printer.PrinterName = s.PrinterName;
                //    rpt.Document.Print(false, true, true);
                //}
                ///


                HPS.BLL.TrafficBLL.BLLTraffic_TFactory TrafficFactory   = new HPS.BLL.TrafficBLL.BLLTraffic_TFactory();
                HPS.BLL.TrafficBLL.BLLTraffic_TKeys    TrafficKey       = new HPS.BLL.TrafficBLL.BLLTraffic_TKeys();
                HPS.BLL.TrafficBLL.BLLTraffic_T        TrafficEntityrpt = new HPS.BLL.TrafficBLL.BLLTraffic_T();
                TrafficKey.TrafficID_bint = (Int64)Hepsa.Core.Common.PersentationController.GetEntityValue(this.TrafficGridView.CurrentRow.Cells[colTrafficID_bint.Name].Value, TypeCode.Int64);
                TrafficEntityrpt          = TrafficFactory.GetBy(TrafficKey);

                HPS.Reports.Forms.StimulViewer frm = new Reports.Forms.StimulViewer(TrafficEntityrpt, false, false);
                frm.ShowDialog();
                //
            }
            catch (Exception ex)
            {
                Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message);
            }
        }
Example #4
0
        private void EditButton_Click(object sender, EventArgs e)
        {
            try
            {
                bool CanNotChangeCount = false;
                BLL.LadeAssignmentBLL.BLLLadeAssignment_TFactory  LadeAssignmentFactory = new HPS.BLL.LadeAssignmentBLL.BLLLadeAssignment_TFactory();
                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.LadeAssignmentBLL.BLLLadeAssignment_T LadeAssignmentEntity = new HPS.BLL.LadeAssignmentBLL.BLLLadeAssignment_T();
                LadeAssignmentEntity = LadeAssignmentFactory.GetBy(LadeAssignmentKey);
                if (LadeAssignmentEntity.Accepted_bit == true)
                {
                    ///Select ladbillcredit
                    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) order by [LadBillCredit_T].[LadBillCreditID_int] desc";
                    List <HPS.BLL.LadBillCreditBLL.BLLLadBillCredit_T> LadBillCreditList = LadBillCreditFactory.GetAllByCondition(condition);
                    ///Select canceleced
                    HPS.BLL.LadeCancelAssignmentBLL.BLLLadeCancelAssignment_TFactory LadeCancelFactory = new HPS.BLL.LadeCancelAssignmentBLL.BLLLadeCancelAssignment_TFactory();
                    List <HPS.BLL.LadeCancelAssignmentBLL.BLLLadeCancelAssignment_T> LadeCancelList    = new List <HPS.BLL.LadeCancelAssignmentBLL.BLLLadeCancelAssignment_T>();
                    LadeCancelList = LadeCancelFactory.GetAllByCondition(string.Format("LadeCancelAssignment_T.LadeAssignmentID_bint={0} order by [LadeCancelAssignment_T].[LadeCancelAssignmentID_int] desc", Hepsa.Core.Common.PersentationController.GetEntityValue(this.LadeAssignmentGridView.CurrentRow.Cells[colLadeAssignmentID_bint.Name].Value, TypeCode.Int64)));
                    ///select Remained
                    DataTable remainedLadeAssignmentTable = new DataTable();
                    string    RemainedCondition           = string.Format("LadeAssignmentID_bint={0}", Hepsa.Core.Common.PersentationController.GetEntityValue(this.LadeAssignmentGridView.CurrentRow.Cells[colLadeAssignmentID_bint.Name].Value, TypeCode.Int64));
                    LadeAssignmentFactory.SelectRemainedDetailSelectByCondition(RemainedCondition, remainedLadeAssignmentTable);
                    int remaindCount_int = 0;
                    if (remainedLadeAssignmentTable != null && remainedLadeAssignmentTable.Rows.Count > 0)
                    {
                        remaindCount_int = (Int32)remainedLadeAssignmentTable.Rows[remainedLadeAssignmentTable.Rows.Count - 1]["RemainderCount_int"];
                    }

                    if (LadeCancelList != null && LadeCancelList.Count > 0)
                    {
                        if (LadeCancelList[0].Count_int != null && remaindCount_int == 0)
                        {
                            throw new ApplicationException("این اطلاع رسانی باطل شده است  و تعداد مانده ها صفر می باشد");
                        }
                        else
                        {
                            CanNotChangeCount = true;
                        }
                    }

                    if (remaindCount_int == 0)
                    {
                        throw new ApplicationException("بار مورد نظر مجوز گرفته است");
                    }
                    else
                    {
                        CanNotChangeCount = true;
                    }

                    HPS.BLL.LadeAssignmentCacelRequestBLL.BLLLadeAssignmentCacelRequest_TFactory LadeAssignmentCacelRequestFactory = new HPS.BLL.LadeAssignmentCacelRequestBLL.BLLLadeAssignmentCacelRequest_TFactory();
                    DataTable LadeAssignmentCacelRequestDataTable = new DataTable();
                    LadeAssignmentCacelRequestFactory.GetAllBy(HPS.BLL.LadeAssignmentCacelRequestBLL.BLLLadeAssignmentCacelRequest_T.LadeAssignmentCacelRequest_TField.LadeAssignmentID_bint, LadeAssignmentKey.LadeAssignmentID_bint, ref LadeAssignmentCacelRequestDataTable);

                    if (!(LadeAssignmentCacelRequestDataTable != null && LadeAssignmentCacelRequestDataTable.Rows.Count > 0 && HPS.Common.CurrentUser.user.CompanyID_int.HasValue == false))
                    {
                        throw new ApplicationException("این اطلاع رسانی بار تأیید شده است و قابل تغییر نمی باشد");
                    }

                    if (string.IsNullOrEmpty(LadeAssignmentCacelRequestDataTable.Rows[0]["AcceptedDate_nvc"].ToString()))
                    {
                        throw new ApplicationException("درخواست انصراف یا اعمال تغییرات قبول نشده است");
                    }
                }
                LadeAssignmentInforming LadeAssignment = new LadeAssignmentInforming(BaseEntityForm1.enmState.Edit, (DataTable)this.LadeAssignmentGridView.DataSource, LadeAssignmentKey, CanNotChangeCount);
                LadeAssignment.ShowDialog();
            }
            catch (Exception ex)
            {
                Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message);
            }
        }
Example #5
0
        public override bool Validate(params object[] value)
        {
            try
            {
                this.Description = string.Empty;
                if (value.Length != Field.Length)
                {
                    this.Description = Hepsa.Core.My.Resources.ValidationMessage.IncorrectDataType;
                    return(false);
                }
                Int64?LadeAssignmentID_bint = (Int64?)value[0];
                int?  Count_int             = (int?)value[1];

                if (LadeAssignmentID_bint.HasValue == false || Count_int.HasValue == false || Count_int == 0)
                {
                    return(true);
                }

                HPS.BLL.LadBillCreditBLL.BLLLadBillCredit_TFactory LadBillCreditFactory = new HPS.BLL.LadBillCreditBLL.BLLLadBillCredit_TFactory();
                string condition = string.Format(" LadBillCredit_T.LadeAssignmentID_bint={0} AND Canceled_bit=0", LadeAssignmentID_bint);
                List <HPS.BLL.LadBillCreditBLL.BLLLadBillCredit_T> LadBillCreditList = LadBillCreditFactory.GetAllByCondition(condition);
                int LadBillCreditCount = 0;
                if (LadBillCreditList != null && LadBillCreditList.Count > 0)
                {
                    LadBillCreditCount = LadBillCreditList.Count;
                }

                HPS.BLL.LadeAssignmentBLL.BLLLadeAssignment_TFactory LadeAssignmentFactory = new HPS.BLL.LadeAssignmentBLL.BLLLadeAssignment_TFactory();
                HPS.BLL.LadeAssignmentBLL.BLLLadeAssignment_TKeys    LadeAssignmentKey     = new HPS.BLL.LadeAssignmentBLL.BLLLadeAssignment_TKeys();
                LadeAssignmentKey.LadeAssignmentID_bint = LadeAssignmentID_bint;
                HPS.BLL.LadeAssignmentBLL.BLLLadeAssignment_T LadeAssignmentEntity = LadeAssignmentFactory.GetBy(LadeAssignmentKey);

                if (LadeAssignmentEntity != null)
                {
                    if (LadeAssignmentEntity.CarCount_int - LadBillCreditCount < Count_int)
                    {
                        this.Description = string.Format(Hepsa.Core.My.Resources.ValidationMessage.ValueShouldNotGreater, "تعداد ماشین حذفی", LadeAssignmentEntity.CarCount_int - LadBillCreditCount);
                        return(false);
                    }
                }
                return(true);
            }
            catch (System.Exception ex)
            {
                this.Description = ex.Message;
                return(false);
            }
        }