예제 #1
0
        protected void ASPxGridView1_StartRowEditing(object sender, DevExpress.Web.Data.ASPxStartRowEditingEventArgs e)
        {
            AccountingPeriod currentEdit        = session.GetObjectByKey <AccountingPeriod>(Guid.Parse(e.EditingKeyValue.ToString()));
            Guid             accountingPeriodId = Guid.Parse(e.EditingKeyValue.ToString());

            if (AccountingPeriodBO.IsChildOfAnother(session, accountingPeriodId))
            {
                e.Cancel = true;
                (sender as ASPxGridView).CancelEdit();
                throw new Exception("Chu kì kế toán này đang là chu kì trực thuộc của một chu kì khác! Không thể chỉnh sửa");
            }

            Session["AccountingPeriodId_cr"] = currentEdit.AccountingPeriodId;
            ASPxGridLookup grid = ASPxGridView1.FindEditRowCellTemplateControl(ASPxGridView1.Columns[5] as GridViewDataColumn, "cp_Grid1").FindControl("GridUnderPeriod") as ASPxGridLookup;

            if (currentEdit.AccountingPeriodTypeId.IsDefault == true)
            {
                XPOAccountingPeriodLookup.Criteria = "[RowStatus] > 0s And [IsActive] = True And [IsActive] <> True And [Code] <> 'NAAN_DEFAULT' And [AccountingPeriodTypeId.IsDefault] = True";
                grid.Enabled = false;
            }
            else
            {
                XPOAccountingPeriodLookup.Criteria = "[RowStatus] > 0s And [IsActive] = True And [Code] <> 'NAAN_DEFAULT' And [AccountingPeriodTypeId.IsDefault] = True";
                grid.Enabled = true;
            }
        }
예제 #2
0
        protected void ASPxGridView1_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            if (e.NewValues["IsActive"] == null)
            {
                e.NewValues["IsActive"] = false;
            }
            if (Util.isExistXpoObject <AccountingPeriod>("Code", (string)e.NewValues["Code"]))
            {
                e.Cancel = true;
                throw (new Exception("Trùng mã chu kì"));
                return;
            }
            if (e.NewValues["AccountingPeriodTypeId!Key"] == null)
            {
                e.Cancel = true;
                throw (new Exception("Chưa chọn thể loại"));
                return;
            }
            AccountingPeriod accountingPeriod = new AccountingPeriod(session);

            accountingPeriod.Description            = (string)e.NewValues["Description"];
            accountingPeriod.Code                   = (string)e.NewValues["Code"];
            accountingPeriod.AccountingPeriodTypeId = session.GetObjectByKey <AccountingPeriodType>(Guid.Parse(e.NewValues["AccountingPeriodTypeId!Key"].ToString()));
            accountingPeriod.FromDateTime           = (DateTime)e.NewValues["FromDateTime"];
            accountingPeriod.ToDateTime             = (DateTime)e.NewValues["ToDateTime"];
            accountingPeriod.RowStatus              = Constant.ROWSTATUS_ACTIVE;
            accountingPeriod.IsActive               = (bool)e.NewValues["IsActive"];
            if (accountingPeriod.Code != null)
            {
                accountingPeriod.Save();
            }
            ASPxGridLookup grid         = ASPxGridView1.FindEditRowCellTemplateControl(ASPxGridView1.Columns[5] as GridViewDataColumn, "cp_Grid1").FindControl("GridUnderPeriod") as ASPxGridLookup;
            List <object>  selectedRows = grid.GridView.GetSelectedFieldValues("AccountingPeriodId");

            if (!accountingPeriod.AccountingPeriodTypeId.IsDefault)
            {
                foreach (var o in selectedRows)
                {
                    AccountingPeriodBO.CreatAccountingPeriodComposite(session, accountingPeriod.AccountingPeriodId, Guid.Parse(o.ToString()));
                }
            }
            e.Cancel = true;
            ASPxGridView1.CancelEdit();
        }
