/// <summary>
    /// UpdatetblService - sửa thông tin tblService
    /// </summary>
    /// <param name="tblService"></param>
    /// <returns></returns>
    public bool UpdateTblService(TblService tblService)
    {
        SqlParameter[] paramList = new SqlParameter[5];

        paramList[0]       = new SqlParameter("@ServiceId", SqlDbType.Int);
        paramList[0].Value = tblService.ServiceId;

        paramList[1]       = new SqlParameter("@ServiceName", SqlDbType.NVarChar, 256);
        paramList[1].Value = tblService.ServiceName;

        paramList[2]       = new SqlParameter("@ServiceLink", SqlDbType.NVarChar, 256);
        paramList[2].Value = tblService.ServiceLink;

        paramList[3]       = new SqlParameter("@Description", SqlDbType.NVarChar, 512);
        paramList[3].Value = tblService.Description;

        paramList[4]       = new SqlParameter("@StatusId", SqlDbType.NVarChar, 256);
        paramList[4].Value = tblService.StatusId;

        if (db.executeUpdate("UpdateTblService", paramList) == 0)
        {
            return(false);
        }
        else
        {
            return(true);
        }
    }
Exemple #2
0
        public static void AddClient(ClientsModel model, ServicesModel ModelServices, int postedbyId)
        {
            DataContext     db              = new DataContext();
            TblClient       tbl             = new TblClient();
            TblBusinessType tblBusinessType = new TblBusinessType();

            tbl.Name = model.Name;

            tbl.TypeOfCompany       = model.TypeOfCompany;
            tbl.LimitedBy           = model.LimitedBy;
            tbl.ShareValue1         = model.ShareValue1;
            tbl.ShareValue2         = model.ShareValue2;
            tbl.ShareCapitalProduct = model.ProductOfShareValues;
            tbl.BusinessObjectives  = model.BusinessObjectives;
            tbl.CNIC = model.CNIC;

            tbl.NTN         = model.NTN;
            tbl.PINCode     = model.PINCode;
            tbl.FBRLogin    = model.FBRLogin;
            tbl.FBRPassword = model.FBRPassword;

            tbl.IncorporationNo = model.IncorporationNo;
            tbl.RegistrationNo  = model.RegistrationNo;
            tbl.RegisteredWith  = model.RegisteredWith;
            tbl.Address         = model.Address;
            tbl.Email           = model.Email;
            tbl.PhoneNo         = model.PhoneNo;
            tbl.MobileNo        = model.MobileNo;
            tbl.FaxNo           = model.FaxNo;
            tbl.CreatedById     = postedbyId;
            tbl.CreatedDate     = Convert.ToDateTime(DateTime.Now.ToShortDateString());
            tbl.IsActive        = true;
            db.TblClients.InsertOnSubmit(tbl);

            db.SubmitChanges();

            TblService tblServices = new TblService();
            var        res         = (from c in db.TblClients
                                      orderby c.Id descending
                                      select c).FirstOrDefault();

            tbl = res;
            int currentClientId = tbl.Id;

            tblServices.ClientId = currentClientId;

            tblBusinessType.BusinessType = model.BusinessType;
            tblBusinessType.ClientId     = currentClientId;
            tblServices.Accounting       = true ? ModelServices.Accounting == "Accounting" : false;
            tblServices.Audit            = true ? ModelServices.Audit == "Audit" : false;
            tblServices.Legal            = true ? ModelServices.Legal == "Legal" : false;
            tblServices.Taxation         = true ? ModelServices.Taxation == "Taxation" : false;
            tblServices.Corporate        = true ? ModelServices.Corporate == "Corporate" : false;

            db.TblBusinessTypes.InsertOnSubmit(tblBusinessType);
            db.TblServices.InsertOnSubmit(tblServices);
            db.SubmitChanges();
            db.Dispose();
            //UpdateAndSaveService( ModelServices, currentClientId);
        }
