Beispiel #1
0
    protected void Grid_Costing_BeforePerformDataSelect(object sender, EventArgs e)
    {
        ASPxGridView g   = sender as ASPxGridView;
        string       sql = "select JobNo from JobOrder where SequenceId='" + SafeValue.SafeString(g.GetMasterRowKeyValue(), "0") + "'";

        this.dsCosting.FilterExpression = "RefNo='" + SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(sql)) + "'";
    }
    protected void grid_PayrollDet_RowDeleted(object sender, DevExpress.Web.Data.ASPxDataDeletedEventArgs e)
    {
        ASPxGridView grd = sender as ASPxGridView;

        UpdateMaster(SafeValue.SafeInt(grd.GetMasterRowKeyValue(), 0));
    }
        protected void grdGeneralJournal_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e)
        {
            ASPxGridView grid = sender as ASPxGridView;

            Guid transactionId = (Guid)grid.GetMasterRowKeyValue();
            Guid accountId     = (Guid)e.NewValues["AccountId!Key"];

            //Validate duuplicate account in transaction
            //Insert mode
            if (grid.IsNewRowEditing)
            {
                bool isExist = TransactionBO.isExistAccountInTransaction(transactionId, accountId);
                if (isExist)
                {
                    Helpers.AddErrorToGridViewColumn(e.Errors, grid.Columns["AccountId!Key"],
                                                     String.Format("Tài khoản này đã được chọn"));
                }
            }
            //Edit mode
            else
            {
                Guid oldAccountId = (Guid)e.OldValues["AccountId!Key"];
                if (!oldAccountId.Equals(accountId))
                {
                    bool isExist = TransactionBO.isExistAccountInTransaction(transactionId, accountId);
                    if (isExist)
                    {
                        Helpers.AddErrorToGridViewColumn(e.Errors, grid.Columns["AccountId!Key"],
                                                         String.Format("Tài khoản này đã được chọn"));
                    }
                }
            }

            //Check negative
            if (e.NewValues["Credit"] != null &&
                (double)e.NewValues["Credit"] < 0)
            {
                Utility.Helpers.AddErrorToGridViewColumn(e.Errors, grid.Columns["Credit"], "Không thể nhập số âm");
            }
            if (e.NewValues["Debit"] != null &&
                (double)e.NewValues["Debit"] < 0)
            {
                Utility.Helpers.AddErrorToGridViewColumn(e.Errors, grid.Columns["Debit"], "Không thể nhập số âm");
            }
            //Check input both credit and debit
            if ((e.NewValues["Credit"] != null
                 //&& e.NewValues["Credit"].ToString().Length > 0
                 && ((double)e.NewValues["Credit"]) > 0) &&
                (e.NewValues["Debit"] != null
                 //&& e.NewValues["Debit"].ToString().Length > 0
                 && ((double)e.NewValues["Debit"]) > 0))
            {
                Utility.Helpers.AddErrorToGridViewColumn(e.Errors, grid.Columns["Credit"], "Chỉ cho phép nhập Nợ hoặc nhập Có");
                Utility.Helpers.AddErrorToGridViewColumn(e.Errors, grid.Columns["Debit"], "Chỉ cho phép nhập Nợ hoặc nhập Có");
            }
            //Check leave blank both credit and debit
            else if ((e.NewValues["Credit"] == null
                      //|| e.NewValues["Credit"].ToString().Length > 0
                      || ((double)e.NewValues["Credit"]) == 0) &&
                     (e.NewValues["Debit"] == null
                      //|| e.NewValues["Debit"].ToString().Length > 0
                      || ((double)e.NewValues["Debit"]) == 0))
            {
                Utility.Helpers.AddErrorToGridViewColumn(e.Errors, grid.Columns["Credit"], "Chưa nhập Nợ hoặc nhập Có");
                Utility.Helpers.AddErrorToGridViewColumn(e.Errors, grid.Columns["Debit"], "Chưa nhập Nợ hoặc nhập Có");
            }
        }