예제 #3
0
 protected void ASPxGridView1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
 {
     try
     {
         AccountingPeriod currentAP = session.GetObjectByKey <AccountingPeriod>((Guid)e.Keys[0]);
         if (Util.isExistXpoObject <AccountingPeriod>("Code", e.NewValues["Code"].ToString()))
         {
             CriteriaOperator criteria0 = new BinaryOperator("Code", e.NewValues["Code"].ToString(), BinaryOperatorType.Equal);
             CriteriaOperator criteria1 = new BinaryOperator("AccountingPeriodId", e.Keys[0], BinaryOperatorType.NotEqual);
             CriteriaOperator criteria2 = new BinaryOperator("RowStatus", Constant.ROWSTATUS_ACTIVE, BinaryOperatorType.GreaterOrEqual);
             CriteriaOperator cr        = new GroupOperator(GroupOperatorType.And, criteria0, criteria1, criteria2);
             AccountingPeriod ap        = session.FindObject <AccountingPeriod>(cr);
             if (ap != null)
             {
                 e.Cancel = true;
                 throw (new Exception("Trùng mã chu kì"));
                 return;
             }
         }
         ASPxGridLookup   grid       = ASPxGridView1.FindEditRowCellTemplateControl(ASPxGridView1.Columns[5] as GridViewDataColumn, "cp_Grid1").FindControl("GridUnderPeriod") as ASPxGridLookup;
         CriteriaOperator criteria_0 = new BinaryOperator("AccountingPeriodId", currentAP, BinaryOperatorType.Equal);
         CriteriaOperator criteria_1 = new BinaryOperator("RowStatus", Constant.ROWSTATUS_ACTIVE, BinaryOperatorType.GreaterOrEqual);
         CriteriaOperator criteria   = new GroupOperator(GroupOperatorType.And, criteria_0, criteria_1);
         XPCollection <AccountingPeriodComposite> collection = new XPCollection <AccountingPeriodComposite>(session, criteria);
         foreach (AccountingPeriodComposite cp in collection)
         {
             cp.RowStatus = Constant.ROWSTATUS_DELETED;
             cp.Save();
         }
         List <object> selectedRows = grid.GridView.GetSelectedFieldValues("AccountingPeriodId");
         if (!currentAP.AccountingPeriodTypeId.IsDefault)
         {
             foreach (var o in selectedRows)
             {
                 AccountingPeriodBO.CreatAccountingPeriodComposite(session, currentAP.AccountingPeriodId, Guid.Parse(o.ToString()));
             }
         }
     }
     catch (Exception)
     {
         throw (new Exception("Trùng mã chu kì"));
     }
 }
예제 #4
0
    protected void cmb_FromCurrency_CustomJSProperties(object sender, DevExpress.Web.ASPxClasses.CustomJSPropertiesEventArgs e)
    {
        ASPxComboBox cmb = sender as ASPxComboBox;

        object[] yahooRate = new object[cmb.Items.Count];
        string   sql       = "";
        //ASPxComboBox _fromCurrency = ASPxGridView1.FindEditRowCellTemplateControl(null, "cmb_FromCurrency") as ASPxComboBox;
        //ASPxComboBox _toCurrency = ASPxGridView1.FindEditRowCellTemplateControl(null, "cmb_ToCurrency") as ASPxComboBox;
        ASPxDateEdit _exRateDate = ASPxGridView1.FindEditRowCellTemplateControl(null, "Date_ExRateDate") as ASPxDateEdit;

        //if (_exRateDate != null && SafeValue.SafeDate(_exRateDate.Date, new DateTime(1753, 01, 01)).ToString("yyyy-MM-dd") == DateTime.Today.ToString("yyyy-MM-dd") && _fromCurrency != null && _toCurrency != null && SafeValue.SafeString(_fromCurrency.Text).Length == 3 && SafeValue.SafeString(_toCurrency.Text).Length == 3)
        //{
        for (int i = 0; i < cmb.Items.Count; i++)
        {
            Stream               objStream;
            StreamReader         objSR;
            System.Text.Encoding encode = System.Text.Encoding.GetEncoding("utf-8");

            string          str         = "http://download.finance.yahoo.com/d/quotes.csv?s=" + cmb.Items[i].Text + System.Configuration.ConfigurationManager.AppSettings["Currency"] + "=X&f=l1";
            HttpWebRequest  wrquest     = (HttpWebRequest)WebRequest.Create(str);
            HttpWebResponse getresponse = null;
            getresponse = (HttpWebResponse)wrquest.GetResponse();

            objStream = getresponse.GetResponseStream();
            objSR     = new StreamReader(objStream, encode, true);
            string strResponse = objSR.ReadToEnd();
            yahooRate[i] = SafeValue.SafeDecimal(strResponse, 0);
        }
        //}
        //else
        //{

        //    for (int i = 0; i < cmb.Items.Count; i++)
        //    {
        //        yahooRate[i] = 0;
        //    }
        //}
        e.Properties["cpYahooRate"] = yahooRate;
    }
        protected void ASPxGridView1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            string biegly = (string)Session["idMediatora"];

            e.NewValues["id_bieglego"] = biegly;
            ASPxPageControl pageControl = ASPxGridView1.FindEditFormTemplateControl("ASPxPageControl1") as ASPxPageControl;
            // ASPxComboBox combobox = pageControl.FindControl("ASPxComboBox1") as ASPxComboBox;
            ASPxComboBox combobox = ASPxGridView1.FindEditRowCellTemplateControl((GridViewDataColumn)ASPxGridView1.Columns["nazwa"], "ASPxComboBox1") as ASPxComboBox;
            var          id       = e.OldValues["id_"];

            try
            {
                var idspecjalizacji = combobox.SelectedItem.Value;
                e.NewValues["id_specjalizacji"] = idspecjalizacji;
                Int64 te = (Int64)Session["key"];
                e.NewValues["id"]  = te;
                e.NewValues["id_"] = te;
            }
            catch (Exception ex)
            { }

            Session["flagaSkarg"] = 1;
        }