Exemple #3
0
 private TblService UpdateOrInsertTblService(TblService newRow, bool save, int index, int user, out int outindex)
 {
     outindex = index;
     using (var context = new WorkFlowManagerDBEntities())
     {
         if (save)
         {
             context.TblServices.AddObject(newRow);
         }
         else
         {
             var oldRow = (from e in context.TblServices
                           where e.Iserial == newRow.Iserial
                           select e).SingleOrDefault();
             if (oldRow != null)
             {
                 GenericUpdate(oldRow, newRow, context);
             }
         }
         context.SaveChanges();
         if (SharedOperation.UseAx())
         {
             if (save)
             {
                 InsertServiceItem(newRow, user);
             }
         }
         return(newRow);
     }
 }
Exemple #4
0
        public static void UpdatedClient(ClientsModel model, ServicesModel ModelServices, int postedbyId, int ClientId)
        {
            DataContext db = new DataContext();

            TblClient result = (from c in db.TblClients
                                where c.Id == ClientId
                                select c).Single();

            result.Name                = model.Name;
            result.TypeOfCompany       = model.TypeOfCompany;
            result.LimitedBy           = model.LimitedBy;
            result.BusinessObjectives  = model.BusinessObjectives;
            result.ShareValue1         = model.ShareValue1;
            result.ShareValue2         = model.ShareValue2;
            result.ShareCapitalProduct = model.ProductOfShareValues;
            result.CNIC                = model.CNIC;
            result.IncorporationNo     = model.IncorporationNo;
            result.RegistrationNo      = model.RegistrationNo;
            result.RegisteredWith      = model.RegisteredWith;
            result.Address             = model.Address;
            result.Email               = model.Email;
            result.PhoneNo             = model.PhoneNo;
            result.MobileNo            = model.MobileNo;
            result.FaxNo               = model.FaxNo;
            result.UpdatedById         = postedbyId;
            result.UpdatedDate         = Convert.ToDateTime(DateTime.Now.ToShortDateString());
            db.SubmitChanges();

            /****************************************************************************************/

            TblService resultServices = (from s in db.TblServices
                                         where s.ClientId == ClientId
                                         select s).SingleOrDefault();

            resultServices.Accounting = true ? ModelServices.Accounting == "Accounting" : false;
            resultServices.Audit      = true ? ModelServices.Audit == "Audit" : false;
            resultServices.Legal      = true ? ModelServices.Legal == "Legal" : false;
            resultServices.Taxation   = true ? ModelServices.Taxation == "Taxation" : false;
            resultServices.Corporate  = true ? ModelServices.Corporate == "Corporate" : false;

            /***************************************************************************************/

            TblBusinessType resultBusinessType = (from b in db.TblBusinessTypes
                                                  where b.ClientId == ClientId
                                                  select b).SingleOrDefault();

            resultBusinessType.BusinessType = model.BusinessType;
            db.SubmitChanges();
            db.Dispose();
        }
    /// <summary>
    /// DeleteTblService - xoa thông tin tblService
    /// </summary>
    /// <param name="tblService"></param>
    /// <returns></returns>
    public bool DeleteTblService(TblService tblService)
    {
        SqlParameter[] paramList = new SqlParameter[1];

        paramList[0]       = new SqlParameter("@ServiceId", SqlDbType.Int);
        paramList[0].Value = tblService.ServiceId;

        if (db.executeUpdate("DeleteTblService", paramList) == 0)
        {
            return(false);
        }
        else
        {
            return(true);
        }
    }
Exemple #6
0
        private int DeleteTblService(TblService row)
        {
            using (var context = new WorkFlowManagerDBEntities())
            {
                var oldRow = (from e in context.TblServices
                              where e.Iserial == row.Iserial
                              select e).SingleOrDefault();
                if (oldRow != null)
                {
                    context.DeleteObject(oldRow);
                }

                context.SaveChanges();
            }
            return(row.Iserial);
        }
Exemple #7
0
        public void SaveMainRow()
        {
            if (SelectedMainRow != null)
            {
                var valiationCollection = new List <ValidationResult>();

                var isvalid = Validator.TryValidateObject(SelectedMainRow, new ValidationContext(SelectedMainRow, null, null), valiationCollection, true);

                if (isvalid)
                {
                    var save    = SelectedMainRow.Iserial == 0;
                    var saveRow = new TblService();
                    saveRow.InjectFrom(SelectedMainRow);
                    Client.UpdateOrInsertTblServiceAsync(saveRow, save, MainRowList.IndexOf(SelectedMainRow), LoggedUserInfo.Iserial);
                }
            }
        }