Beispiel #4
0
        protected void gvPayments_BeforePerformDataSelect(object sender, EventArgs e)
        {
            ASPxGridView gv = (ASPxGridView)sender;

            if (cmbProgram.Value != null)
            {
                gv.DataSource = new FeesPaymentService().GetAllFeesPayment(int.Parse(cmbProgram.GridView.GetRowValues(cmbProgram.GridView.FocusedRowIndex, "ClassID").ToString()), new StudentFeesService().GetStudentFeesById(int.Parse(gv.GetMasterRowKeyValue().ToString()), new SessionManager().GetUserId(this.Session)).UserId, new SessionManager().GetUserId(Session));
            }
        }
Beispiel #5
0
        protected void Grid_ExchangeRate_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            try
            {
                e.Cancel = true;
                session.BeginTransaction();

                ASPxGridView grid = sender as ASPxGridView;

                ExchangeRate exchangeid     = new ExchangeRate(session);
                object       keyvalue       = grid.GetMasterRowKeyValue();
                CurrencyType currencyTypeid = session.GetObjectByKey <CurrencyType>(Guid.Parse(keyvalue.ToString()));
                NAS.DAL.Accounting.Currency.Currency currencyid = BO.get_Currency_true_master(session, currencyTypeid.CurrencyTypeId.ToString(), true, Utility.Constant.ROWSTATUS_ACTIVE);

                //NAS.DAL.Accounting.Currency.Currency NumeratorCurrencyId = BO.get_CurrencyId_currencyId(session, currencyid.CurrencyId.ToString(), Utility.Constant.ROWSTATUS_ACTIVE);
                //NAS.DAL.Accounting.Currency.Currency DenomiratorCurrencyId = BO.get_CurrencyId_currencyId(session, Currency_Id.ToString(), Utility.Constant.ROWSTATUS_ACTIVE);

                //if (BO.check_ExchangeRate_BankId(
                //    session,
                //    NumeratorCurrencyId.CurrencyId.ToString(),
                //    DenomiratorCurrencyId.CurrencyId.ToString(),
                //    bankid.BankId.ToString(),
                //    Utility.Constant.ROWSTATUS_ACTIVE
                //    ))
                //{
                //    throw new Exception(String.Format("Ngân Hàng {0} Trùng, Yêu Cầu Nhập Lại Ngân Hàng", bankid.Code));
                //}

                exchangeid.AffectedDate = DateTime.Parse(e.NewValues["AffectedDate"].ToString());
                if (e.NewValues["BankId!Key"] != null)
                {
                    Bank bankid = session.GetObjectByKey <Bank>(Guid.Parse(e.NewValues["BankId!Key"].ToString()));

                    if (bankid != null)
                    {
                        exchangeid.BankId = bankid;
                        exchangeid.Name   = bankid.Code;
                    }
                }
                exchangeid.Rate = float.Parse(e.NewValues["Rate"].ToString());
                if (e.NewValues["Description"] != null)
                {
                    exchangeid.Description = e.NewValues["Description"].ToString();
                }
                exchangeid.NumeratorCurrencyId   = BO.get_CurrencyId_currencyId(session, currencyid.CurrencyId.ToString(), Utility.Constant.ROWSTATUS_ACTIVE);
                exchangeid.DenomiratorCurrencyId = BO.get_CurrencyId_currencyId(session, Currency_Id.ToString(), Utility.Constant.ROWSTATUS_ACTIVE);
                exchangeid.Status = short.Parse(e.NewValues["Status"].ToString());
                exchangeid.RowCreationTimeStamp = DateTime.Now;
                exchangeid.RowStatus            = Utility.Constant.ROWSTATUS_ACTIVE;
                exchangeid.Save();

                session.CommitTransaction();
                grid.CancelEdit();
                grid.DataBind();
            }
            catch (Exception)
            {
                session.RollbackTransaction();
                throw;
            }
        }
    protected void grid_DoIn_BeforePerformDataSelect(object sender, EventArgs e)
    {
        ASPxGridView grd  = (sender as ASPxGridView) as ASPxGridView;
        string       sql  = "select DoNo from Wh_Trans where Id='" + SafeValue.SafeInt(grd.GetMasterRowKeyValue(), 0) + "'";
        string       doNo = SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(sql), "");

        sql = string.Format(@"select * from Wh_Do d left join (select sum(Qty1) as TotalQty,DoNo from Wh_TransDet group by DoNo) as det on d.DoNo=det.DoNo left join Wh_Trans mast on d.PoNo=mast.DoNo and d.DoType='IN' where BlanketNo='{0}'", doNo);
        DataTable tab = ConnectSql.GetTab(sql);

        grd.DataSource = tab;
    }
