Beispiel #1
0
        public int Insert(decimal taxPercent, decimal DeviceRegisterPrice, bool isWeb = false)
        {
            if (!ClassLibrary.JPermission.CheckPermission("AVL.RegisterDevice.JRegisterDevice.Insert"))
            {
                return(0);
            }
            this.active = false;
            JRegisterDeviceTable AT = new JRegisterDeviceTable();

            AT.SetValueProperty(this);
            Code = AT.Insert();

            decimal Total = 0;

            //Insert factor
            Accounting.Factor.JFactor factor = new Accounting.Factor.JFactor();
            factor.RegisterDate = DateTime.Now;
            factor.userCode     = WebClassLibrary.SessionManager.Current.MainFrame.CurrentUserCode;
            factor.payState     = false;
            //insert active factorItem
            Accounting.Factor.FactorItem.JFactorItem item = new Accounting.Factor.FactorItem.JFactorItem();
            item.count      = 1;
            item.describe   = "هزینه فعال کردن";
            item.product    = 1;
            item.FactorCode = factor.Insert();
            Total           = item.TotalUnitPrice = item.unitPrice = DeviceRegisterPrice;
            item.Insert();
            ////insert charge factorItem
            item.describe = "هزینه شارژ سی روز";
            AVL.Device.JDeviceModel m = new AVL.Device.JDeviceModel();
            m.GetData(this.DeviceType.ToString());
            item.unitPrice = (decimal)m.UnitPrice;
            item.count     = 30;
            Total         += item.TotalUnitPrice = 30 * item.unitPrice;
            item.Insert();
            factor.Tax      = taxPercent * Total / 100;
            factor.Total    = Total + factor.Tax;
            factor.Discount = 0;
            factor.Update();

            ClassLibrary.JHistory jHistory = new ClassLibrary.JHistory();
            jHistory.Save("AVL.RegisterDevice.JRegisterDevice", Code, 0, 0, 0, "ثبت دستگاه", "", 0);
            if (Code > 0 && !isWeb)
            {
                Nodes.DataTable.Merge(JRegisterDevices.GetDataTable(true, "", Code));
            }

            ClassLibrary.JException j = ClassLibrary.JCore.Except;
            //   foreach (Exception ex in ClassLibrary.JSystem.Except)
            //  {
            //       Exception e = ex;
            //   }

            return(Code);
        }
Beispiel #2
0
        public int Insert(bool isWeb = false, bool checkPermission = true)
        {
            bool hasPermission = true;

            if (checkPermission)
            {
                hasPermission = ClassLibrary.JPermission.CheckPermission("AVL.RegisterDevice.JRegisterDevice.Insert");
            }
            if (!hasPermission)
            {
                return(0);
            }
            JRegisterDeviceTable AT = new JRegisterDeviceTable();

            AT.SetValueProperty(this);
            Code = AT.Insert();


            ClassLibrary.JHistory jHistory = new ClassLibrary.JHistory();
            jHistory.Save("AVL.RegisterDevice.JRegisterDevice", Code, 0, 0, 0, "ثبت دستگاه", "", 0);

            try { if (Code > 0 && !isWeb && Nodes != null)
                  {
                      Nodes.DataTable.Merge(JRegisterDevices.GetDataTable(true, "", Code));
                  }
            }
            catch
            {
            }
            ClassLibrary.JException j = ClassLibrary.JCore.Except;
            //   foreach (Exception ex in ClassLibrary.JSystem.Except)
            //  {
            //       Exception e = ex;
            //   }

            return(Code);
        }