Exemple #8
0
 /// <summary>
 /// DeleteTblService - xoa thông tin tblService
 /// </summary>
 /// <param name="tblService"></param>
 /// <returns></returns>
 public bool DeleteTblService(TblService tblService)
 {
     return(tblServiceDao.DeleteTblService(tblService));
 }
Exemple #9
0
 /// <summary>
 /// UpdatetblService - sửa thông tin tblService
 /// </summary>
 /// <param name="tblService"></param>
 /// <returns></returns>
 public bool UpdateTblService(TblService tblService)
 {
     return(tblServiceDao.UpdateTblService(tblService));
 }
Exemple #10
0
 /// <summary>
 /// InserttblService - them thông tin tblService
 /// </summary>
 /// <param name="tblService"></param>
 /// <returns></returns>
 public bool InsertTblService(TblService tblService)
 {
     return(tblServiceDao.InsertTblService(tblService));
 }
Exemple #11
0
        public void InsertServiceItem(TblService objToPost, int userIserial)
        {
            var axapta = new Axapta();//Ready To be Dependent from Ax

            try
            {
                using (var context = new WorkFlowManagerDBEntities())
                {
                    var credential = new NetworkCredential("bcproxy", "around1");
                    var user       = context.TblAuthUsers.FirstOrDefault(x => x.Iserial == userIserial);

                    axapta.LogonAs(user.User_Win_Login, user.User_Domain, credential, "Ccm", null, null, null);

                    axapta.TTSBegin();
                    var itemId    = objToPost.Code;
                    var tableName = "InventTable";

                    var axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                    axaptaRecord.Clear();
                    axaptaRecord.InitValue();

                    axaptaRecord.set_Field("ItemGroupId", objToPost.ServiceGroup);

                    axaptaRecord.set_Field("ItemId", itemId);
                    axaptaRecord.set_Field("ItemName", objToPost.Ename);
                    axaptaRecord.set_Field("ModelGroupID", "Service");
                    axaptaRecord.set_Field("ItemType", 0);
                    axaptaRecord.set_Field("DimGroupId", "Service");
                    //Commit the record to the database.
                    axaptaRecord.Insert();

                    tableName    = "InventTableModule";
                    axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                    axaptaRecord.Clear();
                    axaptaRecord.InitValue();

                    axaptaRecord.set_Field("ItemId", itemId);
                    axaptaRecord.set_Field("ModuleType", 0);
                    axaptaRecord.set_Field("Price", 0.00);

                    axaptaRecord.set_Field("UnitId", "KG");
                    //axaptaRecord.set_Field("PriceUnit", tempu);

                    axaptaRecord.Insert();

                    axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                    axaptaRecord.Clear();
                    axaptaRecord.InitValue();

                    axaptaRecord.set_Field("ItemId", itemId);
                    axaptaRecord.set_Field("ModuleType", 1);
                    axaptaRecord.set_Field("Price", 0.00);
                    axaptaRecord.set_Field("UnitId", "KG");

                    axaptaRecord.Insert();

                    axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                    axaptaRecord.Clear();
                    axaptaRecord.InitValue();

                    axaptaRecord.set_Field("ItemId", itemId);
                    axaptaRecord.set_Field("ModuleType", 2);
                    axaptaRecord.set_Field("Price", 0.00);
                    axaptaRecord.set_Field("UnitId", "KG");
                    axaptaRecord.set_Field("UnitId", "KG");

                    axaptaRecord.Insert();

                    tableName = "InventItemLocation";

                    axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                    axaptaRecord.Clear();
                    axaptaRecord.InitValue();

                    axaptaRecord.set_Field("ItemId", itemId);
                    axaptaRecord.set_Field("InventDIMID", "AllBlank");
                    axaptaRecord.Insert();

                    // Commit the record to the database.
                    axapta.TTSCommit();
                }
            }
            catch (Exception ex)
            {
                axapta.TTSAbort();
                throw ex;
            }
        }