Beispiel #7
0
    protected void grid_InvDet_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
    {
        e.Values["Id"] = SafeValue.SafeString(e.Values["Id"]);
        ASPxGridView grd        = (sender as ASPxGridView) as ASPxGridView;
        string       sql_detCnt = "select ExportInd from jnl_doc where Id='" + SafeValue.SafeInt(grd.GetMasterRowKeyValue(), 0) + "'";
        string       exportInd  = SafeValue.SafeString(Manager.ORManager.ExecuteScalar(sql_detCnt), "N");

        if (exportInd == "Y")
        {
            throw new Exception("Have Posted, can't delete item");
        }
    }
Beispiel #8
0
        protected void gvUsersInRole_BeforePerformDataSelect(object sender, EventArgs e)
        {
            ASPxGridView gridview = sender as ASPxGridView;

            sdsUsersInRole.SelectParameters["rolename"].DefaultValue = gridview.GetMasterRowKeyValue().ToString();
        }
Beispiel #9
0
        protected void ASPxGridView2_BeforePerformDataSelect(object sender, EventArgs e)
        {
            ASPxGridView grdTransactionDetail = (ASPxGridView)sender;

            Session["TransactionId"] = grdTransactionDetail.GetMasterRowKeyValue();
        }
    protected void detailGrid_DataSelect(object sender, EventArgs e)
    {
        ASPxGridView detailGrid = sender as ASPxGridView;

        detailGrid.DataSource = DataProvider.GetItems((int)detailGrid.GetMasterRowKeyValue());
    }
Beispiel #11
0
        protected void gridviewBankBranch_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e)
        {
            ASPxGridView grid = sender as ASPxGridView;

            if (e.NewValues["Code"] == null)
            {
                throw new Exception("Mã số chi nhánh không được để trống.");
            }
            else
            {
                XPCollection <BankBranch> b = new XPCollection <BankBranch>(session, CriteriaOperator.Parse("Code = '" + e.NewValues["Code"].ToString() + "' AND BankId='" + grid.GetMasterRowKeyValue() + "'"));
                if (e.IsNewRow)
                {
                    if (b.Count > 0)
                    {
                        throw new Exception("Mã số chi nhánh đã tồn tại.");
                    }
                }
                else
                {
                    if (e.NewValues["Code"].ToString() != e.OldValues["Code"].ToString())
                    {
                        if (b.Count > 0)
                        {
                            throw new Exception("Mã số chi nhánh đã tồn tại.");
                        }
                    }
                }
            }

            Regex regex = new Regex(@"^[-+]?[0-9]*\.?[0-9]+$");

            if (e.NewValues["PhoneFax"] == null)
            {
                return;
            }
            if (!regex.IsMatch(e.NewValues["PhoneFax"].ToString()))
            {
                throw new Exception("Điện thoại/Fax phải là dạng số.");
            }
        }
    protected void Grid_Invoice_Import_DataSelect(object sender, EventArgs e)
    {
        ASPxGridView grd = sender as ASPxGridView;
        string       sql = "select RefNo from SeaExportRef where sequenceId='" + SafeValue.SafeInt(grd.GetMasterRowKeyValue(), -1) + "'";

        this.dsInvoice.FilterExpression = "MastType='SE' and MastRefNo='" + SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(sql), "0") + "'";
    }
    protected void Grid_RefCont_DataSelect(object sender, EventArgs e)
    {
        ASPxGridView grd = (sender as ASPxGridView) as ASPxGridView;
        string       sql = "select RefNo from SeaExportRef where sequenceId='" + SafeValue.SafeInt(grd.GetMasterRowKeyValue(), 0) + "'";

        this.dsExpRefCont.FilterExpression = "StatusCode='USE' and MkgType='Cont' and RefNo='" + SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(sql), "") + "'";
    }
Beispiel #14
0
        protected void gvAuditDetails_BeforePerformDataSelect(object sender, EventArgs e)
        {
            ASPxGridView gridview = sender as ASPxGridView;

            sdsAuditDetails.SelectParameters["audit_id"].DefaultValue = gridview.GetMasterRowKeyValue().ToString();
        }
    protected void grid_SubSo_BeforePerformDataSelect(object sender, EventArgs e)
    {
        ASPxGridView grd       = (sender as ASPxGridView) as ASPxGridView;
        string       sql       = "select DoNo from Wh_Trans where Id=" + SafeValue.SafeInt(grd.GetMasterRowKeyValue(), 0) + "";
        string       blanketNo = SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(sql), "-1");

        sql = string.Format(@"select mast.DoNo,DoDate,PartyName,TotalQty,DoStatus from Wh_Trans mast left join (select sum(Qty1) as TotalQty,DoNo from Wh_TransDet group by DoNo) as tab on tab.DoNo=mast.DoNo where BlanketNo='{0}' and DoType='PO'", blanketNo);
        DataTable tab = ConnectSql.GetTab(sql);

        grd.DataSource = tab;
    }
Beispiel #16
0
        protected void dgMMateriales_BatchUpdate(object sender, DevExpress.Web.Data.ASPxDataBatchUpdateEventArgs e)
        {
            ASPxGridView dg = (ASPxGridView)sender;

            try
            {
                using (var db = new UnidadDeTrabajo())
                {
                    foreach (var item in e.InsertValues)
                    {
                        db.MarcaMaterial.InsertarValoresMarcaMaterial(item.NewValues, int.Parse(dg.GetMasterRowKeyValue().ToString()));
                    }

                    foreach (var item in e.UpdateValues)
                    {
                        db.MarcaMaterial.ActualizarMarcaMaterial(item.Keys, item.NewValues);
                    }
                    foreach (var item in e.DeleteValues)
                    {
                        db.MarcaMaterial.EliminarMarcaMaterial(item.Keys);
                    }
                }
                dg.JSProperties["cpOperacionesGrid"] = "Operación realizada con éxito";
            }
            catch (Exception ex)
            {
                dg.JSProperties["cpOperacionesGrid"] = "Error: " + ex.Message;
            }
            e.Handled = true;
        }
    protected void grid_SoInv_BeforePerformDataSelect(object sender, EventArgs e)
    {
        ASPxGridView grd  = (sender as ASPxGridView) as ASPxGridView;
        string       sql  = "select DoNo from Wh_Trans where Id='" + SafeValue.SafeInt(grd.GetMasterRowKeyValue(), 0) + "'";
        string       doNo = SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(sql), "");

        sql = string.Format(@"select * from XAArInvoice inv left join Wh_Trans mast on inv.MastRefNo=mast.DoNo and mast.DoType='PO' where BlanketNo='{0}'", doNo);
        DataTable tab = ConnectSql.GetTab(sql);

        grd.DataSource = tab;
    }
Beispiel #18
0
    protected void gridDetail_BeforePerformDataSelect(object sender, EventArgs e)
    {
        ASPxGridView gridViewProducts = (ASPxGridView)sender;

        Session["SessionCategoryID"] = gridViewProducts.GetMasterRowKeyValue();
    }
    protected void gridRecruitmentDet_BeforePerformDataSelect(object sender, EventArgs e)
    {
        ASPxGridView grd = (sender as ASPxGridView) as ASPxGridView;

        this.dsPerson.FilterExpression = string.Format("CHARINDEX('<'+cast({0} as nvarchar(10))+'>',RecruitId)>0", SafeValue.SafeString(grd.GetMasterRowKeyValue(), "0"));
    }
Beispiel #20
0
    protected void Grid_Payable_Import_DataSelect(object sender, EventArgs e)
    {
        ASPxGridView grd = sender as ASPxGridView;
        string       sql = "select ReleaseNo from wh_SORelease where Id=" + SafeValue.SafeInt(grd.GetMasterRowKeyValue(), 0) + "";

        this.dsVoucher.FilterExpression = "MastType='SOR' and MastRefNo='" + SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(sql), "-1") + "'";
    }
Beispiel #21
0
    protected void grdServiceConfig_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
    {
        ASPxGridView gridSC = sender as ASPxGridView;

        e.NewValues["ServiceID"] = gridSC.GetMasterRowKeyValue();
    }
Beispiel #22
0
    protected void Grid_Payable_Import_DataSelect(object sender, EventArgs e)
    {
        ASPxGridView grd   = sender as ASPxGridView;
        string       sql   = "select JobNo from Tpt_Job where Id='" + SafeValue.SafeInt(grd.GetMasterRowKeyValue(), -1) + "'";
        string       refNo = SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(sql));

        this.dsVoucher.FilterExpression = string.Format("MastRefNo='{0}' and MastType='TPT'", refNo);
    }
Beispiel #23
0
    protected void grid_InvDet_BeforePerformDataSelect(object sender, EventArgs e)
    {
        ASPxGridView grd = sender as ASPxGridView;

        this.dsQuotationDet.FilterExpression = "QuoteId='" + SafeValue.SafeInt(grd.GetMasterRowKeyValue(), -1) + "'";
    }
Beispiel #24
0
    protected void grid_TripLog_BeforePerformDataSelect(object sender, EventArgs e)
    {
        ASPxGridView grd = (sender as ASPxGridView) as ASPxGridView;
        string       sql = "select JobNo from tpt_Job where Id='" + SafeValue.SafeInt(grd.GetMasterRowKeyValue(), 0) + "'";

        this.dsTripLog.FilterExpression = " JobNo='" + SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(sql), "") + "' and JobType='Local'";
    }
    protected void grid_PayrollDet_BeforePerformDataSelect(object sender, EventArgs e)
    {
        ASPxGridView grd = sender as ASPxGridView;

        this.dsPayrollDet.FilterExpression = "PayrollId='" + SafeValue.SafeInt(grd.GetMasterRowKeyValue(), 0) + "'";
    }
Beispiel #26
0
    protected void gv_activity_BeforePerformDataSelect(object sender, EventArgs e)
    {
        ASPxGridView grd = (sender as ASPxGridView) as ASPxGridView;
        string       sql = "select JobNo from TPT_Job where Id='" + SafeValue.SafeInt(grd.GetMasterRowKeyValue(), 0) + "'";

        string JobNo = SafeValue.SafeString(ConnectSql.ExecuteScalar(sql));

        dsActivity.FilterExpression = "JobNo='" + JobNo + "'";
    }
    protected void detailGrid_BeforePerformDataSelect(object sender, EventArgs e)
    {
        ASPxGridView grid = sender as ASPxGridView;

        Session["CategoryID"] = grid.GetMasterRowKeyValue();
    }
Beispiel #28
0
    protected void grid_det_BeforePerformDataSelect(object sender, EventArgs e)
    {
        ASPxGridView grd = (sender as ASPxGridView) as ASPxGridView;

        this.dsWhInventoryDet.FilterExpression = " LineINo='" + SafeValue.SafeInt(grd.GetMasterRowKeyValue(), 0) + "'";
    }
    protected void grid_InvDet_BeforePerformDataSelect(object sender, EventArgs e)
    {
        ASPxGridView grd = (sender as ASPxGridView) as ASPxGridView;

        this.dsApPayableDet.FilterExpression = "DocId='" + SafeValue.SafeInt(grd.GetMasterRowKeyValue(), 0) + "'";
    }
Beispiel #30
0
    protected void grid_Mkgs_DataSelect(object sender, EventArgs e)
    {
        ASPxGridView g   = sender as ASPxGridView;
        string       sql = "select JobNo from JobOrder where SequenceId='" + SafeValue.SafeString(g.GetMasterRowKeyValue(), "0") + "'";

        this.dsMarking.FilterExpression = "RefNo='" + SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(sql)) + "'";
        //ASPxGridView grd = sender as ASPxGridView;
        //string sql = "select JobNo from SeaExport where sequenceId='" + SafeValue.SafeInt(grd.GetMasterRowKeyValue(), 0) + "'";
        //string jobNo = SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(sql), "");
        //string sql_jobType = "select mast.jobtype from seaexport job inner join SeaExportRef mast on job.RefNo=mast.Refno  where job.sequenceId='" + SafeValue.SafeInt(grd.GetMasterRowKeyValue(), 0) + "'";
        //string jobType = SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(sql_jobType), "");
        //if (jobType == "FCL")
        //    this.dsMarking.FilterExpression = "JobNo='" + SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(sql), "") + "' and MkgType='Cont'";
        //else
        //    this.dsMarking.FilterExpression = "JobNo='" + SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(sql), "") + "' and MkgType='Bl'";
    }